/* Uche's Specialist Hospital · HMS stylesheet.
   Deep navy + teal brand with a warm gold accent. Dense enough for 1366×768 desk screens, comfortable on tablets and phones. */
:root {
  --bg: #f2f5f8;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --surface-3: #eef2f6;
  --border: #e3e8ee;
  --border-strong: #cfd7e0;
  --text: #0f1d2b;
  --text-2: #475569;
  --muted: #6b7a8c;

  --brand: #0f766e;
  --brand-600: #0d6b64;
  --brand-dark: #0b5650;
  --brand-light: #14b8a6;
  --brand-soft: #e6f5f3;
  --brand-ring: rgba(20, 184, 166, .28);
  --navy: #0b2236;
  --navy-2: #0e2c45;
  --gold: #f5b942;
  --gold-soft: #fff6e2;

  --danger: #c0262d;
  --danger-soft: #fdeced;
  --warn: #a15c00;
  --warn-soft: #fff5e1;
  --ok: #15803d;
  --ok-soft: #e7f7ed;
  --info: #1d5fa8;
  --info-soft: #e8f1fc;
  --purple: #6941c6;
  --purple-soft: #f2edfd;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow-xs: 0 1px 2px rgba(15, 29, 43, .05);
  --shadow: 0 1px 2px rgba(15, 29, 43, .04), 0 4px 14px -6px rgba(15, 29, 43, .10);
  --shadow-lg: 0 18px 40px -12px rgba(11, 34, 54, .28);
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --sidebar-w: 256px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.55 var(--font); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
a { color: var(--brand); text-underline-offset: 2px; }
a:hover { color: var(--brand-dark); }
h1, h2, h3 { font-family: var(--font-display); }
h1 { font-size: 24px; font-weight: 700; margin: 0 0 2px; letter-spacing: -.02em; line-height: 1.25; }
h2 { font-size: 16px; font-weight: 650; margin: 0 0 12px; letter-spacing: -.01em; }
h3 { font-size: 14px; font-weight: 650; margin: 16px 0 8px; color: var(--text-2); }
h4 { font-size: 11px; margin: 10px 0 4px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
p { margin: 0 0 8px; }
code { background: var(--surface-3); border: 1px solid var(--border); border-radius: 5px; padding: 0 5px; font-size: 12px; }
small, .small { font-size: 12px; }
.muted { color: var(--muted); }
.danger-text { color: var(--danger); }
.right { text-align: right; }
.center { text-align: center; }
.pad { padding: 16px 18px 0; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; z-index: 100; background: #fff; padding: 8px 12px; border-radius: 8px; box-shadow: var(--shadow); }
:focus-visible { outline: 3px solid var(--brand-ring); outline-offset: 2px; }
::selection { background: #bdeee7; }
.ico { width: 18px; height: 18px; flex: none; }

/* ---------- Brand ---------- */
.logo { width: 38px; height: 38px; flex: none; display: block; border-radius: 11px; box-shadow: 0 4px 12px -4px rgba(15, 118, 110, .55); }

/* ---------- Layout ---------- */
#app { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 30;
  display: flex; flex-direction: column; color: #cfdbe6;
  background:
    radial-gradient(120% 60% at 0% 0%, rgba(20, 184, 166, .16), transparent 60%),
    linear-gradient(180deg, var(--navy-2) 0%, var(--navy) 100%);
  border-right: 1px solid rgba(255,255,255,.04);
}
.brand { display: flex; gap: 12px; align-items: center; padding: 20px 18px 18px; text-decoration: none; }
.brand strong { display: block; font-family: var(--font-display); font-size: 15px; font-weight: 700; line-height: 1.2; color: #fff; letter-spacing: -.01em; }
.brand small { display: block; color: var(--gold); font-size: 11px; font-weight: 600; letter-spacing: .02em; margin-top: 2px; }
.sidebar nav { flex: 1; overflow-y: auto; padding: 4px 12px 12px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.15) transparent; }
.sidebar nav a {
  position: relative; display: flex; gap: 11px; align-items: center; padding: 9px 12px; margin: 1px 0; border-radius: 10px;
  color: #b9c8d6; text-decoration: none; font-weight: 550; transition: background .15s, color .15s;
}
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar nav a.active { background: linear-gradient(90deg, rgba(20,184,166,.28), rgba(20,184,166,.10)); color: #fff; box-shadow: inset 0 0 0 1px rgba(94, 234, 212, .18); }
.sidebar nav a.active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: var(--gold); }
.sidebar nav a.active .ni { color: #5eead4; }
.ni { width: 19px; height: 19px; flex: none; opacity: .95; }
.nav-group { margin: 18px 12px 6px; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: #6f879b; }
.sidebar-foot { margin: 0 12px 12px; padding: 10px 12px; font-size: 12px; color: #9fb2c3; display: flex; gap: 8px; align-items: center; border-radius: 10px; background: rgba(255,255,255,.04); }
.online-dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: #34d399; box-shadow: 0 0 0 3px rgba(52, 211, 153, .18); }
.online-dot.off { background: #f04438; box-shadow: 0 0 0 3px rgba(240, 68, 56, .2); }
.scrim { display: none; }
.main-col { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; padding: 10px 28px; min-height: 64px;
  background: rgba(255, 255, 255, .86); backdrop-filter: saturate(1.6) blur(12px); -webkit-backdrop-filter: saturate(1.6) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-brand { display: none; }
.topbar-brand .logo { width: 34px; height: 34px; border-radius: 10px; }
.quick-search { flex: 1; max-width: 540px; position: relative; }
.quick-search .ico { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.quick-search input { width: 100%; padding-left: 40px; background: var(--surface-2); border-color: var(--border); border-radius: 999px; min-height: 40px; }
.quick-search input:focus { background: #fff; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding-left: 12px; border-left: 1px solid var(--border); }
.user-chip strong { display: block; font-size: 13px; line-height: 1.2; }
.user-chip small { color: var(--muted); }
.user-avatar { width: 36px; height: 36px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; background: linear-gradient(135deg, var(--brand-light), var(--navy-2)); box-shadow: 0 0 0 2px #fff, 0 0 0 3px var(--border); }
.icon-btn.menu-btn { display: none; }
main { flex: 1; width: 100%; padding: 24px 28px 48px; max-width: 1480px; outline: none; }
.app-foot { padding: 14px 28px 20px; font-size: 12px; color: var(--muted); }
.loading-page { padding: 60px; text-align: center; color: var(--muted); }

/* ---------- Controls ---------- */
input, select, textarea { font: inherit; color: inherit; background: #fff; border: 1px solid var(--border-strong); border-radius: 10px; padding: 8px 12px; min-height: 40px; width: 100%; transition: border-color .15s, box-shadow .15s, background .15s; }
input::placeholder, textarea::placeholder { color: #94a3b4; }
select { appearance: none; -webkit-appearance: none; padding-right: 34px; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7a8c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center / 16px; }
select[multiple] { background-image: none; padding-right: 12px; }
textarea { resize: vertical; }
input[readonly], textarea[readonly] { background: var(--surface-2); }
input:hover, select:hover, textarea:hover { border-color: #b8c3cf; }
input:focus, select:focus, textarea:focus { border-color: var(--brand-light); outline: none; box-shadow: 0 0 0 4px var(--brand-ring); }
input[type=checkbox], input[type=radio] { accent-color: var(--brand); }
input.abnormal { border-color: #e59a2a; background: var(--warn-soft); }
input.critical { border-color: var(--danger); background: var(--danger-soft); font-weight: 600; }
label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 13px; color: var(--text-2); }
label small { font-weight: 400; color: var(--muted); }
label.check { flex-direction: row; align-items: flex-start; gap: 8px; font-weight: 400; color: var(--text); margin: 6px 0; }
label.check input { width: auto; min-height: 0; margin-top: 3px; box-shadow: none; }
fieldset { border: 0; padding: 0; margin: 0 0 18px; min-width: 0; }
legend { font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--brand-dark); margin-bottom: 10px; padding: 0; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; font: inherit; font-weight: 600; font-size: 13px;
  padding: 8px 16px; min-height: 40px; border-radius: 10px; border: 1px solid var(--border-strong); background: #fff; color: var(--text);
  cursor: pointer; text-decoration: none; white-space: nowrap; box-shadow: var(--shadow-xs); transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
}
.btn .ico { width: 16px; height: 16px; }
.btn:hover { background: var(--surface-2); border-color: #b2bfcc; color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.loading { position: relative; color: transparent !important; }
.btn.loading::after { content: ""; position: absolute; width: 14px; height: 14px; border: 2px solid currentColor; border-color: var(--muted) transparent var(--muted) transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-primary { background: linear-gradient(180deg, #129085 0%, var(--brand) 100%); border-color: var(--brand-600); color: #fff; box-shadow: 0 1px 2px rgba(15,118,110,.3), 0 6px 14px -6px rgba(15,118,110,.6), inset 0 1px 0 rgba(255,255,255,.15); }
.btn-primary:hover { background: linear-gradient(180deg, var(--brand) 0%, var(--brand-dark) 100%); border-color: var(--brand-dark); color: #fff; }
.btn-primary.loading::after { border-color: #fff transparent #fff transparent; }
.btn-danger { background: #fff; border-color: #f1b0ac; color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); border-color: transparent; }
.btn-small { padding: 4px 11px; min-height: 30px; font-size: 12px; border-radius: 8px; }
.btn-lg { padding: 11px 22px; min-height: 46px; font-size: 15px; border-radius: 12px; }
.btn-block { width: 100%; }
.btn + .btn { margin-left: 6px; }
.right .btn + .btn, .actions .btn + .btn, .row .btn + .btn { margin-left: 0; }
.icon-btn { display: inline-grid; place-items: center; background: none; border: 0; font-size: 18px; cursor: pointer; padding: 8px; border-radius: 10px; color: var(--text-2); position: relative; transition: background .15s, color .15s; }
.icon-btn .ico { width: 20px; height: 20px; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.link { background: none; border: 0; color: var(--brand); cursor: pointer; padding: 0; font: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row label { flex-direction: row; align-items: center; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-sm { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.stack-sm .btn + .btn { margin-left: 0; }
form.card h2:not(:first-child) { margin-top: 22px; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.seg { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-3); max-width: 100%; overflow-x: auto; }
.seg a { padding: 6px 14px; text-decoration: none; color: var(--text-2); font-weight: 600; font-size: 13px; border-radius: 9px; white-space: nowrap; }
.seg a:hover { color: var(--text); background: rgba(255,255,255,.6); }
.seg a.on { background: #fff; color: var(--brand-dark); box-shadow: var(--shadow-xs), 0 0 0 1px var(--border); }
.tabs { margin-bottom: 16px; }

/* ---------- Cards & grids ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; box-shadow: var(--shadow); }
.card > h2:first-child { display: flex; align-items: center; gap: 8px; }
.card.flush { padding: 0; overflow-x: auto; }
.card.flush > h2.pad { padding-bottom: 12px; }
.card.highlight { background: linear-gradient(180deg, #f2fbf9, var(--brand-soft)); border-color: #bfe5de; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p.muted { margin: 2px 0 0; }
.page-head.hero {
  position: relative; overflow: hidden; align-items: center; padding: 26px 28px; border-radius: 18px; color: #e6eef5;
  background:
    radial-gradient(60% 120% at 100% 0%, rgba(245, 185, 66, .22), transparent 60%),
    radial-gradient(80% 140% at 0% 100%, rgba(20, 184, 166, .35), transparent 60%),
    linear-gradient(120deg, var(--navy-2), var(--navy) 55%, #0b3b55);
  box-shadow: var(--shadow-lg);
}
.page-head.hero::after { content: ""; position: absolute; right: -40px; bottom: -60px; width: 220px; height: 220px; border-radius: 50%; border: 28px solid rgba(255,255,255,.05); pointer-events: none; }
.page-head.hero h1 { color: #fff; font-size: 26px; }
.page-head.hero .muted { color: #a9bccc; }
.page-head.hero .btn:not(.btn-primary) { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.18); color: #fff; box-shadow: none; }
.page-head.hero .btn:not(.btn-primary):hover { background: rgba(255,255,255,.18); }
.page-head.hero .btn-primary { background: linear-gradient(180deg, #ffd27a, var(--gold)); border-color: #e9a92a; color: #3b2a05; box-shadow: 0 6px 16px -6px rgba(245,185,66,.7); }
.page-head.hero .btn-primary:hover { background: linear-gradient(180deg, #ffcb63, #eeae2f); color: #2d2004; }
.page-head.hero .quick-actions { margin: 0; position: relative; z-index: 1; }
.section { margin-top: 24px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.grid { display: grid; gap: 14px 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3x { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.span2 { grid-column: span 2; }
.span3 { grid-column: span 3; }
.span4 { grid-column: 1 / -1; }
.grid > .card { margin-bottom: 0; }
.grid.g2 + .grid, .grid + .card, .card + .grid { margin-top: 18px; }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.dl { display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; margin: 0; }
.dl dt { color: var(--muted); font-size: 13px; }
.dl dd { margin: 0; font-weight: 500; }
.dl dd.big { font-size: 24px; font-weight: 750; letter-spacing: -.02em; }
.list { list-style: none; padding: 0; margin: 0; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.quick-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table th { text-align: left; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding: 11px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: #f6fbfa; }
.table tbody tr:last-child td { border-bottom: 0; }
.table td a:not(.btn) { font-weight: 600; text-decoration: none; }
.table td a:not(.btn):hover { text-decoration: underline; }
.table.compact td, .table.compact th { padding: 7px 10px; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table td.msg { max-width: 380px; }
.row-emergency { background: #fff6f6; box-shadow: inset 4px 0 0 var(--danger); }
.row-hl { box-shadow: inset 4px 0 0 var(--brand-light); }
tr.void td { color: var(--muted); text-decoration: line-through; }
tr.abn td { background: var(--warn-soft); }
.invoice tfoot td, .invoice tfoot th { padding: 9px 14px; border-top: 1px solid var(--border); text-align: right; }
.invoice tfoot th:first-child, .invoice tfoot td:first-child { text-align: right; }
.invoice tr.balance th { font-size: 17px; color: var(--brand-dark); background: var(--brand-soft); }
.flag-h, .flag-l { font-weight: 700; font-size: 11px; padding: 1px 6px; border-radius: 5px; }
.flag-h { background: var(--danger-soft); color: var(--danger); }
.flag-l { background: var(--info-soft); color: var(--info); }

/* ---------- Badges & chips ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 650; padding: 2px 10px 2px 8px; border-radius: 999px; white-space: nowrap; border: 1px solid transparent; line-height: 1.6; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.tone-amber { background: var(--warn-soft); color: var(--warn); border-color: #f6dcae; --tone: #d97706; }
.tone-blue { background: var(--info-soft); color: var(--info); border-color: #c8dcf5; --tone: #2563eb; }
.tone-purple { background: var(--purple-soft); color: var(--purple); border-color: #ddd2f8; --tone: #7c3aed; }
.tone-teal { background: #e4f7f7; color: #0e7076; border-color: #bfe7e9; --tone: #0d9488; }
.tone-coral { background: #fff0ea; color: #b54708; border-color: #fdd3bf; --tone: #ea580c; }
.tone-green { background: var(--ok-soft); color: var(--ok); border-color: #c0e8cf; --tone: #16a34a; }
.tone-gray { background: #f0f3f6; color: #4c5966; border-color: #dfe5ea; --tone: #64748b; }
.tone-red { background: var(--danger-soft); color: var(--danger); border-color: #f6c8c5; --tone: #dc2626; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 12px; }
.chip { display: inline-block; font-size: 12px; padding: 2px 10px; border-radius: 7px; background: var(--surface-3); color: var(--text-2); font-weight: 550; }
.chip.small { font-size: 11px; padding: 0 7px; }
.chip-red { background: var(--danger-soft); color: var(--danger); font-weight: 650; }
.chip-amber { background: var(--warn-soft); color: var(--warn); }
.count-pill { display: inline-block; min-width: 22px; text-align: center; font-size: 11.5px; font-weight: 700; background: #fff; border: 1px solid var(--border); border-radius: 999px; padding: 0 7px; color: var(--text-2); margin-left: 4px; }

/* ---------- Notices ---------- */
.notice { padding: 11px 14px 11px 16px; border-radius: 12px; background: var(--info-soft); color: #173f6d; margin: 8px 0; border: 1px solid #c8dcf5; box-shadow: inset 4px 0 0 #3b82f6; }
.notice.ok { background: var(--ok-soft); color: #0f5132; border-color: #c0e8cf; box-shadow: inset 4px 0 0 #22c55e; }
.notice.warn { background: var(--warn-soft); color: #6b3f00; border-color: #f6dcae; box-shadow: inset 4px 0 0 #f59e0b; }
.notice.danger { background: var(--danger-soft); color: #7a1a12; border-color: #f6c8c5; font-weight: 600; box-shadow: inset 4px 0 0 var(--danger); }
.notice ul { margin: 4px 0 0; padding-left: 18px; }

/* ---------- Patient banner ---------- */
.banner { display: flex; gap: 18px; align-items: flex-start; background: linear-gradient(180deg, #fff, #fbfdfd); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; box-shadow: var(--shadow); flex-wrap: wrap; position: relative; overflow: hidden; }
.banner::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: linear-gradient(90deg, var(--brand-light), var(--brand), var(--gold)); }
.avatar { width: 56px; height: 56px; flex: none; border-radius: 16px; background: linear-gradient(135deg, var(--brand-soft), #d3eeea); color: var(--brand-dark); display: grid; place-items: center; font-weight: 750; font-size: 19px; box-shadow: inset 0 0 0 1px #bfe5de; }
.banner-main { flex: 1; min-width: 240px; }
.banner .meta { display: flex; gap: 6px 16px; flex-wrap: wrap; color: var(--text-2); }
.banner .chips { margin-bottom: 0; }
.banner-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: flex-end; }

/* ---------- Dashboard ---------- */
.flow { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.flow-step {
  position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 16px 14px; text-decoration: none; color: var(--text-2); display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow); font-size: 13px; font-weight: 550;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.flow-step[class*="tone-"] { background: var(--surface); color: var(--text-2); border-color: var(--border); }
.flow-step:not([class*="tone-"]) { --tone: var(--brand); }
.flow-step::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--tone); }
.flow-step::after { content: ""; position: absolute; right: -18px; top: -18px; width: 64px; height: 64px; border-radius: 50%; background: var(--tone); opacity: .08; }
.flow-step .n { font-family: var(--font-display); font-size: 30px; font-weight: 750; color: var(--text); letter-spacing: -.03em; line-height: 1.1; }
.flow-step .l { display: flex; align-items: center; gap: 6px; }
.flow-step .l::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--tone); flex: none; }
.flow-step:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--tone); color: var(--text); }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 16px 14px 68px; min-height: 84px; box-shadow: var(--shadow); display: flex; flex-direction: column; justify-content: center; }
.stat-ico { position: absolute; left: 16px; top: 18px; width: 40px; height: 40px; padding: 9px; border-radius: 12px; color: var(--brand); background: var(--brand-soft); stroke-width: 2; }
.stat span { color: var(--muted); font-size: 12.5px; font-weight: 550; }
.stat strong { font-family: var(--font-display); font-size: 24px; font-weight: 750; letter-spacing: -.02em; line-height: 1.25; }
.stat small { color: var(--muted); }
.stat.warn { border-color: #f6dcae; background: linear-gradient(180deg, #fff, #fffaf0); }
.stat.warn .stat-ico { color: var(--warn); background: var(--warn-soft); }

/* ---------- Kanban (active visits) ---------- */
.kanban { display: grid; grid-template-columns: repeat(6, minmax(190px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x proximity; }
.lane { background: var(--surface-3); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; min-height: 220px; scroll-snap-align: start; }
.lane h3 { display: flex; align-items: center; justify-content: space-between; margin: 0 0 10px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); }
.lane-card { display: flex; flex-direction: column; gap: 2px; background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; text-decoration: none; color: var(--text); box-shadow: var(--shadow-xs); transition: transform .12s, box-shadow .12s, border-color .12s; }
.lane-card:hover { border-color: var(--brand-light); transform: translateY(-1px); box-shadow: var(--shadow); color: var(--text); }
.lane-card small { color: var(--muted); }
.lane-card .badge { align-self: flex-start; margin-top: 6px; }

/* ---------- Vitals ---------- */
.vitals { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; margin-bottom: 8px; }
.vital { border: 1px solid var(--border); border-radius: 12px; padding: 10px; background: var(--surface-2); }
.vital span { display: block; font-size: 10.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.vital strong { font-size: 19px; font-weight: 750; }
.vital small { color: var(--muted); margin-left: 2px; white-space: nowrap; }
.vital strong + small { display: inline-block; }
.vital.abnormal { background: var(--warn-soft); border-color: #f6dcae; }
.vital.critical { background: var(--danger-soft); border-color: #f6c8c5; }
.vital.critical strong { color: var(--danger); }
.unit-wrap { display: flex; align-items: center; gap: 6px; }
.unit-wrap em { font-style: normal; color: var(--muted); font-size: 12px; min-width: 38px; }
.unit-wrap.bp input { width: 76px; }
.priority { display: flex; gap: 8px; flex-wrap: wrap; margin: 0; }
.priority legend { font-size: 13px; text-transform: none; letter-spacing: 0; color: var(--text-2); font-weight: 600; margin-bottom: 4px; }
.radio-pill { flex-direction: row; align-items: center; gap: 6px; border: 1px solid var(--border-strong); background: #fff; border-radius: 999px; padding: 7px 16px; cursor: pointer; font-weight: 650; transition: background .15s, border-color .15s; }
.radio-pill:hover { border-color: #aab7c4; }
.radio-pill input { width: auto; min-height: 0; box-shadow: none; }
.radio-pill.p-emergency:has(input:checked) { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.radio-pill.p-urgent:has(input:checked) { background: var(--warn-soft); border-color: #e59a2a; color: var(--warn); }
.radio-pill.p-routine:has(input:checked) { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-dark); }

/* ---------- Consultation ---------- */
.consult { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 18px; align-items: start; }
.consult-side { position: sticky; top: 80px; max-height: calc(100vh - 96px); overflow-y: auto; }
.order { border: 1px solid var(--border); border-radius: 12px; padding: 11px 13px; margin-bottom: 8px; background: #fff; }
.order.completed { border-left: 4px solid var(--ok); }
.order.cancelled { opacity: .6; }
.order-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.order-head .btn { margin-left: auto; }
.order-box { margin-top: 10px; }
.order-box > summary { list-style: none; display: inline-flex; margin-bottom: 10px; }
.order-box > summary::-webkit-details-marker { display: none; }
.order-box[open] > summary { background: var(--brand-soft); border-color: #bfe5de; color: var(--brand-dark); }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0 12px; margin: 10px 0; max-height: 280px; overflow-y: auto; border: 1px solid var(--border); border-radius: 12px; padding: 6px 12px; background: var(--surface-2); }
.checks label.check { margin: 4px 0; }
.rx-row { display: grid; grid-template-columns: minmax(220px, 3fr) 1fr 1.4fr .7fr 1fr .8fr auto; gap: 8px; align-items: end; padding: 12px; border: 1px solid var(--border); border-radius: 12px; margin-bottom: 8px; background: var(--surface-2); }
.rx-row .span2 { grid-column: auto; }
.rx-row .span3 { grid-column: 1 / 7; grid-row: 2; }
.rx-row .icon-btn { grid-column: 7; grid-row: 1; align-self: center; }
.dx-add { position: relative; margin-top: 10px; }
.suggest { position: absolute; left: 0; right: 0; top: 44px; z-index: 5; background: #fff; border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); max-height: 300px; overflow-y: auto; }
.suggest:empty { display: none; }
.suggest button { display: block; width: 100%; text-align: left; padding: 9px 14px; border: 0; border-bottom: 1px solid var(--border); background: #fff; cursor: pointer; font: inherit; }
.suggest button:hover { background: var(--brand-soft); }
.sticky-actions { position: sticky; bottom: 12px; display: flex; justify-content: space-between; align-items: center; gap: 12px; border-color: #bfe5de; background: rgba(251, 254, 253, .92); backdrop-filter: blur(8px); flex-wrap: wrap; box-shadow: var(--shadow-lg); }
details.history { border-bottom: 1px solid var(--border); padding: 9px 0; }
details.history summary { cursor: pointer; font-weight: 550; }
details.history .grid { margin-top: 8px; }
.timeline { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--border); }
.timeline li { padding: 0 0 12px 16px; position: relative; display: flex; flex-direction: column; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 3px #fff, 0 0 0 4px #bfe5de; }
.timeline li span { color: var(--muted); font-size: 12px; }

/* ---------- Billing ---------- */
.balance-card { text-align: center; color: #e6eef5; border: 0; background: radial-gradient(80% 120% at 100% 0%, rgba(245,185,66,.25), transparent 60%), linear-gradient(135deg, var(--brand), var(--navy-2)); box-shadow: var(--shadow-lg); }
.balance-card span { display: block; color: #bfe9e3; font-weight: 650; text-transform: uppercase; letter-spacing: .07em; font-size: 12px; }
.balance-card strong { display: block; font-family: var(--font-display); font-size: 34px; letter-spacing: -.02em; color: #fff; }
.pay-form { border-top: 1px solid var(--border); margin-top: 16px; padding-top: 6px; }
.receipt { max-width: 540px; margin: 0 auto; }
.receipt h3 { letter-spacing: .14em; margin-top: 12px; color: var(--brand-dark); }
.receipt-logo { display: flex; justify-content: center; margin-bottom: 8px; }
.receipt-logo .logo { width: 48px; height: 48px; border-radius: 14px; }
.temp-pwd { font-size: 22px; text-align: center; }
.temp-pwd code { font-size: 22px; padding: 6px 12px; }

/* ---------- Search, alerts, modal, toasts ---------- */
.search-big { font-size: 16px; min-height: 48px; border-radius: 12px; }
.alerts-panel { position: absolute; right: 24px; top: 60px; width: 390px; max-height: 70vh; overflow-y: auto; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.alerts-panel header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: #fff; }
.alert-item { display: grid; grid-template-columns: 1fr auto; gap: 0 8px; padding: 11px 16px; border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text); }
.alert-item span { grid-column: 1; color: var(--muted); font-size: 12px; }
.alert-item time { grid-column: 2; grid-row: 1; color: var(--muted); font-size: 12px; }
.alert-item.unread { background: #f1faf8; box-shadow: inset 3px 0 0 var(--brand-light); }
.alert-item:hover { background: var(--surface-2); }
.bell .count[hidden] { display: none; }
.bell .count { position: absolute; top: 3px; right: 3px; background: var(--danger); color: #fff; border-radius: 999px; font-size: 10px; font-weight: 700; min-width: 17px; height: 17px; display: grid; place-items: center; padding: 0 4px; box-shadow: 0 0 0 2px #fff; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(11, 34, 54, .5); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 50; padding: 16px; animation: fade .15s ease-out; }
.modal { background: #fff; border-radius: 18px; width: min(560px, 100%); max-height: 90vh; overflow-y: auto; box-shadow: 0 30px 60px -12px rgba(0,0,0,.35); animation: pop .18s ease-out; }
.modal-wide { width: min(860px, 100%); }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: #fff; z-index: 1; }
.modal header h2 { margin: 0; }
.modal-body { padding: 20px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
#toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 60; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--navy); color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); border-left: 4px solid var(--brand-light); transition: opacity .4s, transform .4s; animation: pop .2s ease-out; }
.toast-err { background: #7f1d1d; border-left-color: #f87171; }
.toast-warn { background: #713f12; border-left-color: var(--gold); }
.toast.out { opacity: 0; transform: translateY(8px); }

/* ---------- Login ---------- */
body.auth { background: var(--navy); }
.login-wrap { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: radial-gradient(70% 60% at 0% 0%, rgba(20,184,166,.35), transparent 60%), radial-gradient(60% 60% at 100% 100%, rgba(245,185,66,.18), transparent 60%), linear-gradient(160deg, var(--navy-2), var(--navy)); }
.login-wrap > .card { width: min(560px, 100%); }
.login-shell { width: min(980px, 100%); display: grid; grid-template-columns: 1.1fr 1fr; background: #fff; border-radius: 24px; overflow: hidden; box-shadow: 0 40px 80px -20px rgba(0,0,0,.5); }
.login-hero { position: relative; display: flex; flex-direction: column; justify-content: space-between; gap: 28px; padding: 40px; color: #d7e3ec; overflow: hidden; background: radial-gradient(80% 60% at 100% 0%, rgba(245,185,66,.22), transparent 60%), radial-gradient(90% 70% at 0% 100%, rgba(20,184,166,.45), transparent 60%), linear-gradient(150deg, #0f3a52, var(--navy)); }
.login-hero::after { content: ""; position: absolute; right: -80px; bottom: -80px; width: 280px; height: 280px; border-radius: 50%; border: 40px solid rgba(255,255,255,.05); }
.hero-brand { display: flex; align-items: center; gap: 12px; font-family: var(--font-display); font-weight: 700; font-size: 17px; color: #fff; }
.hero-brand .logo { width: 46px; height: 46px; border-radius: 14px; }
.hero-copy h2 { font-size: 30px; line-height: 1.15; letter-spacing: -.02em; color: #fff; margin: 0 0 12px; font-weight: 750; }
.hero-copy p { color: #a9bccc; font-size: 15px; max-width: 380px; }
.hero-points { list-style: none; padding: 0; margin: 18px 0 0; display: grid; gap: 10px; }
.hero-points li { display: flex; align-items: center; gap: 10px; color: #dbe7ef; }
.hero-points .ico { width: 30px; height: 30px; padding: 6px; border-radius: 9px; background: rgba(255,255,255,.08); color: var(--gold); }
.login-hero > small { color: #7f97aa; position: relative; z-index: 1; }
.login { display: flex; flex-direction: column; gap: 14px; padding: 40px; margin: 0; background: #fff; }
.login h1 { font-size: 26px; }
.login .brand.big { display: none; }
.brand.big { padding: 0 0 4px; border: 0; }
.brand.big strong { color: var(--text); font-size: 17px; }
.brand.big small { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.demo { font-size: 13px; color: var(--text-2); background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: 12px; padding: 10px 14px; }
.demo summary { cursor: pointer; font-weight: 650; }
.demo p { margin: 6px 0 0; line-height: 1.9; }

/* ---------- Print ---------- */
.print-only { display: none; }
@media print {
  .sidebar, .topbar, .scrim, .app-foot, .no-print, .actions, #toasts, .btn { display: none !important; }
  .main-col { margin: 0; }
  main { padding: 0; }
  body { background: #fff; font-size: 12px; }
  .card { box-shadow: none; border: 0; padding: 0; }
  .print-only { display: block; }
  .print-head { display: grid; grid-template-columns: 1fr auto; gap: 8px; border-bottom: 2px solid #000; margin-bottom: 12px; padding-bottom: 8px; }
  .print-head .bill-to { grid-column: 1 / -1; }
  .print-brand { display: flex; gap: 10px; align-items: flex-start; }
  .print-brand .logo { width: 40px; height: 40px; box-shadow: none; }
  .g3x { display: block; }
  .logo { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .flow { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .consult { grid-template-columns: 1fr; }
  .consult-side { position: static; max-height: none; }
  .rx-row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .rx-row label:first-child { grid-column: span 2; }
  .rx-row .span3 { grid-column: 1 / -1; grid-row: auto; }
  .rx-row .icon-btn { grid-column: auto; grid-row: auto; }
}
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s cubic-bezier(.2,.8,.2,1); box-shadow: none; }
  .sidebar.open { transform: none; box-shadow: 0 0 60px rgba(0,0,0,.35); }
  .sidebar.open ~ .scrim { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(11, 34, 54, .45); backdrop-filter: blur(2px); animation: fade .2s; }
  .main-col { margin-left: 0; }
  .icon-btn.menu-btn { display: inline-grid; }
  .topbar-brand { display: block; }
  .topbar { padding: 10px 18px; }
  main { padding: 20px 18px 40px; }
  .app-foot { padding: 12px 18px 18px; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3x { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .user-chip > div { display: none; }
  .user-chip { padding-left: 8px; }
  .hide-sm { display: none; }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .login-shell { grid-template-columns: 1fr; max-width: 460px; }
  .login-hero { display: none; }
  .login .brand.big { display: flex; }
}
@media (max-width: 640px) {
  body { font-size: 14.5px; }
  h1 { font-size: 21px; }
  .topbar { flex-wrap: wrap; gap: 8px 10px; padding: 8px 14px; min-height: 56px; }
  .quick-search { order: 5; flex: 1 0 100%; max-width: none; }
  .user-chip { border-left: 0; padding-left: 0; }
  main { padding: 16px 14px 32px; }
  .app-foot { padding: 10px 14px 16px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .span2, .span3 { grid-column: auto; }
  .card { padding: 16px; border-radius: 12px; }
  .page-head { align-items: stretch; }
  .page-head > div:first-child { min-width: 0; }
  .page-head.hero { padding: 20px; border-radius: 16px; }
  .page-head.hero h1 { font-size: 21px; }
  .quick-actions { width: 100%; }
  .quick-actions .btn { flex: 1 1 auto; }
  .page-head > .actions, .page-head > .row { width: 100%; justify-content: flex-start; }
  .flow { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .flow-step { padding: 13px 13px 11px; }
  .flow-step .n { font-size: 26px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 58px 12px 12px; min-height: 0; justify-content: flex-start; }
  .stat-ico { left: 12px; top: 12px; width: 36px; height: 36px; padding: 8px; }
  .stat strong { font-size: 20px; }
  .kanban { grid-template-columns: repeat(6, 82%); }
  .rx-row { grid-template-columns: 1fr 1fr; }
  .dl { grid-template-columns: 120px 1fr; }
  .banner { padding: 16px; gap: 12px; }
  .banner-actions { justify-content: flex-start; width: 100%; }
  .alerts-panel { right: 8px; left: 8px; top: 100%; width: auto; }
  .actions { justify-content: stretch; }
  .actions > .btn, .actions > form > .btn { flex: 1 1 auto; }
  .login-wrap { padding: 14px; align-items: start; padding-top: 6vh; }
  .login { padding: 26px 22px; }
  .table th, .table td { padding: 10px 12px; }
  #toasts { right: 16px; left: 16px; bottom: 16px; max-width: none; }
  .row > input:not([type=checkbox]):not([type=radio]):not([type=hidden]), .row > select { flex: 1 1 160px; }
}

/* ---------- Server-rendered additions ---------- */
.grow { flex: 1; min-width: 160px; }
.w-num { width: 84px; }
.w-money { width: 124px; }
.row > form { display: inline-flex; }
.row label input.w-num, .row label input.w-money { margin-left: 4px; }
details.card > summary { cursor: pointer; margin-bottom: 8px; font-weight: 650; }
details.card[open] > summary { margin-bottom: 14px; }
.order-box form + form { margin-top: 8px; }
td.right .order-box { text-align: left; display: inline-block; }
td.right .order-box[open] { display: block; min-width: 260px; }
.banner h1 { margin-bottom: 4px; }
.notice.flash { margin: 0 0 16px; }
.validation-summary-valid { display: none; }
.field-validation-error { color: var(--danger); }
dd .badge { margin: 0 4px 4px 0; }
[hidden] { display: none !important; }
button.chip { border: 1px solid transparent; cursor: pointer; font: inherit; font-size: 12px; }
button.chip:hover { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-dark); }
.rx-row [data-rx-override] { grid-column: 1 / 7; grid-row: 3; }
@media (max-width: 1280px) { .rx-row [data-rx-override] { grid-column: 1 / -1; grid-row: auto; } }
form.card > label, form.card > .table-wrap + label { margin-top: 12px; }
.balance-card .badge { display: inline-flex; margin-top: 8px; }
.flow { margin-bottom: 18px; }
.row > input:not(.grow):not(.search-big), .row > select { width: auto; }
.row > .search-big { flex: 1; }

/* ---------- Shared patient-facing bits ---------- */
.btn-xl { padding: 16px 26px; min-height: 60px; font-size: 18px; border-radius: 14px; }
.btn-xl .ico { width: 22px; height: 22px; }
.row.between { justify-content: space-between; }
.dob { margin: 0; }
.dob legend { text-transform: none; letter-spacing: 0; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 5px; }
.dob-row { display: grid; grid-template-columns: 1fr 1fr 1.5fr; gap: 10px; }
.dob-row label { font-size: 11.5px; font-weight: 600; color: var(--muted); }
.patient-link { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; border: 1px solid #bfe5de; background: var(--brand-soft); color: var(--brand-dark); text-decoration: none; font-size: 13px; }
.patient-link span { flex: 1; }
.patient-link:hover { background: #d9f0ec; color: var(--brand-dark); }
.login-shell.login-narrow { grid-template-columns: 1fr; max-width: 440px; }
.login .brand.big.show { display: flex; }
.code-icon { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.code-icon .ico { width: 28px; height: 28px; }
.code-input { font-size: 28px; letter-spacing: .5em; text-align: center; font-variant-numeric: tabular-nums; min-height: 60px; font-weight: 700; }

/* ---------- Patient portal ---------- */
body.portal-in { background: var(--bg); }
.portal-top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; padding: 10px max(20px, calc((100vw - 1040px) / 2));
  background: rgba(11, 34, 54, .96); backdrop-filter: blur(10px); color: #fff; box-shadow: 0 6px 20px -10px rgba(0,0,0,.4);
}
.portal-brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; min-width: 0; }
.portal-brand .logo { width: 36px; height: 36px; }
.portal-brand strong { display: block; font-family: var(--font-display); font-size: 14.5px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.portal-brand small { display: block; color: var(--gold); font-size: 11px; font-weight: 600; }
.portal-brand:hover { color: #fff; }
.portal-tabs { display: flex; gap: 4px; margin: 0 auto; }
.portal-tabs a { display: flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 10px; color: #b9c8d6; text-decoration: none; font-weight: 600; font-size: 13.5px; }
.portal-tabs a:hover { background: rgba(255,255,255,.07); color: #fff; }
.portal-tabs a.on { background: rgba(20,184,166,.22); color: #fff; box-shadow: inset 0 0 0 1px rgba(94,234,212,.2); }
.portal-tabs a.on .ico { color: #5eead4; }
.portal-out-form .btn-ghost { color: #cfdbe6; }
.portal-out-form .btn-ghost:hover { background: rgba(255,255,255,.08); color: #fff; }
.portal-main { max-width: 1040px; margin: 0 auto; padding: 24px 20px 40px; }
.portal-help { margin-top: 28px; text-align: center; color: var(--muted); font-size: 12.5px; }
.portal-hero { display: flex; align-items: center; gap: 16px; padding: 24px; margin-bottom: 18px; border-radius: 18px; color: #dbe7ef; position: relative; overflow: hidden;
  background: radial-gradient(60% 120% at 100% 0%, rgba(245,185,66,.22), transparent 60%), radial-gradient(80% 140% at 0% 100%, rgba(20,184,166,.35), transparent 60%), linear-gradient(120deg, var(--navy-2), var(--navy) 55%, #0b3b55); box-shadow: var(--shadow-lg); }
.portal-hero h1 { color: #fff; margin-bottom: 2px; }
.portal-hero p { margin: 0; color: #a9bccc; }
.portal-hero .avatar { background: rgba(255,255,255,.12); color: #fff; box-shadow: inset 0 0 0 1px rgba(255,255,255,.2); }
.portal-now { border-color: #bfe5de; background: linear-gradient(180deg, #f2fbf9, #fff); }
.portal-now-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; color: var(--brand-dark); }
.pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--brand-light); box-shadow: 0 0 0 0 rgba(20,184,166,.6); animation: pulse 1.8s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 10px rgba(20,184,166,0); } 100% { box-shadow: 0 0 0 0 rgba(20,184,166,0); } }
.portal-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.portal-card { display: flex; flex-direction: column; gap: 2px; padding: 16px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); text-decoration: none; color: var(--text-2); font-size: 13px; font-weight: 550; transition: transform .15s, box-shadow .15s, border-color .15s; }
.portal-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--brand-light); color: var(--text); }
.portal-card strong { font-family: var(--font-display); font-size: 24px; font-weight: 750; color: var(--text); letter-spacing: -.02em; }
.pc-ico { width: 38px; height: 38px; padding: 8px; border-radius: 11px; background: var(--brand-soft); color: var(--brand); margin-bottom: 8px; stroke-width: 2; }
.portal-card.due { border-color: #fdd3bf; background: linear-gradient(180deg, #fff, #fff6f1); }
.portal-card.due .pc-ico { background: #fff0ea; color: #c2410c; }
.appt-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.appt-list li { display: flex; gap: 14px; align-items: center; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.appt-date { width: 54px; flex: none; text-align: center; border-radius: 12px; background: #fff; border: 1px solid var(--border); overflow: hidden; }
.appt-date span { display: block; background: var(--brand); color: #fff; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: 2px 0; }
.appt-date strong { display: block; font-family: var(--font-display); font-size: 22px; padding: 2px 0 4px; }
details.result > summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; list-style: none; }
details.result > summary::-webkit-details-marker { display: none; }
details.result[open] > summary { margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.card.empty { display: grid; place-items: center; gap: 6px; }
.card.empty .ico { width: 34px; height: 34px; color: var(--border-strong); }
.rx-list { list-style: none; padding: 0; margin: 0; }
.rx-list li { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--border); }
.rx-list li:last-child { border-bottom: 0; }
.rx-ico { width: 36px; height: 36px; flex: none; border-radius: 10px; display: grid; place-items: center; background: var(--purple-soft); color: var(--purple); }
.balance-card small { display: block; color: #bfe9e3; margin-top: 4px; }
.card > h2 .ico { color: var(--brand); }
.card > h2 small { font-weight: 500; font-size: 13px; }

/* ---------- Reception kiosk ---------- */
body.kiosk { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; color: var(--text);
  background: radial-gradient(70% 60% at 0% 0%, rgba(20,184,166,.35), transparent 60%), radial-gradient(60% 60% at 100% 100%, rgba(245,185,66,.18), transparent 60%), linear-gradient(160deg, var(--navy-2), var(--navy)); }
.kiosk-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 32px; color: #fff; }
.kiosk-top .hero-brand { font-size: 20px; }
.kiosk-top .logo { width: 52px; height: 52px; border-radius: 15px; }
.kiosk-clock { color: #a9bccc; font-size: 15px; font-weight: 600; }
.kiosk-main { flex: 1; display: grid; place-items: center; padding: 12px 24px 24px; }
.kiosk-card { width: min(620px, 100%); background: #fff; border-radius: 26px; padding: 40px; box-shadow: 0 40px 80px -20px rgba(0,0,0,.5); display: flex; flex-direction: column; gap: 16px; }
.kiosk-card h1 { font-size: 32px; letter-spacing: -.02em; }
.kiosk-card > p { font-size: 16px; }
.kiosk-card input, .kiosk-card textarea { font-size: 20px; min-height: 58px; border-radius: 14px; padding: 12px 16px; }
.kiosk-card textarea { font-size: 17px; min-height: 0; }
.kiosk-card label { font-size: 15px; }
.kiosk-card .dob-row label { font-size: 13px; }
.kiosk-card .dob legend { font-size: 15px; }
.kiosk-step { align-self: flex-start; padding: 4px 12px; border-radius: 999px; background: var(--gold-soft); color: #8a5a00; font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.kiosk-appt { display: flex; gap: 14px; align-items: center; padding: 16px; border-radius: 16px; background: var(--brand-soft); border: 1px solid #bfe5de; font-size: 16px; }
.kiosk-appt .ico { width: 32px; height: 32px; color: var(--brand); }
.kiosk-choices { display: grid; gap: 10px; }
.kiosk-choice { flex-direction: row; align-items: center; gap: 14px; padding: 16px 18px; border: 2px solid var(--border); border-radius: 16px; font-size: 18px; font-weight: 650; color: var(--text); cursor: pointer; transition: border-color .15s, background .15s; }
.kiosk-choice input { width: 24px; height: 24px; min-height: 0; flex: none; }
.kiosk-choice:has(input:checked) { border-color: var(--brand-light); background: var(--brand-soft); color: var(--brand-dark); }
.kiosk-done { text-align: center; align-items: center; }
.done-tick { width: 92px; height: 92px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #22c55e, var(--brand)); box-shadow: 0 16px 30px -10px rgba(22,163,74,.6); animation: pop .3s ease-out; }
.done-tick .ico { width: 48px; height: 48px; stroke-width: 2.6; }
.visit-no { font-family: var(--font-display); font-size: 26px; color: var(--brand-dark); letter-spacing: .02em; }
.kiosk-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 32px 20px; color: #a9bccc; font-size: 14px; }
.kiosk-foot .link { color: #6f879b; font-weight: 500; font-size: 12px; }

@media (max-width: 860px) {
  .portal-top { flex-wrap: wrap; padding: 10px 14px 0; gap: 8px 12px; }
  .portal-out-form { margin-left: auto; }
  .portal-tabs { order: 3; width: calc(100% + 28px); margin: 0 -14px; padding: 4px 8px 6px; overflow-x: auto; justify-content: space-between; border-top: 1px solid rgba(255,255,255,.08); }
  .portal-tabs a { flex-direction: column; gap: 3px; padding: 6px 10px; font-size: 11.5px; flex: 1; min-width: 64px; justify-content: center; }
  .portal-tabs a .ico { width: 20px; height: 20px; }
  .portal-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .portal-main { padding: 16px 14px 32px; }
  .portal-hero { padding: 18px; }
  .portal-hero .avatar { width: 48px; height: 48px; font-size: 16px; }
  .kiosk-top { padding: 16px; }
  .kiosk-clock { display: none; }
  .kiosk-card { padding: 24px 20px; border-radius: 20px; }
  .kiosk-card h1 { font-size: 24px; }
  .kiosk-foot { padding: 12px 16px 16px; flex-direction: column; }
}
/* ---------- Roles & permissions ---------- */
.perm-meter { width: 120px; height: 8px; vertical-align: middle; margin-right: 6px; appearance: none; -webkit-appearance: none; border: 0; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.perm-meter::-webkit-progress-bar { background: var(--surface-3); border-radius: 999px; }
.perm-meter::-webkit-progress-value { background: linear-gradient(90deg, var(--brand-light), var(--brand)); border-radius: 999px; }
.perm-meter::-moz-progress-bar { background: linear-gradient(90deg, var(--brand-light), var(--brand)); border-radius: 999px; }
.perm-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.perm-group { margin: 0; position: relative; }
.perm-group legend { float: left; width: 100%; margin-bottom: 8px; }
.perm-tools { position: absolute; right: 20px; top: 20px; font-size: 12px; color: var(--muted); }
.perm-tools .link { font-size: 12px; font-weight: 600; }
.perm { clear: both; flex-direction: row; align-items: flex-start; gap: 12px; padding: 10px 12px; margin: 0 -8px; border-radius: 10px; cursor: pointer; font-weight: 400; color: var(--text); transition: background .12s; }
.perm:hover { background: var(--surface-2); }
.perm.on { background: var(--brand-soft); }
.perm input { width: 20px; height: 20px; min-height: 0; flex: none; margin-top: 1px; }
.perm span { flex: 1; display: flex; flex-direction: column; }
.perm strong { font-weight: 600; }
.perm small { color: var(--muted); font-size: 12px; }
.perm:has(input:disabled) { cursor: not-allowed; opacity: .85; }
.perm em { align-self: center; font-style: normal; }
.perm-form .sticky-actions { margin-top: 16px; }
.role-danger { margin-top: 4px; }
.back-ico { width: 14px; height: 14px; vertical-align: -2px; }
@media (max-width: 900px) { .perm-groups { grid-template-columns: 1fr; } }
@media (max-width: 640px) { .perm-tools { position: static; margin: -4px 0 6px; } }
/* ---------- Messages ---------- */
.chat { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 16px; height: calc(100vh - 64px - 24px - 60px); min-height: 520px; }
.chat > .card { margin: 0; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.chat-list-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 16px 10px; }
.chat-list-head h1 { font-size: 20px; margin: 0; }
.chat-search { position: relative; margin: 0 16px 10px; }
.chat-search .ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; }
.chat-search input { padding-left: 34px; min-height: 36px; border-radius: 999px; background: var(--surface-2); }
.chat-items { overflow-y: auto; flex: 1; padding: 0 8px 8px; }
.chat-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border-radius: 12px; text-decoration: none; color: var(--text); position: relative; }
.chat-item:hover { background: var(--surface-2); color: var(--text); }
.chat-item.on { background: var(--brand-soft); }
.chat-item.unread strong { font-weight: 750; }
.chat-avatar, .msg-avatar { width: 38px; height: 38px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; background: linear-gradient(135deg, var(--brand-light), var(--navy-2)); }
.chat-avatar.team { border-radius: 12px; background: linear-gradient(135deg, var(--gold), #d97706); color: #3b2a05; }
.chat-item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.chat-item-top { display: flex; justify-content: space-between; gap: 8px; }
.chat-item-top strong { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item-top time { font-size: 11.5px; color: var(--muted); flex: none; }
.chat-item-preview { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item.unread .chat-item-preview { color: var(--text-2); }
.chat-item .chip { align-self: flex-start; margin-top: 3px; }
.chip-ico { width: 12px; height: 12px; vertical-align: -2px; margin-right: 3px; }
.chat-unread { position: absolute; right: 10px; bottom: 12px; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--brand); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.dot-urgent { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); margin-right: 5px; vertical-align: 1px; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.chat-head h2 { margin: 0; font-size: 16px; }
.chat-back { display: none; }
.add-people { position: relative; margin: 0; }
.add-people > summary { margin: 0; }
.add-people[open] form { position: absolute; right: 0; top: 40px; z-index: 5; width: 280px; background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 12px; box-shadow: var(--shadow-lg); }
.chat-thread { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 6px; background: linear-gradient(180deg, var(--surface-2), #fff 40%); }
.msg-day { align-self: center; margin: 10px 0 4px; }
.msg-day span { font-size: 11.5px; font-weight: 650; color: var(--muted); background: var(--surface-3); padding: 3px 10px; border-radius: 999px; }
.msg { display: flex; gap: 8px; align-items: flex-end; max-width: 78%; }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.msg-avatar { width: 30px; height: 30px; font-size: 11px; }
.msg-bubble { background: #fff; border: 1px solid var(--border); border-radius: 16px 16px 16px 4px; padding: 8px 12px 6px; box-shadow: var(--shadow-xs); min-width: 80px; }
.msg.mine .msg-bubble { background: linear-gradient(180deg, #129085, var(--brand)); border-color: var(--brand-600); color: #fff; border-radius: 16px 16px 4px 16px; }
.msg-bubble p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-from { display: block; font-size: 12px; color: var(--brand-dark); }
.msg-bubble time { display: block; text-align: right; font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.msg.mine .msg-bubble time { color: #c8f1ea; }
.msg.urgent .msg-bubble { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.msg-flag { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; color: var(--danger); text-transform: uppercase; letter-spacing: .04em; }
.msg.mine .msg-flag { color: #ffe1e1; }
.msg-flag .ico { width: 13px; height: 13px; }
.chat-reply { display: flex; gap: 10px; align-items: flex-end; padding: 12px 14px; border-top: 1px solid var(--border); background: #fff; }
.chat-reply textarea { flex: 1; resize: none; min-height: 44px; max-height: 160px; border-radius: 14px; }
.chat-reply-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.chat-reply-actions .check { margin: 0; font-size: 12px; }
.chat-compose { padding: 18px; overflow-y: auto; }
.team-picks { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.team-pick { flex-direction: row; align-items: center; gap: 0; cursor: pointer; }
.team-pick input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.team-pick span { padding: 6px 12px; border: 1px solid var(--border-strong); border-radius: 999px; font-weight: 600; font-size: 13px; background: #fff; }
.team-pick input:checked + span { background: var(--brand-soft); border-color: var(--brand-light); color: var(--brand-dark); }
.team-pick input:focus-visible + span { outline: 3px solid var(--brand-ring); }
.people-select { min-height: 140px; }
.chat-empty { flex: 1; display: grid; place-content: center; justify-items: center; gap: 8px; text-align: center; padding: 30px; }

/* ---------- Notification centre ---------- */
.alerts-panel footer { padding: 10px 16px; border-top: 1px solid var(--border); text-align: center; position: sticky; bottom: 0; background: #fff; }
.alerts-panel footer a { font-weight: 600; text-decoration: none; }
.notif-list { margin-bottom: 12px; }
.notif { display: flex; gap: 14px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text); }
.notif:last-child { border-bottom: 0; }
.notif:hover { background: var(--surface-2); color: var(--text); }
.notif .grow { display: flex; flex-direction: column; min-width: 0; }
.notif.unread { background: #f3faf8; box-shadow: inset 4px 0 0 var(--brand-light); }
.notif.unread strong { font-weight: 750; }
.notif.urgent .notif-ico { background: var(--danger-soft); color: var(--danger); }
.notif-ico { width: 38px; height: 38px; flex: none; border-radius: 11px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.notif-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: 12px; color: var(--muted); flex: none; }
#msg-link .count { background: var(--brand); }

@media (max-width: 1024px) {
  .chat { height: calc(100vh - 64px - 20px - 50px); }
}
@media (max-width: 860px) {
  .chat { grid-template-columns: 1fr; height: calc(100vh - 56px - 110px); }
  .chat.chat-open .chat-list { display: none; }
  .chat:not(.chat-open) .chat-pane { display: none; }
  .chat-back { display: inline-grid; }
  .msg { max-width: 90%; }
}
@media (max-width: 640px) {
  .chat { height: calc(100dvh - 110px - 40px); min-height: 420px; }
  .notif { padding: 12px 14px; gap: 10px; }
  .notif-meta .chip { display: none; }
}
/* ---------- Backups ---------- */
.backup-status { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.backup-status h2 { margin: 0 0 2px; }
.backup-status p { margin: 0; }
.backup-status-ico { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; flex: none; }
.backup-status-ico .ico { width: 28px; height: 28px; stroke-width: 2.2; }
.backup-status.ok { border-color: #c0e8cf; background: linear-gradient(180deg, #fff, #f3fbf6); }
.backup-status.ok .backup-status-ico { background: var(--ok-soft); color: var(--ok); }
.backup-status.bad { border-color: #f6c8c5; background: linear-gradient(180deg, #fff, #fff6f6); }
.backup-status.bad .backup-status-ico { background: var(--danger-soft); color: var(--danger); }
.backup-next { display: flex; flex-direction: column; align-items: flex-end; }
.backup-runs li { align-items: flex-start; padding: 10px 18px; }
.restore-steps { padding-left: 20px; margin: 0 0 10px; display: grid; gap: 6px; }
.sms-provider { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.sms-provider h2 { margin: 0 0 2px; }
.sms-provider p { margin: 0; }
.sms-provider input { width: 200px; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
