/* ============================================================
   ระบบศูนย์ข้อมูลสุขภาพดิจิทัล — กลุ่มงานสุขภาพดิจิทัล
   โรงพยาบาล ๕๐ พรรษา มหาวชิราลงกรณ
   Design System  (PHP 8.2 / Bootstrap 5.3)
   ============================================================ */

:root{
  --brand-900:#04302e;
  --brand-800:#064e4a;
  --brand-700:#0b6b64;
  --brand-600:#0d9488;
  --brand-500:#14b8a6;
  --brand-400:#2dd4bf;
  --brand-300:#5eead4;
  --brand-100:#ccfbf1;
  --brand-50:#f0fdfa;

  --accent-600:#4f46e5;
  --accent-500:#6366f1;
  --accent-400:#818cf8;

  --ink-900:#0b1f2a;
  --ink-800:#122b38;
  --ink-700:#1f3b4a;
  --ink-600:#375162;
  --ink-500:#5b7484;
  --ink-400:#8098a6;
  --ink-300:#b4c4cd;
  --ink-200:#dbe5ea;
  --ink-100:#eef4f7;
  --ink-50:#f6fafb;

  --ok:#10b981;   --ok-bg:#ecfdf5;
  --warn:#f59e0b; --warn-bg:#fffbeb;
  --info:#3b82f6; --info-bg:#eff6ff;
  --danger:#ef4444; --danger-bg:#fef2f2;
  --purple:#8b5cf6; --purple-bg:#f5f3ff;
  --pink:#ec4899;
  --cyan:#06b6d4;

  --bg:#f2f6f8;
  --surface:#ffffff;
  --surface-2:#f8fbfc;
  --border:#e3ecef;
  --text:#0b1f2a;
  --muted:#6b8494;

  --radius:16px;
  --radius-sm:10px;
  --radius-lg:22px;
  --shadow-xs:0 1px 2px rgba(11,31,42,.05);
  --shadow-sm:0 2px 8px rgba(11,31,42,.06);
  --shadow:0 6px 22px -6px rgba(11,31,42,.14),0 2px 6px rgba(11,31,42,.05);
  --shadow-lg:0 18px 48px -16px rgba(11,31,42,.26),0 4px 12px rgba(11,31,42,.06);
  --shadow-brand:0 12px 32px -10px rgba(13,148,136,.5);
  --sidebar-w:274px;
  --topbar-h:66px;
  --grad-brand:linear-gradient(135deg,#0d9488 0%,#0b6b64 45%,#064e4a 100%);
  --grad-brand-soft:linear-gradient(135deg,#14b8a6 0%,#0d9488 100%);
  --grad-accent:linear-gradient(135deg,#6366f1 0%,#4f46e5 100%);
  --grad-hero:linear-gradient(130deg,#04302e 0%,#0b6b64 42%,#0d9488 72%,#14b8a6 100%);
}

[data-theme="dark"]{
  --bg:#071a1f;
  --surface:#0d2429;
  --surface-2:#112b31;
  --border:#1b3a41;
  --text:#e6f2f2;
  --muted:#8fa9ae;
  --ink-900:#e6f2f2;
  --ink-800:#d3e6e6;
  --ink-700:#b7d2d3;
  --ink-600:#9bbabc;
  --ink-500:#8fa9ae;
  --ink-400:#7d969a;
  --ink-300:#5d7a7f;
  --ink-200:#22474e;
  --ink-100:#17343a;
  --ink-50:#0f272c;
  --ok-bg:#0b2e26; --warn-bg:#332508; --info-bg:#0d2440; --danger-bg:#3a1414; --purple-bg:#241a45;
  --shadow:0 6px 22px -6px rgba(0,0,0,.5);
  --shadow-lg:0 18px 48px -16px rgba(0,0,0,.6);
}

*{ -webkit-tap-highlight-color:transparent; }
html{ scroll-behavior:smooth; }
body{
  font-family:'Sarabun','Segoe UI',Tahoma,sans-serif;
  background:var(--bg); color:var(--text);
  font-size:15px; line-height:1.65; margin:0;
  -webkit-font-smoothing:antialiased;
  transition:background .25s ease,color .25s ease;
}
a{ text-decoration:none; color:var(--brand-600); }
a:hover{ color:var(--brand-700); }
h1,h2,h3,h4,h5,h6{ font-weight:700; letter-spacing:-.01em; color:var(--text); }
::-webkit-scrollbar{ width:10px; height:10px; }
::-webkit-scrollbar-track{ background:transparent; }
::-webkit-scrollbar-thumb{ background:var(--ink-300); border-radius:20px; border:2px solid transparent; background-clip:content-box; }
::-webkit-scrollbar-thumb:hover{ background:var(--brand-500); background-clip:content-box; }
::selection{ background:var(--brand-300); color:var(--brand-900); }

/* ---------------- Layout ---------------- */
.app{ display:flex; min-height:100vh; }
.sidebar{
  width:var(--sidebar-w); flex:0 0 var(--sidebar-w);
  background:var(--grad-hero);
  color:#d7f4f0; position:fixed; inset:0 auto 0 0; z-index:1040;
  display:flex; flex-direction:column; overflow:hidden;
  box-shadow:4px 0 30px -12px rgba(4,48,46,.55);
  transition:transform .28s cubic-bezier(.4,0,.2,1);
}
.sidebar::before{
  content:''; position:absolute; width:340px; height:340px; border-radius:50%;
  background:radial-gradient(circle,rgba(94,234,212,.22),transparent 68%);
  top:-130px; right:-130px; pointer-events:none;
}
.sidebar::after{
  content:''; position:absolute; width:280px; height:280px; border-radius:50%;
  background:radial-gradient(circle,rgba(99,102,241,.20),transparent 68%);
  bottom:-120px; left:-110px; pointer-events:none;
}
.sidebar-head{
  padding:20px 18px 16px; display:flex; align-items:center; gap:12px;
  border-bottom:1px solid rgba(255,255,255,.10); position:relative; z-index:2;
}
.sidebar-logo{
  width:46px; height:46px; flex:0 0 46px; border-radius:14px;
  background:linear-gradient(140deg,#5eead4,#14b8a6 55%,#6366f1);
  display:grid; place-items:center; font-size:22px; color:#04302e;
  box-shadow:0 8px 20px -6px rgba(45,212,191,.6);
}
.sidebar-title{ font-size:15px; font-weight:700; color:#fff; line-height:1.25; }
.sidebar-sub{ font-size:11.5px; color:#8fd9cf; letter-spacing:.02em; }
.sidebar-scroll{ flex:1; overflow-y:auto; padding:14px 12px 26px; position:relative; z-index:2; }
.sidebar-scroll::-webkit-scrollbar{ width:6px; }
.sidebar-scroll::-webkit-scrollbar-thumb{ background:rgba(255,255,255,.22); border:none; }
.nav-label{
  font-size:10.5px; text-transform:uppercase; letter-spacing:.13em; color:#6fc4b9;
  padding:16px 12px 7px; font-weight:700;
}
.nav-item{
  display:flex; align-items:center; gap:11px; padding:10px 13px; border-radius:12px;
  color:#c3e9e4; font-size:14.2px; font-weight:500; margin-bottom:3px;
  transition:all .18s ease; position:relative; cursor:pointer; border:none; background:none; width:100%; text-align:left;
}
.nav-item i:first-child{ font-size:17px; width:22px; text-align:center; flex:0 0 22px; opacity:.92; }
.nav-item:hover{ background:rgba(255,255,255,.11); color:#fff; transform:translateX(3px); }
.nav-item.active{
  background:linear-gradient(90deg,rgba(255,255,255,.20),rgba(255,255,255,.06));
  color:#fff; font-weight:600; box-shadow:inset 0 0 0 1px rgba(255,255,255,.14);
}
.nav-item.active::before{
  content:''; position:absolute; left:-12px; top:50%; transform:translateY(-50%);
  width:4px; height:24px; border-radius:0 4px 4px 0; background:#5eead4; box-shadow:0 0 12px #5eead4;
}
/* จุดบอกตำแหน่งปัจจุบัน (ด้านขวา) — เห็นชัดแม้เมนูยาว */
.nav-item.active::after{
  content:''; position:absolute; right:13px; top:50%; transform:translateY(-50%);
  width:7px; height:7px; border-radius:50%; background:#5eead4;
  box-shadow:0 0 9px #5eead4,0 0 0 3px rgba(94,234,212,.22);
}
.nav-item.active .nav-badge{ margin-right:16px; }
.nav-badge{
  margin-left:auto; font-size:11px; font-weight:700; padding:2px 8px; border-radius:20px;
  background:rgba(255,255,255,.2); color:#fff;
}
.nav-badge.hot{ background:#f43f5e; color:#fff; }
.sidebar-foot{
  padding:13px 16px; border-top:1px solid rgba(255,255,255,.1);
  font-size:11.5px; color:#7fc9be; position:relative; z-index:2;
}

.main{ flex:1; margin-left:var(--sidebar-w); min-width:0; display:flex; flex-direction:column; }

/* ---------------- Topbar ---------------- */
.topbar{
  height:var(--topbar-h); background:color-mix(in srgb,var(--surface) 88%,transparent);
  backdrop-filter:blur(14px); border-bottom:1px solid var(--border);
  display:flex; align-items:center; gap:14px; padding:0 22px;
  position:sticky; top:0; z-index:1030;
}
.btn-burger{
  display:none; border:1px solid var(--border); background:var(--surface); color:var(--text);
  width:40px; height:40px; border-radius:11px; font-size:19px; align-items:center; justify-content:center;
}
.topbar-search{
  flex:1; max-width:430px; position:relative;
}
.topbar-search input{
  width:100%; height:42px; border-radius:12px; border:1px solid var(--border);
  background:var(--surface-2); padding:0 14px 0 40px; font-size:14px; color:var(--text);
  transition:all .2s;
}
.topbar-search input:focus{
  outline:none; border-color:var(--brand-500); background:var(--surface);
  box-shadow:0 0 0 4px rgba(20,184,166,.14);
}
.topbar-search i{ position:absolute; left:14px; top:50%; transform:translateY(-50%); color:var(--muted); font-size:15px; }
.topbar-actions{ margin-left:auto; display:flex; align-items:center; gap:9px; }
.icon-btn{
  width:42px; height:42px; border-radius:12px; border:1px solid var(--border); background:var(--surface);
  color:var(--ink-600); display:grid; place-items:center; font-size:18px; position:relative;
  transition:all .18s; cursor:pointer;
}
.icon-btn:hover{ background:var(--brand-50); color:var(--brand-700); border-color:var(--brand-300); transform:translateY(-1px); }
[data-theme="dark"] .icon-btn:hover{ background:var(--ink-100); }
.icon-btn .dot{
  position:absolute; top:8px; right:9px; width:9px; height:9px; border-radius:50%;
  background:#f43f5e; border:2px solid var(--surface); animation:pulse 2s infinite;
}
@keyframes pulse{ 0%,100%{ transform:scale(1); opacity:1 } 50%{ transform:scale(1.25); opacity:.75 } }

.user-chip{
  display:flex; align-items:center; gap:10px; padding:5px 12px 5px 5px; border-radius:40px;
  border:1px solid var(--border); background:var(--surface); cursor:pointer; transition:all .18s;
}
.user-chip:hover{ border-color:var(--brand-300); box-shadow:var(--shadow-sm); }
.user-chip .uname{ font-size:13.5px; font-weight:600; line-height:1.15; }
.user-chip .urole{ font-size:11px; color:var(--muted); }

/* ---------------- Content ---------------- */
.content{ padding:24px 24px 60px; flex:1; }
.page-head{ display:flex; align-items:flex-start; gap:16px; margin-bottom:22px; flex-wrap:wrap; }
.page-head .ph-icon{
  width:54px; height:54px; flex:0 0 54px; border-radius:16px; display:grid; place-items:center;
  background:var(--grad-brand-soft); color:#fff; font-size:25px; box-shadow:var(--shadow-brand);
}
.page-title{ font-size:24px; font-weight:800; margin:0; line-height:1.3; }
.page-sub{ font-size:13.5px; color:var(--muted); margin:2px 0 0; }
.page-actions{ margin-left:auto; display:flex; gap:9px; flex-wrap:wrap; }
.breadcrumb-mini{ font-size:12.5px; color:var(--muted); margin-bottom:6px; }
.breadcrumb-mini a{ color:var(--brand-600); }

/* ---------------- Cards ---------------- */
.card-x{
  background:var(--surface); border:1px solid var(--border); border-radius:var(--radius);
  box-shadow:var(--shadow-sm); overflow:hidden; transition:box-shadow .25s,transform .25s;
}
.card-x:hover{ box-shadow:var(--shadow); }
.card-x-head{
  padding:15px 20px; border-bottom:1px solid var(--border); display:flex; align-items:center; gap:11px;
  background:var(--surface-2);
}
.card-x-head h6{ margin:0; font-size:15.5px; font-weight:700; display:flex; align-items:center; gap:9px; }
.card-x-head h6 i{ color:var(--brand-600); }
.card-x-head .tools{ margin-left:auto; display:flex; gap:7px; align-items:center; }
.card-x-body{ padding:20px; }
.card-x-body.p0{ padding:0; }

/* ---------------- Stat cards ---------------- */
.stat-grid{ display:grid; grid-template-columns:repeat(auto-fit,minmax(228px,1fr)); gap:16px; }
.stat{
  position:relative; border-radius:var(--radius); padding:20px; overflow:hidden;
  background:var(--surface); border:1px solid var(--border); box-shadow:var(--shadow-sm);
  transition:transform .25s cubic-bezier(.4,0,.2,1),box-shadow .25s;
}
.stat:hover{ transform:translateY(-4px); box-shadow:var(--shadow-lg); }
.stat::after{
  content:''; position:absolute; right:-42px; top:-42px; width:130px; height:130px; border-radius:50%;
  background:var(--c,var(--brand-500)); opacity:.09; transition:transform .4s;
}
.stat:hover::after{ transform:scale(1.25); }
.stat-ico{
  width:52px; height:52px; border-radius:15px; display:grid; place-items:center; font-size:24px;
  color:#fff; background:var(--c,var(--brand-500)); box-shadow:0 10px 22px -10px var(--c,var(--brand-500));
  margin-bottom:14px;
}
.stat-val{ font-size:31px; font-weight:800; line-height:1; letter-spacing:-.03em; }
.stat-lbl{ font-size:13.5px; color:var(--muted); margin-top:6px; font-weight:500; }
.stat-foot{ font-size:12px; margin-top:11px; display:flex; align-items:center; gap:6px; color:var(--muted); }
.stat-foot .up{ color:var(--ok); font-weight:700; }
.stat-foot .down{ color:var(--danger); font-weight:700; }

/* ---------------- Hero ---------------- */
.hero{
  border-radius:var(--radius-lg); background:var(--grad-hero); color:#fff; padding:36px 38px;
  position:relative; overflow:hidden; box-shadow:0 24px 60px -24px rgba(4,48,46,.65); margin-bottom:24px;
}
.hero::before{
  content:''; position:absolute; width:460px; height:460px; border-radius:50%;
  background:radial-gradient(circle,rgba(94,234,212,.30),transparent 65%); top:-190px; right:-90px;
}
.hero::after{
  content:''; position:absolute; inset:0;
  background-image:linear-gradient(rgba(255,255,255,.055) 1px,transparent 1px),
                   linear-gradient(90deg,rgba(255,255,255,.055) 1px,transparent 1px);
  background-size:44px 44px; mask-image:radial-gradient(circle at 30% 40%,#000,transparent 78%);
}
.hero-inner{ position:relative; z-index:2; }
.hero h1{ color:#fff; font-size:30px; font-weight:800; margin:0 0 10px; line-height:1.3; }
.hero p{ color:#c9f0eb; font-size:15.5px; margin:0; max-width:760px; }
.hero-badges{ display:flex; gap:10px; flex-wrap:wrap; margin-top:20px; }
.hero-badge{
  display:inline-flex; align-items:center; gap:8px; padding:7px 15px; border-radius:40px;
  background:rgba(255,255,255,.14); border:1px solid rgba(255,255,255,.22);
  font-size:13px; font-weight:500; color:#eafffb; backdrop-filter:blur(6px);
}
.hero-badge i{ color:#5eead4; }

/* ---------------- Buttons ---------------- */
.btn{ border-radius:11px; font-weight:600; font-size:14px; padding:9px 17px; transition:all .18s; border-width:1px; }
.btn i{ margin-right:5px; }
.btn:focus{ box-shadow:none; }
.btn-brand{
  background:var(--grad-brand-soft); border:none; color:#fff;
  box-shadow:0 8px 20px -9px rgba(13,148,136,.75);
}
.btn-brand:hover{ color:#fff; transform:translateY(-2px); box-shadow:0 12px 26px -9px rgba(13,148,136,.85); }
.btn-accent{ background:var(--grad-accent); border:none; color:#fff; box-shadow:0 8px 20px -9px rgba(79,70,229,.7); }
.btn-accent:hover{ color:#fff; transform:translateY(-2px); }
.btn-soft{ background:var(--brand-50); color:var(--brand-700); border:1px solid var(--brand-100); }
.btn-soft:hover{ background:var(--brand-100); color:var(--brand-800); }
[data-theme="dark"] .btn-soft{ background:var(--ink-100); color:var(--brand-300); border-color:var(--border); }
.btn-ghost{ background:var(--surface); border:1px solid var(--border); color:var(--ink-700); }
.btn-ghost:hover{ background:var(--surface-2); border-color:var(--brand-300); color:var(--brand-700); }
.btn-pill{ border-radius:40px; }
.btn-sm{ padding:6px 12px; font-size:13px; border-radius:9px; }
.btn-xs{ padding:4px 9px; font-size:12px; border-radius:8px; }
.btn-lg{ padding:12px 24px; font-size:15.5px; border-radius:13px; }

/* ---------------- Badges ---------------- */
.badge-x{
  display:inline-flex; align-items:center; gap:5px; padding:4px 11px; border-radius:30px;
  font-size:12px; font-weight:600; line-height:1.5; white-space:nowrap; border:1px solid transparent;
}
.badge-x i{ font-size:12px; }
.st-new{ background:#eef2ff; color:#4338ca; border-color:#e0e7ff; }
.st-assigned{ background:#eff6ff; color:#1d4ed8; border-color:#dbeafe; }
.st-progress{ background:#fff7ed; color:#c2410c; border-color:#ffedd5; }
.st-waiting{ background:#fefce8; color:#a16207; border-color:#fef9c3; }
.st-delivered{ background:#ecfeff; color:#0e7490; border-color:#cffafe; }
.st-done{ background:#ecfdf5; color:#047857; border-color:#d1fae5; }
.st-rejected{ background:#fef2f2; color:#b91c1c; border-color:#fee2e2; }
.st-cancelled{ background:#f8fafc; color:#475569; border-color:#e2e8f0; }
.p-low{ background:#f8fafc; color:#64748b; border-color:#e2e8f0; }
.p-normal{ background:#eff6ff; color:#2563eb; border-color:#dbeafe; }
.p-high{ background:#fff7ed; color:#ea580c; border-color:#ffedd5; }
.p-urgent{ background:#fef2f2; color:#dc2626; border-color:#fecaca; }
.sys-online{ background:#ecfdf5; color:#047857; border-color:#d1fae5; }
.sys-develop{ background:#eef2ff; color:#4338ca; border-color:#e0e7ff; }
.sys-maint{ background:#fffbeb; color:#b45309; border-color:#fef3c7; }
.sys-offline{ background:#fef2f2; color:#b91c1c; border-color:#fee2e2; }
.sys-retired{ background:#f8fafc; color:#64748b; border-color:#e2e8f0; }
.lv-public{ background:#ecfdf5; color:#047857; border-color:#d1fae5; }
.lv-internal{ background:#eff6ff; color:#1d4ed8; border-color:#dbeafe; }
.lv-restricted{ background:#fff7ed; color:#c2410c; border-color:#ffedd5; }
.lv-confidential{ background:#fef2f2; color:#b91c1c; border-color:#fee2e2; }
[data-theme="dark"] .badge-x{ filter:brightness(.88) saturate(1.35); }

.chip{
  display:inline-flex; align-items:center; gap:5px; padding:3px 10px; border-radius:8px;
  font-size:11.5px; font-weight:600; background:var(--ink-100); color:var(--ink-600);
}
[data-theme="dark"] .chip{ background:var(--ink-100); color:var(--ink-300); }

/* ---------------- Avatar ---------------- */
.avatar{
  display:inline-grid; place-items:center; border-radius:50%; color:#fff; font-weight:700;
  flex:0 0 auto; letter-spacing:-.02em; box-shadow:0 3px 9px -3px rgba(0,0,0,.3); object-fit:cover;
}
.avatar-lg{ border-radius:22px; }

/* ---------------- Tables ---------------- */
.table-x{ width:100%; margin:0; font-size:14px; border-collapse:separate; border-spacing:0; }
.table-x thead th{
  background:var(--surface-2); color:var(--ink-600); font-weight:700; font-size:12.5px;
  text-transform:uppercase; letter-spacing:.05em; padding:13px 16px; border-bottom:1px solid var(--border);
  white-space:nowrap; position:sticky; top:0; z-index:3;
}
.table-x tbody td{ padding:13px 16px; border-bottom:1px solid var(--border); vertical-align:middle; }
.table-x tbody tr{ transition:background .15s; }
.table-x tbody tr:hover{ background:var(--brand-50); }
[data-theme="dark"] .table-x tbody tr:hover{ background:var(--ink-100); }
.table-x tbody tr:last-child td{ border-bottom:none; }
.table-x .num{ text-align:right; font-variant-numeric:tabular-nums; }
.table-x .mono{ font-family:'JetBrains Mono',ui-monospace,Consolas,monospace; font-size:12.8px; }
.table-wrap{ overflow-x:auto; }

/* ---------------- Forms ---------------- */
.form-label{ font-size:13.5px; font-weight:600; color:var(--ink-700); margin-bottom:6px; }
.form-label .req{ color:var(--danger); }
.form-control,.form-select{
  border-radius:11px; border:1px solid var(--border); padding:10px 14px; font-size:14.2px;
  background:var(--surface); color:var(--text); transition:all .18s; min-height:44px;
}
.form-control:focus,.form-select:focus{
  border-color:var(--brand-500); box-shadow:0 0 0 4px rgba(20,184,166,.13); background:var(--surface);
  color:var(--text);
}
.form-control::placeholder{ color:var(--ink-400); }
.form-text{ font-size:12.3px; color:var(--muted); }
.form-check-input{ width:1.15em; height:1.15em; border-color:var(--ink-300); }
.form-check-input:checked{ background-color:var(--brand-600); border-color:var(--brand-600); }
.form-section{
  border:1px dashed var(--border); border-radius:var(--radius); padding:20px; margin-bottom:20px;
  background:var(--surface-2);
}
.form-section-title{
  font-size:14px; font-weight:700; color:var(--brand-700); display:flex; align-items:center; gap:9px;
  margin:-4px 0 16px;
}
[data-theme="dark"] .form-section-title{ color:var(--brand-300); }
.input-group-text{ background:var(--surface-2); border-color:var(--border); color:var(--ink-500); border-radius:11px; }

/* ---------------- Timeline ---------------- */
.timeline{ position:relative; padding-left:34px; }
.timeline::before{
  content:''; position:absolute; left:11px; top:8px; bottom:8px; width:2px;
  background:linear-gradient(180deg,var(--brand-400),var(--border)); border-radius:2px;
}
.tl-item{ position:relative; padding-bottom:22px; }
.tl-item:last-child{ padding-bottom:0; }
.tl-dot{
  position:absolute; left:-34px; top:2px; width:24px; height:24px; border-radius:50%;
  display:grid; place-items:center; font-size:12px; background:var(--brand-600); color:#fff;
  box-shadow:0 0 0 4px var(--surface),0 0 0 5px var(--border);
}
.tl-dot.muted{ background:var(--ink-300); }
.tl-time{ font-size:12px; color:var(--muted); }
.tl-body{
  background:var(--surface-2); border:1px solid var(--border); border-radius:12px;
  padding:12px 15px; margin-top:5px; font-size:14px;
}

/* ---------------- List group ---------------- */
.list-x{ list-style:none; padding:0; margin:0; }
.list-x li{
  display:flex; align-items:center; gap:13px; padding:13px 0; border-bottom:1px solid var(--border);
}
.list-x li:last-child{ border-bottom:none; }
.list-x li:hover{ background:var(--surface-2); }

/* ---------------- Progress ---------------- */
.progress{ height:8px; border-radius:20px; background:var(--ink-100); }
.progress-bar{ border-radius:20px; background:var(--grad-brand-soft); }
.progress-ring{ transform:rotate(-90deg); }
.progress-ring circle{ fill:none; stroke-width:8; stroke-linecap:round; }

/* ---------------- Misc ---------------- */
.kv{ display:flex; gap:12px; padding:9px 0; border-bottom:1px dashed var(--border); font-size:14px; }
.kv:last-child{ border-bottom:none; }
.kv .k{ color:var(--muted); min-width:180px; flex:0 0 auto; font-weight:500; }
.kv .v{ font-weight:600; flex:1; word-break:break-word; }
.empty-state{ text-align:center; padding:56px 20px; color:var(--muted); }
.empty-state i{ font-size:56px; color:var(--ink-200); display:block; margin-bottom:14px; }
.divider{ height:1px; background:var(--border); margin:20px 0; }
.text-muted-x{ color:var(--muted)!important; }
.fw-600{ font-weight:600 } .fw-700{ font-weight:700 } .fw-800{ font-weight:800 }
.rounded-x{ border-radius:var(--radius)!important; }
.hover-lift{ transition:transform .22s,box-shadow .22s; }
.hover-lift:hover{ transform:translateY(-4px); box-shadow:var(--shadow-lg); }
.clamp-2{ display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
.clamp-3{ display:-webkit-box; -webkit-line-clamp:3; -webkit-box-orient:vertical; overflow:hidden; }
.gradient-text{ background:var(--grad-brand-soft); -webkit-background-clip:text; background-clip:text; color:transparent; }

/* ---------------- News / content cards ---------------- */
.post-card{
  background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); overflow:hidden;
  height:100%; display:flex; flex-direction:column; transition:transform .25s,box-shadow .25s;
}
.post-card:hover{ transform:translateY(-5px); box-shadow:var(--shadow-lg); }
.post-thumb{
  height:132px; background:var(--grad-hero); display:grid; place-items:center; color:#fff; font-size:38px;
  position:relative; overflow:hidden;
}
.post-thumb::after{
  content:''; position:absolute; inset:0;
  background-image:linear-gradient(rgba(255,255,255,.07) 1px,transparent 1px),
                   linear-gradient(90deg,rgba(255,255,255,.07) 1px,transparent 1px);
  background-size:26px 26px;
}
.post-body{ padding:17px 19px 19px; flex:1; display:flex; flex-direction:column; }
.post-title{ font-size:16px; font-weight:700; line-height:1.45; margin:9px 0 8px; }
.post-title a{ color:var(--text); }
.post-title a:hover{ color:var(--brand-600); }
.post-meta{ font-size:12px; color:var(--muted); display:flex; align-items:center; gap:12px; margin-top:auto; padding-top:12px; }

/* ---------------- Dataset / system cards ---------------- */
.ds-card{
  background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); padding:19px;
  height:100%; transition:transform .22s,box-shadow .22s,border-color .22s; position:relative; overflow:hidden;
}
.ds-card:hover{ transform:translateY(-4px); box-shadow:var(--shadow-lg); border-color:var(--brand-300); }
.ds-card .ds-code{
  font-family:'JetBrains Mono',monospace; font-size:11.5px; color:var(--brand-600); font-weight:700;
  letter-spacing:.04em;
}
.ds-card h6{ font-size:15.5px; margin:7px 0 8px; line-height:1.45; }

/* ---------------- Login ---------------- */
.login-wrap{
  min-height:100vh; display:grid; grid-template-columns:1.05fr .95fr;
}
.login-side{
  background:var(--grad-hero); color:#fff; padding:52px; display:flex; flex-direction:column;
  justify-content:center; position:relative; overflow:hidden;
}
.login-side::before{
  content:''; position:absolute; width:600px; height:600px; border-radius:50%;
  background:radial-gradient(circle,rgba(94,234,212,.26),transparent 62%); top:-240px; right:-180px;
}
.login-side::after{
  content:''; position:absolute; inset:0;
  background-image:linear-gradient(rgba(255,255,255,.05) 1px,transparent 1px),
                   linear-gradient(90deg,rgba(255,255,255,.05) 1px,transparent 1px);
  background-size:40px 40px; mask-image:radial-gradient(circle at 40% 45%,#000,transparent 76%);
}
.login-side-inner{ position:relative; z-index:2; max-width:520px; }
.login-side h2{ color:#fff; font-size:32px; font-weight:800; line-height:1.35; margin:22px 0 14px; }
.login-side p{ color:#b8e8e2; font-size:15.5px; }
.login-feats{ list-style:none; padding:0; margin:28px 0 0; }
.login-feats li{ display:flex; align-items:center; gap:12px; padding:9px 0; color:#d5f5f0; font-size:14.5px; }
.login-feats i{ width:34px; height:34px; border-radius:11px; background:rgba(255,255,255,.14); display:grid; place-items:center; font-size:16px; color:#5eead4; flex:0 0 34px; }
.login-main{ display:flex; align-items:center; justify-content:center; padding:36px; background:var(--surface); }
.login-box{ width:100%; max-width:410px; }
.login-logo{
  width:66px; height:66px; border-radius:20px; background:var(--grad-brand-soft); color:#fff;
  display:grid; place-items:center; font-size:31px; margin-bottom:20px; box-shadow:var(--shadow-brand);
}
@media(max-width:991px){
  .login-wrap{ grid-template-columns:1fr; }
  .login-side{ display:none; }
}

/* ---------------- Footer ---------------- */
.foot{
  padding:20px 24px; border-top:1px solid var(--border); color:var(--muted); font-size:12.8px;
  display:flex; gap:12px; flex-wrap:wrap; align-items:center; background:var(--surface);
}
.foot .sp{ margin-left:auto; }

/* ---------------- Flash / toast ---------------- */
.flash-wrap{ position:fixed; top:78px; right:22px; z-index:2000; display:flex; flex-direction:column; gap:10px; max-width:390px; }
.flash-x{
  background:var(--surface); border:1px solid var(--border); border-left:4px solid var(--brand-600);
  border-radius:12px; padding:13px 16px; box-shadow:var(--shadow-lg); font-size:14px;
  display:flex; gap:11px; align-items:flex-start; animation:slideIn .3s cubic-bezier(.4,0,.2,1);
}
.flash-x.ok{ border-left-color:var(--ok); } .flash-x.ok i{ color:var(--ok); }
.flash-x.err{ border-left-color:var(--danger); } .flash-x.err i{ color:var(--danger); }
.flash-x.warn{ border-left-color:var(--warn); } .flash-x.warn i{ color:var(--warn); }
.flash-x.info{ border-left-color:var(--info); } .flash-x.info i{ color:var(--info); }
@keyframes slideIn{ from{ opacity:0; transform:translateX(40px) } to{ opacity:1; transform:none } }

/* ---------------- Dropdown ---------------- */
.dropdown-menu{
  border-radius:14px; border:1px solid var(--border); box-shadow:var(--shadow-lg); padding:7px;
  font-size:14px; background:var(--surface); min-width:230px;
}
.dropdown-item{ border-radius:9px; padding:9px 13px; color:var(--ink-700); display:flex; align-items:center; gap:10px; }
.dropdown-item:hover{ background:var(--brand-50); color:var(--brand-700); }
[data-theme="dark"] .dropdown-item{ color:var(--ink-300); }
[data-theme="dark"] .dropdown-item:hover{ background:var(--ink-100); }
.dropdown-header{ font-size:12px; font-weight:700; color:var(--muted); text-transform:uppercase; letter-spacing:.06em; }

/* ---------------- Modal ---------------- */
.modal-content{ border-radius:var(--radius-lg); border:none; box-shadow:var(--shadow-lg); background:var(--surface); }
.modal-header{ border-bottom:1px solid var(--border); padding:18px 24px; }
.modal-title{ font-size:17px; font-weight:700; }
.modal-body{ padding:22px 24px; }
.modal-footer{ border-top:1px solid var(--border); padding:15px 24px; }
[data-theme="dark"] .btn-close{ filter:invert(1) grayscale(1); }

/* ---------------- Tabs ---------------- */
.nav-pills .nav-link{
  border-radius:11px; font-weight:600; font-size:14px; color:var(--ink-600); padding:9px 17px;
}
.nav-pills .nav-link:hover{ background:var(--brand-50); color:var(--brand-700); }
.nav-pills .nav-link.active{ background:var(--grad-brand-soft); color:#fff; box-shadow:0 6px 16px -8px rgba(13,148,136,.8); }

/* ---------------- Chart ---------------- */
.chart-box{ position:relative; width:100%; }
.chart-box.h240{ height:240px } .chart-box.h280{ height:280px } .chart-box.h320{ height:320px }

/* ---------------- Landing (public) ---------------- */
.land-hero{
  background:var(--grad-hero); color:#fff; padding:76px 24px 96px; position:relative; overflow:hidden;
}
.land-hero::before{
  content:''; position:absolute; width:700px; height:700px; border-radius:50%;
  background:radial-gradient(circle,rgba(94,234,212,.24),transparent 62%); top:-280px; right:-160px;
}
.land-hero::after{
  content:''; position:absolute; inset:0;
  background-image:linear-gradient(rgba(255,255,255,.055) 1px,transparent 1px),
                   linear-gradient(90deg,rgba(255,255,255,.055) 1px,transparent 1px);
  background-size:48px 48px; mask-image:radial-gradient(circle at 35% 40%,#000,transparent 78%);
}
.land-inner{ position:relative; z-index:2; max-width:1180px; margin:0 auto; }
.land-title{ font-size:42px; font-weight:800; color:#fff; line-height:1.28; margin:0 0 16px; }
.land-sub{ font-size:17.5px; color:#c4eeea; max-width:720px; }
.land-nav{
  position:sticky; top:0; z-index:1030; background:color-mix(in srgb,var(--surface) 90%,transparent);
  backdrop-filter:blur(14px); border-bottom:1px solid var(--border);
}
.land-nav-inner{
  max-width:1180px; margin:0 auto; padding:12px 24px; display:flex; align-items:center; gap:14px;
}
.land-brand{ display:flex; align-items:center; gap:11px; font-weight:700; color:var(--text); }
.land-brand .lb-ico{
  width:42px; height:42px; border-radius:13px; background:var(--grad-brand-soft); color:#fff;
  display:grid; place-items:center; font-size:20px; box-shadow:var(--shadow-brand);
}
.land-menu{ margin-left:auto; display:flex; gap:4px; flex-wrap:wrap; }
.land-menu a{
  padding:8px 14px; border-radius:10px; font-size:14px; font-weight:600; color:var(--ink-600);
}
.land-menu a:hover{ background:var(--brand-50); color:var(--brand-700); }
.sec{ padding:62px 24px; }
.sec-inner{ max-width:1180px; margin:0 auto; }
.sec-title{ font-size:27px; font-weight:800; margin:0 0 8px; }
.sec-sub{ color:var(--muted); font-size:15px; margin-bottom:30px; }
.feature{
  background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); padding:25px;
  height:100%; transition:transform .25s,box-shadow .25s,border-color .25s;
}
.feature:hover{ transform:translateY(-5px); box-shadow:var(--shadow-lg); border-color:var(--brand-300); }
.feature-ico{
  width:52px; height:52px; border-radius:15px; display:grid; place-items:center; font-size:24px; color:#fff;
  margin-bottom:15px;
}

/* ---------------- ปฏิทิน ---------------- */
.cal-grid{ display:grid; grid-template-columns:repeat(7,1fr); gap:6px; }
.cal-head{
  text-align:center; font-size:12.5px; font-weight:700; color:var(--ink-600);
  padding:8px 0; text-transform:uppercase; letter-spacing:.04em;
}
.cal-head.sun{ color:#ef4444; } .cal-head.sat{ color:#6366f1; }
.cal-cell{
  min-height:104px; border:1px solid var(--border); border-radius:12px; padding:7px;
  background:var(--surface); transition:border-color .18s,box-shadow .18s; overflow:hidden;
}
.cal-cell:hover{ border-color:var(--brand-300); box-shadow:var(--shadow-sm); }
.cal-cell.empty{ background:transparent; border:1px dashed var(--border); opacity:.4; }
.cal-cell.today{ border-color:var(--brand-500); box-shadow:0 0 0 3px rgba(13,148,136,.13); background:var(--brand-50); }
.cal-cell.sun .cal-day span:first-child{ color:#ef4444; }
.cal-cell.sat .cal-day span:first-child{ color:#6366f1; }
.cal-day{ display:flex; align-items:center; gap:5px; margin-bottom:5px; }
.cal-day span:first-child{ font-size:14px; font-weight:700; }
.cal-count{
  margin-left:auto; font-size:10.5px; font-weight:700; padding:1px 6px; border-radius:20px;
  background:var(--brand-100); color:var(--brand-700);
}
[data-theme="dark"] .cal-count{ background:var(--ink-100); color:var(--brand-300); }
.cal-evs{ display:flex; flex-direction:column; gap:3px; }
.cal-ev{
  font-size:11.2px; padding:3px 6px; border-radius:6px; cursor:pointer; line-height:1.35;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis; transition:filter .15s,transform .15s;
}
.cal-ev:hover{ filter:brightness(.94); transform:translateX(2px); }
.cal-ev b{ font-weight:800; }
.cal-more{ font-size:10.5px; color:var(--muted); padding-left:5px; }
@media(max-width:991px){
  .cal-cell{ min-height:76px; padding:5px; }
  .cal-ev{ font-size:10px; }
  .cal-head{ font-size:10.5px; }
}

/* ---------------- Responsive ---------------- */
@media(max-width:1199px){
  :root{ --sidebar-w:250px; }
  .content{ padding:20px 18px 56px; }
}
@media(max-width:991px){
  .sidebar{ transform:translateX(-100%); }
  .sidebar.open{ transform:none; }
  .main{ margin-left:0; }
  .btn-burger{ display:flex; }
  .topbar-search{ display:none; }
  .land-title{ font-size:31px; }
  .hero h1{ font-size:24px; }
  .hero{ padding:26px 22px; }
  .page-title{ font-size:20px; }
  .stat-val{ font-size:26px; }
  .content{ padding:16px 14px 50px; }
  .overlay{
    position:fixed; inset:0; background:rgba(4,20,25,.5); backdrop-filter:blur(3px); z-index:1035; display:none;
  }
  .overlay.show{ display:block; }
}
@media(max-width:575px){
  .topbar{ padding:0 13px; gap:9px; }
  .user-chip .uinfo{ display:none; }
  .kv .k{ min-width:110px; font-size:13px; }
  .hero-badges{ gap:7px; }
  .hero-badge{ font-size:12px; padding:5px 11px; }
}

/* ---------------- Print ---------------- */
@media print{
  .sidebar,.topbar,.page-actions,.foot,.flash-wrap,.no-print{ display:none!important; }
  .main{ margin-left:0; }
  .content{ padding:0; }
  body{ background:#fff; }
  .card-x{ box-shadow:none; border:1px solid #ccc; }
}
