/* ── Bayside Health design system bridge ──────────────────────────
   The full token set lives in css/design-tokens.css (navy #1B3757,
   coral #E97051, teal #A8DBDD, cream #F5FBF1, ramps, radii, shadows).
   Here we re-map the app's original --bh-* names onto those tokens so
   every existing usage re-skins automatically. Fonts: Hanken Grotesk
   (display) + Source Sans 3 (body), self-hosted via css/fonts.css. */
:root {
    --bh-navy: var(--navy);          /* #1B3757 — primary */
    --bh-navy-dark: var(--navy-800);
    --bh-navy-darker: var(--navy-900);
    --bh-mint: var(--teal);          /* #A8DBDD — soft supporting */
    --bh-mint-tint: var(--teal-50);
    --bh-sienna: var(--coral);       /* #E97051 — primary accent */
    --bh-sienna-dark: var(--coral-600);
    --bh-sienna-rgb: 233, 112, 81;
    --bh-ink: var(--ink);
    --bh-muted: var(--text-muted);
    --bh-bg: var(--cream);

    /* Coral CTA tuned a shade darker (#d85a3c) so white text clears AA on
       large/bold; primary buttons + key calls-to-action use this. */
    --bh-cta: var(--coral-600);
    --bh-cta-hover: #c14e30;

    /* feed the brand into Bootstrap's theme tokens */
    --bs-primary: var(--navy);
    --bs-primary-rgb: 27, 55, 87;
    --bs-link-color: var(--blue);
    --bs-link-color-rgb: 60, 124, 194;
    --bs-link-hover-color: var(--blue-600);
    --bs-link-hover-color-rgb: 47, 101, 159;
    --bs-body-font-family: var(--font-body);
    --bs-border-radius: var(--radius-md);
}

html {
    /* Render native controls (datalist/select pop-ups, scrollbars) in light mode
       so they stay legible even when the OS is in dark mode. */
    color-scheme: light;
}

html, body {
    font-family: var(--font-body);
    color: var(--bh-ink);
    background-color: var(--bh-bg);
}

/* Brand-coloured inline validation message — transparent burnt sienna. */
.alert-brand-error {
    background-color: rgba(var(--bh-sienna-rgb), 0.12);
    border: 1px solid rgba(var(--bh-sienna-rgb), 0.4);
    color: var(--bh-sienna-dark);
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    color: var(--bh-navy);
    font-weight: var(--fw-bold);
    letter-spacing: var(--tracking-snug);
}

/* Heading that scales with its container (not the viewport, which ignores the
   sidebar width) so it stays on a single line without overflowing. */
.fit-heading {
    white-space: nowrap;
    font-size: clamp(1rem, 4cqi, 2.5rem);
}

/* Keep form fields from stretching across the whole screen. Selects size to
   their content (within sensible bounds); text/date inputs cap at a uniform
   width. Textareas keep their own (wider) container width for free text. */
.form-select {
    width: auto;
    min-width: 10rem;
    max-width: 28rem;
}
input.form-control {
    max-width: 22rem;
}
/* Date inputs only need to fit a date — size them like the dropdowns. */
input[type="date"].form-control {
    width: auto;
    min-width: 10rem;
}

a {
    color: var(--blue);
}
.btn-link {
    color: var(--bh-navy);
}

a:hover {
    color: var(--blue-600);
    text-decoration: underline;
}

/* Buttons read as pills with a confident weight (design system). */
.btn {
    border-radius: var(--radius-pill);
    font-weight: var(--fw-semibold);
}

/* Primary = coral CTA. */
.btn-primary {
    --bs-btn-bg: var(--bh-cta);
    --bs-btn-border-color: var(--bh-cta);
    --bs-btn-hover-bg: var(--bh-cta-hover);
    --bs-btn-hover-border-color: var(--bh-cta-hover);
    --bs-btn-active-bg: var(--bh-cta-hover);
    --bs-btn-active-border-color: var(--bh-cta-hover);
    --bs-btn-disabled-bg: var(--bh-cta);
    --bs-btn-disabled-border-color: var(--bh-cta);
    color: #fff;
}

/* Secondary = navy outline → navy fill on hover. */
.btn-outline-primary {
    --bs-btn-color: var(--bh-navy);
    --bs-btn-border-color: var(--bh-navy);
    --bs-btn-hover-bg: var(--bh-navy);
    --bs-btn-hover-border-color: var(--bh-navy);
    --bs-btn-active-bg: var(--bh-navy);
    --bs-btn-active-border-color: var(--bh-navy);
}

/* Tertiary / quiet = soft neutral outline (used widely for low-emphasis actions). */
.btn-outline-secondary {
    --bs-btn-color: var(--text-body);
    --bs-btn-border-color: var(--border-default);
    --bs-btn-hover-bg: var(--surface-sunken);
    --bs-btn-hover-border-color: var(--border-strong);
    --bs-btn-hover-color: var(--bh-navy);
    --bs-btn-active-bg: var(--surface-sunken);
    --bs-btn-active-border-color: var(--border-strong);
    --bs-btn-active-color: var(--bh-navy);
}

/* Navy status / confirmation text (replaces Bootstrap success-green) */
.text-brand {
    color: var(--bh-navy) !important;
    font-weight: 500;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-select:focus, .form-check-input:focus {
  box-shadow: var(--ring-focus);
  border-color: var(--border-focus);
}

/* Form fields: design radius + calm default border (blue focus comes from the rule above). */
.form-control, .form-select {
    border-color: var(--border-default);
    border-radius: var(--radius-md);
}

/* tables & cards pick up subtle brand cues */
.table > thead th {
    color: var(--bh-navy);
    border-bottom-color: var(--bh-navy);
}

.card {
    border-color: var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.card-title a {
    color: var(--bh-navy);
}

.alert-info {
    --bs-alert-color: var(--bh-navy-darker);
    --bs-alert-bg: var(--bh-mint-tint);
    --bs-alert-border-color: var(--bh-mint);
}

.content {
    padding-top: 1.1rem;
}

/* ── Unit selector (home) ─────────────────────────────────────────── */
.unit-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
    gap: 1rem;
    max-width: 740px;
}

.unit-card {
    font-family: inherit;
    width: 100%;
    text-align: left;
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-left: 4px solid var(--bh-navy);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1rem 1.15rem 0.9rem;
    cursor: pointer;
    transition: box-shadow .12s ease, transform .12s ease, border-color .12s ease;
}

.unit-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(27, 55, 87, .13);
    border-color: var(--bh-sienna);
}

.unit-card:focus-visible {
    outline: none;
    box-shadow: 0 0 0 0.2rem rgba(var(--bh-sienna-rgb), .4);
}

.unit-card-acute {
    border-left-color: var(--bh-sienna);
}

.unit-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.unit-code {
    background: var(--bh-navy);
    color: #fff;
    font-size: .8rem;
    font-weight: 600;
    letter-spacing: .02em;
    padding: .15rem .55rem;
    border-radius: 6px;
}

.unit-card-acute .unit-code {
    background: var(--bh-sienna);
}

.unit-count {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    background: var(--bh-mint-tint);
    color: var(--bh-navy-darker);
    font-size: .75rem;
    padding: .15rem .55rem;
    border-radius: 999px;
    white-space: nowrap;
}

.unit-card-acute .unit-count {
    background: rgba(var(--bh-sienna-rgb), .12);
    color: var(--bh-sienna-dark);
}

.unit-name {
    margin-top: .7rem;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--bh-navy);
}

.unit-open {
    margin-top: .85rem;
    font-size: .82rem;
    color: var(--bh-navy);
    display: flex;
    align-items: center;
    gap: .3rem;
}

.unit-card:hover .unit-open {
    color: var(--bh-sienna);
}

h1:focus {
    outline: none;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* Print views (e.g. ward-round list) — hide the app chrome so only the report prints */
@page {
    size: A4;
    margin: 12mm;
}

@media print {
    .sidebar, .top-row, #blazor-error-ui, .no-print {
        display: none !important;
    }

    .content {
        padding: 0 !important;
    }

    html, body {
        background: #fff !important;
    }
}

/* ── Shared UI kit (card-based refresh) ───────────────────────────── */
.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}
.page-head .eyebrow {
    font-size: .72rem;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--bh-muted);
}
.page-head h1 {
    margin-bottom: 0;
}
.page-head-actions {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
}
/* On narrow screens let the (one or two) header buttons grow to share the row
   evenly so the header reads as one tidy block rather than ragged wrapping. */
@media (max-width: 576px) {
    .page-head-actions {
        width: 100%;
    }
    .page-head-actions .btn {
        flex: 1 1 auto;
        white-space: nowrap;
    }
}

/* Section-level heading row: label left, action buttons right. Wraps on narrow
   screens so the buttons drop under the heading instead of overflowing. */
.section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .5rem 1rem;
    flex-wrap: wrap;
    margin-bottom: .5rem;
}
.section-head-actions {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
}
.section-head-actions .btn {
    white-space: nowrap;
}

/* Quiet secondary navigation under the page head (e.g. register / discharges). */
.page-sublinks {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: .5rem;
    margin: -.5rem 0 1.25rem;
    font-size: .85rem;
}
.page-sublinks a {
    color: var(--bh-muted);
    text-decoration: none;
}
.page-sublinks a:hover {
    color: var(--bh-navy);
    text-decoration: underline;
}
.page-sublinks .sublink-sep {
    color: #c4ccd3;
}

/* Prominent, clean quick-action pills under the page head (e.g. register patient,
   recent discharges, record cancellation). More visible than the quiet sublinks,
   without competing with the primary header button. */
.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin: -.25rem 0 1.5rem;
}
.quick-action {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .45rem .85rem;
    font-size: .85rem;
    font-weight: 600;
    color: var(--bh-navy);
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: 999px;
    text-decoration: none;
    box-shadow: var(--shadow-sm);
    transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease, background-color .15s ease;
}
.quick-action svg {
    color: var(--bh-muted);
    flex-shrink: 0;
    transition: color .15s ease;
}
.quick-action:hover {
    color: var(--bh-navy);
    border-color: var(--bh-navy);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md, 0 4px 10px rgba(27, 55, 87, .1));
}
.quick-action:hover svg {
    color: var(--bh-navy);
}
/* The cancellation pill reads in the coral accent so it's distinct from the
   routine register / discharges actions. */
.quick-action--alt {
    color: var(--bh-sienna-dark, #b8472b);
}
.quick-action--alt svg {
    color: var(--bh-coral, #e97051);
}
.quick-action--alt:hover {
    color: var(--bh-sienna-dark, #b8472b);
    border-color: var(--bh-coral, #e97051);
}
.quick-action--alt:hover svg {
    color: var(--bh-coral, #e97051);
}

/* Admit is the primary action of this row — a solid coral pill (same size as the
   others) so it stands out while still sitting inline with them. */
.quick-action--admit {
    color: #fff;
    background: var(--bh-cta);
    border-color: var(--bh-cta);
}
.quick-action--admit svg {
    color: #fff;
}
.quick-action--admit:hover {
    color: #fff;
    background: var(--bh-cta-hover);
    border-color: var(--bh-cta-hover);
}
.quick-action--admit:hover svg {
    color: #fff;
}

/* Sticky page head: keeps the heading + Print button pinned at the top of the
   content while a long list scrolls underneath. The opaque page-coloured
   background and bottom border let rows slide cleanly under it. */
.page-head--sticky {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--bh-bg);
    margin-bottom: 0;
    padding-bottom: .75rem;
    border-bottom: 1px solid var(--border-subtle);
}
.page-head--sticky + .quick-actions {
    margin-top: .85rem;
}
@media (min-width: 641px) {
    /* Sit just below the sticky top bar (3.5rem tall) rather than the viewport edge. */
    .page-head--sticky {
        top: 3.5rem;
    }
}

.app-card {
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1rem 1.15rem;
}

/* Admin hub — grid of tool tiles. */
.admin-tools {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
    gap: 1rem;
    max-width: 880px;
}
.admin-tool {
    display: flex;
    align-items: flex-start;
    gap: .85rem;
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1rem 1.15rem;
    text-decoration: none;
    color: var(--bh-ink);
    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
a.admin-tool:hover {
    border-color: var(--bh-navy);
    box-shadow: 0 8px 20px -14px rgba(27, 55, 87, .6);
    transform: translateY(-1px);
    color: var(--bh-ink);
}
.admin-tool--soon { opacity: .6; }
.admin-tool-icon {
    flex: 0 0 auto;
    width: 2.4rem;
    height: 2.4rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    background: var(--bh-mint-tint);
    color: var(--bh-navy);
}
.admin-tool-body { display: flex; flex-direction: column; gap: .15rem; min-width: 0; flex: 1; }
.admin-tool-title { font-weight: 600; color: var(--bh-navy); }
.admin-tool-desc { font-size: .82rem; color: var(--bh-muted); }

/* Dictionary admin table: fixed columns so the actions stay on screen; long
   synonym/qualifier cells truncate with the full value on hover. */
.dict-table { table-layout: fixed; }
/* Wrap long unbreakable tokens (e.g. "Abdominal/general") so they stay inside
   their column in a narrow window instead of spilling over the next cell. */
.dict-table td, .dict-table th { overflow-wrap: anywhere; }
.dict-table td.trunc, .dict-table th.trunc {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Structured qualifier-group editor card. */
.qual-group {
    background: #f8fafb;
    border: 1px solid #e3e9ee;
    border-radius: 10px;
    padding: .6rem .75rem;
    margin-bottom: .5rem;
}

/* Name-template help: calm the inline code and lay out examples + preview tidily. */
.tmpl-help code {
    background: var(--bh-mint-tint);
    color: var(--bh-navy);
    padding: .05rem .35rem;
    border-radius: 4px;
    font-size: .82em;
}
.tmpl-help .tmpl-examples {
    display: grid;
    gap: .2rem;
    margin-top: .35rem;
}
.tmpl-help .arrow { color: var(--bh-muted); margin: 0 .2rem; }

.tmpl-preview {
    display: grid;
    gap: .25rem;
    margin-top: .6rem;
    padding: .5rem .7rem;
    background: var(--bh-mint-tint);
    border-radius: 8px;
}
.tmpl-preview .lbl {
    display: inline-block;
    min-width: 3.5rem;
    font-size: .68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--bh-muted);
}
.tmpl-preview strong { color: var(--bh-navy); }
.app-card--accent { border-left: 4px solid var(--bh-navy); }
.app-card--urgent { border-left: 4px solid var(--bh-sienna); }

.kpi-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
    gap: .75rem;
    margin-bottom: 1.25rem;
    max-width: 920px;
}
.kpi {
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xs);
    padding: .75rem .95rem;
}
.kpi-label {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--bh-muted);
}
/* Big confident figure (design "Stat" treatment). */
.kpi-value {
    font-family: var(--font-display);
    font-size: 1.85rem;
    font-weight: var(--fw-black);
    line-height: 1.1;
    letter-spacing: var(--tracking-tight);
    color: var(--bh-navy);
}
.kpi-unit { font-size: .8rem; font-weight: 400; color: var(--bh-muted); }

/* Dashboard section bands: a titled rule that groups a KPI row with its detail
   cards (Reports page). The events variant is accented to set clinical safety
   figures apart from routine activity. */
.dash-section {
    display: flex;
    align-items: baseline;
    gap: .65rem;
    flex-wrap: wrap;
    margin: 2rem 0 .9rem;
    padding-bottom: .4rem;
    border-bottom: 3px solid var(--bh-navy);
}
.dash-section:first-child { margin-top: .25rem; }
.dash-section h4 {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: .02em;
    text-transform: uppercase;
    color: var(--bh-navy);
    margin: 0;
}
.dash-section--events { border-bottom-color: var(--bh-sienna); }
.dash-section--events h4 { color: var(--bh-sienna-dark); }

.chip {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    font-size: .75rem;
    padding: .1rem .5rem;
    border-radius: 999px;
    white-space: nowrap;
}
/* Tonal status pills (design system Badge tones). */
.chip--muted   { background: var(--teal-50); color: #1f6e70; }
.chip--navy    { background: var(--pale-blue); color: var(--navy); }
.chip--alert   { background: var(--coral-50); color: var(--coral-600); }
.chip--success { background: var(--success-50); color: var(--success); }
.chip--info    { background: var(--info-50); color: var(--info); }
/* Amber "needs attention" pill, distinct from the coral alert tone. */
.chip--flag    { background: #FBEED2; color: #9A6B0F; }

.patient-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    font-size: .85rem;
    color: var(--bh-muted);
}
.patient-meta .sep {
    color: #c4ccd3;
    margin: 0 .45rem;
}

.avatar {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    border-radius: 50%;
    background: var(--bh-mint-tint);
    color: var(--bh-navy-darker);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .8rem;
    font-weight: 600;
}

.list-card {
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    max-width: 920px;
}
.list-head, .list-row {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: .65rem 1rem;
}
.list-head {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--bh-muted);
    border-bottom: 1px solid #eef2f5;
}
.list-row {
    border-bottom: 1px solid #f0f3f5;
    color: var(--bh-ink);
    text-decoration: none;
    transition: background .1s ease;
}
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: #f7f9fa; }
.list-row-main { flex: 1; min-width: 0; }
/* Single line + ellipsis so a long name clips inside its (possibly squeezed)
   column instead of overflowing on top of the next column. */
.list-row-title { display: block; font-weight: 500; color: var(--bh-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row-sub { display: block; font-size: .78rem; color: var(--bh-muted); }
/* Compact metadata line, only shown when the table columns collapse on narrow screens (see below). */
.list-row-meta { display: none; }
.list-row-chev { color: var(--bh-muted); font-size: 1.1rem; flex-shrink: 0; }
.col-date { width: 6.5rem; flex-shrink: 0; }
.col-consultant { width: 11rem; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-stay { width: 6rem; text-align: right; flex-shrink: 0; }
.col-status { width: 13rem; display: flex; justify-content: flex-end; align-items: center; gap: .3rem; flex-wrap: wrap; }
/* Keep row column text stable on hover (the row is a link, so it would otherwise
   pick up the global a:hover colour). */
.list-row .col-date, .list-row .col-consultant { color: var(--bh-ink); }

/* Narrow content area: the patient lists carry too many fixed columns to fit, so
   the name (flex) column would otherwise be crushed first. Instead, collapse the
   secondary columns into a sub-line under the name — Admitted first, then
   Consultant — so the name stays visible as long as possible.

   Driven by a container query on .content (see MainLayout.razor.css), so it reacts
   to the real list width (viewport minus the sidebar), not the viewport. Scoped to
   .list-card--stack so other list views are unaffected. */
.meta-consultant { display: none; }

@container (max-width: 760px) {
    .list-card--stack .col-date { display: none; }
    .list-card--stack .list-row-meta { display: block; }
}

@container (max-width: 620px) {
    .list-card--stack .col-consultant { display: none; }
    .list-card--stack .meta-consultant { display: inline; }
}

.empty-state {
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 2.5rem 2rem;
    text-align: center;
    color: var(--bh-muted);
    max-width: 920px;
}

/* ── Expandable patient rows (UnitList) ──────────────────────────── */
/* The row splits into a navigating link plus a chevron toggle button so the
   patient can be opened in place without losing the click-through to the
   admission. */
.patient-item { border-bottom: 1px solid #f0f3f5; }
.patient-item:last-child { border-bottom: none; }
.patient-item.is-open { background: #f7f9fa; }
.patient-row { padding-right: .5rem; border-bottom: none; }
.patient-link {
    display: flex;
    align-items: center;
    gap: .85rem;
    flex: 1;
    min-width: 0;
    color: var(--bh-ink);
    text-decoration: none;
}
.patient-link .col-date, .patient-link .col-consultant { color: var(--bh-ink); }
.row-expand {
    flex-shrink: 0;
    border: none;
    background: transparent;
    color: var(--bh-muted);
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    line-height: 1;
}
.row-expand:hover { background: rgba(0,0,0,.05); color: var(--bh-ink); }
.row-expand-chev {
    font-size: 1.2rem;
    transform: rotate(90deg);
    transition: transform .15s ease;
}
.is-open .row-expand-chev { transform: rotate(-90deg); }

.patient-expand {
    padding: .25rem 1rem 1rem 3.6rem;
    display: flex;
    flex-direction: column;
    gap: .85rem;
}
.px-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: .5rem 1.25rem;
    margin: 0;
}
.px-summary > div { min-width: 0; }
.px-summary-wide { grid-column: 1 / -1; }
.px-summary dt {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--bh-muted);
    font-weight: 600;
    margin: 0;
}
.px-summary dd { margin: 0; color: var(--bh-ink); font-size: .9rem; }
.px-ops-head {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--bh-muted);
    font-weight: 600;
    margin-bottom: .35rem;
}
.px-op {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    padding: .3rem 0;
    border-top: 1px solid #eef2f5;
}
.px-op-name { color: var(--bh-ink); font-size: .9rem; min-width: 0; }
.px-op-meta { color: var(--bh-muted); font-size: .8rem; flex-shrink: 0; white-space: nowrap; }
.px-empty { color: var(--bh-muted); font-size: .85rem; }

/* ── Discharges-to-review banner (UnitList) ──────────────────────── */
.review-banner {
    background: rgba(var(--bh-sienna-rgb), .06);
    border: 1px solid rgba(var(--bh-sienna-rgb), .25);
    border-radius: 12px;
    padding: 1rem 1.1rem;
    margin-bottom: 1.25rem;
    max-width: 920px;
}
.review-banner-head {
    display: flex;
    align-items: center;
    gap: .6rem;
    font-weight: 600;
    color: var(--bh-sienna-dark);
}

/* ── Database maintenance: unmatched-diagnosis rows ──────────────── */
.maint-row {
    padding: .7rem 1rem;
    border-bottom: 1px solid #f0f3f5;
}
.maint-row:last-child { border-bottom: none; }
.maint-row--done { background: var(--success-50); }
.maint-row-head {
    display: flex;
    align-items: baseline;
    gap: .6rem;
    margin-bottom: .45rem;
}
.maint-row--done .maint-row-head { margin-bottom: .25rem; }
.maint-text { font-weight: 500; color: var(--bh-ink); }
.maint-actions, .maint-add {
    display: flex;
    align-items: center;
    gap: .4rem;
    flex-wrap: wrap;
}
.maint-search { max-width: 18rem; margin-left: auto; }
.maint-noguess { margin-right: .25rem; }

/* Narrow screens: stack the per-row controls full-width so the match button,
   dictionary search and "+ New" don't wrap into a cramped, ragged row. */
@media (max-width: 640px) {
    .maint-actions, .maint-add { flex-direction: column; align-items: stretch; }
    .maint-actions > .btn, .maint-add > .btn { width: 100%; }
    .maint-search { max-width: none; margin-left: 0; }
    .maint-best { justify-content: center; }
}
.maint-best { display: inline-flex; align-items: center; gap: .4rem; }
.maint-best-label {
    font-size: .62rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    opacity: .75;
    border-right: 1px solid rgba(255,255,255,.4);
    padding-right: .4rem;
}
.maint-row-resolved {
    display: flex;
    align-items: center;
    gap: .4rem;
    color: var(--success);
    font-size: .9rem;
}
.resolved-tick {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.1rem;
    height: 1.1rem;
    border-radius: 50%;
    background: var(--success-50);
    color: var(--success);
    font-size: .75rem;
}

/* ── Sign-in screen ──────────────────────────────────────────────
   Chromeless, on-brand login with a softly animated aurora backdrop. */
.auth-shell {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    overflow: hidden;
    background: radial-gradient(120% 120% at 50% 0%, var(--bh-navy) 0%, var(--bh-navy-darker) 70%);
}

/* Slow-drifting colour blobs behind the card. */
.auth-aurora { position: absolute; inset: 0; z-index: 0; filter: blur(60px); }
.auth-aurora .blob { position: absolute; border-radius: 50%; opacity: 0.55; will-change: transform; }
.auth-aurora .blob-1 {
    width: 38rem; height: 38rem; top: -14rem; left: -10rem;
    background: radial-gradient(circle at 30% 30%, var(--bh-mint), transparent 65%);
    animation: auth-drift-1 22s ease-in-out infinite;
}
.auth-aurora .blob-2 {
    width: 30rem; height: 30rem; bottom: -12rem; right: -8rem;
    background: radial-gradient(circle at 50% 50%, rgba(var(--bh-sienna-rgb), 0.9), transparent 65%);
    animation: auth-drift-2 26s ease-in-out infinite;
}
.auth-aurora .blob-3 {
    width: 24rem; height: 24rem; top: 40%; left: 55%;
    background: radial-gradient(circle at 50% 50%, rgba(168, 219, 221, 0.7), transparent 60%);
    animation: auth-drift-3 30s ease-in-out infinite;
}

.auth-card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 25rem;
    background: rgba(255, 255, 255, 0.97);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 20px;
    padding: 2.4rem 2.2rem 1.8rem;
    box-shadow: 0 30px 60px -20px rgba(8, 20, 35, 0.55);
    text-align: center;
}

/* Brand + card rise together; the stack caps the column width. */
.auth-stack {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 25rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: auth-rise 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* The Peninsula wordmark is the light/reversed version, so it sits straight on
   the dark aurora backdrop above the card — no chip or badge needed. */
.auth-brand {
    width: min(17rem, 72%);
    height: auto;
    display: block;
    margin-bottom: 1.6rem;
    filter: drop-shadow(0 4px 14px rgba(8, 20, 35, 0.45));
}
.auth-title { font-size: 1.4rem; margin: 0; }
.auth-sub { color: var(--bh-muted); margin: 0.15rem 0 1.4rem; font-size: 0.95rem; }

.auth-form { text-align: left; }
.auth-field { margin-bottom: 1rem; }
.auth-field label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--bh-navy);
    margin-bottom: 0.35rem;
}
.auth-field input {
    width: 100%;
    padding: 0.7rem 0.85rem;
    border: 1.5px solid #d7dee4;
    border-radius: 10px;
    font-size: 0.98rem;
    background: #fff;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.auth-field input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: var(--ring-focus);
}

.auth-submit {
    width: 100%;
    margin-top: 0.4rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border: none;
    border-radius: var(--radius-pill);
    background: var(--bh-cta);
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}
.auth-submit:hover {
    background: var(--bh-cta-hover);
    transform: translateY(-1px);
    box-shadow: 0 10px 22px -10px rgba(216, 90, 60, 0.8);
}
.auth-submit:active { transform: translateY(0); }
.auth-submit svg { transition: transform 0.18s ease; }
.auth-submit:hover svg { transform: translateX(3px); }

.auth-alert {
    background: rgba(var(--bh-sienna-rgb), 0.12);
    border: 1px solid rgba(var(--bh-sienna-rgb), 0.4);
    color: var(--bh-sienna-dark);
    border-radius: 10px;
    padding: 0.6rem 0.8rem;
    font-size: 0.88rem;
    margin-bottom: 1.1rem;
    animation: auth-shake 0.4s ease;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--bh-muted);
    font-size: 0.8rem;
    margin: 1.2rem 0;
}
.auth-divider::before, .auth-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: #e2e8ed;
}

.auth-sso {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.7rem 1rem;
    border: 1.5px solid #d7dee4;
    border-radius: 10px;
    background: #fff;
    color: var(--bh-ink);
    font-weight: 600;
    text-decoration: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.auth-sso:hover { border-color: var(--bh-navy); box-shadow: 0 6px 16px -10px rgba(27, 55, 87, 0.6); color: var(--bh-ink); }

.auth-foot { margin: 1.5rem 0 0; font-size: 0.75rem; color: var(--bh-muted); }

@keyframes auth-rise {
    from { opacity: 0; transform: translateY(18px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes auth-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}
@keyframes auth-drift-1 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(4rem, 2.5rem) scale(1.1); }
}
@keyframes auth-drift-2 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(-3.5rem, -2rem) scale(1.12); }
}
@keyframes auth-drift-3 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(-2.5rem, 3rem) scale(0.92); }
}

/* Respect users who prefer no motion: keep the design, drop the movement. */
@media (prefers-reduced-motion: reduce) {
    .auth-stack { animation: none; }
    .auth-aurora .blob { animation: none; }
    .auth-submit:hover svg { transform: none; }
}
/* ── Embedded risk-calculator report (PDF.js) on the risk assessment page ── */
.risk-report-pdf {
    max-height: 640px;
    overflow: auto;
    background: var(--grey-100);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 12px;
    text-align: center;
}

.risk-report-pdf .pdf-page {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    background: #fff;
}

/* ── Demo-site banner (Demo:Banner=true on hosted demos only) ─────── */
.demo-banner {
    background: var(--coral-600, #d85a3c);
    color: #fff;
    text-align: center;
    font-weight: 600;
    font-size: 0.85rem;
    letter-spacing: 0.02em;
    padding: 6px 12px;
}

/* Variant for the login screen: the auth shell is a fixed overlay, so the
   banner pins to its top edge instead of flowing above it. */
.demo-banner--overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 5;
}
