:root{--bg:#f5f7fb;--surface:#fff;--ink:#172033;--muted:#718096;--line:#e8ecf3;--blue:#2563eb;--blue2:#1d4ed8;--purple:#7c3aed;--green:#0f9f6e;--orange:#f97316;--amber:#d99000;--sidebar:#101828;--sidebar2:#182236;--shadow:0 12px 35px rgba(16,24,40,.06);--radius:18px}*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--ink);font-family:'DM Sans',sans-serif;font-size:14px}.app-shell{min-height:100vh;display:flex}.sidebar{width:260px;background:linear-gradient(180deg,#101827,#111a2c);color:#c7d0df;padding:18px 14px;display:flex;flex-direction:column;position:fixed;inset:0 auto 0 0;z-index:20}.brand{display:flex;align-items:center;gap:11px;padding:8px 10px 20px;color:#fff}.brand strong{font:800 21px Manrope}.brand small{display:block;color:#7f8da6;font-size:10px;margin-top:2px;letter-spacing:.7px}.brand-mark{width:34px;height:34px;background:linear-gradient(145deg,#3b82f6,#7c3aed);border-radius:10px;display:flex;align-items:center;justify-content:center;gap:2px;transform:rotate(-6deg);box-shadow:0 8px 22px #2563eb44}.brand-mark span{width:3px;height:15px;border-radius:4px;background:#fff}.brand-mark span:nth-child(2){height:20px}.brand-mark span:nth-child(3){height:11px}.lab-switcher{display:flex;align-items:center;gap:9px;background:#ffffff09;border:1px solid #ffffff12;border-radius:12px;padding:10px;margin-bottom:18px}.lab-avatar{width:34px;height:34px;border-radius:9px;background:#e9f1ff;color:#2453a6;display:grid;place-items:center;font-weight:800;font-size:11px}.lab-meta{flex:1;min-width:0}.lab-meta b,.lab-meta small{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.lab-meta b{font-size:12px;color:#eef3fb}.lab-meta small{font-size:10px;color:#77859e;margin-top:3px}.icon-btn{border:0;background:transparent;color:#8996aa;font-size:17px}.nav-label{font-size:9px;letter-spacing:1.2px;color:#66748c;font-weight:700;margin:18px 11px 7px}.nav-item{display:flex;align-items:center;gap:11px;height:40px;padding:0 11px;color:#9ca9bc;text-decoration:none;border-radius:10px;margin:2px 0;cursor:pointer;font-size:12px;font-weight:600;transition:.2s}.nav-item span{width:19px;text-align:center;font-size:16px}.nav-item em{font-style:normal;margin-left:auto;font-size:9px;background:#25324a;color:#aab8ce;padding:3px 6px;border-radius:9px}.nav-item em.orange{background:#44291a;color:#ffb37d}.nav-item:hover{background:#ffffff08;color:#fff}.nav-item.active{background:linear-gradient(90deg,#2563eb,#2858c8);color:#fff;box-shadow:0 8px 20px #2563eb22}.sidebar-bottom{margin-top:auto}.upgrade-card{background:linear-gradient(135deg,#182a4b,#18223b);border:1px solid #ffffff12;border-radius:14px;padding:13px;margin-bottom:12px}.spark{color:#7aa7ff;font-size:18px}.upgrade-card b{font-size:11px;color:#fff;display:block;margin-top:3px}.upgrade-card p{font-size:10px;color:#8594aa;line-height:1.5;margin:4px 0 9px}.upgrade-card button{border:0;background:#fff;color:#172033;border-radius:8px;font-size:10px;font-weight:700;padding:7px 9px}.user-card{display:flex;align-items:center;gap:9px;padding:10px;border-top:1px solid #ffffff0e}.user-card .avatar{width:31px;height:31px}.user-card div:nth-child(2){flex:1}.user-card b,.user-card small{display:block}.user-card b{font-size:11px;color:#e8edf6}.user-card small{font-size:9px;color:#748199;margin-top:2px}.user-card>span{color:#718096}.main{margin-left:260px;width:calc(100% - 260px)}.topbar{height:70px;background:#fff;border-bottom:1px solid var(--line);display:flex;align-items:center;justify-content:space-between;padding:0 30px;position:sticky;top:0;z-index:10}.crumb{display:flex;gap:10px;align-items:center;font-size:12px}.crumb span{color:#8b97aa}.crumb b{color:#c0c7d2}.crumb strong{color:#202b3d}.top-actions{display:flex;align-items:center;gap:10px}.search{height:38px;width:310px;border:1px solid var(--line);border-radius:10px;display:flex;align-items:center;padding:0 9px;gap:7px;background:#fafbfc}.search span{font-size:19px;color:#7b879a}.search input{border:0;outline:0;background:transparent;flex:1;font:500 11px 'DM Sans';color:var(--ink)}kbd{font:600 9px DM Sans;background:#fff;border:1px solid #e2e7ef;padding:3px 5px;border-radius:5px;color:#9aa4b3}.round-btn{width:37px;height:37px;border:1px solid var(--line);border-radius:10px;background:#fff;color:#65728a}.notification{position:relative}.notification i{position:absolute;right:7px;top:7px;width:6px;height:6px;border-radius:50%;background:#ef4444;border:1px solid #fff}.profile{display:flex;align-items:center;gap:7px;padding-left:6px;font-size:11px;font-weight:600}.avatar{background:linear-gradient(135deg,#dbeafe,#ede9fe);color:#384a8b;border-radius:50%;width:34px;height:34px;display:grid;place-items:center;font-weight:800;font-size:10px}.avatar.small{width:32px;height:32px}.profile b{color:#9ba5b5;font-size:12px}.mobile-menu{display:none}.content{padding:30px;max-width:1600px;margin:auto}.hero-row{display:flex;justify-content:space-between;align-items:flex-end;margin-bottom:25px}.eyebrow{font-size:9px;font-weight:800;letter-spacing:1.2px;color:#8a96a8;margin:0 0 7px}.hero-row h1{font:800 27px Manrope;margin:0;letter-spacing:-.6px}.hero-row h1 span{color:#7c3aed}.sub{color:#7a8799;margin:7px 0 0;font-size:12px}.hero-actions{display:flex;gap:9px}.btn{border:0;border-radius:9px;height:39px;padding:0 18px;font:700 11px DM Sans;cursor:pointer}.btn.secondary{background:#fff;border:1px solid var(--line);color:#56647a}.btn.primary{background:var(--blue);color:#fff;box-shadow:0 8px 18px #2563eb25}.stats-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:14px}.stat-card,.panel{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow)}.stat-card{padding:17px;position:relative;overflow:hidden;min-height:142px}.stat-top{display:flex;justify-content:space-between;align-items:center;color:#7c8798;font-size:11px;font-weight:600}.stat-icon{width:31px;height:31px;border-radius:9px;display:grid;place-items:center;font-weight:800}.stat-icon.blue{background:#eaf2ff;color:#2563eb}.stat-icon.purple{background:#f0eaff;color:#7c3aed}.stat-icon.green{background:#e6f8f0;color:#0f9f6e}.stat-icon.amber{background:#fff5df;color:#c18100}.stat-number{font:800 24px Manrope;margin-top:9px;letter-spacing:-.6px}.trend{font-size:9px;font-weight:800;margin-top:4px}.trend span{font-weight:500;color:#98a2b1;margin-left:3px}.trend.up{color:#0f9f6e}.trend.warn{color:#d99000}.sparkline,.mini-bars{height:27px;display:flex;align-items:flex-end;gap:4px;position:absolute;right:16px;bottom:15px;width:86px}.sparkline i,.mini-bars i{display:block;flex:1;border-radius:3px 3px 0 0;background:#bfdbfe}.purple-line i{background:#ddd0ff}.mini-bars i{background:#bdebd9}.progress{height:6px;background:#edf0f5;border-radius:10px;margin-top:16px;overflow:hidden}.progress span{height:100%;display:block;background:linear-gradient(90deg,#f6b73c,#f97316);border-radius:10px}.progress-note{font-size:8px;color:#99a3b2;display:block;margin-top:5px}.dashboard-grid{display:grid;grid-template-columns:1.8fr 1fr;gap:14px;margin-top:14px}.panel{padding:19px}.panel-head{display:flex;justify-content:space-between;align-items:flex-start;margin-bottom:15px}.panel-head h2{font:800 14px Manrope;margin:0}.panel-head p{font-size:10px;color:#8c97a7;margin:4px 0 0}.link-btn{border:0;background:transparent;color:var(--blue);font:700 10px DM Sans;cursor:pointer}.table-wrap{overflow:auto}.table-wrap table{width:100%;border-collapse:collapse;min-width:670px}.table-wrap th{text-align:left;color:#98a1b0;font-size:9px;font-weight:700;text-transform:uppercase;letter-spacing:.4px;padding:8px 9px;border-bottom:1px solid var(--line)}.table-wrap td{padding:11px 9px;border-bottom:1px solid #f0f2f6;color:#6d788b;font-size:10px}.table-wrap tr:last-child td{border-bottom:0}.patient{display:flex;align-items:center;gap:8px}.patient b,.patient small{display:block}.patient b{color:#283346;font-size:10px}.patient small{font-size:8px;color:#9aa3b1;margin-top:3px}.p-avatar{width:30px;height:30px;border-radius:9px;display:grid;place-items:center;font-size:9px;font-weight:800}.a1{background:#e8f0ff;color:#315ec0}.a2{background:#f2eaff;color:#7545c7}.a3{background:#e8f9f1;color:#1b8e66}.a4{background:#fff1e8;color:#bd6c2b}.pill{font-size:8px;font-weight:800;padding:5px 7px;border-radius:20px;display:inline-block}.pill.success{background:#e8f8f1;color:#13855f}.pill.progress-pill{background:#edf3ff;color:#3565c9}.pill.pending{background:#fff5e4;color:#b97700}.activity-panel{min-height:100%}.live{font-size:9px;font-weight:800;color:#12956a;display:flex;gap:5px;align-items:center}.live i{width:6px;height:6px;border-radius:50%;background:#21b37f;box-shadow:0 0 0 4px #dff8ed}.activity-list{display:flex;flex-direction:column}.activity{display:flex;gap:10px;padding:12px 0;border-bottom:1px solid #f0f2f6}.activity:last-child{border-bottom:0}.activity-icon{width:30px;height:30px;border-radius:9px;display:grid;place-items:center;font-weight:800;flex:none}.activity-icon.blue{background:#eaf2ff;color:#2563eb}.activity-icon.green{background:#e8f8f1;color:#0f9f6e}.activity-icon.purple{background:#f0eaff;color:#7c3aed}.activity-icon.amber{background:#fff5df;color:#c18100}.activity b{font-size:10px}.activity p{margin:3px 0;color:#718096;font-size:9px}.activity small{color:#a3acb9;font-size:8px}.bottom-grid{display:grid;grid-template-columns:1.8fr 1fr;gap:14px;margin-top:14px}.chart-panel{min-height:280px}.chart-panel select{border:1px solid var(--line);border-radius:7px;padding:6px 9px;background:#fff;color:#667388;font:600 9px DM Sans}.chart{display:flex;height:190px;margin-top:12px}.y-labels{width:40px;display:flex;flex-direction:column;justify-content:space-between;color:#a5adba;font-size:8px;padding:4px 0 20px}.chart-area{position:relative;flex:1}.grid-lines{position:absolute;inset:0 0 22px;background:repeating-linear-gradient(to bottom,#fff 0,#fff 44px,#eef1f5 45px);border-top:1px solid #eef1f5}.chart svg{position:absolute;inset:0 0 23px;width:100%;height:calc(100% - 23px)}.x-labels{position:absolute;bottom:0;left:0;right:0;display:flex;justify-content:space-between;color:#a5adba;font-size:8px}.quick-panel{min-height:280px}.quick-grid{display:grid;grid-template-columns:1fr 1fr;gap:9px}.quick-grid button{position:relative;text-align:left;background:#fbfcfe;border:1px solid #edf0f5;border-radius:11px;padding:12px;cursor:pointer;min-height:95px;transition:.2s}.quick-grid button:hover{border-color:#cbd8f5;transform:translateY(-2px);box-shadow:0 8px 18px #1720330a}.qa{width:29px;height:29px;border-radius:8px;display:grid;place-items:center;margin-bottom:8px;font-weight:800}.qa.blue{background:#eaf2ff;color:#2563eb}.qa.purple{background:#f0eaff;color:#7c3aed}.qa.green{background:#e8f8f1;color:#0f9f6e}.qa.orange{background:#fff0e7;color:#ed6c22}.quick-grid b,.quick-grid small{display:block}.quick-grid b{font-size:9px}.quick-grid small{font-size:8px;color:#9aa3b1;margin-top:3px}.quick-grid strong{position:absolute;right:10px;bottom:11px;color:#b0b8c4}.modal-backdrop{position:fixed;inset:0;background:#0b1220aa;backdrop-filter:blur(4px);display:none;align-items:center;justify-content:center;z-index:50;padding:20px}.modal-backdrop.show{display:flex}.modal{background:#fff;border-radius:18px;width:min(900px,100%);max-height:90vh;overflow:auto;box-shadow:0 30px 90px #10182844}.modal-head{padding:20px 22px;border-bottom:1px solid var(--line);display:flex;justify-content:space-between;align-items:center}.modal-head h2{font:800 17px Manrope;margin:0}.modal-head p{font-size:10px;color:#8994a5;margin:4px 0 0}.modal-head .close{border:0;background:#f4f6f9;width:32px;height:32px;border-radius:8px;cursor:pointer}.modal-body{padding:22px}.form-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:14px}.field label{font-size:9px;font-weight:800;color:#6c778a;display:block;margin-bottom:6px}.field input,.field select,.field textarea{width:100%;height:42px;border:1px solid #e2e7ef;border-radius:8px;padding:0 12px;outline:none;font:500 13px DM Sans;color:#263247;background:#fff}.field textarea{height:80px;padding-top:10px}.field input:focus,.field select:focus{border-color:#8bb0ff;box-shadow:0 0 0 3px #2563eb12}.full{grid-column:1/-1}.modal-foot{display:flex;justify-content:flex-end;align-items:center;flex-wrap:wrap;gap:12px;padding:15px 22px;border-top:1px solid var(--line);background:#fbfcfe}.modal-foot .btn{white-space:nowrap;flex-shrink:0}
.password-field{position:relative}
.password-field input{width:100%;padding-right:42px}
.pw-toggle{position:absolute;right:10px;top:50%;transform:translateY(-50%);background:none;border:0;cursor:pointer;padding:4px;color:#8a96a8;display:flex;align-items:center;justify-content:center}
.pw-toggle:hover{color:#56647a}.toast{position:fixed;right:25px;bottom:25px;background:#101828;color:#fff;border-radius:12px;padding:12px 15px;display:flex;gap:10px;align-items:center;box-shadow:0 18px 45px #10182844;transform:translateY(130px);opacity:0;transition:.3s;z-index:70}.toast.show{transform:translateY(0);opacity:1}.toast>span{width:25px;height:25px;border-radius:7px;background:#0f9f6e;display:grid;place-items:center}.toast b,.toast small{display:block}.toast b{font-size:10px}.toast small{font-size:8px;color:#9aa6b8;margin-top:2px}.page-placeholder{padding:35px}.empty-card{background:#fff;border:1px solid var(--line);border-radius:18px;padding:45px;text-align:center;box-shadow:var(--shadow)}.empty-card .big-icon{width:60px;height:60px;border-radius:18px;background:#eaf2ff;color:#2563eb;display:grid;place-items:center;font-size:25px;margin:0 auto 15px}.empty-card h2{font:800 20px Manrope;margin:0}.empty-card p{color:#8490a1;font-size:11px;max-width:430px;margin:7px auto 18px}.mini-table{margin-top:18px;width:100%;border-collapse:collapse;text-align:left}.mini-table th,.mini-table td{padding:12px;border-bottom:1px solid var(--line);font-size:10px}.report-demo{border:1px solid #dfe5ee;border-radius:12px;overflow:hidden;margin-top:16px}.report-head{padding:16px;background:linear-gradient(135deg,#f8fbff,#f6f3ff);display:flex;justify-content:space-between}.report-head h3{margin:0;font:800 16px Manrope}.report-head small{color:#78859a}.report-table{width:100%;border-collapse:collapse}.report-table th,.report-table td{padding:10px 12px;border-bottom:1px solid #edf0f4;text-align:left;font-size:10px}.report-table th{background:#fafbfc;color:#8a96a7}.flag-high{color:#d23b43;font-weight:800}.flag-normal{color:#0f9f6e;font-weight:800}@media(max-width:1100px){.stats-grid{grid-template-columns:repeat(2,1fr)}.dashboard-grid,.bottom-grid{grid-template-columns:1fr}.search{width:230px}}@media(max-width:800px){.sidebar{transform:translateX(-100%);transition:.25s}.sidebar.open{transform:translateX(0)}.main{margin-left:0;width:100%}.mobile-menu{display:block;border:0;background:transparent;font-size:20px;margin-right:10px}.topbar{padding:0 15px}.crumb{display:none}.profile span,.profile b{display:none}.search{width:min(45vw,260px)}.content{padding:18px}.hero-row{align-items:flex-start;gap:15px;flex-direction:column}.hero-actions{width:100%}.hero-actions .btn{flex:1}.stats-grid{grid-template-columns:1fr 1fr}.form-grid{grid-template-columns:1fr 1fr}}@media(max-width:540px){.stats-grid{grid-template-columns:1fr}.search{display:none}.top-actions{margin-left:auto}.form-grid{grid-template-columns:1fr}.quick-grid{grid-template-columns:1fr 1fr}.panel{padding:14px}.hero-row h1{font-size:23px}}

/* ============ AUTH SCREENS, PROFILE MENU, ACCESS DENIED ============ */
.auth-wrap{min-height:100vh;display:flex;align-items:center;justify-content:center;background:var(--bg);padding:20px}
.auth-card{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow);width:min(560px,100%);padding:36px}
.auth-brand{display:flex;align-items:center;gap:11px;margin-bottom:22px}
.auth-brand .brand-mark{width:34px;height:34px;background:linear-gradient(145deg,#3b82f6,#7c3aed);border-radius:10px;display:flex;align-items:center;justify-content:center;gap:2px;transform:rotate(-6deg);box-shadow:0 8px 22px #2563eb44}
.auth-brand .brand-mark span{width:3px;height:15px;border-radius:4px;background:#fff}
.auth-brand .brand-mark span:nth-child(2){height:20px}
.auth-brand .brand-mark span:nth-child(3){height:11px}
.auth-brand strong{font:800 20px Manrope;color:var(--ink)}
.auth-card h1{font:800 22px Manrope;margin:0 0 6px;color:var(--ink)}
.auth-card p.sub{margin:0 0 22px}
.auth-steps{display:flex;gap:8px;margin-bottom:22px}
.auth-steps span{flex:1;height:4px;border-radius:4px;background:var(--line)}
.auth-steps span.done{background:var(--blue)}
.auth-error{background:#fef2f2;border:1px solid #fecaca;color:#b91c1c;font-size:11px;padding:10px 12px;border-radius:8px;margin-bottom:14px}
[data-theme="dark"] .auth-error{background:#3a1518;border-color:#5c2228;color:#f6a3a9}
.auth-success{text-align:center;padding:10px 0}
.auth-success .big-icon{width:64px;height:64px;border-radius:18px;background:#e8f8f1;color:#0f9f6e;display:grid;place-items:center;font-size:28px;margin:0 auto 18px}
.profile-menu{display:none;position:absolute;top:44px;right:0;background:var(--surface);border:1px solid var(--line);border-radius:12px;box-shadow:0 18px 45px rgba(16,24,40,.18);min-width:220px;padding:10px;z-index:60;text-align:left}
.profile-menu.show{display:block}
.profile-menu .pm-head{padding:8px 10px 10px;border-bottom:1px solid var(--line);margin-bottom:6px}
.profile-menu .pm-head b{display:block;font-size:12px;color:var(--ink)}
.profile-menu .pm-head small{display:block;font-size:10px;color:var(--muted);margin-top:2px}
.profile-menu button{width:100%;text-align:left;background:transparent;border:0;padding:9px 10px;border-radius:8px;font:600 11px DM Sans;color:var(--ink);cursor:pointer}
.profile-menu button:hover{background:var(--bg)}
.profile-menu button.danger{color:#d23b43}
.perm-table{width:100%;border-collapse:collapse;margin-top:16px}
.perm-table th,.perm-table td{padding:10px 12px;border-bottom:1px solid var(--line);text-align:center;font-size:10px}
.perm-table th:first-child,.perm-table td:first-child{text-align:left;font-weight:700;color:var(--ink)}
.perm-table input[type="checkbox"]{width:16px;height:16px;cursor:pointer}

/* ============ DARK THEME ============
   Most surfaces already read from CSS variables (--bg, --surface, --ink,
   --line), so redefining those here covers the majority of the app for
   free. The rules below patch the handful of places the original design
   used a literal hex color instead of a variable (inputs, modal, topbar,
   report table header, etc.) so dark mode reaches every corner without
   touching a single existing light-theme rule. */
[data-theme="dark"] {
  --bg: #0d1220;
  --surface: #151b2c;
  --surface2: #1c2438;
  --ink: #e7ebf5;
  --muted: #93a0b8;
  --line: #2a3350;
  --shadow: 0 12px 35px rgba(0,0,0,.35);
}
[data-theme="dark"] .sidebar { background: linear-gradient(180deg,#080c16,#0a0f1c); }
[data-theme="dark"] .topbar { background: var(--surface); }
[data-theme="dark"] .crumb strong { color: var(--ink); }
[data-theme="dark"] .mobile-menu { color: var(--ink); }
[data-theme="dark"] .search { background: var(--surface2); }
[data-theme="dark"] .search input { color: var(--ink); }
[data-theme="dark"] .search span { color: var(--muted); }
[data-theme="dark"] kbd { background: var(--surface2); border-color: var(--line); color: var(--muted); }
[data-theme="dark"] .round-btn { background: var(--surface2); border-color: var(--line); color: var(--muted); }
[data-theme="dark"] .btn.secondary { background: var(--surface2); border-color: var(--line); color: var(--ink); }
[data-theme="dark"] .table-wrap td { color: var(--muted); border-bottom-color: var(--line); }
[data-theme="dark"] .patient b { color: var(--ink); }
[data-theme="dark"] .chart-panel select { background: var(--surface2); color: var(--ink); border-color: var(--line); }
[data-theme="dark"] .grid-lines { background: repeating-linear-gradient(to bottom, var(--surface) 0, var(--surface) 44px, var(--line) 45px); }
[data-theme="dark"] .quick-grid button { background: var(--surface2); border-color: var(--line); }
[data-theme="dark"] .quick-grid button:hover { border-color: var(--blue); }
[data-theme="dark"] .modal { background: var(--surface); }
[data-theme="dark"] .modal-head .close { background: var(--surface2); color: var(--ink); }
[data-theme="dark"] .field label { color: var(--muted); }
[data-theme="dark"] .field input,
[data-theme="dark"] .field select,
[data-theme="dark"] .field textarea { background: var(--surface2); border-color: var(--line); color: var(--ink); }
[data-theme="dark"] .modal-foot { background: var(--surface2); border-top-color: var(--line); }
[data-theme="dark"] .report-demo { border-color: var(--line); }
[data-theme="dark"] .report-head { background: linear-gradient(135deg, var(--surface2), var(--surface)); }
[data-theme="dark"] .report-table th { background: var(--surface2); color: var(--muted); }
[data-theme="dark"] .report-table td { border-bottom-color: var(--line); }
[data-theme="dark"] .mini-table th, [data-theme="dark"] .mini-table td { border-bottom-color: var(--line); }
[data-theme="dark"] .lab-switcher { background: #ffffff06; border-color: #ffffff10; }