/* Hospital Information System
   Layout: phones (drawer menu, stacked cards) → tablets portrait/landscape → desktop (fixed sidebar). */

/* ---------- Tokens ----------
   The Advance Ledger (Sage) look: a black menu where the open page is a solid block of the accent colour,
   white cards on a cool grey page, forest green accent. Dark mode: [data-theme="dark"], near-black neutrals.
   --primary* come from the theme colour: Hospital Settings → Appearance overrides them (see theme_style() in functions.php).
   The cross logo is always red on white. */
:root {
    --bg: #f1f5fb; --surface: #ffffff; --surface-2: #f6f8fc; --surface-3: #e8eef7;
    --border: #e0e7f1; --text: #0f172a; --text-2: #334155; --muted: #475569;
    --primary: #2563eb; --primary-strong: #1d4fbf; --on-primary: #ffffff; --primary-soft: #e4ecfd;
    --side-bg: #0f2557; --side-border: rgba(255, 255, 255, .1); --side-text: rgba(255, 255, 255, .84); --side-muted: rgba(255, 255, 255, .55);
    --side-strong: #ffffff; --side-hover: rgba(255, 255, 255, .1); --side-active-bg: #2f6ff0; --side-active: #ffffff;
    /* the brand band (kiosk and TV headers, ticker, sign-in card, phone top line); the name is historical */
    --brand-red: #0f2557; --brand-red-strong: #0a1a40; --on-brand-red: #ffffff;
    --logo-bg: #ffffff; --logo-cross: #d32f2f;
    --side-logo-bg: var(--logo-bg); --side-logo: var(--logo-cross);
    --green: #0f7a55; --green-soft: #e2f5ec;
    --amber: #a55a05; --amber-soft: #fdf0d9;
    --red: #c22f2f; --red-soft: #fde7e7;
    --blue: #1d4ed8; --blue-soft: #dbeafe;
    --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 4px 16px rgba(15, 23, 42, .05);
    --radius: 12px; --radius-sm: 9px;
    --side-w: 256px; --side-mini: 72px; --top-h: 60px;
    color-scheme: light;
}
:root[data-theme="dark"] {
    --bg: #0e0e10; --surface: #18181b; --surface-2: #202024; --surface-3: #26262b;
    --border: #2e2e34; --text: #ececef; --text-2: #d4d4da; --muted: #b8b8c0;
    --primary: #85bd9a; --primary-strong: #b0d4bd; --on-primary: #04170b; --primary-soft: #173123;
    --side-bg: #0a1a3d; --side-border: rgba(255, 255, 255, .08); --side-text: rgba(255, 255, 255, .8); --side-muted: rgba(255, 255, 255, .5);
    --side-strong: #ffffff; --side-hover: rgba(255, 255, 255, .08); --side-active-bg: #2f6ff0; --side-active: #ffffff;
    --brand-red: #0d2f73; --brand-red-strong: #0a2459; --on-brand-red: #ffffff;
    --green: #3fc28f; --green-soft: #12322a;
    --amber: #f0b23f; --amber-soft: #3a2c10;
    --red: #f07a7a; --red-soft: #3c1b1e;
    --blue: #7ab0ff; --blue-soft: #14274a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0; background: var(--bg); color: var(--text);
    font: 15px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    min-height: 100vh; min-height: 100dvh;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; text-wrap: balance; }
p { margin: 0 0 .8rem; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }
code { font-family: Consolas, "Cascadia Mono", monospace; font-size: .88em; background: var(--surface-3); padding: .1em .35em; border-radius: 5px; }
small { font-size: .84em; }
.icon { flex: none; vertical-align: -4px; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; min-height: 100dvh; }
.sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--side-w); z-index: 40;
    background: var(--surface); border-right: 1px solid var(--border);
    display: flex; flex-direction: column; transition: transform .2s ease, width .2s ease;
}
.side-top { display: flex; align-items: center; gap: .25rem; min-height: var(--top-h); padding: .45rem .5rem .45rem 1rem; border-bottom: 1px solid var(--border); flex: none; }
.brand { display: flex; align-items: center; gap: .65rem; color: var(--text); font-weight: 700; min-width: 0; flex: 1; }
.brand:hover { text-decoration: none; }
/* The hospital name wraps onto up to 3 lines instead of being cut off */
.brand-text { font-size: .86rem; line-height: 1.18; letter-spacing: -.005em; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; }
.logo-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--logo-bg); color: var(--logo-cross); box-shadow: inset 0 0 0 1px var(--border); display: grid; place-items: center; flex: none; }
.side-nav { flex: 1; overflow-y: auto; padding: .5rem .6rem 1rem; scrollbar-width: thin; }
.nav-group { font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: .9rem .6rem .3rem; white-space: nowrap; overflow: hidden; }
.side-nav a { display: flex; align-items: center; gap: .75rem; padding: .58rem .7rem; border-radius: var(--radius-sm); color: var(--text-2); font-weight: 600; white-space: nowrap; }
.side-nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.side-nav a.active { background: var(--primary-soft); color: var(--primary-strong); }
.side-user { display: flex; align-items: center; gap: .6rem; padding: .7rem .8rem; border-top: 1px solid var(--border); flex: none; }
.side-user-info { min-width: 0; flex: 1; line-height: 1.25; }
.side-user-info strong, .side-user-info small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user-info small { color: var(--muted); }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-strong); display: grid; place-items: center; font-weight: 700; font-size: .85rem; flex: none; }
.avatar:hover { text-decoration: none; }
.avatar-sm { width: 34px; height: 34px; }
.backdrop { display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 35; }

.main { flex: 1; min-width: 0; margin-left: var(--side-w); display: flex; flex-direction: column; transition: margin-left .2s ease; }
.topbar {
    position: sticky; top: 0; z-index: 30; height: var(--top-h); display: flex; align-items: center; gap: .75rem;
    padding: 0 1.25rem; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
.topbar-title { font-size: 1.05rem; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: .35rem; }
.clock { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .88rem; margin-right: .4rem; white-space: nowrap; }
.icon-btn.menu-btn { display: none; }
.icon-btn { width: 40px; height: 40px; border-radius: 10px; border: 0; background: transparent; color: var(--text-2); display: inline-grid; place-items: center; cursor: pointer; flex: none; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
:root[data-theme="dark"] .i-moon, :root:not([data-theme="dark"]) .i-sun { display: none; }
.content { flex: 1; padding: 1.5rem 1.25rem 2rem; width: 100%; max-width: 1500px; margin: 0 auto; }
.site-footer { text-align: center; color: var(--muted); font-size: .84rem; padding: 1rem 1rem 1.4rem; }
.footer-links { display: flex; flex-wrap: wrap; justify-content: center; gap: .25rem 1rem; margin-bottom: .35rem; }

/* Collapsed sidebar (desktop) */
@media (min-width: 1024px) {
    .nav-mini .sidebar { width: var(--side-mini); }
    .nav-mini .main { margin-left: var(--side-mini); }
    .nav-mini .brand-text, .nav-mini .side-nav a span, .nav-mini .side-user-info, .nav-mini .side-user .icon-btn { display: none; }
    .nav-mini .nav-group { height: 1px; padding: 0; margin: .6rem .4rem; background: var(--border); }
    .nav-mini .side-top { padding: 0; justify-content: center; flex-direction: column; height: auto; gap: 0; padding: .6rem 0; }
    .nav-mini .brand { flex: none; }
    .nav-mini .side-nav a { justify-content: center; padding: .65rem 0; }
    .nav-mini .side-user { justify-content: center; }
    .nav-mini .collapse-btn { transform: rotate(180deg); }
}
/* Tablets and phones: the menu becomes a drawer */
@media (max-width: 1023.98px) {
    .sidebar { transform: translateX(-100%); width: min(300px, 86vw); box-shadow: var(--shadow); }
    .nav-open .sidebar { transform: none; }
    .nav-open .backdrop { display: block; }
    .main { margin-left: 0; }
    .icon-btn.menu-btn { display: inline-grid; }
    .icon-btn.collapse-btn { display: none; }
}

/* ---------- Sign-in & public pages ---------- */
.auth-wrap { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1.5rem 1rem; }
.auth-card { width: 100%; max-width: 430px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 1.75rem; box-shadow: var(--shadow); }
.auth-card.wide { max-width: 900px; }
.auth-card h2 { margin-bottom: 1rem; font-size: 1.25rem; }
.auth-logo { display: flex; align-items: center; gap: .8rem; color: var(--text); margin-bottom: 1.4rem; }
.auth-logo:hover { text-decoration: none; }
.auth-logo .logo-mark { width: 48px; height: 48px; border-radius: 13px; }
.auth-logo strong { display: block; font-size: 1.1rem; line-height: 1.2; }
.auth-logo small { color: var(--muted); }

/* ---------- Page head ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .75rem 1rem; margin-bottom: 1.25rem; }
.page-head h2 { font-size: 1.35rem; }
.page-head p { color: var(--muted); margin: .2rem 0 0; max-width: 70ch; }
.page-head .actions, .btn-group { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

/* ---------- Cards & grids ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 1.1rem; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; padding: .9rem 1.15rem; border-bottom: 1px solid var(--border); }
.card-head h3 { font-size: 1.02rem; display: flex; align-items: center; gap: .5rem; }
.card-head small { color: var(--muted); }
.card-body { padding: 1.15rem; }
.grid { display: grid; gap: 1.1rem; }
.grid > * { min-width: 0; }
.grid-2, .grid-3 { display: grid; gap: 1rem; grid-template-columns: 1fr; }
.grid-2 > *, .grid-3 > * { min-width: 0; }
@media (min-width: 700px) { .grid-2 { grid-template-columns: 1fr 1fr; } .grid-3 { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1100px) { .grid-main { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); align-items: start; } .grid-half { grid-template-columns: 1fr 1fr; align-items: start; } }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .9rem; margin-bottom: 1.25rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; display: flex; gap: .85rem; align-items: center; color: var(--text); box-shadow: var(--shadow); min-width: 0; }
a.stat:hover { border-color: var(--primary); text-decoration: none; }
.stat-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--primary-soft); color: var(--primary-strong); display: grid; place-items: center; flex: none; }
.stat-icon.green { background: var(--green-soft); color: var(--green); }
.stat-icon.amber { background: var(--amber-soft); color: var(--amber); }
.stat-icon.red { background: var(--red-soft); color: var(--red); }
.stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: .86rem; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 40px; padding: .5rem 1rem;
    border: 1px solid transparent; border-radius: var(--radius-sm); background: var(--primary); color: var(--on-primary);
    font: inherit; font-weight: 700; cursor: pointer; white-space: nowrap; text-decoration: none; line-height: 1.2;
}
.btn:hover { background: var(--primary-strong); text-decoration: none; }
.btn-light { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-light:hover { background: var(--surface-3); }
.btn-danger { background: var(--red); color: #fff; }
:root[data-theme="dark"] .btn-danger { color: #1a0606; }
.btn-danger:hover { background: var(--red); filter: brightness(1.1); }
.btn-success { background: var(--green); color: #fff; }
:root[data-theme="dark"] .btn-success { color: #04130d; }
.btn-success:hover { background: var(--green); filter: brightness(1.1); }
.btn-sm { min-height: 32px; padding: .28rem .65rem; font-size: .86rem; border-radius: 8px; }
.btn-sm .icon { width: 16px; height: 16px; }
.btn-lg { min-height: 48px; padding: .7rem 1.4rem; font-size: 1.02rem; }
.btn-block { display: flex; width: 100%; }
.btn[disabled], .btn.disabled { opacity: .5; pointer-events: none; }
form.inline { display: inline; }

/* ---------- Forms ---------- */
.field { margin-bottom: .9rem; min-width: 0; }
.field label, .label { display: block; font-weight: 600; font-size: .86rem; margin-bottom: .3rem; color: var(--text-2); }
label.req::after { content: " *"; color: var(--red); }
input[type=text], 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=search], select, textarea {
    width: 100%; min-height: 42px; padding: .5rem .75rem; background: var(--surface-2); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius-sm); font: inherit;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: var(--primary); }
input[type=file] { width: 100%; padding: .5rem; background: var(--surface-2); border: 1px dashed var(--border); border-radius: var(--radius-sm); color: var(--text-2); font: inherit; }
input[readonly] { opacity: .85; }
::placeholder { color: var(--muted); opacity: .8; }
.hint { display: block; color: var(--muted); font-size: .82rem; margin-top: .25rem; }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 500; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); flex: none; }
.form-grid { display: grid; gap: 0 1rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .form-grid .full { grid-column: 1 / -1; } }
@media (min-width: 1100px) { .form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .form-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.form-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .5rem; }
.filters { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; margin-bottom: 1rem; }
.filters .field { flex: 1 1 160px; margin-bottom: 0; }
.filters .btn { flex: none; }
.input-row { display: flex; gap: .5rem; }
.input-row > input, .input-row > select { flex: 1; min-width: 0; }
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 44px; }
.pw-toggle { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .65rem .9rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; white-space: nowrap; background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num, .text-right { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions > * { margin-left: .25rem; }
.table td small { color: var(--muted); display: block; }
/* Phones: rows become cards (add class "table-cards" and data-label on each td) */
@media (max-width: 639.98px) {
    .table-cards thead { display: none; }
    .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
    .table-cards tr { padding: .7rem .9rem; border-bottom: 1px solid var(--border); }
    .table-cards td { border: 0; padding: .18rem 0; text-align: left !important; }
    .table-cards td[data-label]::before { content: attr(data-label); display: inline-block; min-width: 7.5em; color: var(--muted); font-size: .8rem; font-weight: 600; }
    .table-cards td.actions { padding-top: .5rem; white-space: normal; }
    .table-cards td.actions > * { margin: 0 .3rem .3rem 0; }
}

/* ---------- Small parts ---------- */
.badge { display: inline-block; padding: .14rem .55rem; border-radius: 999px; font-size: .76rem; font-weight: 700; white-space: nowrap; background: var(--surface-3); color: var(--text-2); }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-blue { background: var(--blue-soft); color: var(--blue); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-red { background: var(--red-soft); color: var(--red); }
.alert { padding: .75rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; border: 1px solid transparent; font-weight: 600; overflow-wrap: anywhere; }
.alert-success { background: var(--green-soft); color: var(--green); border-color: var(--green-soft); }
.alert-error { background: var(--red-soft); color: var(--red); border-color: var(--red-soft); }
.alert-warning { background: var(--amber-soft); color: var(--amber); border-color: var(--amber-soft); }
.alert-info { background: var(--blue-soft); color: var(--blue); border-color: var(--blue-soft); }
.list { list-style: none; margin: 0; padding: 0; }
.list-item { display: flex; align-items: center; gap: .85rem; padding: .8rem 1.15rem; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.list-item:last-child { border-bottom: 0; }
.list-item .title { font-weight: 700; overflow-wrap: anywhere; }
.list-item .sub { color: var(--muted); font-size: .88rem; overflow-wrap: anywhere; }
.grow { flex: 1; min-width: 0; }
.empty { text-align: center; color: var(--muted); padding: 2.5rem 1rem; }
.empty .icon { width: 40px; height: 40px; opacity: .6; margin-bottom: .5rem; }
.pager { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; padding: .8rem 1.15rem; border-top: 1px solid var(--border); }
.pager a, .pager span.disabled { padding: .3rem .7rem; border-radius: 8px; border: 1px solid var(--border); color: var(--text-2); font-weight: 600; font-size: .88rem; }
.pager a.current { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.pager span.disabled { opacity: .45; }
.pager .count { margin-left: auto; color: var(--muted); font-size: .86rem; }
.tabs { display: flex; gap: .25rem; overflow-x: auto; border-bottom: 1px solid var(--border); margin-bottom: 1.1rem; scrollbar-width: none; }
.tabs a { padding: .6rem .95rem; color: var(--muted); font-weight: 700; white-space: nowrap; border-bottom: 2px solid transparent; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--primary-strong); border-bottom-color: var(--primary); }
.kv { display: grid; grid-template-columns: minmax(110px, 34%) 1fr; gap: .4rem .9rem; margin: 0; }
.kv dt { color: var(--muted); font-size: .88rem; }
.kv dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.log-box { background: #0a1020; color: #d5def0; font: .84rem/1.6 Consolas, "Cascadia Mono", monospace; padding: .9rem 1rem; border-radius: var(--radius-sm); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 340px; overflow-y: auto; }
.diff-list { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); font: .84rem/1.5 Consolas, monospace; }
.diff-list li { padding: .3rem .7rem; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.diff-list li:last-child { border-bottom: 0; }
.tag { display: inline-block; min-width: 68px; margin-right: .5rem; font-weight: 700; font-size: .72rem; }
.tag-new { color: var(--green); } .tag-changed { color: var(--amber); } .tag-deleted { color: var(--red); }
.doc { line-height: 1.65; }
.doc h3 { margin: 1.4rem 0 .5rem; font-size: 1.08rem; }
.doc h4 { margin: 1rem 0 .35rem; font-size: .98rem; }
.doc ol, .doc ul { padding-left: 1.25rem; margin: 0 0 .8rem; }
.doc li { margin-bottom: .3rem; }
details.faq { border-bottom: 1px solid var(--border); padding: .2rem 0; }
details.faq summary { cursor: pointer; font-weight: 700; padding: .7rem 0; }
details.faq p { color: var(--text-2); }
.toc { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }

/* Dialogs */
dialog.dialog { border: 1px solid var(--border); border-radius: 16px; background: var(--surface); color: var(--text); padding: 1.4rem; width: min(560px, calc(100vw - 2rem)); max-height: calc(100dvh - 2rem); overflow-y: auto; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); }
dialog.dialog.wide { width: min(860px, calc(100vw - 2rem)); }
dialog.dialog::backdrop { background: rgba(0, 0, 0, .6); }
dialog.dialog h3 { margin-bottom: .9rem; display: flex; align-items: center; gap: .5rem; }

/* Patient banner (top of clinical pages) */
.patient-banner { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; align-items: center; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: var(--radius); padding: .85rem 1.1rem; margin-bottom: 1.1rem; }
.patient-banner .name { font-size: 1.12rem; font-weight: 700; }
.patient-banner .meta { color: var(--text-2); font-size: .9rem; }
.patient-banner .allergy { color: var(--red); font-weight: 700; }

/* Queue (staff screen) */
.now-serving { text-align: center; padding: 1.5rem 1rem; }
.now-serving .ticket { font-size: clamp(2.8rem, 9vw, 5rem); font-weight: 800; line-height: 1; letter-spacing: .02em; color: var(--primary-strong); font-variant-numeric: tabular-nums; }
.now-serving .who { color: var(--text-2); margin-top: .5rem; }
.queue-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .6rem; }
.queue-actions .btn { min-height: 52px; }

/* Bed map */
.bed-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .7rem; }
.bed { border: 1px solid var(--border); border-left-width: 4px; border-radius: var(--radius-sm); padding: .65rem .75rem; background: var(--surface-2); min-width: 0; }
.bed strong { display: block; }
.bed small { color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bed.available { border-left-color: var(--green); } .bed.occupied { border-left-color: var(--amber); }
.bed.cleaning { border-left-color: var(--blue); } .bed.maintenance { border-left-color: var(--red); }

/* Simple bar chart (reports) */
.bars { display: grid; gap: .45rem; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 30%) 1fr auto; gap: .6rem; align-items: center; font-size: .9rem; }
.bar-row .track { background: var(--surface-3); border-radius: 6px; height: 12px; overflow: hidden; }
.bar-row .fill { background: var(--primary); height: 100%; border-radius: 6px; min-width: 2px; }
.bar-row .val { font-variant-numeric: tabular-nums; color: var(--text-2); }

/* ---------- Utilities ---------- */
.muted { color: var(--muted); } .nowrap { white-space: nowrap; } .strong { font-weight: 700; }
.mb-0 { margin-bottom: 0 !important; } .mb-1 { margin-bottom: .5rem !important; } .mb-2 { margin-bottom: 1rem !important; }
.mt-1 { margin-top: .5rem !important; } .mt-2 { margin-top: 1rem !important; }
.text-center { text-align: center; } .text-red { color: var(--red); } .text-green { color: var(--green); }
.hide-mobile { } @media (max-width: 639.98px) { .hide-mobile { display: none !important; } }
[hidden] { display: none !important; }

/* ---------- Phones ---------- */
@media (max-width: 639.98px) {
    body { font-size: 15px; }
    .content { padding: 1rem .8rem 1.5rem; }
    .topbar { padding: 0 .6rem; }
    .clock { display: none; }
    .card-body { padding: .95rem; }
    .card-head { padding: .8rem .95rem; }
    .list-item { padding: .75rem .95rem; }
    .page-head h2 { font-size: 1.2rem; }
    .page-head .actions { width: 100%; }
    .page-head .actions .btn { flex: 1; }
    .stats { grid-template-columns: 1fr 1fr; gap: .6rem; }
    .stat { padding: .8rem; flex-direction: column; align-items: flex-start; gap: .5rem; }
    .form-actions .btn { flex: 1 1 auto; }
    .auth-card { padding: 1.25rem; }
    .kv { grid-template-columns: 1fr; gap: 0; }
    .kv dd { margin-bottom: .5rem; }
    input, select, textarea { font-size: 16px !important; }   /* stops iOS zooming into fields */
}

/* ---------- Print (receipts, results, tickets) ---------- */
.print-only { display: none; }
@media print {
    :root, :root[data-theme] { --bg: #fff; --surface: #fff; --surface-2: #fff; --surface-3: #f1f1f1; --border: #bbb; --text: #000; --text-2: #222; --muted: #444; --primary: #000; --primary-strong: #000; --shadow: none; color-scheme: light; }
    body { background: #fff; color: #000; font-size: 12pt; }
    .sidebar, .topbar, .site-footer, .backdrop, .no-print, .alert, .pager, .tabs { display: none !important; }
    .main { margin: 0 !important; }
    .content { padding: 0; max-width: none; }
    .card { box-shadow: none; border: 0; margin: 0 0 .5rem; break-inside: avoid; }
    .print-only { display: block; }
    .badge { background: none !important; color: #000 !important; border: 1px solid #999; }
    a { color: #000; text-decoration: none; }
}
.print-sheet { max-width: 820px; margin: 0 auto; }
.print-header { text-align: center; margin-bottom: 1rem; padding-bottom: .75rem; border-bottom: 2px solid var(--border); }
.print-header h2 { font-size: 1.3rem; }
.print-header p { margin: 0; color: var(--text-2); font-size: .9rem; }
.sign-line { margin-top: 2.5rem; display: flex; justify-content: space-between; gap: 2rem; }
.sign-line div { flex: 1; border-top: 1px solid var(--text); padding-top: .3rem; text-align: center; font-size: .86rem; }

/* Patient picker */
.picker { position: relative; }
.picker-results { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow); max-height: 280px; overflow-y: auto; }
.picker-results button { display: block; width: 100%; text-align: left; padding: .55rem .8rem; background: none; border: 0; border-bottom: 1px solid var(--border); color: var(--text); font: inherit; cursor: pointer; }
.picker-results button:last-child { border-bottom: 0; }
.picker-results button:hover, .picker-results button:focus { background: var(--surface-2); }
.picker-results small { display: block; color: var(--muted); }
.picker-empty { padding: .7rem .8rem; color: var(--muted); }

/* ---------- The menu: its own colours (green band in light mode) ---------- */
.sidebar { background: var(--side-bg); border-right-color: var(--side-border); scrollbar-color: var(--side-muted) transparent; }
.sidebar .side-top { border-bottom-color: var(--side-border); }
.sidebar .brand { color: var(--side-strong); }
.sidebar .logo-mark { background: var(--side-logo-bg); color: var(--side-logo); box-shadow: none; }
.sidebar .nav-group { color: var(--side-muted); }
.sidebar .side-nav a { color: var(--side-text); }
.sidebar .side-nav a:hover { background: var(--side-hover); color: var(--side-strong); }
.sidebar .side-nav a.active { background: var(--side-active-bg); color: var(--side-active); }
.sidebar .side-user { border-top-color: var(--side-border); }
.sidebar .side-user-info strong { color: var(--side-strong); }
.sidebar .side-user-info small { color: var(--side-muted); }
.sidebar .icon-btn { color: var(--side-text); }
.sidebar .icon-btn:hover { background: var(--side-hover); color: var(--side-strong); }
.sidebar .avatar { background: var(--side-active-bg); color: var(--side-strong); }
.sidebar :focus-visible { outline-color: var(--side-strong); }
@media (min-width: 1024px) { .nav-mini .sidebar .nav-group { background: var(--side-border); } }
.topbar { background: color-mix(in srgb, var(--surface) 90%, transparent); }
/* Sign-in and public help pages: a soft wash of the theme colour behind the card */
.auth-wrap { background: radial-gradient(1100px 520px at 50% -8%, var(--primary-soft), transparent 70%), var(--bg); }

/* ---------- Public screens (queue kiosk, TV display) ----------
   Their own page styles use these: white on cool grey by default, near-black when the hospital's default background is dark. */
body.kiosk, body.board {
    --k-bg: #f3f5f9; --k-top: #ffffff; --k-panel: #ffffff; --k-border: #cbd3df; --k-btn: #ffffff; --k-btn-on: #e3f0e8; --k-field: #ffffff;
    --k-text: #0f172a; --k-text2: #334155; --k-muted: #475569; --k-faint: #a3adbb; --k-strong: #0b1220;
    --k-ok: #0f7a55; --k-pri-bg: #fdf0d9; --k-pri: #b86a00; --k-pri-text: #7a4300; --k-err: #c22f2f; --k-flash: #ffeeb8;
}
:root[data-theme="dark"] body.kiosk, :root[data-theme="dark"] body.board {
    --k-bg: #0e0e10; --k-top: #18181b; --k-panel: #18181b; --k-border: #3f3f46; --k-btn: #202024; --k-btn-on: #2e2e34; --k-field: #141417;
    --k-text: #ececef; --k-text2: #d4d4da; --k-muted: #b8b8c0; --k-faint: #6b6b75; --k-strong: #ffffff;
    --k-ok: #3fc28f; --k-pri-bg: #3a2c10; --k-pri: #f0b23f; --k-pri-text: #fde68a; --k-err: #f07a7a; --k-flash: #3a2c10;
}

/* The cross logo is a solid red cross (the icon set draws outlines) */
.logo-mark svg { width: 62%; height: 62%; }
.logo-mark svg path { fill: currentColor; stroke: none; }

/* ---------- Red, green and white ----------
   Red is the hospital's brand band (menu header, logo, sign-in card, kiosk and TV header bars);
   green (the theme colour) is for actions; everything else is white on a light neutral page. */
.sidebar { background: linear-gradient(180deg, #13306b 0%, var(--side-bg) 50%, #0a1a40 100%); }   /* navy */
:root[data-theme="dark"] .sidebar { background: linear-gradient(180deg, #0f2556 0%, var(--side-bg) 100%); }
.sidebar .side-top { background: transparent; border-bottom-color: var(--side-border); }
.sidebar .brand { color: var(--on-brand-red); }
.sidebar .logo-mark { box-shadow: 0 1px 3px rgba(0, 0, 0, .18); }
.sidebar .collapse-btn { color: rgba(255, 255, 255, .85); }
.sidebar .collapse-btn:hover { background: rgba(255, 255, 255, .16); color: #fff; }
.sidebar .avatar { background: var(--primary-soft); color: var(--primary-strong); }
:root[data-theme="dark"] .sidebar .avatar { background: var(--primary-soft); color: var(--primary); }
/* Phones and tablets (menu hidden): keep a red line at the top so the brand is always there */
@media (max-width: 1023.98px) { .topbar { border-top: 4px solid var(--brand-red); } }
.auth-card { border-top: 5px solid var(--brand-red); }
/* Kiosk and TV display: red header bar */
body.kiosk .k-top, body.board .b-top { background: var(--brand-red); border-bottom-color: var(--brand-red-strong); color: var(--on-brand-red); }
body.kiosk .k-top span, body.board .b-name span, body.board .b-clock span { color: rgba(255, 255, 255, .86); }
body.board .b-top .b-btn { background: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .35); color: #fff; }
body.board .b-top .b-btn:hover { background: rgba(255, 255, 255, .26); }
body.board .b-top .b-btn.off { color: #fff; border-color: #fff; background: rgba(0, 0, 0, .18); }

/* The client's own logo in the square mark (menu, sign-in page) */
.logo-mark.has-logo, .sidebar .logo-mark.has-logo { background: #fff; padding: 3px; overflow: hidden; }
.logo-mark.has-logo img { width: 100%; height: 100%; object-fit: contain; display: block; }

/* ---------- Dashboard: colourful summary tiles (blue, green, purple, orange) ---------- */
.dash-tiles .stat { color: #fff; border: 0; box-shadow: 0 6px 16px rgba(15, 40, 90, .12); }
.dash-tiles .stat:nth-child(4n+1) { background: linear-gradient(135deg, #2f80ed, #1d5fd1); }
.dash-tiles .stat:nth-child(4n+2) { background: linear-gradient(135deg, #2bb673, #179c5b); }
.dash-tiles .stat:nth-child(4n+3) { background: linear-gradient(135deg, #8b5cf6, #6d3fe0); }
.dash-tiles .stat:nth-child(4n+4) { background: linear-gradient(135deg, #f7a531, #ec8a12); }
.dash-tiles .stat .stat-icon { background: rgba(255, 255, 255, .2) !important; color: #fff !important; }
.dash-tiles .stat .stat-label { color: rgba(255, 255, 255, .9); }
.dash-tiles .stat:hover { filter: brightness(1.05); border: 0; }
.topbar-title { color: var(--primary-strong); }
:root[data-theme="dark"] .topbar-title { color: var(--text); }
