/* Clinic Reception — staff interface
   ==========================================================================================

   The design system for every view except the waiting-room TV, which keeps Bootstrap 4 and
   kiosk.css (see _KioskLayout.cshtml). Nothing here is loaded by that page, so restyling the
   staff views cannot reach the screen on the wall.

   Written by hand rather than as a Bootstrap theme. The staff side is fifteen small views whose
   needs are a form, a table, and an account menu; a framework's worth of components to override
   cost more than it saved, and the two dated dependencies the old markup carried — jQuery for
   dropdowns, Bootstrap's own reset — go away with it. jQuery itself stays, because unobtrusive
   validation needs it, and its classes (input-validation-error, field-validation-error,
   validation-summary-errors) are styled below.

   Conventions:
     - Colour, spacing, radius and shadow come from the tokens in :root. Do not hardcode a hex.
     - Anything a finger drives is at least 44px tall on a coarse pointer.
     - Focus is always visible, and never removed — only restyled.
     - Motion is suppressed under prefers-reduced-motion.

   Layout order: tokens, reset, app shell, page furniture, cards, forms, buttons, tables, queue,
   badges, alerts, menus, utilities. */

/* ==========================================================================================
   1. Tokens
   ========================================================================================== */

:root {
    /* Teal, not the scaffolding's blue: it reads as clinical without the "unvisited link" feel,
       and holds up against the red a called patient's row uses. */
    --accent: #0d7c7c;
    --accent-hover: #0a6767;
    --accent-active: #085555;
    --accent-tint: #e6f2f2;
    --accent-ring: rgba(13, 124, 124, .28);

    --surface: #ffffff;
    --ground: #f6f8fa;
    --raised: #fbfcfd;

    --text: #1f2328;
    --text-muted: #656d76;
    --text-faint: #8b949e;
    --text-on-accent: #ffffff;

    --border: #d0d7de;
    --border-subtle: #e7ebef;
    --border-strong: #afb8c1;

    --danger: #b42a3c;
    --danger-hover: #97202f;
    --danger-tint: #fdf0f1;
    --danger-border: #f2c4c9;

    --success: #1a7f37;
    --success-tint: #eef7f0;
    --success-border: #c3e6cd;

    --warning-text: #7a4b06;
    --warning-tint: #fdf6e8;
    --warning-border: #f0dcae;

    --info-tint: #eff5fb;
    --info-border: #cddff0;

    /* A 4px base step, so every gap is a multiple and vertical rhythm holds without ad-hoc
       margins. */
    --s1: .25rem;
    --s2: .5rem;
    --s3: .75rem;
    --s4: 1rem;
    --s5: 1.5rem;
    --s6: 2rem;
    --s7: 3rem;

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-pill: 999px;

    --shadow-sm: 0 1px 2px rgba(31, 35, 40, .06);
    --shadow: 0 1px 3px rgba(31, 35, 40, .07), 0 8px 24px -12px rgba(31, 35, 40, .12);
    --shadow-lg: 0 8px 32px -8px rgba(31, 35, 40, .18);

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,
            "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
    --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

    --header-height: 4rem;
    --content-width: 70rem;
}

/* ==========================================================================================
   2. Reset and base
   ========================================================================================== */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--ground);
    color: var(--text);
    font-family: var(--font);
    font-size: 1rem;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    margin: 0;
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: -.011em;
}

p {
    margin: 0 0 var(--s3);
}

p:last-child {
    margin-bottom: 0;
}

a {
    color: var(--accent);
    text-decoration: none;
}

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

hr {
    height: 1px;
    margin: var(--s5) 0;
    border: 0;
    background: var(--border-subtle);
}

img {
    max-width: 100%;
    height: auto;
}

/* Component rules set display, which outranks the user agent's [hidden] and leaves anything the
   server or a script hides — an error banner, an empty state — showing as an empty box. */
[hidden] {
    display: none !important;
}

/* Focus is restyled, never removed. :focus-visible keeps the ring off mouse clicks while
   guaranteeing it for keyboard and switch access. */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }
}

/* ==========================================================================================
   3. App shell
   ========================================================================================== */

.skip-link {
    position: absolute;
    left: var(--s3);
    top: -3rem;
    z-index: 100;
    padding: var(--s2) var(--s4);
    border-radius: var(--radius-sm);
    background: var(--surface);
    box-shadow: var(--shadow);
    font-weight: 600;
    transition: top .15s ease;
}

.skip-link:focus {
    top: var(--s3);
    text-decoration: none;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 30;
    background: var(--surface);
    border-bottom: 1px solid var(--border-subtle);
}

.app-header__bar {
    display: flex;
    align-items: center;
    gap: var(--s4);
    width: 100%;
    max-width: var(--content-width);
    min-height: var(--header-height);
    margin: 0 auto;
    padding: var(--s2) var(--s4);
}

.brand {
    display: flex;
    align-items: center;
    gap: var(--s3);
    flex: 0 0 auto;
    color: var(--text);
    font-weight: 650;
    font-size: 1rem;
    letter-spacing: -.01em;
}

.brand:hover {
    color: var(--text);
    text-decoration: none;
}

.brand__logo {
    display: block;
    width: auto;
    max-width: 7.5rem;
    height: 2rem;
    object-fit: contain;
}

.brand__name {
    white-space: nowrap;
}

/* Shown in place of the wide logo by a clinic that has uploaded none. */
.brand__mark {
    display: block;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: var(--radius-sm);
}

/* Primary navigation. On a phone this collapses behind the toggle; the language switcher and
   account menu stay out of it deliberately, because someone who cannot read the current language
   must be able to change it without first finding a hamburger. */
.app-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--s1);
    flex: 1 1 auto;
    min-width: 0;
}

.app-nav__link {
    display: inline-flex;
    align-items: center;
    padding: var(--s2) var(--s3);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: .9375rem;
    font-weight: 500;
    white-space: nowrap;
}

.app-nav__link:hover {
    background: var(--ground);
    color: var(--text);
    text-decoration: none;
}

.app-nav__link[aria-current="page"] {
    background: var(--accent-tint);
    color: var(--accent-active);
    font-weight: 600;
}

/* A group of administrative pages: a dropdown in the bar, and an accordion inside the collapsed
   navigation on a phone, where a panel floating over a vertical drawer would be worse than one
   that simply pushes the rest down. Built on <details>, like the account menu, so it opens with a
   keyboard and works before any script loads. */
.nav-group {
    position: relative;
}

.nav-group__trigger {
    cursor: pointer;
    list-style: none;
}

.nav-group__trigger::-webkit-details-marker {
    display: none;
}

.nav-group[open] > .nav-group__trigger {
    background: var(--ground);
    color: var(--text);
}

.nav-group__caret {
    width: .875rem;
    height: .875rem;
    margin-left: var(--s1);
    color: var(--text-faint);
}

.nav-group[open] .nav-group__caret {
    transform: rotate(180deg);
}

.nav-group__panel {
    left: 0;
    right: auto;
    min-width: 12rem;
}

.app-header__actions {
    display: flex;
    align-items: center;
    gap: var(--s2);
    flex: 0 0 auto;
    margin-left: auto;
}

.nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
}

.nav-toggle:hover {
    background: var(--ground);
}

.nav-toggle svg {
    width: 1.25rem;
    height: 1.25rem;
}

.app-main {
    flex: 1 0 auto;
    width: 100%;
    padding: var(--s6) var(--s4) var(--s7);
}

.container {
    width: 100%;
    max-width: var(--content-width);
    margin: 0 auto;
}

.container--narrow {
    max-width: 32rem;
}

/* The two queue screens sit on a desk monitor and carry a six-column table next to a form; at the
   default reading width the last column fell off the card. */
.container--wide {
    max-width: 84rem;
}

.container--form {
    max-width: 46rem;
}

.app-footer {
    padding: var(--s4);
    border-top: 1px solid var(--border-subtle);
    background: var(--surface);
    color: var(--text-faint);
    font-size: .8125rem;
}

.app-footer .container {
    display: flex;
    justify-content: center;
}

/* ==========================================================================================
   4. Page furniture
   ========================================================================================== */

.page-head {
    display: flex;
    align-items: flex-start;
    gap: var(--s4);
    margin-bottom: var(--s5);
}

.page-head__text {
    min-width: 0;
}

.page-title {
    font-size: 1.5rem;
}

.page-sub {
    margin: var(--s1) 0 0;
    color: var(--text-muted);
    font-size: .9375rem;
}

.page-head__actions {
    display: flex;
    gap: var(--s2);
    margin-left: auto;
    flex: 0 0 auto;
}

/* ==========================================================================================
   5. Cards
   ========================================================================================== */

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

.card + .card {
    margin-top: var(--s5);
}

.card__head {
    display: flex;
    align-items: center;
    gap: var(--s3);
    padding: var(--s4) var(--s5);
    border-bottom: 1px solid var(--border-subtle);
}

.card__title {
    font-size: 1rem;
}

.card__sub {
    margin: var(--s1) 0 0;
    color: var(--text-muted);
    font-size: .875rem;
}

.card__head-actions {
    margin-left: auto;
}

.card__body {
    padding: var(--s5);
}

.card__body--flush {
    padding: 0;
}

/* A card whose whole content is a table: the table's own borders provide the separation. */
.card--table .card__body {
    padding: 0;
    overflow: hidden;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ==========================================================================================
   6. Forms
   ========================================================================================== */

.form-grid {
    display: grid;
    gap: var(--s4);
}

@media (min-width: 40rem) {
    .form-grid--2 {
        grid-template-columns: 1fr 1fr;
    }

    .form-grid__full {
        grid-column: 1 / -1;
    }
}

.field {
    display: flex;
    flex-direction: column;
    gap: var(--s1);
    min-width: 0;
}

.field > label,
.label {
    color: var(--text);
    font-size: .875rem;
    font-weight: 550;
}

.input,
.select,
textarea.input {
    width: 100%;
    min-height: 2.625rem;
    padding: var(--s2) var(--s3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.4;
    transition: border-color .12s ease, box-shadow .12s ease;
    appearance: none;
}

.input::placeholder {
    color: var(--text-faint);
}

.input:hover,
.select:hover {
    border-color: var(--border-strong);
}

.input:focus,
.select:focus,
textarea.input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
}

.input:disabled,
.select:disabled {
    background: var(--ground);
    color: var(--text-muted);
    cursor: not-allowed;
}

/* The chevron is drawn in CSS so the control needs no icon font and no extra request. */
.select {
    padding-right: 2.25rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23656d76' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--s3) center;
    background-size: 1rem;
}

.hint {
    color: var(--text-muted);
    font-size: .8125rem;
}

/* Read-only facts shown alongside editable fields — email and role on the account page. */
.readout {
    display: flex;
    flex-direction: column;
    gap: var(--s1);
}

.readout__value {
    display: flex;
    align-items: center;
    gap: var(--s2);
    min-height: 2.625rem;
    padding: var(--s2) var(--s3);
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    background: var(--raised);
    color: var(--text-muted);
    word-break: break-word;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: var(--s3);
    margin-top: var(--s5);
}

.form-actions--end {
    justify-content: flex-end;
}

/* Validation. The first three selectors are jQuery unobtrusive validation's own class names, and
   the fourth is the server-rendered summary; all four have to look like one system. */
.field-validation-error,
.text-danger {
    color: var(--danger);
    font-size: .8125rem;
}

.input.input-validation-error,
.select.input-validation-error {
    border-color: var(--danger);
}

.input.input-validation-error:focus,
.select.input-validation-error:focus {
    box-shadow: 0 0 0 3px rgba(180, 42, 60, .22);
}

.validation-summary-errors {
    margin-bottom: var(--s4);
    padding: var(--s3) var(--s4);
    border: 1px solid var(--danger-border);
    border-radius: var(--radius);
    background: var(--danger-tint);
    color: var(--danger);
    font-size: .9375rem;
}

.validation-summary-errors ul {
    margin: 0;
    padding-left: var(--s4);
}

.validation-summary-errors ul:only-child li:only-child {
    list-style: none;
    margin-left: calc(-1 * var(--s4));
}

.validation-summary-valid {
    display: none;
}

/* ==========================================================================================
   7. Buttons
   ========================================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--s2);
    min-height: 2.625rem;
    padding: var(--s2) var(--s4);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: .9375rem;
    font-weight: 550;
    line-height: 1.2;
    text-align: center;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color .12s ease, border-color .12s ease, color .12s ease;
    appearance: none;
}

.btn:hover {
    text-decoration: none;
}

.btn:disabled,
.btn[disabled] {
    opacity: .55;
    cursor: not-allowed;
}

.btn--primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--text-on-accent);
}

.btn--primary:hover:not(:disabled) {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: var(--text-on-accent);
}

.btn--primary:active:not(:disabled) {
    background: var(--accent-active);
}

.btn--secondary {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text);
}

.btn--secondary:hover:not(:disabled) {
    background: var(--ground);
    border-color: var(--border-strong);
    color: var(--text);
}

.btn--danger {
    background: var(--surface);
    border-color: var(--danger-border);
    color: var(--danger);
}

.btn--danger:hover:not(:disabled) {
    background: var(--danger);
    border-color: var(--danger);
    color: var(--text-on-accent);
}

/* Destructive and irreversible: filled from the start, so it never looks like the safe choice. */
.btn--danger-solid {
    background: var(--danger);
    border-color: var(--danger);
    color: var(--text-on-accent);
}

.btn--danger-solid:hover:not(:disabled) {
    background: var(--danger-hover);
    border-color: var(--danger-hover);
    color: var(--text-on-accent);
}

.btn--ghost {
    background: transparent;
    border-color: transparent;
    color: var(--text-muted);
}

.btn--ghost:hover:not(:disabled) {
    background: var(--ground);
    color: var(--text);
}

.btn--sm {
    min-height: 2rem;
    padding: var(--s1) var(--s3);
    font-size: .875rem;
}

.btn--block {
    width: 100%;
}

.btn--link {
    min-height: 0;
    padding: 0;
    border: 0;
    background: none;
    color: var(--accent);
    font-weight: 500;
}

.btn--link:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

/* Comfortable targets for fingers, without inflating controls for a mouse. */
@media (hover: none) and (pointer: coarse) {
    .btn,
    .input,
    .select,
    .nav-toggle,
    .seg__btn {
        min-height: 2.75rem;
    }
}

/* ==========================================================================================
   8. Tables
   ========================================================================================== */

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9375rem;
}

.table th,
.table td {
    padding: var(--s3) var(--s4);
    text-align: left;
    vertical-align: middle;
}

.table thead th {
    position: sticky;
    top: 0;
    background: var(--raised);
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-muted);
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.table tbody tr + tr {
    border-top: 1px solid var(--border-subtle);
}

.table tbody tr:hover {
    background: var(--raised);
}

.table td.num {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
}

.table td.actions,
.table th.actions {
    width: 1%;
    white-space: nowrap;
    text-align: right;
}

.row-actions {
    display: inline-flex;
    gap: var(--s2);
    justify-content: flex-end;
}

/* Phones: each row becomes a card, every cell labelled from its data-label attribute. The queue
   scripts set data-label on the cells they create, so live-inserted rows stack identically. */
@media (max-width: 47.99rem) {
    .table-stacked thead {
        display: none;
    }

    .table-stacked,
    .table-stacked tbody,
    .table-stacked tr,
    .table-stacked td {
        display: block;
        width: auto;
    }

    .table-stacked tbody tr {
        margin: var(--s4);
        border: 1px solid var(--border-subtle);
        border-radius: var(--radius);
        background: var(--surface);
        box-shadow: var(--shadow-sm);
    }

    .table-stacked tbody tr + tr {
        border-top: 1px solid var(--border-subtle);
    }

    .table-stacked td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: var(--s3);
        padding: var(--s3) var(--s4);
        border-bottom: 1px solid var(--border-subtle);
        text-align: right;
        word-break: break-word;
    }

    .table-stacked td:last-child {
        border-bottom: 0;
    }

    .table-stacked td::before {
        content: attr(data-label);
        flex: 0 0 40%;
        color: var(--text-muted);
        font-size: .75rem;
        font-weight: 600;
        letter-spacing: .04em;
        text-transform: uppercase;
        text-align: left;
    }

    /* Action cells carry an empty label: give the controls the row instead. */
    .table-stacked td[data-label=""]::before,
    .table-stacked td.actions::before {
        content: none;
    }

    .table-stacked td[data-label=""],
    .table-stacked td.actions {
        width: auto;
        text-align: left;
    }

    .table-stacked td[data-label=""] .row-actions,
    .table-stacked td.actions .row-actions {
        display: flex;
        width: 100%;
    }

    .table-stacked td[data-label=""] .row-actions > *,
    .table-stacked td.actions .row-actions > * {
        flex: 1 1 auto;
    }

    .table-stacked td[data-label=""] .btn,
    .table-stacked td.actions .btn {
        width: 100%;
    }
}

/* ==========================================================================================
   9. Queue rows
   ========================================================================================== */

/* A patient who has been called. Kept legible rather than loud: this list is read over a
   shoulder at a desk, not from across a room like the TV. */
.is-called {
    background: var(--accent-tint) !important;
}

.is-called td:first-child {
    box-shadow: inset 3px 0 0 var(--accent);
}

/* Flashes once when the row changes state, so a receptionist watching the list sees which line
   moved without having to re-read all of them. */
@keyframes row-flash {
    from {
        background-color: var(--accent-tint);
    }

    to {
        background-color: transparent;
    }
}

.is-flash {
    animation: row-flash 1.2s ease-out 2;
}

.queue-card {
    font-variant-numeric: tabular-nums;
}

/* ==========================================================================================
   10. Badges
   ========================================================================================== */

.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--s1);
    padding: .125rem var(--s2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-pill);
    background: var(--ground);
    color: var(--text-muted);
    font-size: .75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge--accent {
    border-color: transparent;
    background: var(--accent-tint);
    color: var(--accent-active);
}

.badge--success {
    border-color: var(--success-border);
    background: var(--success-tint);
    color: var(--success);
}

.badge--muted {
    background: var(--surface);
}

/* ==========================================================================================
   11. Alerts and empty states
   ========================================================================================== */

.alert {
    display: flex;
    align-items: flex-start;
    gap: var(--s3);
    margin-bottom: var(--s5);
    padding: var(--s3) var(--s4);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    background: var(--surface);
    font-size: .9375rem;
}

.alert__text {
    flex: 1 1 auto;
    min-width: 0;
}

.alert--success {
    border-color: var(--success-border);
    background: var(--success-tint);
    color: var(--success);
}

.alert--danger {
    border-color: var(--danger-border);
    background: var(--danger-tint);
    color: var(--danger);
}

.alert--warning {
    border-color: var(--warning-border);
    background: var(--warning-tint);
    color: var(--warning-text);
}

.alert--info {
    border-color: var(--info-border);
    background: var(--info-tint);
    color: var(--text);
}

.alert__close {
    flex: 0 0 auto;
    width: 1.75rem;
    height: 1.75rem;
    padding: 0;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: inherit;
    font-size: 1.125rem;
    line-height: 1;
    opacity: .6;
    cursor: pointer;
}

.alert__close:hover {
    opacity: 1;
    background: rgba(31, 35, 40, .06);
}

.empty {
    padding: var(--s7) var(--s5);
    text-align: center;
    color: var(--text-muted);
}

.empty__title {
    margin-bottom: var(--s1);
    color: var(--text);
    font-size: 1rem;
    font-weight: 600;
}

.empty__text {
    max-width: 34rem;
    margin: 0 auto;
    font-size: .9375rem;
}

/* ==========================================================================================
   12. Segmented control (language) and menus
   ========================================================================================== */

.seg {
    display: inline-flex;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--ground);
}

.seg__btn {
    min-height: 2rem;
    padding: 0 var(--s3);
    border: 0;
    border-radius: calc(var(--radius-sm) - 2px);
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: .8125rem;
    font-weight: 600;
    cursor: pointer;
}

.seg__btn:hover {
    color: var(--text);
}

.seg__btn[aria-current="true"] {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-sm);
}

/* Account menu. A <details> element rather than scripted show/hide: keyboard and screen-reader
   behaviour come for free, and it works before any JavaScript loads. */
.menu {
    position: relative;
}

.menu__trigger {
    display: inline-flex;
    align-items: center;
    gap: var(--s2);
    min-height: 2.375rem;
    padding: var(--s1) var(--s2) var(--s1) var(--s1);
    border: 1px solid transparent;
    border-radius: var(--radius-pill);
    color: var(--text);
    font-size: .875rem;
    font-weight: 550;
    cursor: pointer;
    list-style: none;
}

.menu__trigger::-webkit-details-marker {
    display: none;
}

.menu__trigger:hover {
    background: var(--ground);
}

.menu[open] > .menu__trigger {
    background: var(--ground);
    border-color: var(--border-subtle);
}

.avatar {
    display: grid;
    place-items: center;
    width: 1.875rem;
    height: 1.875rem;
    border-radius: 50%;
    background: var(--accent-tint);
    color: var(--accent-active);
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.menu__caret {
    width: .875rem;
    height: .875rem;
    color: var(--text-muted);
}

.menu__panel {
    position: absolute;
    right: 0;
    top: calc(100% + var(--s2));
    z-index: 40;
    min-width: 15rem;
    padding: var(--s2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}

.menu__meta {
    padding: var(--s2) var(--s3) var(--s3);
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: var(--s2);
}

.menu__name {
    font-weight: 600;
    word-break: break-word;
}

.menu__email {
    color: var(--text-muted);
    font-size: .8125rem;
    word-break: break-all;
}

.menu__item {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 2.25rem;
    padding: var(--s2) var(--s3);
    border: 0;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--text);
    font-family: inherit;
    font-size: .9375rem;
    text-align: left;
    cursor: pointer;
}

.menu__item:hover {
    background: var(--ground);
    color: var(--text);
    text-decoration: none;
}

/* Which page inside the group you are on. Without this the group's trigger said "you are
   somewhere in here" and the panel would not say where. */
.menu__item[aria-current="page"] {
    background: var(--accent-tint);
    color: var(--accent-active);
    font-weight: 600;
}

.menu__form {
    margin: 0;
}

/* ==========================================================================================
   12b. Confirmation dialog
   ========================================================================================== */

/* A native <dialog>: the browser supplies focus trapping, Escape and the backdrop. */
.modal {
    width: min(28rem, calc(100vw - 2rem));
    padding: 0;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    color: var(--text);
}

.modal::backdrop {
    background: rgba(31, 35, 40, .45);
}

.modal__panel {
    padding: var(--s5);
}

.modal__title {
    margin-bottom: var(--s2);
    font-size: 1.125rem;
}

.modal__text {
    margin-bottom: var(--s5);
    color: var(--text-muted);
}

.modal__actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--s2);
}

@media (max-width: 47.99rem) {
    .modal__actions {
        flex-direction: column-reverse;
    }

    .modal__actions .btn {
        width: 100%;
    }
}

/* ==========================================================================================
   12a. Sign-in and password pages
   ========================================================================================== */

/* The only pages an unauthenticated visitor sees. Centred rather than left-aligned in a grid
   column: there is one thing to do on them, so the page should say so. */
.auth {
    width: 100%;
    max-width: 25rem;
    margin: var(--s6) auto;
}

.auth__head {
    margin-bottom: var(--s5);
    text-align: center;
}

.auth__title {
    font-size: 1.375rem;
}

.auth__sub {
    margin: var(--s2) 0 0;
    color: var(--text-muted);
    font-size: .9375rem;
}

.auth__foot {
    margin-top: var(--s4);
    text-align: center;
    font-size: .875rem;
}

/* A single glyph standing in for an outcome — sent, changed, denied — on the pages that only
   report one. */
.auth__mark {
    display: grid;
    place-items: center;
    width: 3rem;
    height: 3rem;
    margin: 0 auto var(--s4);
    border-radius: 50%;
    background: var(--accent-tint);
    color: var(--accent);
}

.auth__mark svg {
    width: 1.5rem;
    height: 1.5rem;
}

.auth__mark--danger {
    background: var(--danger-tint);
    color: var(--danger);
}

/* Checkbox rows: "remember me" and anything like it. */
.check {
    display: flex;
    align-items: center;
    gap: var(--s2);
    font-size: .9375rem;
}

.check input[type="checkbox"] {
    width: 1.0625rem;
    height: 1.0625rem;
    margin: 0;
    accent-color: var(--accent);
    cursor: pointer;
}

.check label {
    margin: 0;
    cursor: pointer;
}

/* ==========================================================================================
   12c. Picture thumbnails (waiting-room advertisements)
   ========================================================================================== */

.thumb-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
    gap: var(--s4);
}

.thumb {
    display: flex;
    flex-direction: column;
    gap: var(--s2);
    margin: 0;
}

.thumb__img {
    width: 100%;
    aspect-ratio: 16 / 9;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    background: var(--ground);
    object-fit: cover;
}

.thumb__name {
    color: var(--text-muted);
    font-size: .75rem;
    word-break: break-all;
}

.thumb__actions {
    margin: 0;
}

/* The file input is a browser-drawn control; give it the same box as a text field without
   pretending its button is ours. */
input[type="file"].input {
    padding: var(--s2);
    line-height: 1.6;
    cursor: pointer;
}

/* Volume slider with its value beside it. */
.range-row {
    display: flex;
    align-items: center;
    gap: var(--s3);
}

.range {
    flex: 1 1 auto;
    min-width: 0;
    height: 1.25rem;
    padding: 0;
    border: 0;
    background: transparent;
    accent-color: var(--accent);
    cursor: pointer;
}

.range-value {
    flex: 0 0 3.5rem;
    color: var(--text-muted);
    font-size: .875rem;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.audio-preview {
    width: 100%;
    max-width: 22rem;
    height: 2.5rem;
}

/* Current logo or mark, shown above its file field on the clinic settings page. */
.brand-preview {
    display: flex;
    align-items: center;
    gap: var(--s3);
    padding: var(--s3);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    background: var(--raised);
}

.brand-preview img {
    max-width: 12rem;
    max-height: 3rem;
    object-fit: contain;
}

.brand-preview__mark {
    width: 2.5rem;
    height: 2.5rem;
    max-width: none;
    max-height: none;
}

/* ==========================================================================================
   13. Utilities
   ========================================================================================== */

.stack > * + * {
    margin-top: var(--s4);
}

.stack--tight > * + * {
    margin-top: var(--s2);
}

.stack--loose > * + * {
    margin-top: var(--s5);
}

.cluster {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--s2);
}

.split {
    display: grid;
    gap: var(--s5);
    align-items: start;
}

@media (min-width: 62rem) {
    .split--form-list {
        grid-template-columns: minmax(0, 22rem) minmax(0, 1fr);
    }

    .split--charts {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }
}

/* ---------------------------------------------------------------------------------------------
   Statistics
   --------------------------------------------------------------------------------------------- */

/* Period switch. Links rather than a control, so the choice lives in the address and a clinic
   can bookmark the view it opens every morning. */
.range {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--s2);
    margin-bottom: var(--s5);
}

.range__option {
    padding: var(--s2) var(--s3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    font-size: .9375rem;
}

.range__option:hover { border-color: var(--border-strong); }

.range__option.is-current {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--text-on-accent);
}

.range__dates {
    margin-left: auto;
    color: var(--text-muted);
    font-size: .9375rem;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
    gap: var(--s4);
    margin-bottom: var(--s5);
}

/* Four figures, so they are cards rather than a table: each one is meant to be read on its own
   and none of them is a row in a series. */
.stat {
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    padding: var(--s4);
}

.stat__label {
    margin: 0 0 var(--s1);
    font-size: .8125rem;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.stat__value {
    margin: 0;
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.stat__note {
    margin: var(--s1) 0 0;
    color: var(--text-faint);
    font-size: .875rem;
}

/* Only the figure that asks for attention gets colour; the rest stay plain so that it stands out
   when it appears. */
.stat--warn { border-color: var(--warning-border); background: var(--warning-tint); }
.stat--warn .stat__value { color: var(--warning-text); }

/* Bars in CSS rather than a charting library: two dozen values do not justify shipping one, and
   the page has to work with nothing loaded from anywhere else. */
.chart {
    display: flex;
    align-items: flex-end;
    gap: var(--s2);
    height: 11rem;
    margin-top: var(--s3);
    overflow-x: auto;
    /* Room above the tallest bar for its own figure. Without it the number is clipped: a box
       scrolling on one axis clips the other, whatever overflow-y says. */
    padding: 1.6rem 0 var(--s1);
}

.chart__slot {
    flex: 1 0 1.75rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    height: 100%;
    gap: var(--s1);
    min-width: 1.75rem;
}

.chart__bar {
    /* A floor of two pixels: an hour with one patient must not be indistinguishable from an hour
       with none. */
    height: max(var(--h), 2px);
    width: 100%;
    background: var(--accent);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    position: relative;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.chart__value {
    position: absolute;
    top: -1.35rem;
    font-size: .8125rem;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
}

.chart__tick {
    font-size: .75rem;
    color: var(--text-faint);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.muted {
    color: var(--text-muted);
}

.small {
    font-size: .875rem;
}

.mono {
    font-family: var(--font-mono);
    font-size: .9375rem;
}

.nowrap {
    white-space: nowrap;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ==========================================================================================
   14. Narrow screens
   ========================================================================================== */

@media (max-width: 61.99rem) {
    .app-header__bar {
        flex-wrap: wrap;
        gap: var(--s2);
    }

    .nav-toggle {
        display: inline-flex;
        order: 3;
    }

    .app-header__actions {
        order: 2;
    }

    /* Collapsed by default, revealed by the toggle. Kept in the DOM either way so the links stay
       reachable when scripting is unavailable — see site.js, which only opens what the
       :target-less markup already renders. */
    .app-nav {
        display: none;
        order: 4;
        flex: 1 0 100%;
        flex-direction: column;
        align-items: stretch;
        gap: var(--s1);
        padding: var(--s2) 0 var(--s3);
        border-top: 1px solid var(--border-subtle);
    }

    .app-nav.is-open {
        display: flex;
    }

    .app-nav__link {
        padding: var(--s3);
        font-size: 1rem;
    }

    /* In the drawer a group is not a dropdown but a labelled section, always visible: the drawer
       is already a vertical list, and hiding four links behind another tap only adds one.
       Both hiding mechanisms browsers use for a closed <details> are overridden explicitly rather
       than left to whichever one the engine happens to implement. */
    .nav-group,
    .nav-group__panel {
        width: 100%;
    }

    .nav-group__panel {
        position: static;
        min-width: 0;
        margin: 0 0 var(--s2) var(--s3);
        padding: 0;
        border: 0;
        border-left: 2px solid var(--border-subtle);
        border-radius: 0;
        box-shadow: none;
        background: transparent;
    }

    .nav-group__panel .menu__item {
        min-height: 2.75rem;
        font-size: 1rem;
    }

    /* Reads as a section heading, but stays a control: site.js opens these groups here, and if
       it never runs the heading is the only way in. It used to have pointer-events: none, which
       on a phone left the links behind it unreachable altogether. */
    .nav-group__trigger {
        padding-bottom: var(--s1);
        color: var(--text-faint);
        font-size: .75rem;
        font-weight: 600;
        letter-spacing: .04em;
        text-transform: uppercase;
    }

    .nav-group__trigger:hover {
        background: transparent;
    }

    .nav-group[open] > .nav-group__trigger {
        background: transparent;
    }

    .nav-group__caret {
        display: none;
    }

    .app-main {
        padding: var(--s5) var(--s3) var(--s6);
    }

    .page-head {
        flex-direction: column;
        gap: var(--s3);
    }

    .page-head__actions {
        margin-left: 0;
        width: 100%;
    }

    .page-head__actions .btn {
        flex: 1 1 auto;
    }

    .card__head,
    .card__body {
        padding: var(--s4);
    }

    .form-actions .btn {
        flex: 1 1 auto;
    }
}

/* No JavaScript: the toggle cannot work, so show the navigation rather than hiding links behind a
   dead control. */
.no-js .nav-toggle {
    display: none !important;
}

.no-js .app-nav {
    display: flex;
}

/* Which build is running. Quiet on purpose: needed when somebody asks whether an update landed,
   invisible the rest of the time. */
.app-footer__version {
    margin-left: var(--s2);
    color: var(--text-faint);
    font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------------------------------------
   Help: a role's steps, and what changed
   --------------------------------------------------------------------------------------------- */

.steps {
    list-style: none;
    margin: 0 0 var(--s5);
    padding: 0;
    display: grid;
    gap: var(--s3);
}

/* Numbered because the steps are a sequence — reception really does register before anyone can
   be called. Where an order is not real, numbering it is a lie about the content. */
.step {
    display: flex;
    gap: var(--s3);
    align-items: flex-start;
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    padding: var(--s4);
}

.step__number {
    flex: 0 0 auto;
    width: 1.85rem;
    height: 1.85rem;
    border-radius: 50%;
    background: var(--accent-tint);
    color: var(--accent-active);
    font-weight: 700;
    font-size: .9375rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-variant-numeric: tabular-nums;
}

.step__title { margin: .1rem 0 var(--s1); font-size: 1.0625rem; }

.step__body { margin: 0; color: var(--text-muted); line-height: 1.5; }

.step__link { display: inline-block; margin-top: var(--s2); font-size: .9375rem; }

.card--news { border-color: var(--accent); }

.news { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s3); }

.news__title { margin: 0 0 .15rem; font-weight: 600; }

.news__body { margin: 0; color: var(--text-muted); line-height: 1.5; }

.news__version {
    margin-left: var(--s2);
    color: var(--text-faint);
    font-size: .8125rem;
    font-weight: 400;
    font-variant-numeric: tabular-nums;
}

/* The dot next to Help. Small enough to ignore, present enough to notice once. */
.app-nav__new {
    display: inline-block;
    width: .45rem;
    height: .45rem;
    margin-left: .35rem;
    border-radius: 50%;
    background: var(--accent);
    vertical-align: .35em;
}
