/* Doctor Data Hub — admin UI.
   Redesign ported from Claude Design "Dashboard.dc.html" (navy sidebar + teal accent). */
:root{
  --teal:#0d9488; --teal-d:#0f766e; --teal-bg:#e6faf7;
  --navy:#0f2743; --navy2:#0b1e36;
  --ink:#16233a; --muted:#64748b; --muted2:#94a3b8; --line:#e6ebf1; --line2:#f1f5f9;
  --bg:#eef1f6; --card:#fff;
  --green:#15803d; --greenbg:#e7f6ee; --amber:#b45309; --amberbg:#fff4e5; --red:#dc2626;
  --radius:18px; --shadow:0 12px 28px -12px rgba(15,37,64,.28);
}
*{box-sizing:border-box}
body{margin:0;font-family:"Noto Sans Thai",system-ui,"Segoe UI",Tahoma,sans-serif;color:var(--ink);background:var(--bg);-webkit-font-smoothing:antialiased}
h1,h2,h3,strong,th{font-weight:800}
a{color:var(--teal);text-decoration:none}
/* buttons carry their own colour — keep the generic link hover off them, or it wins
   on specificity (a:hover 0,1,1 > .btn-primary 0,1,0) and hides the label */
a:not(.btn):not(.mini):not(.chip):hover{color:var(--teal-d)}
.mono{font-family:"IBM Plex Mono",ui-monospace,Menlo,Consolas,monospace}
code{font-family:"IBM Plex Mono",ui-monospace,monospace;background:var(--line2);padding:2px 7px;border-radius:7px;font-size:.85em;color:var(--muted)}
.muted{color:var(--muted)}
::-webkit-scrollbar{width:10px;height:10px}
::-webkit-scrollbar-thumb{background:#cbd5e1;border-radius:8px;border:2px solid var(--bg)}

/* ---------- app shell ---------- */
.app{display:flex;min-height:100vh}
.sidebar{width:264px;flex:0 0 264px;background:linear-gradient(180deg,#0f2743 0%,#0b1e36 100%);color:#e8eef6;
  display:flex;flex-direction:column;position:sticky;top:0;height:100vh}
.brand{display:flex;align-items:center;gap:13px;padding:24px 22px 20px}
.brand .logo{width:46px;height:46px;border-radius:13px;background:linear-gradient(135deg,#14b8a6,#0d9488);
  display:flex;align-items:center;justify-content:center;box-shadow:0 8px 18px -6px rgba(13,148,136,.7)}
.brand strong{display:block;font-size:16px;letter-spacing:.2px}
.brand small{display:block;font-size:12px;color:#8ea6c4;margin-top:1px;font-weight:400}
.nav-label{padding:6px 22px 2px;font-size:11px;letter-spacing:1px;color:#617792;font-weight:600;text-transform:uppercase;margin-top:6px}
.sidebar nav{display:flex;flex-direction:column;gap:3px;padding:8px 12px}
.sidebar nav a,.sidebar nav button{display:flex;align-items:center;gap:12px;width:100%;border:none;background:transparent;cursor:pointer;
  font-family:inherit;font-size:14.5px;font-weight:500;color:#b8c9de;padding:11px 14px;border-radius:12px;text-align:left;transition:background .15s}
.sidebar nav a svg{flex:0 0 auto;color:#7f9ab8}
.sidebar nav a:hover{background:rgba(255,255,255,.06)}
.sidebar nav a.active{background:linear-gradient(135deg,#14b8a6,#0d9488);color:#fff;font-weight:700;box-shadow:0 8px 18px -8px rgba(13,148,136,.7)}
.sidebar nav a.active svg{color:#fff}
.sidebar nav a.soon{opacity:.85;cursor:default;color:#5f748f}
.sidebar nav a.soon svg{color:#5f748f}
.sidebar nav a.soon em{margin-left:auto;font-style:normal;font-size:10px;font-weight:700;background:rgba(20,184,166,.18);color:#5eead4;padding:3px 8px;border-radius:20px}
.sidebar nav a .grow{flex:1}
.sidebar-foot{margin-top:auto;padding:16px 18px;border-top:1px solid rgba(255,255,255,.08);display:flex;align-items:center;gap:11px}
.sidebar-foot .ava{width:38px;height:38px;border-radius:50%;background:#1f3a5c;display:flex;align-items:center;justify-content:center;font-weight:700;font-size:14px;color:#a9c3e0}
.sidebar-foot .who{flex:1;min-width:0}
.sidebar-foot .who b{display:block;font-size:13px;font-weight:600}
.sidebar-foot .who span{display:block;font-size:11px;color:#7f97b4}
.sidebar-foot a.out{color:#8ea6c4;padding:6px;border-radius:8px;display:flex}
.sidebar-foot a.out:hover{background:rgba(255,255,255,.06)}
.main{flex:1;min-width:0;max-height:100vh;overflow-y:auto;padding:32px 40px 48px}

/* ---------- page head ---------- */
.page-head{display:flex;align-items:flex-start;justify-content:space-between;gap:20px;flex-wrap:wrap;margin-bottom:26px}
.page-head h1{font-size:28px;margin:0 0 4px}
.page-head p{margin:0;color:var(--muted);font-size:15px}

/* ---------- buttons ---------- */
.btn{border:0;border-radius:12px;padding:12px 20px;font-weight:700;font-size:14.5px;cursor:pointer;display:inline-flex;align-items:center;gap:8px;font-family:inherit}
.btn-primary{background:var(--teal);color:#fff;box-shadow:0 10px 22px -10px rgba(13,148,136,.8)}
.btn-primary:hover{background:var(--teal-d);color:#fff}
.btn-secondary{background:var(--navy);color:#fff}
.btn-secondary:hover{color:#fff}
.btn-ghost{background:#fff;border:1px solid #e2e8f0;color:#475569;font-weight:600}
.btn-ghost:hover{background:#eef2f7;color:#475569}
.btn.full{width:100%;justify-content:center}

/* ---------- cards ---------- */
.card{background:var(--card);border:1px solid var(--line);border-radius:16px;overflow:hidden}
.panel{background:var(--card);border:1px solid var(--line);border-radius:var(--radius);padding:24px}
.lift{transition:transform .16s ease,box-shadow .16s ease}
.lift:hover{transform:translateY(-2px);box-shadow:var(--shadow)}

/* ---------- toolbar ---------- */
.toolbar{background:#fff;border:1px solid var(--line);border-radius:16px;padding:16px;display:flex;gap:12px;align-items:center;flex-wrap:wrap;margin-bottom:18px}
.toolbar .search{position:relative;flex:1;min-width:240px}
.toolbar .search svg{position:absolute;left:14px;top:50%;transform:translateY(-50%);color:#94a3b8;pointer-events:none}
.toolbar .search input{width:100%;padding:11px 14px 11px 42px}
.toolbar input,.toolbar select{border:1px solid #e2e8f0;background:#f8fafc;border-radius:11px;padding:11px 14px;font:inherit;outline:none;color:#334155}
.toolbar select{background:#fff;cursor:pointer}
.toolbar input:focus,.toolbar select:focus{border-color:var(--teal);box-shadow:0 0 0 3px rgba(13,148,136,.12)}
.viewtoggle{display:flex;background:#f1f5f9;border-radius:11px;padding:3px;gap:2px}
.viewtoggle button{border:none;cursor:pointer;padding:7px 11px;border-radius:8px;display:flex;align-items:center;color:#94a3b8;background:transparent}
.viewtoggle button.on{color:var(--teal);background:#fff;box-shadow:0 2px 6px -2px rgba(0,0,0,.15)}
.result-row{display:flex;align-items:center;justify-content:space-between;margin:0 4px 12px;color:var(--muted);font-size:14px}
.result-row b{color:var(--ink)}

/* ---------- table ---------- */
table{width:100%;border-collapse:collapse}
th,td{padding:16px 22px;text-align:left;font-size:14px;vertical-align:middle}
th{background:#f8fafc;color:#7688a0;font-size:12px;font-weight:700;text-transform:uppercase;letter-spacing:.4px;border-bottom:1px solid var(--line2)}
td{border-bottom:1px solid var(--line2)}
tr:last-child td{border-bottom:0}
.row-hover:hover,tbody tr:hover{background:#f7fafc}
.empty{text-align:center;color:var(--muted);padding:40px}
.pager{padding:14px 22px;color:var(--muted);font-size:13px;border-top:1px solid var(--line2)}
.actions{display:flex;gap:7px;align-items:center;justify-content:flex-end}
.actions form{margin:0}
.mini{border:1px solid #e2e8f0;background:#fff;border-radius:9px;padding:7px 12px;font-size:13px;font-weight:600;cursor:pointer;color:#475569;white-space:nowrap;display:inline-block}
.mini:hover{background:#eef2f7;color:#475569}
.mini.danger,.mini.danger:hover{color:var(--red);border-color:#fde2e2}
.mini.danger:hover{background:#fff1f1}

/* doctor identity cell */
.who-cell{display:flex;align-items:center;gap:12px;min-width:0}
.avatar{flex:0 0 auto;border-radius:11px;color:#fff;display:flex;align-items:center;justify-content:center;font-weight:700;width:40px;height:40px;font-size:13px}
.avatar.lg{width:52px;height:52px;border-radius:14px;font-size:16px}
.who-cell .nm{min-width:0}
.who-cell .nm b{display:block;font-weight:700;font-size:14.5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.who-cell .nm span{display:block;font-size:12.5px;color:var(--muted2);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}

/* branch chips inside rows/cards */
.bchips{display:flex;flex-wrap:wrap;gap:5px}
.bchip{font-size:12px;color:var(--teal-d);background:var(--teal-bg);padding:3px 10px;border-radius:8px;white-space:nowrap}
.bchip.more{color:var(--muted);background:var(--line2)}
.bchip.none{color:var(--muted2);background:#f8fafc;border:1px dashed #e2e8f0}

/* ---------- status pill ---------- */
.pill{display:inline-flex;align-items:center;gap:6px;font-size:12.5px;font-weight:600;padding:5px 11px;border-radius:20px;white-space:nowrap}
.pill:before{content:"";width:7px;height:7px;border-radius:50%;background:currentColor;opacity:.9}
.pill.live{background:var(--greenbg);color:var(--green)}
.pill.draft{background:var(--amberbg);color:var(--amber)}
/* keep old .badge markup working too */
.badge{display:inline-flex;align-items:center;gap:6px;padding:5px 11px;border-radius:20px;font-size:12.5px;font-weight:600}
.badge:before{content:"";width:7px;height:7px;border-radius:50%;background:currentColor}
.badge.live{color:var(--green);background:var(--greenbg)}
.badge.draft{color:var(--amber);background:var(--amberbg)}

/* ---------- KPI cards (overview) ---------- */
.kpi-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:18px;margin-bottom:26px}
.kpi{background:#fff;border:1px solid var(--line);border-radius:var(--radius);padding:20px 22px}
.kpi .top{display:flex;align-items:center;justify-content:space-between}
.kpi .ico{width:44px;height:44px;border-radius:12px;display:flex;align-items:center;justify-content:center}
.kpi .trend{font-size:12px;font-weight:600;padding:4px 10px;border-radius:20px}
.kpi .trend.up{color:var(--green);background:var(--greenbg)}
.kpi .trend.flat{color:var(--muted);background:var(--line2)}
.kpi .val{font-size:34px;font-weight:800;margin-top:16px;letter-spacing:-.5px}
.kpi .lab{color:var(--muted);font-size:13.5px;margin-top:2px}
.two-col{display:grid;grid-template-columns:1.5fr 1fr;gap:18px}
.panel h3{margin:0;font-size:17px;font-weight:700}
.barlist{display:flex;flex-direction:column;gap:14px}
.barlist .b-top{display:flex;justify-content:space-between;font-size:14px;margin-bottom:6px}
.barlist .b-top b{font-weight:600}
.bar{height:9px;background:#eef2f7;border-radius:6px;overflow:hidden}
.bar>i{display:block;height:100%;background:linear-gradient(90deg,#14b8a6,#0d9488);border-radius:6px}
.spec-list{display:flex;flex-direction:column;gap:13px}
.spec-list .s{display:flex;align-items:center;gap:12px}
.spec-list .dot{width:12px;height:12px;border-radius:4px;flex:0 0 auto}
.spec-list .s span.nm{flex:1;font-size:14px}

/* ---------- branch cards ---------- */
.branch-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:18px}
.branch-card{background:#fff;border:1px solid var(--line);border-radius:var(--radius);padding:20px 22px}
.branch-card .bc-top{display:flex;align-items:center;justify-content:space-between;margin-bottom:14px}
.branch-card .bc-ico{width:42px;height:42px;border-radius:12px;background:var(--teal-bg);display:flex;align-items:center;justify-content:center;color:var(--teal)}
.branch-card .bc-name b{font-weight:700;font-size:16px}
.branch-card .bc-name span{font-size:12.5px;color:var(--muted2)}
.branch-card .bc-stats{display:flex;gap:22px;padding:14px 0;border-top:1px solid var(--line2);border-bottom:1px solid var(--line2)}
.branch-card .bc-stats .n{font-size:22px;font-weight:800}
.branch-card .bc-stats .n.teal{color:var(--teal)}
.branch-card .bc-stats .l{font-size:12px;color:var(--muted2)}

/* ---------- flash ---------- */
.flash{padding:13px 18px;border-radius:14px;margin-bottom:16px;font-weight:500}
.flash.ok{background:var(--greenbg);color:#166534;border:1px solid #bbe6c9}
.flash.err{background:#fdecea;color:#b91c1c;border:1px solid #f6c9c4}

/* ---------- forms ---------- */
.form{padding:30px}
.grid2{display:grid;grid-template-columns:1fr 1fr;gap:20px 26px;margin-bottom:22px}
.fg{display:flex;flex-direction:column;gap:7px;margin-bottom:8px}
.fg.full{grid-column:1/-1}
.fg label{font-weight:600;font-size:13px;color:#475569}
.fg input,.fg select,.fg textarea{border:1px solid #e2e8f0;border-radius:11px;padding:11px 14px;font:inherit;background:#f8fafc;outline:none;color:var(--ink)}
.fg input:focus,.fg select:focus,.fg textarea:focus{border-color:var(--teal);box-shadow:0 0 0 3px rgba(13,148,136,.12)}
.chips{display:flex;flex-wrap:wrap;gap:9px;margin-top:4px}
.chip{display:inline-flex;align-items:center;gap:7px;font-size:13.5px;padding:8px 12px;border-radius:10px;cursor:pointer;border:1px solid #e2e8f0;background:#fff;color:#475569}
.chip:hover{background:#f8fafc}
.chip input{accent-color:var(--teal);width:16px;height:16px}
.chip.on,.chip:has(input:checked){border-color:var(--teal);background:var(--teal-bg);color:var(--teal-d);font-weight:600}
.form-foot{display:flex;justify-content:flex-end;gap:12px;margin-top:16px;padding-top:22px;border-top:1px solid var(--line2)}

/* ---------- import dropzone ---------- */
.dropzone{border:2px dashed #cbd5e1;border-radius:16px;padding:44px;text-align:center;background:#f8fafc}
.dropzone .dz-ico{width:64px;height:64px;border-radius:16px;background:var(--teal-bg);display:flex;align-items:center;justify-content:center;margin:0 auto 16px;color:var(--teal)}
.dropzone b{font-size:16px}
.dropzone p{color:var(--muted2);font-size:13.5px;margin:5px 0 18px}
.tip{display:flex;gap:14px;margin-top:22px;padding:16px;background:#f0f9ff;border:1px solid #d8ecfb;border-radius:14px;font-size:14px;color:#334155;line-height:1.6}
.tip .i{color:#0284c7;flex:0 0 auto}
.filelist{display:flex;flex-wrap:wrap;gap:10px;margin-top:6px}

/* import preview stat tiles */
.statgrid{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:14px;margin-bottom:16px}
.stat{background:#fff;border:1px solid var(--line);border-radius:14px;padding:16px 18px}
.stat b{display:block;font-size:26px;line-height:1;color:var(--teal)}
.stat span{display:block;font-size:12.5px;color:var(--muted);margin-top:6px}

/* ---------- login ---------- */
.login-wrap{min-height:100vh;display:grid;place-items:center;background:linear-gradient(135deg,#0f2743,#0b1e36)}
.login-card{background:#fff;border-radius:20px;padding:32px;width:min(390px,92vw);box-shadow:0 30px 70px rgba(0,0,0,.35)}
.login-brand{text-align:center;margin-bottom:20px}
.login-brand .logo{width:56px;height:56px;border-radius:15px;margin:0 auto 10px;background:linear-gradient(135deg,#14b8a6,#0d9488);display:flex;align-items:center;justify-content:center}
.login-brand strong{display:block;font-size:19px}
.login-brand small{color:var(--muted)}
.login-card .fg{margin-bottom:14px}
.login-card .hint{text-align:center;color:var(--muted2);font-size:12px;margin:14px 0 0}

@media(max-width:1000px){.kpi-grid{grid-template-columns:repeat(2,1fr)}.two-col{grid-template-columns:1fr}.branch-grid{grid-template-columns:repeat(2,1fr)}}
@media(max-width:820px){.sidebar{display:none}.main{padding:20px}.grid2{grid-template-columns:1fr}.kpi-grid,.branch-grid{grid-template-columns:1fr}}
