h1:focus {
    outline: none;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.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;
}
.tenant-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid #dee2e6;
}

    .tenant-bar .tenant-bar-name {
        font-weight: 600;
        margin-right: auto;
    }

.tenant-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 28rem;
    margin-bottom: 2rem;
}

    .tenant-list .tenant-option {
        display: flex;
        justify-content: space-between;
        width: 100%;
    }

.tenant-create,
.invite-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 28rem;
}

/* ---- Shell ---- */

:root {
    --shell-border: #d0d7de;
    --shell-muted: #57606a;
    --shell-surface: #f6f8fa;
    --allergy-bg: #fff4e5;
    --allergy-border: #b35900;
    --danger-text: #a40e26;
    --row-selected: #cfe2ff;
}

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    background: #fff;
}

.app-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.app-header {
    border-bottom: 1px solid var(--shell-border);
    background: var(--shell-surface);
}

.app-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.app-header-top .tenant-bar {
    border-bottom: none;
    padding: 0 0.75rem;
}

.app-menu.e-menu-wrapper,
.app-menu.e-menu-wrapper ul {
    background: transparent;
}

.app-menu-shortcut {
    float: right;
    margin-left: 2rem;
    color: var(--shell-muted);
}

.app-toolbar.e-toolbar {
    border-left: none;
    border-right: none;
    min-height: 0;
}

.workspace-tabs {
    padding: 0 0.5rem;
}

    .workspace-tabs .e-content {
        display: none;
    }

    .workspace-tabs-inactive .e-tab-header .e-toolbar-item.e-active .e-tab-text {
        font-weight: normal;
    }

.app-main {
    flex: 1;
    overflow: auto;
    padding: 0.75rem 1rem;
}

.static-page {
    padding: 1rem;
}

.status-bar {
    display: flex;
    gap: 1.5rem;
    padding: 0.25rem 1rem;
    border-top: 1px solid var(--shell-border);
    background: var(--shell-surface);
    color: var(--shell-muted);
    font-size: 12px;
}

    .status-bar .status-bar-time {
        margin-left: auto;
    }

.page-header {
    display: flex;
    align-items: center;
    gap: 1rem;
}

    .page-header h1 {
        margin: 0.25rem 0 0.75rem;
        font-size: 1.4rem;
    }

.home-actions {
    display: flex;
    gap: 0.5rem;
}

kbd {
    border: 1px solid var(--shell-border);
    border-radius: 3px;
    padding: 0 0.3rem;
    background: #fff;
    font-size: 12px;
}

.dense-grid.e-grid .e-rowcell,
.dense-grid.e-grid .e-headercell {
    padding-top: 2px;
    padding-bottom: 2px;
}

/* Status is always in words; colour only reinforces it (RULE-009). */
.status-badge {
    display: inline-block;
    margin-left: 0.4rem;
    padding: 0 0.4rem;
    border: 1px solid currentColor;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.status-inactive { color: var(--shell-muted); }
.status-deceased { color: #24292f; background: #eaeef2; }
.status-interpreter { color: #0550ae; }

/* ---- Patient finder ---- */

.patient-finder {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.patient-finder-criteria {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1.25rem;
}

    .patient-finder-search .e-input-group {
        width: 320px;
    }

.patient-finder-modes,
.patient-finder-filters {
    display: flex;
    gap: 1rem;
}

.patient-finder-status {
    color: var(--shell-muted);
    font-size: 12px;
    min-height: 1em;
}

.patient-finder-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

/* ---- Command search ---- */

.command-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

    .command-item .command-item-label {
        flex: 1;
    }

    .command-item .command-item-menu {
        color: var(--shell-muted);
        font-size: 12px;
    }

.command-item-unavailable .command-item-label {
    color: var(--shell-muted);
}

/* ---- Patient workspace ---- */

.patient-workspace {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    height: 100%;
}

.patient-banner {
    display: flex;
    gap: 1rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--shell-border);
    border-left: 4px solid #0969da;
    background: #fff;
}

.patient-banner-flagged {
    border-left-color: var(--shell-muted);
}

.patient-banner-identity {
    flex: 1;
    min-width: 0;
}

.patient-banner-name {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

    .patient-banner-name h1 {
        margin: 0;
        font-size: 1.25rem;
    }

.patient-banner-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 0.15rem 1.25rem;
    margin: 0.35rem 0 0;
}

    .patient-banner-facts div {
        display: flex;
        gap: 0.35rem;
    }

    .patient-banner-facts dt {
        color: var(--shell-muted);
    }

    .patient-banner-facts dd {
        margin: 0;
    }

.patient-banner-comment {
    margin-top: 0.25rem;
    color: var(--shell-muted);
}

.patient-banner-allergies {
    flex: 0 0 340px;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--shell-border);
}

    .patient-banner-allergies h2 {
        margin: 0 0 0.25rem;
        font-size: 0.85rem;
        text-transform: uppercase;
        color: var(--shell-muted);
    }

.allergies-unknown,
.allergies-present {
    border-color: var(--allergy-border);
    background: var(--allergy-bg);
}

.allergy-state {
    margin: 0;
    font-weight: 600;
}

.allergy-state-unknown {
    color: var(--allergy-border);
}

.allergy-table {
    width: 100%;
    border-collapse: collapse;
}

    .allergy-table th {
        text-align: left;
        font-weight: 600;
        font-size: 12px;
        color: var(--shell-muted);
    }

    .allergy-table td,
    .allergy-table th {
        padding: 1px 4px;
    }

.allergy-severe td {
    color: var(--danger-text);
    font-weight: 600;
}

.patient-workspace-body {
    display: flex;
    gap: 0.75rem;
    flex: 1;
    min-height: 0;
}

.patient-sections {
    flex: 0 0 220px;
    border: 1px solid var(--shell-border);
    overflow: auto;
}

.section-node-unavailable {
    color: var(--shell-muted);
}

.e-treeview .e-list-item.e-active .section-node,
.e-treeview .e-list-item.e-hover .section-node {
    color: inherit;
}

.patient-section-content {
    flex: 1;
    min-width: 0;
    overflow: auto;
}

    .patient-section-content > h2 {
        margin: 0 0 0.5rem;
        font-size: 1.1rem;
    }

.section-placeholder {
    padding: 1rem;
    border: 1px dashed var(--shell-border);
    color: var(--shell-muted);
}

.details-groups {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 0.75rem;
}

    .details-groups section {
        border: 1px solid var(--shell-border);
        padding: 0.5rem 0.75rem;
    }

    .details-groups h3 {
        margin: 0 0 0.35rem;
        font-size: 0.95rem;
    }

    .details-groups dl {
        display: grid;
        grid-template-columns: 9.5rem 1fr;
        gap: 0.15rem 0.5rem;
        margin: 0;
    }

    .details-groups dt {
        color: var(--shell-muted);
    }

    .details-groups dd {
        margin: 0;
    }

@media (max-width: 900px) {
    .patient-banner,
    .patient-workspace-body {
        flex-direction: column;
    }

    .patient-banner-allergies,
    .patient-sections {
        flex-basis: auto;
    }
}

/* ---- Appointment book and waiting room ---- */

.book-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}

.book-toolbar-spacer {
    flex: 1;
}

.book-selection {
    min-height: 1.4em;
    margin-bottom: 0.3rem;
    color: var(--shell-muted);
}

.appointment-book .e-appointment {
    border-radius: 2px;
}

.appt-card {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
    font-size: 12px;
    overflow: hidden;
}

    .appt-card .appt-name {
        font-weight: 600;
    }

    .appt-card .appt-meta,
    .appt-card .appt-status-text {
        font-size: 11px;
    }

    .appt-card .appt-status-text {
        text-transform: uppercase;
        letter-spacing: 0.02em;
    }

.appt-unavailable {
    font-size: 11px;
    color: #57606a;
}

/* Status colours (design tokens); every status is also written in text (RULE-009). */
.appointment-book.e-schedule .e-appointment.appt-status-booked, .legend-item.appt-status-booked { background: var(--ck-info-soft); color: #1e3a8a; border-color: #93b4f5; }
.appointment-book.e-schedule .e-appointment.appt-status-waiting, .legend-item.appt-status-waiting { background: var(--ck-warning-soft); color: var(--ck-warning-text); border-color: #e9b56d; }
.appointment-book.e-schedule .e-appointment.appt-status-withdoctor, .legend-item.appt-status-withdoctor { background: #cfe0fc; color: #172554; border-color: var(--ck-info); }
.appointment-book.e-schedule .e-appointment.appt-status-atbilling, .legend-item.appt-status-atbilling { background: var(--ck-success-soft); color: var(--ck-success-text); border-color: #7fcf97; }
.appointment-book.e-schedule .e-appointment.appt-status-completed, .legend-item.appt-status-completed { background: #eef1f3; color: var(--ck-ink); border-color: #aab4bb; }
.appointment-book.e-schedule .e-appointment.appt-status-didnotattend, .legend-item.appt-status-didnotattend { background: var(--ck-critical-soft); color: var(--ck-critical-text); border-color: #f0a0a0; }
.appointment-book.e-schedule .e-appointment.appt-urgent { box-shadow: inset 4px 0 0 var(--ck-critical); }

.appointment-book .e-appointment .e-appointment-details {
    color: inherit;
}

.book-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.4rem;
}

.legend-item {
    padding: 0 0.5rem;
    border: 1px solid var(--shell-border);
    border-radius: 3px;
    font-size: 12px;
}

.legend-urgent { border-left: 4px solid #cf222e; }
.legend-unavailable { background: #f6f8fa; color: var(--shell-muted); }
.legend-on-the-day,
.e-schedule.appointment-book .e-vertical-view .e-work-cells.cell-on-the-day,
.e-schedule.appointment-book .e-vertical-view .e-work-cells.e-work-hours.cell-on-the-day { background: #fff8c5; }

.status-urgent { color: #cf222e; }
.status-done { color: #1a7f37; }

.waiting-band { padding: 0 0.4rem; border-radius: 3px; border: 1px solid transparent; }
.waiting-band-short { background: #dafbe1; color: #044f1e; border-color: #2da44e; }
.waiting-band-medium { background: #fff8c5; color: #4d2d00; border-color: #d4a72c; }
.waiting-band-long { background: #ffebe9; color: #82071e; border-color: #ff8182; }

.waiting-sort {
    display: flex;
    gap: 0.75rem;
}

.booking-slot {
    display: flex;
    gap: 1.25rem;
    padding: 0.4rem 0.6rem;
    margin-bottom: 0.5rem;
    background: var(--shell-surface);
    border: 1px solid var(--shell-border);
}

.booking-patient {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.4rem 0;
}

.booking-fields {
    display: grid;
    grid-template-columns: 220px 140px 1fr auto auto;
    align-items: end;
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.booking-booked-by {
    color: var(--shell-muted);
    white-space: nowrap;
}

/* ---- Consultation ---- */

.consult-start {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 720px;
}

.consult-start-fields,
.consult-header,
.consult-fields,
.past-visits-toolbar,
.visit-preview-header,
.finalise-search,
.finalise-options {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

.consult-header {
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--shell-border);
    margin-bottom: 0.5rem;
}

.consult-timer {
    color: var(--shell-muted);
}

.consult-fields {
    margin: 0.4rem 0;
}

    .consult-fields > .e-input-group,
    .consult-fields > .e-float-input,
    .consult-fields > .e-control-wrapper {
        flex: 1 1 220px;
    }

.consult-note textarea {
    min-height: 280px;
    font-family: Consolas, "Cascadia Mono", Menlo, monospace;
    font-size: 13px;
    line-height: 1.45;
}

/* Save state is always in words (UX-009). */
.save-state {
    padding: 0 0.5rem;
    border-radius: 3px;
    border: 1px solid var(--shell-border);
    font-size: 12px;
}

.save-state-saved { color: #044f1e; border-color: #2da44e; }
.save-state-unsaved, .save-state-saving { color: #4d2d00; border-color: #d4a72c; background: #fff8c5; }
.save-state-failed, .save-state-conflict, .save-state-noteditable { color: #82071e; border-color: #ff8182; background: #ffebe9; }

.status-draft { color: #9a6700; }

.past-visits-toolbar {
    margin-bottom: 0.4rem;
}

.visit-preview {
    margin-top: 0.75rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--shell-border);
}

.visit-preview-empty {
    color: var(--shell-muted);
}

.note-text {
    white-space: pre-wrap;
    font-family: Consolas, "Cascadia Mono", Menlo, monospace;
    font-size: 13px;
    margin: 0.5rem 0;
}

.amendment {
    border-left: 3px solid #d4a72c;
    padding-left: 0.6rem;
    margin-top: 0.6rem;
}

.amendment-header {
    color: var(--shell-muted);
    font-size: 12px;
}

.finalise-items {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

    .finalise-items h3 {
        margin: 0 0 0.4rem;
        font-size: 0.95rem;
    }

.finalise-search {
    margin-bottom: 0.4rem;
}

.finalise-fields {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-top: 0.75rem;
}

/* Badges inside dense grid rows: the grid's compact line-height otherwise draws the border through the text. */
.e-grid .e-rowcell .status-badge,
.e-grid .e-rowcell .waiting-band {
    line-height: 16px;
    vertical-align: middle;
}

/* ---- Billing ---- */

.account-fields {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 0.6rem 0.75rem;
    margin: 0.5rem 0;
}

.account-lines-toolbar {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin: 0.5rem 0 0.35rem;
}

.account-total {
    text-align: right;
    margin: 0.35rem 0;
    font-size: 1.05rem;
}

.billing-warnings {
    margin: 0.25rem 0 0;
    padding-left: 1.2rem;
}

.payment-heading {
    margin: 0.6rem 0 0.35rem;
    font-size: 0.95rem;
}

.payment-tenders {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: end;
    margin-bottom: 0.5rem;
}

    .payment-tenders > .e-input-group,
    .payment-tenders > .e-float-input,
    .payment-tenders > .e-control-wrapper {
        width: 150px;
    }

.payment-change {
    padding-bottom: 0.4rem;
}

.payment-summary {
    display: flex;
    gap: 1.5rem;
    margin-top: 0.4rem;
}

.payment-mismatch {
    color: var(--danger-text);
}

.billing-outstanding {
    font-size: 1.05rem;
}

.billing-actions {
    margin-top: 0.35rem;
}

.invoice-paid { color: #044f1e; }
.invoice-held { color: #9a6700; }
.invoice-cancelled { color: var(--shell-muted); text-decoration: line-through; }

.member-functions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* ---- Setup ---- */

.setup-form {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.setup-hint {
    color: var(--shell-muted);
    max-width: 900px;
}

/* ---- Prescribing and results ---- */

.rx-allergies {
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--shell-border);
    margin-bottom: 0.5rem;
}

.rx-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    margin: 0.4rem 0;
}

.setup-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 0.75rem;
    max-width: 1000px;
}

.setup-cards h3 {
    margin: 0 0 0.3rem;
}

.rx-medicine,
.rx-listing {
    border: 1px solid var(--shell-border);
    padding: 0.4rem 0.6rem;
    margin: 0.4rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.rx-listing-rpbs {
    border-left: 4px solid #6a4c93;
}

.rx-type {
    display: inline-block;
    font-size: 0.75em;
    padding: 0 0.35rem;
    border-radius: 3px;
    margin-right: 0.3rem;
    background: #e8eef7;
    color: #234;
}

.rx-type-tpp {
    background: #f3eadb;
    color: #4a3410;
}

.rx-restriction {
    white-space: pre-line;
    font-size: 0.9em;
    max-height: 9rem;
    overflow-y: auto;
}

.rx-caution {
    color: #8a4b00;
}

.rx-note {
    color: var(--shell-muted);
}

.inbox-tabs {
    display: flex;
    gap: 0.4rem;
}

.inbox-layout {
    display: grid;
    grid-template-columns: minmax(380px, 40%) 1fr;
    gap: 0.75rem;
}

.inbox-detail {
    overflow: auto;
    max-height: calc(100vh - 290px);
    border: 1px solid var(--shell-border);
    padding: 0.5rem 0.75rem;
}

.inbox-current {
    font-weight: 700;
}

.result-preview-header,
.result-states {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
}

.result-values {
    border-collapse: collapse;
    margin: 0.5rem 0;
}

    .result-values th,
    .result-values td {
        padding: 2px 10px 2px 0;
        text-align: left;
    }

    .result-values th {
        color: var(--shell-muted);
        font-weight: 600;
        font-size: 12px;
    }

.result-value-abnormal td {
    color: var(--danger-text);
    font-weight: 600;
}

.review-panel {
    display: grid;
    grid-template-columns: 200px 210px 1fr auto;
    gap: 0.75rem;
    align-items: end;
    margin: 0.6rem 0;
}

.contact-attempts {
    margin: 0.3rem 0;
    padding-left: 1.2rem;
    color: var(--shell-muted);
}

/* ---- Clinical record: observations, family/social history ---- */

.obs-layout {
    display: grid;
    grid-template-columns: minmax(520px, 1fr) minmax(320px, 40%);
    gap: 0.75rem;
}

.obs-chart {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.obs-bmi {
    font-size: 0.9em;
    margin-right: 0.75rem;
}

.obs-error {
    text-decoration: line-through;
    color: var(--shell-muted);
}

.obs-entry {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 0.35rem 0.75rem;
    align-items: center;
    margin: 0.4rem 0 0.6rem;
}

.family-social {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
    gap: 1rem;
}

.family-social h3 {
    margin: 0 0 0.4rem;
}

/* ---- Paper scripts (PBS prescription form, A4) ---- */

.print-layout {
    background: #e9ecef;
    min-height: 100vh;
    padding: 1rem;
}

.script-controls {
    max-width: 210mm;
    margin: 0 auto 1rem;
    background: #fff;
    padding: 0.75rem 1rem;
    border: 1px solid #ccc;
}

.script-controls h1 {
    font-size: 1.2rem;
    margin: 0 0 0.5rem;
}

.script-sheet {
    position: relative;
    width: 210mm;
    height: 297mm;
    margin: 0 auto;
    background: #fff;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    color: #000;
}

.script-offset,
.script-copy {
    position: absolute;
    top: 0;
    left: 0;
}

.script-offset {
    width: 210mm;
    height: 297mm;
}

.script-copy {
    width: 105mm;
    height: 297mm;
}

.script-field,
.script-mark,
.script-mark-small,
.script-item,
.script-guide,
.script-guide-label {
    position: absolute;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 9pt;
    line-height: 3.6mm;
    white-space: nowrap;
}

.script-mark {
    font-size: 13pt;
    font-weight: bold;
}

.script-mark-small {
    font-size: 10pt;
    font-weight: bold;
}

.script-bold {
    font-weight: bold;
}

.script-item {
    width: 78mm;
    white-space: normal;
}

.script-medicine {
    font-weight: bold;
}

.script-qty {
    display: flex;
    gap: 10mm;
}

.script-guide,
.script-guide-label {
    display: none;
    color: #7a9fb5;
}

.script-guide {
    border: 0.2mm dashed #7a9fb5;
}

.script-guide-label {
    font-size: 6.5pt;
}

.show-guides .script-guide,
.show-guides .script-guide-label {
    display: block;
}

@media print {
    @page {
        size: A4;
        margin: 0;
    }

    html,
    body {
        margin: 0;
        padding: 0;
        background: #fff;
    }

    .no-print,
    #components-reconnect-modal {
        display: none !important;
    }

    .print-layout {
        padding: 0;
        background: #fff;
    }

    .script-sheet {
        margin: 0;
        box-shadow: none;
    }

    /* Outlines are for the screen unless this is an alignment test. */
    .script-sheet:not(.print-guides) .script-guide,
    .script-sheet:not(.print-guides) .script-guide-label {
        display: none !important;
    }
}

/* ---- Admin portal ---- */

.admin-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.admin-header {
    border-bottom: 2px solid #6a4c93;
    background: #f7f4fb;
}

.admin-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.25rem 0.75rem;
}

.admin-title {
    font-weight: 600;
    color: #4a2f73;
}

.admin-main {
    padding: 0.75rem 1rem;
}

.admin-columns {
    display: grid;
    grid-template-columns: minmax(380px, 34%) 1fr;
    gap: 1rem;
}

.admin-columns h3 {
    margin: 0 0 0.4rem;
}

/* Healthcare Identifiers */
.form-row {
    display: flex;
    gap: 0.5rem;
}

    .form-row > * {
        flex: 1 1 0;
        min-width: 0;
    }

.mono {
    font-family: Consolas, "Courier New", monospace;
}

.ihi-panel .book-toolbar {
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

.ihi-due {
    color: var(--shell-warning, #b45309);
}

.ihi-outcome {
    margin-top: 0.5rem;
}

.ihi-diff {
    border-collapse: collapse;
    margin: 0.25rem 0;
    font-size: 0.9rem;
}

    .ihi-diff th, .ihi-diff td {
        border: 1px solid var(--shell-border);
        padding: 0.15rem 0.4rem;
        text-align: left;
    }

.ihi-messages {
    margin: 0.25rem 0 0;
    padding-left: 1.1rem;
    font-size: 0.9rem;
}

.hi-diag dl, dl.hi-diag {
    display: grid;
    grid-template-columns: 12rem 1fr;
    gap: 0.15rem 0.5rem;
}

    .hi-diag dt, dl.hi-diag dt {
        color: var(--shell-muted);
    }

    .hi-diag dd, dl.hi-diag dd {
        margin: 0;
    }

/* Correspondence and clinical images */
.doc-toolbar {
    flex-wrap: wrap;
    align-items: center;
}

.doc-spacer {
    flex: 1 1 auto;
}

.doc-preview-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
    margin-bottom: 0.35rem;
}

.doc-muted {
    color: var(--shell-muted);
    font-size: 0.9rem;
}

.doc-details, .doc-note {
    margin: 0.25rem 0;
}

.doc-frame {
    width: 100%;
    height: 420px;
    border: 1px solid var(--shell-border);
    background: #fff;
}

.doc-frame-tall {
    height: calc(90vh - 320px);
}

.doc-image {
    max-width: 100%;
    max-height: 560px;
    border: 1px solid var(--shell-border);
}

.doc-text {
    white-space: pre-wrap;
    max-height: 420px;
    overflow: auto;
    border: 1px solid var(--shell-border);
    padding: 0.5rem;
}

.template-editor {
    display: flex;
    gap: 0.75rem;
}

    .template-editor > :first-child {
        flex: 1 1 auto;
        min-width: 0;
    }

.template-fields {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    width: 210px;
    flex: 0 0 auto;
    max-height: calc(90vh - 320px);
    overflow: auto;
}

    .template-fields .e-btn {
        justify-content: flex-start;
        text-transform: none;
        font-family: Consolas, "Courier New", monospace;
    }

.letter-sheet {
    width: 210mm;
    min-height: 297mm;
    margin: 1rem auto;
    padding: 20mm;
    box-sizing: border-box;
    background: #fff;
    color: #000;
    font-family: Arial, sans-serif;
    font-size: 11pt;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.25);
    position: relative;
}

    .letter-sheet.letter-draft::before {
        content: "DRAFT";
        position: absolute;
        top: 40%;
        left: 0;
        right: 0;
        text-align: center;
        font-size: 96pt;
        color: rgba(0, 0, 0, 0.08);
        transform: rotate(-30deg);
        pointer-events: none;
    }

@media print {
    .letter-sheet {
        margin: 0;
        box-shadow: none;
        width: auto;
        min-height: 0;
        padding: 0;
    }
}

.combination-items { margin: 0.5rem 0 0.5rem 1.25rem; padding: 0; }
.combination-items li { margin-bottom: 0.4rem; }
.combination-setup { display: grid; grid-template-columns: minmax(260px, 1fr) 2fr; gap: 1rem; }
.combination-detail h3 { margin: 0 0 0.25rem; font-size: 1rem; }
@media (max-width: 760px) { .combination-setup { grid-template-columns: 1fr; } }
