/* =====================================================================
   RSSD Clinic Cloud — shared design system
   Loaded after each page's own <style>, so these rules win on shared
   components while page-specific layouts keep working.
   Type: IBM Plex Sans (one family, tabular figures for clinical data)
   Colour: indigo (brand) + clinical teal (positive) on a cool canvas
   ===================================================================== */
@font-face{font-family:'IBM Plex Sans'; font-style:normal; font-weight:400; font-display:swap; src:url('../fonts/ibm-plex-sans-latin-400-normal.woff2') format('woff2');}
@font-face{font-family:'IBM Plex Sans'; font-style:normal; font-weight:500; font-display:swap; src:url('../fonts/ibm-plex-sans-latin-500-normal.woff2') format('woff2');}
@font-face{font-family:'IBM Plex Sans'; font-style:normal; font-weight:600; font-display:swap; src:url('../fonts/ibm-plex-sans-latin-600-normal.woff2') format('woff2');}
@font-face{font-family:'IBM Plex Sans'; font-style:normal; font-weight:700; font-display:swap; src:url('../fonts/ibm-plex-sans-latin-700-normal.woff2') format('woff2');}
:root{
  /* core palette */
  --ink:#0E1630; --ink-2:#334155; --muted:#5B6B82; --faint:#8A97AB;
  --canvas:#F3F5F9; --surface:#FFFFFF; --sunken:#F7F9FC; --line:#DDE3EC; --line-soft:#EAEFF5;
  --brand:#24308F; --brand-hover:#1C2672; --brand-tint:#EEF0FA; --brand-ring:rgba(36,48,143,.22);
  --teal:#0E9F7E; --teal-deep:#0A7A61; --teal-tint:#E3F5EF;
  --amber:#B7791F; --amber-tint:#FDF3E1;
  --red:#C0352B; --red-tint:#FCEBE9;
  --violet:#6D4FC2; --violet-tint:#F1ECFC;

  /* legacy tokens used inside page-specific CSS — remapped to the new palette */
  --blue:var(--brand); --blue-deep:var(--brand-hover); --blue-light:var(--brand-tint);
  --mint:var(--teal); --mint-deep:var(--teal-deep); --mint-light:var(--teal-tint);
  --amber-light:var(--amber-tint); --purple:var(--violet); --purple-light:var(--violet-tint);
  --slate:#475569; --slate-light:#EEF2F6;
  --danger:var(--red); --danger-light:var(--red-tint);
  --bg:var(--canvas); --card:var(--surface); --text:var(--ink); --border:var(--line);
  --radius:10px;
  --font:'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --shadow-pop:0 18px 48px rgba(14,22,48,.18), 0 2px 6px rgba(14,22,48,.06);
}

*{box-sizing:border-box;}
html{-webkit-text-size-adjust:100%;}
html, body{margin:0; padding:0;}
body{font-family:var(--font); font-size:14px; line-height:1.5; background:var(--canvas); color:var(--ink); -webkit-font-smoothing:antialiased; font-feature-settings:"tnum" 1;}
.disp, h1, h2, h3{font-family:var(--font); letter-spacing:-.01em;}
.mono{font-family:var(--font); font-variant-numeric:tabular-nums; letter-spacing:0;}
button, input, select, textarea{font-family:inherit; font-size:inherit;}
a{color:inherit;}
:focus-visible{outline:2px solid var(--brand); outline-offset:2px;}
@media (prefers-reduced-motion:reduce){ *{transition:none !important; animation:none !important;} }

/* ---------- Sidebar ---------- */
.sidebar{width:252px; flex-shrink:0; background:var(--surface); border-right:1px solid var(--line); color:var(--ink-2); display:flex; flex-direction:column; height:100vh; position:sticky; top:0; z-index:40;}
.brand{padding:18px 16px 16px; display:flex; align-items:center; gap:11px; border-bottom:1px solid var(--line-soft);}
.brand-mark{width:38px; height:38px; border-radius:9px; flex-shrink:0; background:var(--brand); color:#fff; display:flex; align-items:center; justify-content:center; font-weight:600; font-size:17px; box-shadow:none;}
.brand-mark svg{width:19px; height:19px; stroke:#fff;}
.brand-text{min-width:0; flex:1;}
.brand-word{font-size:14.5px; font-weight:600; color:var(--ink); line-height:1.25; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.brand-tag{font-size:12px; letter-spacing:0; color:var(--muted); font-weight:400; margin-top:1px; text-transform:none;}
.nav-close{display:none; margin-left:auto; width:34px; height:34px; border:none; background:transparent; border-radius:8px; color:var(--muted); cursor:pointer; align-items:center; justify-content:center;}
.nav-close svg{width:18px; height:18px;}
.nav-scroll{flex:1; overflow-y:auto; padding:10px 10px 14px;}
.nav-section{font-size:12px; font-weight:500; color:var(--faint); padding:14px 10px 6px;}
.nav-item{display:flex; align-items:center; gap:11px; padding:8px 10px; border-radius:7px; font-size:14px; font-weight:500; color:var(--ink-2); text-decoration:none; margin-bottom:1px; position:relative;}
.nav-item svg{width:18px; height:18px; stroke:currentColor; stroke-width:1.7; flex-shrink:0; color:var(--faint);}
.nav-item:hover{background:var(--sunken); color:var(--ink);}
.nav-item.active{background:var(--brand-tint); color:var(--brand); font-weight:600;}
.nav-item.active svg{color:var(--brand);}
.nav-item.active::before{content:""; position:absolute; left:-10px; top:7px; bottom:7px; width:3px; background:var(--brand); border-radius:0 3px 3px 0;}
.nav-item.locked{color:var(--faint);}
.nav-item .nav-lock{width:14px; height:14px; margin-left:auto; color:var(--faint);}
.sidebar-plan{margin:0 12px 10px; padding:9px 12px; border:1px solid var(--line); border-radius:8px; display:flex; align-items:center; gap:8px; font-size:13px; color:var(--ink-2);}
.sidebar-plan .plan-dot{width:8px; height:8px; border-radius:50%; flex-shrink:0;}
.sidebar-plan a{margin-left:auto; color:var(--brand); font-weight:600; text-decoration:none; font-size:12.5px;}
.sidebar-foot{margin:0; padding:12px 14px 16px; border-top:1px solid var(--line-soft); background:transparent; border-radius:0;}
.sidebar-foot .sf-row{display:flex; align-items:center; gap:10px; margin:0;}
.sidebar-foot .sf-avatar{width:34px; height:34px; border-radius:50%; flex-shrink:0;}
.sf-meta{min-width:0; flex:1;}
.sidebar-foot .sf-name{font-size:13.5px; font-weight:600; color:var(--ink); white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.sidebar-foot .sf-role{font-size:12px; color:var(--muted);}
.sf-logout{width:34px; height:34px; border-radius:8px; display:flex; align-items:center; justify-content:center; color:var(--muted);}
.sf-logout:hover{background:var(--red-tint); color:var(--red);}
.sf-logout svg{width:17px; height:17px;}
.sidebar-scrim{display:none;}

/* ---------- Main + top bar ---------- */
.main{flex:1; min-width:0; height:100vh; overflow-y:auto;}
.topbar{background:rgba(255,255,255,.92); backdrop-filter:saturate(1.4) blur(8px); border-bottom:1px solid var(--line); padding:10px 28px; min-height:60px; display:flex; align-items:center; gap:14px; position:sticky; top:0; z-index:20;}
.nav-toggle{display:none; width:38px; height:38px; border-radius:8px; border:1px solid var(--line); background:var(--surface); color:var(--ink); align-items:center; justify-content:center; cursor:pointer; flex-shrink:0;}
.nav-toggle svg{width:19px; height:19px;}
.clinic-tag{display:flex; align-items:center; gap:10px; padding:0; border:none; border-radius:0; min-width:0;}
.clinic-tag .dot{display:none;}
.clinic-tag .pname{font-size:12.5px; font-weight:500; color:var(--muted); line-height:1.3;}
.clinic-tag .psub{font-size:15px; font-weight:600; color:var(--ink); line-height:1.3;}
.top-actions{display:flex; align-items:center; gap:12px; margin-left:auto;}
.profile{display:flex; align-items:center; gap:10px;}
.profile img{width:34px; height:34px; border-radius:50%; object-fit:cover;}
.profile .pname{font-size:13.5px; font-weight:600;}
.profile .prole{font-size:12px; color:var(--muted);}

/* ---------- Banners ---------- */
.app-banner{display:flex; align-items:center; gap:12px; padding:10px 28px; font-size:13.5px; border-bottom:1px solid transparent; flex-wrap:wrap;}
.app-banner svg{width:18px; height:18px; flex-shrink:0;}
.app-banner span{flex:1; min-width:220px;}
.banner-info{background:var(--brand-tint); color:var(--brand); border-color:#D9DDF3;}
.banner-warn{background:var(--amber-tint); color:#7A4E0E; border-color:#F3DFB8;}
.banner-danger{background:var(--red-tint); color:#8E2219; border-color:#F2CCC7;}
.banner-dark{background:var(--ink); color:#E7EAF3;}
.banner-btn{padding:6px 14px; border-radius:7px; background:currentColor; text-decoration:none; font-weight:600; font-size:13px; white-space:nowrap;}
.banner-info .banner-btn{background:var(--brand); color:#fff;}
.banner-warn .banner-btn{background:#7A4E0E; color:#fff;}
.banner-danger .banner-btn{background:var(--red); color:#fff;}
.banner-dark .banner-btn{background:#fff; color:var(--ink);}

/* ---------- Page scaffolding ---------- */
.page{max-width:1320px; margin:0 auto; padding:26px 28px 56px;}
.page-head{display:flex; align-items:flex-end; justify-content:space-between; gap:14px; flex-wrap:wrap; margin-bottom:20px;}
.page-head h1{font-size:24px; font-weight:600; margin:0 0 4px; line-height:1.25;}
.page-head p{font-size:14px; color:var(--muted); margin:0; max-width:70ch;}

.panel{background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); box-shadow:none;}
.panel-head{display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:14px;}
.panel-head h3, .panel h3{font-size:15px; font-weight:600; margin:0;}
.panel-head p{font-size:13px; color:var(--muted);}

/* ---------- Buttons ---------- */
.btn{display:inline-flex; align-items:center; justify-content:center; gap:8px; border-radius:8px; padding:9px 16px; min-height:38px; font-size:14px; font-weight:600; cursor:pointer; border:1px solid transparent; text-decoration:none; line-height:1.2; transition:background-color .15s, border-color .15s;}
.btn svg{width:16px; height:16px; stroke:currentColor;}
.btn-primary{background:var(--brand); color:#fff; box-shadow:none;}
.btn-primary:hover{background:var(--brand-hover);}
.btn-primary:disabled, .btn:disabled{opacity:.55; cursor:not-allowed;}
.btn-ghost{background:var(--surface); border-color:var(--line); color:var(--ink);}
.btn-ghost:hover{background:var(--sunken); border-color:#C9D2DF;}
.btn-danger{background:var(--red-tint); color:var(--red);}
.btn-danger:hover{background:#F8D9D5;}
.btn-success{background:var(--teal); color:#fff;}
.btn-success:hover{background:var(--teal-deep);}
.btn-sm{padding:6px 12px; min-height:32px; font-size:13px;}

/* ---------- Stats & pills ---------- */
.stats{gap:12px;}
.stat-card{background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); padding:16px 18px;}
.stat-icon{width:36px; height:36px; border-radius:8px;}
.stat-value{font-size:24px; font-weight:600; letter-spacing:-.01em;}
.stat-label{font-size:13px; color:var(--muted);}
.stat-pill{background:var(--surface); border:1px solid var(--line); border-radius:8px; padding:7px 13px; font-size:13px; font-weight:500; color:var(--ink-2);}
.stat-pill b{font-family:var(--font); font-weight:600; color:var(--ink);}

/* ---------- Search & filters ---------- */
.search-box{background:var(--surface); border:1px solid var(--line); border-radius:8px; padding:0 12px; min-height:38px; max-width:360px;}
.search-box:focus-within{border-color:var(--brand); box-shadow:0 0 0 3px var(--brand-ring);}
.search-box input{font-size:14px; padding:8px 0;}
.filter-select, .filter-date{border:1px solid var(--line); border-radius:8px; min-height:38px; padding:7px 10px; font-size:14px; background:var(--surface);}
.tab-btn{font-size:14px;}

/* ---------- Tables ---------- */
table{width:100%; border-collapse:collapse;}
thead th{text-align:left; font-size:12.5px; font-weight:600; text-transform:none; letter-spacing:0; color:var(--muted); padding:11px 16px; border-bottom:1px solid var(--line); background:var(--sunken); white-space:nowrap;}
tbody td{padding:11px 16px; font-size:14px; border-bottom:1px solid var(--line-soft); vertical-align:middle;}
tbody tr:hover td{background:#FAFBFD;}
tbody tr:last-child td{border-bottom:none;}
.panel > table, .panel{overflow:auto;}
.empty-row td{text-align:center; padding:44px 16px; color:var(--muted); font-size:14px;}
.empty-mini{padding:28px; text-align:center; color:var(--muted); font-size:14px;}
.p-avatar, .u-avatar, .oc-avatar{border-radius:50%;}
.p-name, .u-name{font-size:14px; font-weight:600;}
.p-sub, .u-sub{font-size:12.5px; color:var(--muted);}
.row-btn{width:32px; height:32px; border-radius:7px; border:1px solid var(--line);}
.row-btn:hover{background:var(--sunken);}
.row-btn svg{width:15px; height:15px;}

/* ---------- Badges ---------- */
.status-badge, .queue-badge, .role-chip, .method-chip, .cat-chip, .type-chip, .bg-chip, .expiry-badge, .stock-badge, .token-chip{font-size:12px; font-weight:600; border-radius:6px; padding:3px 8px; letter-spacing:0; text-transform:none;}
.token-chip, .queue-token{font-variant-numeric:tabular-nums; font-family:var(--font);}

/* ---------- Forms ---------- */
.form-field label, .field label{display:block; font-size:13px; font-weight:600; color:var(--ink-2); margin-bottom:6px;}
.form-field input, .form-field select, .form-field textarea, .field input, .field select, .field textarea{width:100%; padding:9px 12px; min-height:40px; border:1px solid #CDD5E1; border-radius:8px; font-size:14px; background:var(--surface); color:var(--ink); outline:none; transition:border-color .15s, box-shadow .15s;}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus, .field input:focus, .field select:focus, .field textarea:focus{border-color:var(--brand); box-shadow:0 0 0 3px var(--brand-ring);}
.form-field input:disabled{background:var(--sunken); color:var(--muted);}
.form-error{font-size:12.5px;}
.hint, .field-hint{font-size:12.5px; color:var(--muted); margin-top:5px;}

/* ---------- Modal ---------- */
.overlay{background:rgba(14,22,48,.45);}
.modal{border-radius:14px; box-shadow:var(--shadow-pop);}
.modal-head{padding:18px 22px;}
.modal-head h2{font-size:17px; font-weight:600;}
.modal-close{width:34px; height:34px; border-radius:8px; background:transparent;}
.modal-close:hover{background:var(--sunken);}
.modal-body{padding:20px 22px;}
.modal-foot{padding:14px 22px; background:var(--sunken);}

/* ---------- Toast ---------- */
.toast{background:var(--ink); color:#fff; border-radius:10px; font-size:14px; padding:12px 16px; box-shadow:var(--shadow-pop);}

/* ---------- Generic helpers for new pages ---------- */
.grid{display:grid; gap:16px;}
.grid-2{grid-template-columns:repeat(2, minmax(0,1fr));}
.grid-3{grid-template-columns:repeat(3, minmax(0,1fr));}
.grid-4{grid-template-columns:repeat(4, minmax(0,1fr));}
.pad{padding:18px 20px;}
.muted{color:var(--muted);}
.small{font-size:13px;}
.num{font-variant-numeric:tabular-nums; text-align:right;}
.chip{display:inline-flex; align-items:center; gap:6px; font-size:12px; font-weight:600; border-radius:6px; padding:3px 8px; background:var(--sunken); color:var(--ink-2); white-space:nowrap;}
.chip.ok{background:var(--teal-tint); color:var(--teal-deep);}
.chip.warn{background:var(--amber-tint); color:#8A5A12;}
.chip.bad{background:var(--red-tint); color:var(--red);}
.chip.info{background:var(--brand-tint); color:var(--brand);}
.chip.dark{background:var(--ink); color:#fff;}
.kv{display:grid; grid-template-columns:150px 1fr; gap:8px 14px; font-size:14px;}
.kv dt{color:var(--muted);} .kv dd{margin:0; font-weight:500;}
.alert{padding:11px 14px; border-radius:8px; font-size:14px; margin-bottom:16px; border:1px solid transparent;}
.alert-success{background:var(--teal-tint); color:var(--teal-deep); border-color:#BFE6D8;}
.alert-error{background:var(--red-tint); color:#8E2219; border-color:#F2CCC7;}
.alert-info{background:var(--brand-tint); color:var(--brand); border-color:#D9DDF3;}
.section-title{font-size:15px; font-weight:600; margin:0 0 12px;}
.meter{height:6px; background:var(--line-soft); border-radius:4px; overflow:hidden;}
.meter > span{display:block; height:100%; background:var(--brand); border-radius:4px;}

/* ---------- Responsive ---------- */
@media (max-width:1100px){ .grid-4{grid-template-columns:repeat(2,minmax(0,1fr));} .grid-3{grid-template-columns:repeat(2,minmax(0,1fr));} }
@media (max-width:900px){
  .sidebar{display:flex !important; position:fixed; left:0; top:0; bottom:0; transform:translateX(-102%); transition:transform .22s ease; box-shadow:none;}
  body.nav-open .sidebar{transform:none; box-shadow:var(--shadow-pop);}
  body.nav-open .sidebar-scrim{display:block; position:fixed; inset:0; background:rgba(14,22,48,.4); z-index:35;}
  .nav-close{display:flex;}
  .nav-toggle{display:flex;}
  .topbar{padding:10px 16px;}
  .page{padding:20px 16px 48px;}
  .app-banner{padding:10px 16px;}
  .profile > div{display:none;}
  .grid-2, .grid-3{grid-template-columns:1fr;}
}
@media (max-width:560px){ .grid-4{grid-template-columns:1fr;} .page-head h1{font-size:21px;} .kv{grid-template-columns:1fr;} }

@media print{
  .sidebar, .topbar, .app-banner, .toolbar, .no-print{display:none !important;}
  .main{height:auto; overflow:visible;}
  body{background:#fff;}
}
.form-field label.check-row{display:flex; font-weight:500; margin:0; min-height:40px;}

/* Sentence-case labels everywhere (page CSS used tracked-out capitals) */
.bi-type, .bt-label, .cp-label, .dc-fee-label, .item-table th, .item-table thead th, .item-type-tag, .lh-invoice .lbl,
.result-stat-label, .rx-table th, .section-label, .summary-label{text-transform:none; letter-spacing:0; font-size:12.5px; font-weight:600;}
.toast{min-width:220px;}
@media (max-width:900px){
  .panel{overflow-x:auto;}
  .panel table{min-width:680px;}
  thead th, tbody td{white-space:nowrap;}
}

/* One type family across the product (older page CSS referenced Manrope / Plex Mono) */
*{font-family:var(--font) !important;}
.mono, .token-chip, .queue-token, .cp-token, td.num, .num{font-variant-numeric:tabular-nums;}
@media (max-width:640px){
  .stats{grid-template-columns:repeat(2, minmax(0,1fr)) !important;}
  .stat-card{padding:14px;}
  .stat-value{font-size:20px;}
}
