/* ============================================================
   MediLab Diagnostics — Design System
   Modern clinical SaaS: soft surfaces, indigo/teal accents,
   dark mode, responsive, print-ready.
   ============================================================ */
:root{
  --font: "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", "Cascadia Code", Consolas, "Liberation Mono", monospace;

  --bg: #f4f6fb;
  --bg-soft: #eef1f8;
  --surface: #ffffff;
  --surface-2: #f8fafd;
  --surface-3: #f1f4fa;
  --border: #e3e8f2;
  --border-strong: #d3daea;
  --text: #0f1a2e;
  --text-2: #4a5670;
  --text-3: #7c89a3;

  --primary: #4f46e5;
  --primary-2: #6366f1;
  --primary-soft: #eef0ff;
  --primary-text: #4338ca;
  --teal: #0d9488;
  --teal-soft: #e6faf7;
  --green: #16a34a;
  --green-soft: #e9f9ef;
  --amber: #d97706;
  --amber-soft: #fef5e7;
  --red: #dc2626;
  --red-soft: #fdeeee;
  --violet: #7c3aed;
  --violet-soft: #f3edff;
  --blue: #2563eb;
  --blue-soft: #eaf1fe;
  --pink: #db2777;

  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;
  --shadow-xs: 0 1px 2px rgba(15,26,46,.05);
  --shadow-sm: 0 1px 3px rgba(15,26,46,.06), 0 1px 2px rgba(15,26,46,.04);
  --shadow: 0 6px 20px -6px rgba(15,26,46,.12), 0 2px 6px rgba(15,26,46,.05);
  --shadow-lg: 0 24px 60px -12px rgba(15,26,46,.22), 0 8px 24px rgba(15,26,46,.08);

  --sidebar-w: 260px;
  --topbar-h: 64px;
  --sidebar-bg: linear-gradient(178deg,#0c1428 0%,#101c38 55%,#0d1730 100%);
  --sidebar-text: #aab6d4;
  --sidebar-active: #ffffff;
}

[data-theme="dark"]{
  --bg: #070c18;
  --bg-soft: #0a1122;
  --surface: #0e1730;
  --surface-2: #111c39;
  --surface-3: #16223f;
  --border: #1e2b4a;
  --border-strong: #2a3a5f;
  --text: #e7ecf7;
  --text-2: #a7b3cd;
  --text-3: #71809f;
  --primary-soft: #1a1f4d;
  --primary-text: #a5b4fc;
  --teal-soft: #0c2f2c;
  --green-soft: #0d2a1c;
  --amber-soft: #2d2008;
  --red-soft: #2e1113;
  --violet-soft: #241545;
  --blue-soft: #101f3e;
  --shadow: 0 8px 24px -8px rgba(0,0,0,.6), 0 2px 8px rgba(0,0,0,.4);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.4);
  --sidebar-bg: linear-gradient(178deg,#060b16 0%,#0a1428 100%);
}

*,*::before,*::after{ box-sizing:border-box; }
html{ -webkit-text-size-adjust:100%; }
body{
  margin:0; font-family:var(--font); background:var(--bg); color:var(--text);
  font-size:14px; line-height:1.55; -webkit-font-smoothing:antialiased;
}
h1,h2,h3,h4,h5{ margin:0; font-weight:650; letter-spacing:-.015em; }
p{ margin:0; }
a{ color:var(--primary); text-decoration:none; }
a:hover{ text-decoration:underline; }
button{ font-family:inherit; }
.ico{ vertical-align:-3px; flex:none; }
.mono{ font-family:var(--mono); font-size:.92em; letter-spacing:-.02em; }
.muted{ color:var(--text-3); }
.text2{ color:var(--text-2); }
.tiny{ font-size:12px; }
.small{ font-size:13px; }
.nowrap{ white-space:nowrap; }
.tnum{ font-variant-numeric:tabular-nums; }
.center{ text-align:center; }
.right{ text-align:right; }
.strong{ font-weight:650; }
.spacer{ flex:1; }
.hidden{ display:none !important; }
hr.sep{ border:0; border-top:1px solid var(--border); margin:16px 0; }

/* ---------- App shell ---------- */
.app{ display:flex; min-height:100vh; }

.sidebar{
  width:var(--sidebar-w); flex:none; position:fixed; inset:0 auto 0 0; z-index:60;
  background:var(--sidebar-bg); color:var(--sidebar-text);
  display:flex; flex-direction:column; transition:transform .25s ease;
  border-right:1px solid rgba(255,255,255,.06);
}
.sidebar-brand{
  display:flex; align-items:center; gap:11px; padding:18px 20px 16px;
  border-bottom:1px solid rgba(255,255,255,.07);
}
.brand-mark{
  width:38px; height:38px; border-radius:11px; flex:none;
  background:linear-gradient(135deg,#6366f1,#0ea5e9);
  display:grid; place-items:center; color:#fff;
  box-shadow:0 6px 16px -4px rgba(99,102,241,.7), inset 0 1px 0 rgba(255,255,255,.25);
}
.brand-name{ color:#fff; font-weight:700; font-size:15px; letter-spacing:-.01em; line-height:1.15; }
.brand-sub{ font-size:11px; color:#7f8db0; letter-spacing:.06em; text-transform:uppercase; }

.sidebar-nav{ flex:1; overflow-y:auto; padding:14px 12px 24px; scrollbar-width:thin; }
.sidebar-nav::-webkit-scrollbar{ width:4px; }
.sidebar-nav::-webkit-scrollbar-thumb{ background:rgba(255,255,255,.14); border-radius:4px; }
.nav-section{ font-size:10.5px; font-weight:700; letter-spacing:.11em; text-transform:uppercase; color:#5f6e92; padding:16px 12px 7px; }
.nav-item{
  display:flex; align-items:center; gap:11px; padding:9px 12px; border-radius:10px;
  color:var(--sidebar-text); font-weight:500; font-size:13.5px; margin-bottom:2px;
  transition:background .15s, color .15s; text-decoration:none; position:relative;
}
.nav-item:hover{ background:rgba(255,255,255,.065); color:#fff; text-decoration:none; }
.nav-item.active{
  background:linear-gradient(92deg,rgba(99,102,241,.32),rgba(99,102,241,.12));
  color:#fff; box-shadow:inset 0 0 0 1px rgba(129,140,248,.28);
}
.nav-item.active::before{
  content:""; position:absolute; left:-12px; top:9px; bottom:9px; width:3px;
  border-radius:0 3px 3px 0; background:linear-gradient(#818cf8,#22d3ee);
}
.nav-item .ico{ opacity:.85; }
.nav-item.active .ico{ opacity:1; color:#c7d2fe; }
.nav-badge{
  margin-left:auto; font-size:10.5px; font-weight:700; min-width:20px; text-align:center;
  background:rgba(255,255,255,.14); color:#fff; border-radius:20px; padding:1px 6px;
}
.nav-badge.hot{ background:#ef4444; box-shadow:0 0 0 3px rgba(239,68,68,.18); }

.sidebar-foot{
  padding:12px; border-top:1px solid rgba(255,255,255,.07); display:flex; align-items:center; gap:10px;
}
.sidebar-foot .avatar{ width:34px; height:34px; font-size:12px; }
.sidebar-foot .who{ min-width:0; }
.sidebar-foot .who b{ display:block; color:#fff; font-size:12.5px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.sidebar-foot .who span{ font-size:11px; color:#7f8db0; text-transform:capitalize; }

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

.topbar{
  height:var(--topbar-h); position:sticky; top:0; z-index:40;
  display:flex; align-items:center; gap:14px; padding:0 26px;
  background:color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter:blur(14px); -webkit-backdrop-filter:blur(14px);
  border-bottom:1px solid var(--border);
}
.page-heading h1{ font-size:17px; line-height:1.2; }
.page-heading .crumb{ font-size:11.5px; color:var(--text-3); margin-top:1px; }
.topbar .spacer{ flex:1; }

.global-search{
  display:flex; align-items:center; gap:8px; background:var(--surface);
  border:1px solid var(--border); border-radius:10px; padding:7px 11px;
  min-width:230px; color:var(--text-3); box-shadow:var(--shadow-xs);
}
.global-search input{
  border:0; outline:0; background:transparent; color:var(--text); font-size:13px; width:100%; font-family:inherit;
}
.kbd{
  font-family:var(--mono); font-size:10.5px; border:1px solid var(--border-strong); border-bottom-width:2px;
  border-radius:5px; padding:0 5px; color:var(--text-3); background:var(--surface-2);
}

.icon-btn{
  width:36px; height:36px; display:inline-grid; place-items:center; border-radius:10px;
  border:1px solid var(--border); background:var(--surface); color:var(--text-2);
  cursor:pointer; transition:.15s; position:relative; flex:none;
}
.icon-btn:hover{ color:var(--text); border-color:var(--border-strong); background:var(--surface-2); }
.icon-btn .dot{
  position:absolute; top:7px; right:8px; width:7px; height:7px; border-radius:50%;
  background:#ef4444; box-shadow:0 0 0 2px var(--surface);
}

.avatar{
  width:36px; height:36px; border-radius:10px; display:grid; place-items:center; flex:none;
  background:linear-gradient(135deg,#6366f1,#8b5cf6); color:#fff; font-weight:700; font-size:13px;
  letter-spacing:.01em;
}
.avatar.sm{ width:30px; height:30px; font-size:11px; border-radius:9px; }
.avatar.lg{ width:64px; height:64px; font-size:20px; border-radius:16px; }
.avatar.teal{ background:linear-gradient(135deg,#0d9488,#14b8a6); }

.user-chip{ display:flex; align-items:center; gap:9px; padding:4px 5px 4px 4px; border-radius:11px; cursor:pointer; }
.user-chip:hover{ background:var(--surface-2); }
.user-chip .who{ line-height:1.25; }
.user-chip .who b{ display:block; font-size:12.5px; }
.user-chip .who span{ font-size:11px; color:var(--text-3); text-transform:capitalize; }

.dropdown{ position:relative; }
.dropdown-menu{
  position:absolute; right:0; top:calc(100% + 8px); min-width:210px; z-index:70;
  background:var(--surface); border:1px solid var(--border); border-radius:12px;
  box-shadow:var(--shadow-lg); padding:6px; display:none;
}
.dropdown.open .dropdown-menu{ display:block; animation:pop .14s ease; }
@keyframes pop{ from{ opacity:0; transform:translateY(-4px) scale(.98); } }
.dropdown-menu a, .dropdown-menu button{
  display:flex; align-items:center; gap:9px; width:100%; padding:8px 10px; border:0; background:none;
  border-radius:8px; color:var(--text-2); font-size:13px; cursor:pointer; text-align:left; font-family:inherit;
}
.dropdown-menu a:hover, .dropdown-menu button:hover{ background:var(--surface-2); color:var(--text); text-decoration:none; }
.dropdown-menu .danger{ color:var(--red); }
.dropdown-menu .menu-sep{ height:1px; background:var(--border); margin:5px 4px; }
.dropdown-head{ padding:9px 10px 7px; }
.dropdown-head b{ display:block; font-size:13px; }
.dropdown-head span{ font-size:11.5px; color:var(--text-3); }

/* ---------- Content ---------- */
.content{ padding:24px 26px 60px; max-width:1560px; width:100%; margin:0 auto; }

.page-intro{ display:flex; align-items:flex-end; gap:16px; margin-bottom:20px; flex-wrap:wrap; }
.page-intro h2{ font-size:22px; }
.page-intro p{ color:var(--text-3); font-size:13px; margin-top:3px; }
.page-intro .actions{ margin-left:auto; display:flex; gap:9px; flex-wrap:wrap; }

.card{
  background:var(--surface); border:1px solid var(--border); border-radius:var(--radius);
  box-shadow:var(--shadow-sm); min-width:0;
}
.card-pad{ padding:20px; }
.card-head{
  display:flex; align-items:center; gap:12px; padding:16px 20px; border-bottom:1px solid var(--border);
}
.card-head h3{ font-size:14.5px; }
.card-head .sub{ font-size:12px; color:var(--text-3); }
.card-head .actions{ margin-left:auto; display:flex; gap:8px; align-items:center; }
.card-body{ padding:20px; }
.card-foot{ padding:13px 20px; border-top:1px solid var(--border); background:var(--surface-2); border-radius:0 0 var(--radius) var(--radius); }

/* Stat cards */
.stats{ display:grid; grid-template-columns:repeat(auto-fit,minmax(215px,1fr)); gap:16px; }
.stat{
  background:var(--surface); border:1px solid var(--border); border-radius:var(--radius);
  padding:17px 18px 15px; box-shadow:var(--shadow-sm); position:relative; overflow:hidden;
  transition:transform .16s ease, box-shadow .16s ease;
}
.stat:hover{ transform:translateY(-2px); box-shadow:var(--shadow); }
.stat::after{
  content:""; position:absolute; right:-26px; top:-26px; width:96px; height:96px; border-radius:50%;
  background:radial-gradient(circle, var(--tint, rgba(99,102,241,.13)), transparent 68%);
}
.stat .top{ display:flex; align-items:center; gap:10px; margin-bottom:11px; }
.stat .label{ font-size:12px; font-weight:600; color:var(--text-3); text-transform:uppercase; letter-spacing:.055em; }
.stat .ic{
  width:33px; height:33px; border-radius:9px; display:grid; place-items:center; margin-left:auto;
  background:var(--tint-bg, var(--primary-soft)); color:var(--tint-fg, var(--primary));
}
.stat .value{ font-size:27px; font-weight:700; letter-spacing:-.03em; line-height:1.1; font-variant-numeric:tabular-nums; }
.stat .value small{ font-size:14px; font-weight:600; color:var(--text-3); margin-left:3px; }
.stat .foot{ display:flex; align-items:center; gap:6px; margin-top:7px; font-size:12px; color:var(--text-3); }
.delta{ display:inline-flex; align-items:center; gap:2px; font-weight:650; font-size:11.5px; padding:1px 6px; border-radius:20px; }
.delta.up{ color:var(--green); background:var(--green-soft); }
.delta.down{ color:var(--red); background:var(--red-soft); }
.delta.flat{ color:var(--text-3); background:var(--surface-3); }

/* ---------- Buttons ---------- */
.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:7px;
  padding:8.5px 15px; border-radius:10px; border:1px solid transparent; font-size:13px;
  font-weight:600; cursor:pointer; transition:.15s; text-decoration:none; white-space:nowrap;
  line-height:1.3; font-family:inherit;
}
.btn:hover{ text-decoration:none; }
.btn-sm{ padding:6px 11px; font-size:12px; border-radius:8px; }
.btn-lg{ padding:11px 20px; font-size:14px; border-radius:11px; }
.btn-primary{
  background:linear-gradient(180deg,#6366f1,#4f46e5); color:#fff;
  box-shadow:0 1px 2px rgba(79,70,229,.35), 0 6px 16px -6px rgba(79,70,229,.55), inset 0 1px 0 rgba(255,255,255,.18);
}
.btn-primary:hover{ filter:brightness(1.06); color:#fff; }
.btn-secondary{
  background:var(--surface); color:var(--text); border-color:var(--border-strong); box-shadow:var(--shadow-xs);
}
.btn-secondary:hover{ background:var(--surface-2); color:var(--text); }
.btn-soft{ background:var(--primary-soft); color:var(--primary-text); }
.btn-soft:hover{ filter:brightness(.97); color:var(--primary-text); }
.btn-success{ background:linear-gradient(180deg,#22c55e,#16a34a); color:#fff; box-shadow:0 6px 16px -6px rgba(22,163,74,.5); }
.btn-success:hover{ filter:brightness(1.05); color:#fff; }
.btn-danger{ background:linear-gradient(180deg,#ef4444,#dc2626); color:#fff; }
.btn-danger:hover{ filter:brightness(1.05); color:#fff; }
.btn-ghost{ color:var(--text-2); background:transparent; }
.btn-ghost:hover{ background:var(--surface-3); color:var(--text); }
.btn-outline{ border-color:var(--border-strong); color:var(--text-2); background:transparent; }
.btn-outline:hover{ border-color:var(--primary); color:var(--primary); background:var(--primary-soft); }
.btn[disabled]{ opacity:.5; pointer-events:none; }
.btn-block{ width:100%; }
.btn-row{ display:flex; gap:8px; flex-wrap:wrap; }

/* ---------- Forms ---------- */
.field{ margin-bottom:15px; }
.field > label{ display:block; font-size:12.5px; font-weight:600; color:var(--text-2); margin-bottom:5px; }
.field .hint{ font-size:11.5px; color:var(--text-3); margin-top:4px; }
.req{ color:var(--red); }
input:not([type]),input[type=text],input[type=search],input[type=email],input[type=password],input[type=number],input[type=date],
input[type=time],input[type=datetime-local],input[type=tel],input[type=url],input[type=color],select,textarea{
  width:100%; padding:9px 12px; border:1px solid var(--border-strong); border-radius:10px;
  background:var(--surface); color:var(--text); font-size:13.5px; font-family:inherit;
  transition:border-color .15s, box-shadow .15s; outline:none;
}
input:focus,select:focus,textarea:focus{ border-color:var(--primary); box-shadow:0 0 0 3px rgba(99,102,241,.14); }
input::placeholder,textarea::placeholder{ color:var(--text-3); }
select{ appearance:none; background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%237c89a3' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat:no-repeat; background-position:right 11px center; padding-right:32px; }
textarea{ resize:vertical; min-height:76px; }
.grid{ display:grid; gap:15px; }
.grid-2{ grid-template-columns:1fr 1fr; }
.grid-3{ grid-template-columns:repeat(3,1fr); }
.grid-4{ grid-template-columns:repeat(4,1fr); }
.grid-auto{ grid-template-columns:repeat(auto-fit,minmax(190px,1fr)); }
@media(max-width:900px){ .grid-3,.grid-4{ grid-template-columns:1fr 1fr; } }
@media(max-width:620px){ .grid-2,.grid-3,.grid-4{ grid-template-columns:1fr; } }
.form-actions{ display:flex; gap:9px; padding-top:6px; }
.check{ display:flex; align-items:center; gap:8px; font-size:13px; color:var(--text-2); cursor:pointer; }
.check input{ width:16px; height:16px; accent-color:var(--primary); }

.seg{ display:inline-flex; background:var(--surface-3); border-radius:10px; padding:3px; gap:2px; }
.seg button, .seg a{
  border:0; background:transparent; padding:6px 13px; border-radius:8px; font-size:12.5px;
  font-weight:600; color:var(--text-3); cursor:pointer; font-family:inherit; text-decoration:none !important;
}
.seg button.on, .seg a.on{ background:var(--surface); color:var(--text); box-shadow:var(--shadow-xs); }

/* ---------- Tables ---------- */
.table-wrap{ overflow-x:auto; border-radius:0 0 var(--radius) var(--radius); min-width:0; }
table.tbl{ width:100%; border-collapse:separate; border-spacing:0; font-size:13px; }
.tbl th{
  text-align:left; font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.06em;
  color:var(--text-3); padding:11px 14px; background:var(--surface-2); border-bottom:1px solid var(--border);
  white-space:nowrap; position:sticky; top:0; z-index:1;
}
.tbl td{ padding:11px 14px; border-bottom:1px solid var(--border); vertical-align:middle; }
.tbl tbody tr:last-child td{ border-bottom:0; }
.tbl tbody tr{ transition:background .12s; }
.tbl tbody tr:hover{ background:var(--surface-2); }
.tbl .row-link{ cursor:pointer; }
.tbl td.actions{ text-align:right; white-space:nowrap; }
.tbl .sub{ font-size:11.5px; color:var(--text-3); }
.tbl td.nw, .tbl td.mono, .tbl th.nw{ white-space:nowrap; }
.tbl.wide{ min-width:1060px; }
.tbl.mid{ min-width:820px; }
.tbl.compact th{ padding:8px 12px; }
.tbl.compact td{ padding:8px 12px; }
.empty-state{ text-align:center; padding:52px 20px; color:var(--text-3); }
.empty-state .ic-wrap{
  width:56px; height:56px; border-radius:16px; background:var(--surface-3); display:grid; place-items:center;
  margin:0 auto 13px; color:var(--text-3);
}
.empty-state h4{ color:var(--text); font-size:15px; margin-bottom:4px; }

/* ---------- Badges & pills ---------- */
.badge{
  display:inline-flex; align-items:center; gap:4px; font-size:11px; font-weight:650;
  padding:2.5px 8px; border-radius:20px; white-space:nowrap; line-height:1.5;
}
.badge::before{ content:""; width:5px; height:5px; border-radius:50%; background:currentColor; opacity:.85; }
.badge-slate{ background:var(--surface-3); color:var(--text-2); }
.badge-blue{ background:var(--blue-soft); color:var(--blue); }
.badge-amber{ background:var(--amber-soft); color:var(--amber); }
.badge-violet{ background:var(--violet-soft); color:var(--violet); }
.badge-green{ background:var(--green-soft); color:var(--green); }
.badge-teal{ background:var(--teal-soft); color:var(--teal); }
.badge-red{ background:var(--red-soft); color:var(--red); }
.badge-critical{ background:var(--red); color:#fff; animation:pulse 2s infinite; }
.badge-critical::before{ background:#fff; }
@keyframes pulse{ 0%,100%{ box-shadow:0 0 0 0 rgba(220,38,38,.4);} 50%{ box-shadow:0 0 0 5px rgba(220,38,38,0);} }
.badge-plain::before{ display:none; }
.chip{
  display:inline-flex; align-items:center; gap:5px; font-size:12px; padding:3px 9px; border-radius:20px;
  background:var(--surface-3); color:var(--text-2); font-weight:550;
}
.priority{ font-size:10px; font-weight:800; padding:2px 7px; border-radius:5px; letter-spacing:.05em; text-transform:uppercase; }
.priority.STAT{ background:#fef2f2; color:#dc2626; border:1px solid #fecaca; }
.priority.Urgent{ background:#fffbeb; color:#d97706; border:1px solid #fde68a; }
[data-theme="dark"] .priority.STAT{ background:#3a1214; border-color:#7f1d1d; }
[data-theme="dark"] .priority.Urgent{ background:#332406; border-color:#78350f; }

/* ---------- Flash / toast ---------- */
.flashes{ position:fixed; top:76px; right:22px; z-index:200; display:flex; flex-direction:column; gap:9px; max-width:380px; }
.flash{
  display:flex; gap:10px; align-items:flex-start; padding:12px 14px; border-radius:12px;
  background:var(--surface); border:1px solid var(--border); box-shadow:var(--shadow-lg);
  font-size:13px; animation:slideIn .25s ease;
}
.flash.success{ border-left:3px solid var(--green); }
.flash.error{ border-left:3px solid var(--red); }
.flash.info{ border-left:3px solid var(--blue); }
.flash .msg{ flex:1; color:var(--text); }
.flash .x{ border:0; background:none; color:var(--text-3); cursor:pointer; padding:0; }
@keyframes slideIn{ from{ opacity:0; transform:translateX(24px);} }

/* ---------- Modal ---------- */
.modal-backdrop{
  position:fixed; inset:0; background:rgba(8,14,28,.55); backdrop-filter:blur(3px);
  z-index:150; display:none; align-items:flex-start; justify-content:center; padding:6vh 20px 20px; overflow-y:auto;
}
.modal-backdrop.open{ display:flex; animation:fadeIn .15s ease; }
@keyframes fadeIn{ from{ opacity:0; } }
.modal{
  background:var(--surface); border-radius:16px; width:100%; max-width:560px; box-shadow:var(--shadow-lg);
  border:1px solid var(--border); animation:pop .18s ease; margin-bottom:6vh;
}
.modal.lg{ max-width:840px; }
.modal-head{ display:flex; align-items:center; gap:12px; padding:17px 20px; border-bottom:1px solid var(--border); }
.modal-head h3{ font-size:15.5px; }
.modal-head .sub{ font-size:12px; color:var(--text-3); }
.modal-head .x{ margin-left:auto; }
.modal-body{ padding:20px; max-height:66vh; overflow-y:auto; }
.modal-foot{ display:flex; gap:9px; justify-content:flex-end; padding:14px 20px; border-top:1px solid var(--border); background:var(--surface-2); border-radius:0 0 16px 16px; }

/* ---------- Tabs ---------- */
.tabs{ display:flex; gap:4px; border-bottom:1px solid var(--border); margin-bottom:20px; overflow-x:auto; }
.tab{
  padding:9px 14px; font-size:13px; font-weight:600; color:var(--text-3); border:0; background:none;
  border-bottom:2px solid transparent; cursor:pointer; white-space:nowrap; font-family:inherit; text-decoration:none;
  display:inline-flex; align-items:center; gap:6px;
}
.tab:hover{ color:var(--text); text-decoration:none; }
.tab.on{ color:var(--primary); border-bottom-color:var(--primary); }

/* ---------- Charts (pure SVG) ---------- */
.chart-wrap{ width:100%; overflow:hidden; }
.chart-legend{ display:flex; gap:16px; flex-wrap:wrap; margin-top:12px; font-size:12px; color:var(--text-2); }
.chart-legend span{ display:inline-flex; align-items:center; gap:6px; }
.chart-legend i{ width:9px; height:9px; border-radius:3px; display:inline-block; }

/* ---------- Misc components ---------- */
.alert{ display:flex; gap:10px; padding:12px 14px; border-radius:12px; font-size:13px; margin-bottom:16px; }
.alert-warn{ background:var(--amber-soft); color:#92400e; border:1px solid #fde68a; }
.alert-danger{ background:var(--red-soft); color:#991b1b; border:1px solid #fecaca; }
.alert-info{ background:var(--blue-soft); color:#1e40af; border:1px solid #bfdbfe; }
[data-theme="dark"] .alert-warn{ color:#fcd34d; border-color:#78350f; }
[data-theme="dark"] .alert-danger{ color:#fca5a5; border-color:#7f1d1d; }
[data-theme="dark"] .alert-info{ color:#93c5fd; border-color:#1e3a8a; }

.kv{ display:grid; grid-template-columns:auto 1fr; gap:7px 18px; font-size:13px; }
.kv dt{ color:var(--text-3); font-size:12px; }
.kv dd{ margin:0; font-weight:550; }
.kv.list{ grid-template-columns:1fr; gap:2px; }

.timeline{ position:relative; padding-left:26px; }
.timeline::before{ content:""; position:absolute; left:8px; top:6px; bottom:6px; width:2px; background:var(--border); }
.tl-item{ position:relative; padding-bottom:17px; }
.tl-item:last-child{ padding-bottom:0; }
.tl-item::before{
  content:""; position:absolute; left:-24px; top:4px; width:12px; height:12px; border-radius:50%;
  background:var(--surface); border:2.5px solid var(--border-strong);
}
.tl-item.done::before{ background:var(--green); border-color:var(--green); box-shadow:0 0 0 3px var(--green-soft); }
.tl-item.current::before{ background:var(--primary); border-color:var(--primary); box-shadow:0 0 0 3px var(--primary-soft); }
.tl-item .t{ font-size:13px; font-weight:600; }
.tl-item .d{ font-size:11.5px; color:var(--text-3); }

.stepper{ display:flex; align-items:center; gap:0; margin:4px 0 22px; }
.step{ display:flex; align-items:center; gap:8px; flex:1; min-width:0; }
.step .num{
  width:28px; height:28px; border-radius:50%; display:grid; place-items:center; flex:none;
  font-size:12px; font-weight:700; background:var(--surface-3); color:var(--text-3); border:1px solid var(--border);
}
.step .lbl{ font-size:12px; font-weight:600; color:var(--text-3); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.step.done .num{ background:var(--green); border-color:var(--green); color:#fff; }
.step.done .lbl{ color:var(--text-2); }
.step.active .num{ background:var(--primary); border-color:var(--primary); color:#fff; box-shadow:0 0 0 4px var(--primary-soft); }
.step.active .lbl{ color:var(--text); }
.step .bar{ flex:1; height:2px; background:var(--border); margin:0 10px; min-width:12px; }
.step.done .bar{ background:var(--green); }

.progress{ height:7px; background:var(--surface-3); border-radius:20px; overflow:hidden; }
.progress > i{ display:block; height:100%; border-radius:20px; background:linear-gradient(90deg,#6366f1,#22d3ee); }

.dot-ind{ width:8px; height:8px; border-radius:50%; display:inline-block; }

.barcode-strip{ display:flex; gap:2px; align-items:flex-end; height:42px; }
.barcode-strip i{ width:2px; background:#0f1a2e; display:block; }

.result-flag{ font-weight:700; font-size:11px; }
.flag-high,.flag-critical{ color:var(--red); }
.flag-low{ color:var(--amber); }
.flag-normal{ color:var(--green); }
.flag-abnormal{ color:var(--violet); }
tr.row-critical td{ background:color-mix(in srgb, var(--red-soft) 60%, transparent); }

/* Patient picker */
.picker{ position:relative; }
.picker-results{
  position:absolute; top:calc(100% + 5px); left:0; right:0; background:var(--surface); z-index:80;
  border:1px solid var(--border); border-radius:12px; box-shadow:var(--shadow-lg); max-height:300px; overflow-y:auto; display:none;
}
.picker-results.open{ display:block; }
.picker-item{ padding:10px 13px; cursor:pointer; border-bottom:1px solid var(--border); display:flex; gap:10px; align-items:center; }
.picker-item:last-child{ border-bottom:0; }
.picker-item:hover, .picker-item.sel{ background:var(--primary-soft); }
.picker-item b{ font-size:13px; display:block; }
.picker-item span{ font-size:11.5px; color:var(--text-3); }

/* Test selection list */
.test-pick{ max-height:420px; overflow-y:auto; border:1px solid var(--border); border-radius:12px; }
.test-row{
  display:flex; align-items:center; gap:11px; padding:10px 13px; border-bottom:1px solid var(--border); cursor:pointer;
  transition:background .12s;
}
.test-row:last-child{ border-bottom:0; }
.test-row:hover{ background:var(--surface-2); }
.test-row.on{ background:var(--primary-soft); }
.test-row input{ width:16px; height:16px; accent-color:var(--primary); flex:none; }
.test-row .tname{ flex:1; min-width:0; }
.test-row .tname b{ font-size:13px; font-weight:600; display:block; }
.test-row .tname span{ font-size:11px; color:var(--text-3); }
.test-row .price{ font-weight:650; font-size:12.5px; color:var(--text-2); }

.summary-box{ background:var(--surface-2); border:1px solid var(--border); border-radius:12px; padding:16px; }
.summary-line{ display:flex; justify-content:space-between; font-size:13px; padding:4px 0; color:var(--text-2); }
.summary-line.total{ border-top:1px dashed var(--border-strong); margin-top:8px; padding-top:10px; font-size:16px; font-weight:700; color:var(--text); }

/* Login */
.auth-wrap{ min-height:100vh; display:grid; grid-template-columns:1.05fr .95fr; }
@media(max-width:900px){ .auth-wrap{ grid-template-columns:1fr; } .auth-side{ display:none; } }
.auth-side{
  position:relative; overflow:hidden; padding:52px; color:#fff;
  background:radial-gradient(1000px 600px at 10% -10%, #4338ca 0%, transparent 60%),
             radial-gradient(800px 500px at 110% 110%, #0e7490 0%, transparent 55%),
             linear-gradient(150deg,#0b1120,#131c3a 70%);
  display:flex; flex-direction:column; justify-content:space-between;
}
.auth-side .grid-lines{
  position:absolute; inset:0; opacity:.16;
  background-image:linear-gradient(rgba(255,255,255,.28) 1px,transparent 1px),linear-gradient(90deg,rgba(255,255,255,.28) 1px,transparent 1px);
  background-size:44px 44px; mask-image:radial-gradient(ellipse at 30% 30%,#000,transparent 72%);
}
.auth-side h2{ font-size:34px; line-height:1.15; letter-spacing:-.03em; max-width:440px; position:relative; }
.auth-side p{ color:#9fb0d6; margin-top:14px; max-width:400px; font-size:14px; position:relative; }
.auth-features{ display:grid; gap:13px; position:relative; margin-top:32px; }
.auth-feature{ display:flex; gap:11px; align-items:flex-start; font-size:13px; color:#c3cfe8; }
.auth-feature .ic{ width:30px; height:30px; border-radius:9px; display:grid; place-items:center; background:rgba(255,255,255,.09); color:#a5b4fc; flex:none; }
.auth-form-wrap{ display:flex; align-items:center; justify-content:center; padding:40px 24px; background:var(--bg); }
.auth-card{ width:100%; max-width:392px; }
.auth-card h1{ font-size:24px; margin-bottom:6px; }
.auth-card .sub{ color:var(--text-3); font-size:13.5px; margin-bottom:26px; }
.demo-users{ margin-top:22px; border-top:1px dashed var(--border-strong); padding-top:16px; }
.demo-users .lbl{ font-size:11px; text-transform:uppercase; letter-spacing:.07em; color:var(--text-3); font-weight:700; margin-bottom:8px; }
.demo-grid{ display:grid; grid-template-columns:1fr 1fr; gap:6px; }
.demo-btn{
  display:flex; align-items:center; gap:8px; padding:7px 10px; border-radius:9px; border:1px solid var(--border);
  background:var(--surface); cursor:pointer; font-size:12px; font-family:inherit; color:var(--text-2); text-align:left;
}
.demo-btn:hover{ border-color:var(--primary); background:var(--primary-soft); color:var(--primary-text); }
.demo-btn b{ display:block; font-size:12px; color:var(--text); }
.demo-btn span{ font-size:10.5px; color:var(--text-3); }

/* Report / print */
.report-sheet{
  background:#fff; color:#111827; max-width:860px; margin:0 auto; border-radius:8px;
  box-shadow:0 10px 40px -12px rgba(0,0,0,.25); padding:34px 38px; font-size:12.5px;
}
.report-sheet h1,.report-sheet h2,.report-sheet h3{ color:#111827; }
.rp-head{ display:flex; gap:18px; align-items:flex-start; border-bottom:2.5px solid #1e3a8a; padding-bottom:14px; }
.rp-logo{ width:56px; height:56px; border-radius:14px; background:linear-gradient(135deg,#4f46e5,#0ea5e9); display:grid; place-items:center; color:#fff; flex:none; }
.rp-lab h1{ font-size:20px; letter-spacing:-.02em; }
.rp-lab .tag{ font-size:11px; color:#6b7280; }
.rp-meta{ margin-left:auto; text-align:right; font-size:11px; color:#4b5563; line-height:1.6; }
.rp-patient{ display:grid; grid-template-columns:repeat(4,1fr); gap:8px 16px; padding:14px 0; border-bottom:1px solid #e5e7eb; font-size:11.5px; }
.rp-patient div span{ display:block; color:#6b7280; font-size:9.5px; text-transform:uppercase; letter-spacing:.06em; }
.rp-patient div b{ font-size:12px; color:#111827; }
.rp-test{ margin-top:18px; }
.rp-test h3{ font-size:12.5px; background:#eef2ff; color:#3730a3; padding:6px 10px; border-radius:6px; display:flex; justify-content:space-between; }
.rp-table{ width:100%; border-collapse:collapse; margin-top:6px; font-size:11px; }
.rp-table th{ text-align:left; background:#f9fafb; color:#374151; font-size:9.5px; text-transform:uppercase; letter-spacing:.05em; padding:6px 9px; border-bottom:1px solid #e5e7eb; }
.rp-table td{ padding:6px 9px; border-bottom:1px solid #f1f3f6; }
.rp-flag{ font-weight:700; font-size:10px; }
.rp-sig{ display:flex; justify-content:space-between; margin-top:34px; align-items:flex-end; }
.rp-sig .line{ border-top:1px solid #9ca3af; padding-top:5px; font-size:10.5px; color:#4b5563; width:190px; text-align:center; }
.rp-footer{ margin-top:26px; border-top:1px solid #e5e7eb; padding-top:10px; font-size:9.5px; color:#6b7280; line-height:1.6; }
.watermark{ position:absolute; inset:0; display:grid; place-items:center; pointer-events:none; opacity:.05; font-size:90px; font-weight:800; transform:rotate(-24deg); }

@media print{
  body{ background:#fff !important; }
  .sidebar,.topbar,.no-print,.flashes{ display:none !important; }
  .main{ margin-left:0 !important; }
  .content{ padding:0 !important; max-width:none !important; }
  .report-sheet{ box-shadow:none; border-radius:0; max-width:none; padding:0 6mm; }
  @page{ size:A4; margin:10mm; }
  .print-only{ display:block !important; }
}
.print-only{ display:none; }

/* Mobile */
.sb-overlay{ position:fixed; inset:0; background:rgba(8,14,28,.5); z-index:55; display:none; }
@media(max-width:1100px){
  .sidebar{ transform:translateX(-100%); }
  body.sb-open .sidebar{ transform:none; box-shadow:var(--shadow-lg); }
  body.sb-open .sb-overlay{ display:block; }
  .main{ margin-left:0; }
  .hamburger{ display:inline-grid !important; }
  .global-search{ display:none; }
}
.hamburger{ display:none; }
@media(max-width:760px){
  .flashes{ top:auto; bottom:14px; left:12px; right:12px; max-width:none; }
  .content{ padding:16px 14px 50px; }
  .topbar{ padding:0 14px; }
  .user-chip .who{ display:none; }
  .page-intro .actions{ width:100%; }
  .report-sheet{ padding:20px 16px; }
  .rp-patient{ grid-template-columns:1fr 1fr; }
}
