/*
 * Clinic Management System - application styles.
 *
 * This is the design system for every screen behind the login. Bootstrap 5.3
 * still does the layout work - the grid, the utilities, the dropdown and
 * modal behaviour - but its skin is replaced here so that the hundred-odd
 * pages in this app look like one product rather than a default theme with
 * a designed sidebar bolted on.
 *
 * The file is in four parts:
 *
 *   1. Tokens - the indigo/violet brand, the neutrals, and the Bootstrap
 *      root variables they feed.
 *   2. Base type.
 *   3. Bootstrap's components, retinted one by one.
 *   4. This app's own furniture - sidebar, top bar, helpers.
 *
 * Bootstrap 5.3 bakes its colours into each component's own scoped custom
 * properties (--bs-btn-bg and so on) rather than reading one shared value,
 * so a component has to be overridden explicitly to change. The root
 * variables in part 1 are the exceptions that do cascade, and they are set
 * first so the per-component blocks below stay as short as possible.
 *
 * login.css carries the same tokens for the sign-in screen, which is the
 * only page that does not load this file.
 *
 * The fonts are self-hosted from /assets/fonts: the Content-Security-Policy
 * only allows this site's own origin, and a clinic whose internet is down
 * still has to be able to work.
 */

@font-face {
    font-family: 'Schibsted Grotesk';
    src: url('../fonts/schibsted-grotesk-latin.woff2') format('woff2');
    font-weight: 400 800;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'IBM Plex Mono';
    src: url('../fonts/ibm-plex-mono-400-latin.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'IBM Plex Mono';
    src: url('../fonts/ibm-plex-mono-500-latin.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

/* ================================================================== */
/* 1. Tokens                                                           */
/* ================================================================== */

:root {
    /* The brand. --brand-grad is the mark on the sidebar, the primary
       button and the active menu row - the three places the gradient is
       allowed to appear. */
    --brand: #6366f1;
    --brand-strong: #4f46e5;
    --brand-deep: #4338ca;
    --brand-2: #8b5cf6;
    --brand-soft: #a5b4fc;
    --brand-tint: #eef2ff;
    --brand-grad: linear-gradient(135deg, #6366f1, #8b5cf6);

    /* Text, strongest to faintest. All carry a little of the brand's violet
       so grey text never looks cold next to indigo. */
    --ink: #1e1b2e;
    --body: #5c5972;
    --label: #4c4960;
    --muted: #9b98ac;
    --faint: #b4b1c2;

    /* Surfaces and rules. */
    --paper: #f6f6f9;
    --surface: #ffffff;
    --sunken: #f6f6fb;
    --line: #efeef4;   /* a structural hairline: card and table borders */
    --rule: #e2e0eb;   /* a rule you are meant to see: inputs, buttons  */

    /* Status colours, each with the tint its badge sits on and the darker
       tone its text uses on that tint. */
    --ok: #10b981;
    --ok-bg: #d8f5e9;
    --ok-text: #047857;
    --danger: #ef4444;
    --danger-bg: #fee2e2;
    --danger-text: #b91c1c;
    --warn: #f59e0b;
    --warn-bg: #fef3c7;
    --warn-text: #b45309;
    --info: #3b82f6;
    --info-bg: #dbeafe;
    --info-text: #1d4ed8;

    --sidebar-width: 272px;
    --sidebar-width-collapsed: 76px;
    --sans: 'Schibsted Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --mono: 'IBM Plex Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
    --heading-font: var(--sans);

    --shadow-sm: 0 1px 2px rgba(30, 27, 46, .05);
    --shadow-md: 0 10px 24px -14px rgba(30, 27, 46, .22);
    --shadow-brand: 0 8px 18px -8px rgba(99, 102, 241, .55);

    /* ---- Bootstrap's own root variables ---------------------------- */

    --bs-body-font-family: var(--sans);
    --bs-body-font-size: 0.9rem;
    --bs-body-color: #1e1b2e;
    --bs-body-color-rgb: 30, 27, 46;
    --bs-body-bg: #f6f6f9;
    --bs-emphasis-color: #1e1b2e;
    --bs-secondary-color: #7d7a91;   /* .text-muted reads this */
    --bs-tertiary-color: #9b98ac;
    --bs-border-color: #e2e0eb;
    --bs-border-color-translucent: #e2e0eb;
    --bs-heading-color: #1e1b2e;

    /* One rounded family. Bootstrap's button, input, dropdown and alert all
       resolve their radius from --bs-border-radius; card and modal get a
       larger one of their own below. */
    --bs-border-radius: 11px;
    --bs-border-radius-sm: 9px;
    --bs-border-radius-lg: 14px;
    --bs-border-radius-xl: 18px;
    --bs-border-radius-2xl: 22px;

    --bs-box-shadow: var(--shadow-md);
    --bs-box-shadow-sm: var(--shadow-sm);
    --bs-box-shadow-lg: 0 24px 48px -28px rgba(30, 27, 46, .35);

    /* The .text-*, .bg-* and .text-bg-* utilities resolve from these. */
    --bs-primary-rgb: 99, 102, 241;
    --bs-secondary-rgb: 124, 122, 145;
    --bs-success-rgb: 16, 185, 129;
    --bs-danger-rgb: 239, 68, 68;
    --bs-warning-rgb: 245, 158, 11;
    --bs-info-rgb: 59, 130, 246;
    --bs-light-rgb: 246, 246, 251;
    --bs-dark-rgb: 30, 27, 46;

    --bs-danger-bg-subtle: #fee2e2;
    --bs-danger-text-emphasis: #b91c1c;
    --bs-danger-border-subtle: #fbc5c5;

    --bs-link-color-rgb: 99, 102, 241;
    --bs-link-hover-color-rgb: 79, 70, 229;
}

/* ================================================================== */
/* 2. Base                                                             */
/* ================================================================== */

body {
    background-color: var(--paper);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 0.9rem;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
    font-family: var(--heading-font);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--ink);
}

a,
a:hover {
    text-decoration: none;
}

::selection {
    background: var(--brand-tint);
    color: var(--brand-deep);
}

/*
 * Nearly every list and detail page opens with the same line - a quiet
 * heading above the content ("Patient register", "Invoice history"). Set in
 * the mono face it becomes the page's eyebrow, the same device the sign-in
 * screen uses above its headline, and it costs no markup change on the
 * fifty-odd pages that already have one.
 */
.h6.text-muted,
h2.h6.text-muted {
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted) !important;
}

/* ================================================================== */
/* 3. Buttons                                                          */
/* ================================================================== */

.btn {
    --bs-btn-padding-x: 0.95rem;
    --bs-btn-padding-y: 0.5rem;
    --bs-btn-font-size: 0.85rem;
    --bs-btn-font-weight: 600;
    --bs-btn-border-width: 1px;
    font-family: var(--sans);
    transition: background-color .18s ease, border-color .18s ease,
                color .18s ease, box-shadow .18s ease, transform .12s ease;
}

.btn:active {
    transform: translateY(1px);
}

.btn-sm {
    --bs-btn-padding-x: 0.62rem;
    --bs-btn-padding-y: 0.32rem;
    --bs-btn-font-size: 0.78rem;
    --bs-btn-border-radius: 9px;
}

.btn i {
    /* Bootstrap Icons sit a shade high next to Schibsted Grotesk. */
    vertical-align: -0.06em;
}

/* The primary action wears the brand gradient, the same one as the sidebar
   mark. Bootstrap has no --bs-btn-bg-image, so the gradient is painted here
   and the variables below only have to carry the colours the gradient sits
   on when the button is disabled or focused. */
.btn-primary {
    --bs-btn-bg: var(--brand);
    --bs-btn-border-color: transparent;
    --bs-btn-color: #fff;
    --bs-btn-hover-bg: var(--brand-strong);
    --bs-btn-hover-border-color: transparent;
    --bs-btn-hover-color: #fff;
    --bs-btn-active-bg: var(--brand-deep);
    --bs-btn-active-border-color: transparent;
    --bs-btn-disabled-bg: var(--brand-soft);
    --bs-btn-disabled-border-color: transparent;
    --bs-btn-focus-shadow-rgb: 99, 102, 241;
    background-image: var(--brand-grad);
    box-shadow: var(--shadow-brand);
}

.btn-primary:hover,
.btn-primary:focus-visible {
    background-image: linear-gradient(135deg, #4f46e5, #7c3aed);
    box-shadow: 0 10px 22px -8px rgba(99, 102, 241, .65);
}

.btn-primary:active,
.btn-primary.disabled,
.btn-primary:disabled {
    background-image: none;
    box-shadow: none;
}

.btn-outline-primary {
    --bs-btn-color: var(--brand-strong);
    --bs-btn-border-color: var(--brand-soft);
    --bs-btn-bg: var(--surface);
    --bs-btn-hover-bg: var(--brand);
    --bs-btn-hover-border-color: var(--brand);
    --bs-btn-hover-color: #fff;
    --bs-btn-active-bg: var(--brand-strong);
    --bs-btn-active-border-color: var(--brand-strong);
    --bs-btn-disabled-color: var(--muted);
    --bs-btn-disabled-border-color: var(--rule);
    --bs-btn-focus-shadow-rgb: 99, 102, 241;
}

/* By far the most common button here: the row of small view / edit / status
   icons at the end of every table row. Three of them sit side by side in a
   list of twenty rows, so this one stays quiet until it is pointed at. */
.btn-outline-secondary {
    --bs-btn-color: var(--body);
    --bs-btn-bg: var(--surface);
    --bs-btn-border-color: var(--rule);
    --bs-btn-hover-bg: var(--brand-tint);
    --bs-btn-hover-border-color: var(--brand-soft);
    --bs-btn-hover-color: var(--brand-deep);
    --bs-btn-active-bg: var(--brand);
    --bs-btn-active-border-color: var(--brand);
    --bs-btn-active-color: #fff;
    --bs-btn-disabled-color: var(--muted);
    --bs-btn-disabled-border-color: var(--line);
    --bs-btn-focus-shadow-rgb: 99, 102, 241;
}

.btn-success {
    --bs-btn-bg: var(--ok);
    --bs-btn-border-color: var(--ok);
    --bs-btn-hover-bg: #059669;
    --bs-btn-hover-border-color: #059669;
    --bs-btn-active-bg: #047857;
    --bs-btn-active-border-color: #047857;
    --bs-btn-focus-shadow-rgb: 16, 185, 129;
}

.btn-outline-success {
    --bs-btn-color: var(--ok-text);
    --bs-btn-bg: var(--surface);
    --bs-btn-border-color: #9ae6c6;
    --bs-btn-hover-bg: var(--ok);
    --bs-btn-hover-border-color: var(--ok);
    --bs-btn-hover-color: #fff;
    --bs-btn-active-bg: #059669;
    --bs-btn-active-border-color: #059669;
    --bs-btn-focus-shadow-rgb: 16, 185, 129;
}

.btn-danger {
    --bs-btn-bg: var(--danger);
    --bs-btn-border-color: var(--danger);
    --bs-btn-hover-bg: #dc2626;
    --bs-btn-hover-border-color: #dc2626;
    --bs-btn-active-bg: var(--danger-text);
    --bs-btn-active-border-color: var(--danger-text);
    --bs-btn-focus-shadow-rgb: 239, 68, 68;
}

.btn-outline-danger {
    --bs-btn-color: var(--danger-text);
    --bs-btn-bg: var(--surface);
    --bs-btn-border-color: #f6b9b9;
    --bs-btn-hover-bg: var(--danger);
    --bs-btn-hover-border-color: var(--danger);
    --bs-btn-hover-color: #fff;
    --bs-btn-active-bg: #dc2626;
    --bs-btn-active-border-color: #dc2626;
    --bs-btn-focus-shadow-rgb: 239, 68, 68;
}

.btn-outline-warning {
    --bs-btn-color: var(--warn-text);
    --bs-btn-bg: var(--surface);
    --bs-btn-border-color: #f6d998;
    --bs-btn-hover-bg: var(--warn);
    --bs-btn-hover-border-color: var(--warn);
    --bs-btn-hover-color: #fff;
    --bs-btn-active-bg: #d97706;
    --bs-btn-active-border-color: #d97706;
    --bs-btn-focus-shadow-rgb: 245, 158, 11;
}

.btn-outline-dark {
    --bs-btn-color: var(--ink);
    --bs-btn-bg: var(--surface);
    --bs-btn-border-color: var(--rule);
    --bs-btn-hover-bg: var(--ink);
    --bs-btn-hover-border-color: var(--ink);
    --bs-btn-active-bg: var(--ink);
    --bs-btn-active-border-color: var(--ink);
    --bs-btn-focus-shadow-rgb: 30, 27, 46;
}

.btn-link {
    --bs-btn-color: var(--brand-strong);
    --bs-btn-hover-color: var(--brand-deep);
    --bs-btn-font-weight: 600;
    text-decoration: none;
}

.btn-link:hover {
    text-decoration: underline;
    text-underline-offset: 2px;
}

.btn-close {
    --bs-btn-close-opacity: .4;
    --bs-btn-close-hover-opacity: .9;
    --bs-btn-close-focus-shadow: 0 0 0 3px rgba(99, 102, 241, .18);
}

/* ================================================================== */
/* 4. Forms                                                            */
/* ================================================================== */

/* Field labels take the mono, letterspaced treatment from the sign-in form.
   It is the cheapest way to make a plain Bootstrap form read as part of
   this product instead of a default one. */
.form-label,
.col-form-label {
    font-family: var(--mono);
    font-size: 10.5px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--label);
    margin-bottom: 0.4rem;
}

.form-control,
.form-select {
    border: 1px solid var(--rule);
    background-color: var(--surface);
    color: var(--ink);
    font-size: 0.875rem;
    padding: 0.52rem 0.75rem;
    transition: border-color .18s ease, box-shadow .18s ease;
}

.form-control::placeholder {
    color: var(--muted);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--brand-soft);
    box-shadow: 0 0 0 3.5px rgba(99, 102, 241, .14);
}

.form-control:disabled,
.form-control[readonly],
.form-select:disabled {
    background-color: var(--sunken);
    color: var(--body);
}

.form-control-sm,
.form-select-sm {
    font-size: 0.8rem;
    padding: 0.35rem 0.6rem;
}

.form-control.is-invalid,
.form-select.is-invalid {
    border-color: var(--danger);
    background-image: none;   /* the message below already says so */
    padding-right: 0.75rem;
}

.form-control.is-invalid:focus,
.form-select.is-invalid:focus {
    border-color: var(--danger);
    box-shadow: 0 0 0 3.5px rgba(239, 68, 68, .13);
}

.invalid-feedback {
    font-size: 0.78rem;
    color: var(--danger-text);
}

/* ID proof files (patient form, see data-id-proof in app.js). The real
   file input is hidden; its <label> is the Upload button. */
.idp-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
}

.idp-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.idp-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.idp-input:focus-visible + .idp-actions label[for] {
    outline: 0;
    box-shadow: 0 0 0 3.5px rgba(99, 102, 241, .25);
}

.idp-count {
    margin-left: auto;
    font-size: 0.8rem;
    color: var(--muted);
}

.idp-count.is-full {
    color: var(--warn-text);
}

.idp-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.idp-grid:empty {
    display: none;
}

.idp-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--paper);
    font-size: 0.875rem;
    transition: opacity .15s ease;
}

.idp-card.is-saved {
    background: var(--ok-bg);
    border-color: transparent;
}

.idp-card-media {
    flex: none;
    display: flex;
}

.idp-thumb {
    width: 64px;
    height: 44px;
    border-radius: 6px;
    object-fit: cover;
    background: var(--surface);
    box-shadow: 0 0 0 1px rgba(30, 27, 46, .08);
}

.idp-pdf {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: var(--danger-bg);
    color: var(--danger-text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.idp-card-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.idp-card-text strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--ink);
}

.idp-card-state,
.idp-card-removing {
    font-size: 0.78rem;
    color: var(--muted);
}

.idp-card-state a {
    font-weight: 600;
}

.idp-card-removing,
.idp-card.is-removing .idp-card-state {
    display: none;
}

.idp-card.is-removing .idp-card-removing {
    display: block;
    color: var(--danger-text);
}

.idp-card.is-removing {
    background: var(--paper);
    border-color: var(--line);
    border-style: dashed;
}

.idp-card.is-removing .idp-card-media,
.idp-card.is-removing .idp-card-text strong {
    opacity: .45;
}

.idp-card-remove {
    flex: none;
    width: 30px;
    height: 30px;
    margin: 0;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.idp-card-remove:hover {
    background: var(--line);
    color: var(--danger-text);
}

/* Saved cards: the checkbox is the toggle; show a bin, or "undo" once ticked. */
.idp-card-remove input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.idp-card-remove:focus-within {
    box-shadow: 0 0 0 3px rgba(99, 102, 241, .25);
}

.idp-card-remove .bi-arrow-counterclockwise,
.idp-card.is-removing .idp-card-remove .bi-trash3 {
    display: none;
}

.idp-card.is-removing .idp-card-remove .bi-arrow-counterclockwise {
    display: inline;
}

/* A saved file the viewer may not open (no patients.view_id_proof). */
.idp-locked {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: var(--surface);
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.idp-tag {
    margin-left: 4px;
    padding: 1px 6px;
    border-radius: 99px;
    background: var(--surface);
    color: var(--ok-text);
    font-size: 10.5px;
    font-weight: 600;
    vertical-align: middle;
}

.idp-note {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--warn-bg);
    color: var(--warn-text);
    font-size: 0.82rem;
    line-height: 1.45;
}

.idp-note[hidden] {
    display: none;
}

.idp-note .bi {
    margin-top: 1px;
}

/* Aadhaar masking modal (data-id-mask). The canvas keeps the image's
   real resolution and is shown scaled to fit. */
.mask-stage {
    border-radius: 12px;
    overflow: hidden;
    background: #111;
    display: flex;
    justify-content: center;
}

.mask-canvas {
    display: block;
    max-width: 100%;
    max-height: 62vh;
    cursor: crosshair;
    touch-action: none;   /* drawing a box must not scroll the page on touch */
}

/* Live camera modal (data-camera-capture). */
.cam-stage {
    position: relative;
    aspect-ratio: 4 / 3;
    border-radius: 12px;
    overflow: hidden;
    background: #111;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cam-video,
.cam-still {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.cam-video[hidden],
.cam-still[hidden],
.cam-message[hidden] {
    display: none;
}

.cam-message {
    padding: 24px;
    max-width: 420px;
    text-align: center;
    color: #e5e7eb;
    font-size: 0.9rem;
}

/* Searchable select (data-searchable-select, see app.js): a .form-select
   look-alike button that opens a panel with a search box and a list. */
.ss {
    position: relative;
}

.ss-native {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    border: 0 !important;
}

.ss-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-align: left;
    cursor: pointer;
    min-height: calc(1.5em + 1.04rem + 2px);
}

.ss.is-open .ss-trigger {
    border-color: var(--brand-soft);
    box-shadow: 0 0 0 3.5px rgba(99, 102, 241, .14);
}

.ss-trigger-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ss-trigger-text.is-placeholder {
    color: var(--muted);
}

.ss-flag {
    flex: none;
    width: 22px;
    height: 16.5px;
    border-radius: 3px;
    object-fit: cover;
    box-shadow: 0 0 0 1px rgba(30, 27, 46, .08);
}

.ss-panel {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    min-width: 260px;
    z-index: 1060;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: 0 20px 44px -22px rgba(30, 27, 46, .35), 0 2px 6px rgba(30, 27, 46, .06);
}

.ss-search {
    margin-bottom: 6px;
}

.ss-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 280px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.ss-group {
    padding: 8px 10px 4px;
    font: 500 10px var(--mono);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.ss-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 0.875rem;
    color: var(--ink);
    cursor: pointer;
}

.ss-option.is-active {
    background: var(--brand-tint);
}

.ss-option.is-selected {
    font-weight: 600;
    color: var(--brand-deep);
}

.ss-tick {
    margin-left: auto;
    color: var(--brand);
}

.ss-empty {
    padding: 14px 10px;
    font-size: 0.85rem;
    color: var(--muted);
    text-align: center;
}

.form-text {
    font-size: 0.78rem;
    color: var(--muted);
}

.input-group-text {
    background-color: var(--sunken);
    border: 1px solid var(--rule);
    color: var(--body);
    font-size: 0.85rem;
}

.form-check-input {
    border-color: var(--rule);
}

.form-check-input:checked {
    background-color: var(--brand);
    border-color: var(--brand);
}

.form-check-input:focus {
    border-color: var(--brand-soft);
    box-shadow: 0 0 0 3.5px rgba(99, 102, 241, .14);
}

.form-check-label {
    font-size: 0.86rem;
}

/* A required field is named next to its label, not marked by colour alone. */
.required-mark::after {
    content: " *";
    color: var(--danger);
}

/* ================================================================== */
/* 5. Cards                                                            */
/* ================================================================== */

.card {
    --bs-card-border-color: var(--line);
    --bs-card-bg: var(--surface);
    --bs-card-border-radius: 16px;
    --bs-card-inner-border-radius: 15px;
    --bs-card-spacer-x: 1.15rem;
    --bs-card-spacer-y: 1.15rem;
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
}

.card-header {
    background-color: var(--surface);
    border-bottom: 1px solid var(--line);
    font-family: var(--heading-font);
    font-weight: 700;
    font-size: 0.87rem;
    letter-spacing: -0.015em;
    color: var(--ink);
    padding: 0.9rem 1.15rem;
}

.card-footer {
    background-color: #fbfbfd;
    border-top: 1px solid var(--line);
    padding: 0.9rem 1.15rem;
}

.card.border-danger {
    border-color: #f6c6c6 !important;
}

/* ================================================================== */
/* 6. Tables                                                           */
/* ================================================================== */

.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--ink);
    --bs-table-border-color: var(--line);
    --bs-table-hover-bg: #fafaff;
    --bs-table-hover-color: var(--ink);
    margin-bottom: 0;
}

.table > :not(caption) > * > * {
    padding: 0.72rem 0.8rem;
}

.table thead th {
    font-family: var(--mono);
    font-size: 10.5px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--label);
    background-color: #fafafd;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

.table tbody td {
    border-bottom-color: var(--line);
    vertical-align: middle;
}

/* Inside a card the card's own border already closes the table off, and a
   last row rule would sit a hair inside the rounded corner. */
.card > .table-responsive > .table > tbody > tr:last-child > td,
.card > .table > tbody > tr:last-child > td {
    border-bottom-width: 0;
}

.table-bordered > :not(caption) > * > * {
    border-color: var(--line);
}

/* Bootstrap's "highlighted row" - the calendar uses it to mark today. */
.table-primary {
    --bs-table-bg: var(--brand-tint);
    --bs-table-color: var(--ink);
    --bs-table-border-color: #dcdefb;
    --bs-table-hover-bg: #e6eafe;
    --bs-table-hover-color: var(--ink);
}

/* ================================================================== */
/* 7. Badges                                                           */
/* ================================================================== */

/*
 * Status is a soft pill: a tint with its own darker text, the same shape as
 * the "Live" tags on the dashboard. Bootstrap writes .text-bg-* colours
 * with !important, so each variant has to answer in kind.
 */

.badge {
    --bs-badge-padding-x: 0.62em;
    --bs-badge-padding-y: 0.42em;
    --bs-badge-font-size: 10.5px;
    --bs-badge-font-weight: 700;
    --bs-badge-border-radius: 20px;
    letter-spacing: 0.015em;
    border: 1px solid transparent;
    vertical-align: middle;
}

.badge.text-bg-primary {
    color: var(--brand-deep) !important;
    background-color: var(--brand-tint) !important;
    border-color: #dcdefb;
}

.badge.text-bg-success {
    color: var(--ok-text) !important;
    background-color: var(--ok-bg) !important;
    border-color: #a7e9cd;
}

.badge.text-bg-danger {
    color: var(--danger-text) !important;
    background-color: var(--danger-bg) !important;
    border-color: #fac4c4;
}

.badge.text-bg-warning {
    color: var(--warn-text) !important;
    background-color: var(--warn-bg) !important;
    border-color: #f7de9e;
}

.badge.text-bg-info {
    color: var(--info-text) !important;
    background-color: var(--info-bg) !important;
    border-color: #bcd6fb;
}

.badge.text-bg-secondary {
    color: var(--body) !important;
    background-color: #f0eff5 !important;
    border-color: #e2e0eb;
}

.badge.text-bg-light {
    color: var(--body) !important;
    background-color: var(--sunken) !important;
    border-color: var(--line);
}

.badge.text-bg-dark {
    color: #fff !important;
    background-color: var(--ink) !important;
    border-color: var(--ink);
}

/* ================================================================== */
/* 8. Alerts                                                           */
/* ================================================================== */

.alert {
    --bs-alert-border-radius: 14px;
    border: 1px solid transparent;
    padding: 0.85rem 1.05rem;
    font-size: 0.86rem;
    color: var(--ink);
    background-color: var(--sunken);
}

.alert-success {
    background-color: var(--ok-bg);
    border-color: #a7e9cd;
    color: #065f46;
}

.alert-danger {
    background-color: var(--danger-bg);
    border-color: #fac4c4;
    color: #991b1b;
}

.alert-warning {
    background-color: var(--warn-bg);
    border-color: #f7de9e;
    color: #92400e;
}

.alert-info {
    background-color: var(--brand-tint);
    border-color: #dcdefb;
    color: var(--brand-deep);
}

.alert .btn-close {
    padding: 1rem 1.1rem;
}

/* ================================================================== */
/* 9. Lists, pagination, tabs, dropdowns, modals                       */
/* ================================================================== */

.list-group {
    --bs-list-group-bg: var(--surface);
    --bs-list-group-border-color: var(--line);
    --bs-list-group-color: var(--ink);
    --bs-list-group-border-radius: 15px;
    --bs-list-group-action-hover-bg: #fafaff;
    --bs-list-group-action-hover-color: var(--ink);
    --bs-list-group-active-bg: var(--brand);
    --bs-list-group-active-border-color: var(--brand);
    --bs-list-group-item-padding-x: 1.15rem;
    --bs-list-group-item-padding-y: 0.72rem;
}

/* Each page number is its own rounded chip rather than one segmented bar -
   it matches the buttons beside it on the same screen. */
.pagination {
    --bs-pagination-color: var(--body);
    --bs-pagination-bg: var(--surface);
    --bs-pagination-border-color: var(--rule);
    --bs-pagination-border-radius: 9px;
    --bs-pagination-hover-color: var(--brand-deep);
    --bs-pagination-hover-bg: var(--brand-tint);
    --bs-pagination-hover-border-color: var(--brand-soft);
    --bs-pagination-focus-color: var(--brand-deep);
    --bs-pagination-focus-bg: var(--brand-tint);
    --bs-pagination-focus-box-shadow: 0 0 0 3.5px rgba(99, 102, 241, .14);
    --bs-pagination-active-bg: var(--brand);
    --bs-pagination-active-border-color: var(--brand);
    --bs-pagination-active-color: #fff;
    --bs-pagination-disabled-color: var(--muted);
    --bs-pagination-disabled-bg: var(--surface);
    --bs-pagination-disabled-border-color: var(--line);
    gap: 4px;
}

.pagination .page-link {
    border-radius: 9px;
    font-weight: 600;
    font-size: 0.78rem;
}

.page-link:hover {
    text-decoration: none;
}

/* Tabs as a ruled row: the current one is marked with a brand underline
   rather than a raised folder tab. */
.nav-tabs {
    --bs-nav-tabs-border-color: var(--line);
    --bs-nav-tabs-border-width: 1px;
    --bs-nav-tabs-link-active-color: var(--brand-deep);
    --bs-nav-tabs-link-active-bg: transparent;
    --bs-nav-tabs-link-active-border-color: transparent;
    --bs-nav-tabs-link-hover-border-color: transparent;
    --bs-nav-link-color: var(--body);
    --bs-nav-link-hover-color: var(--ink);
    --bs-nav-link-font-size: 0.86rem;
    --bs-nav-link-font-weight: 600;
    gap: 0.25rem;
}

.nav-tabs .nav-link {
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    padding: 0.6rem 0.85rem;
}

.nav-tabs .nav-link.active {
    border-bottom-color: var(--brand);
}

.dropdown-menu {
    --bs-dropdown-border-color: var(--line);
    --bs-dropdown-border-radius: 14px;
    --bs-dropdown-link-color: var(--ink);
    --bs-dropdown-link-hover-bg: var(--brand-tint);
    --bs-dropdown-link-hover-color: var(--brand-deep);
    --bs-dropdown-link-active-bg: var(--brand);
    --bs-dropdown-link-active-color: #fff;
    --bs-dropdown-font-size: 0.86rem;
    --bs-dropdown-divider-bg: var(--line);
    --bs-dropdown-item-padding-x: 0.9rem;
    box-shadow: 0 20px 44px -26px rgba(30, 27, 46, .35);
}

.dropdown-item {
    border-radius: 9px;
}

.dropdown-menu > li {
    padding: 0 0.35rem;
}

.dropdown-menu > li:first-child {
    padding-top: 0.25rem;
}

.dropdown-menu > li:last-child {
    padding-bottom: 0.25rem;
}

.dropdown-item:hover {
    text-decoration: none;
}

/* Coloured menu items keep their colour on hover/press instead of
   turning into red-on-indigo. */
.dropdown-item.text-danger:hover,
.dropdown-item.text-danger:focus,
.dropdown-item.text-danger:active {
    background: var(--danger-bg);
    color: var(--danger-text) !important;
}

.dropdown-item.text-success:hover,
.dropdown-item.text-success:focus,
.dropdown-item.text-success:active {
    background: #dcfce7;
    color: #15803d !important;
}

/* ------------------------------------------------------------------ */
/* SweetAlert2 confirm dialogs (see data-confirm in app.js)            */
/* ------------------------------------------------------------------ */

.swal-app {
    border-radius: 16px;
    padding: 1.75rem 1.5rem 1.5rem;
    font-family: var(--sans);
}

.swal-app .swal2-title {
    font-family: var(--heading-font);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.01em;
}

.swal-app .swal2-html-container {
    font-size: .92rem;
    color: var(--muted);
}

.swal-app .swal2-icon {
    transform: scale(.8);
    margin: .25rem auto .5rem;
}

/* A text box in the dialog (e.g. the cancellation reason) looks like the app's inputs. */
.swal-app .swal2-input {
    width: auto;
    height: 44px;
    margin: 1rem 1.25rem .25rem;
    padding: 0 14px;
    font-size: 15px;
    border: 1px solid var(--rule);
    border-radius: 11px;
    box-shadow: none;
}

.swal-app .swal2-input:focus {
    border-color: var(--brand-soft);
    box-shadow: 0 0 0 3.5px rgba(99, 102, 241, .14);
}

.swal-app .swal2-actions {
    gap: .5rem;
    margin-top: 1.25rem;
}

.swal-app-btn {
    height: 40px;
    padding: 0 18px;
    border-radius: 10px;
    border: 1px solid transparent;
    font-size: .9rem;
    font-weight: 600;
    transition: background-color .15s ease, border-color .15s ease;
}

.swal-app-btn.is-primary {
    background: var(--brand);
    color: #fff;
}

.swal-app-btn.is-primary:hover {
    background: var(--brand-strong);
}

.swal-app-btn.is-danger {
    background: var(--danger);
    color: #fff;
}

.swal-app-btn.is-danger:hover {
    background: var(--danger-text);
}

.swal-app-btn.is-outline {
    background: #fff;
    border-color: var(--rule);
    color: var(--body);
}

.swal-app-btn.is-outline:hover {
    background: var(--sunken);
    color: var(--ink);
}

.swal-app-btn:focus-visible {
    outline: 0;
    box-shadow: 0 0 0 3.5px rgba(99, 102, 241, .25);
}

.modal-content {
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 30px 60px -30px rgba(30, 27, 46, .4);
}

.modal-header,
.modal-footer {
    border-color: var(--line);
}

.modal-title {
    font-family: var(--heading-font);
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: -0.02em;
}

.progress {
    background-color: var(--sunken);
}

/* ================================================================== */
/* 10. The sidebar                                                     */
/* ================================================================== */

.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    background: linear-gradient(180deg, #312a63 0%, #4338ca 45%, #6d4fe0 100%);
    color: #fff;
    overflow: hidden;
    /* Above a Bootstrap offcanvas backdrop (z-index 1040) so a slide-over
       panel - see .offcanvas-wide below - never dims the sidebar. */
    z-index: 1050;
    padding: 0.85rem 0.85rem 0.75rem;
    transition: width 0.2s ease-in-out;
}

.app-sidebar .sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0 0.4rem;
    margin-bottom: 0.5rem;
    flex: none;
    text-decoration: none;
}

.app-sidebar .sidebar-brand:hover {
    text-decoration: none;
}

.app-sidebar .sidebar-brand-mark {
    width: 36px;
    height: 36px;
    flex: none;
    border-radius: 11px;
    background: #fff;
    color: var(--brand-deep);
    display: flex;
    align-items: center;
    justify-content: center;
}

.app-sidebar .sidebar-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    min-width: 0;
    white-space: nowrap;
}

.app-sidebar .sidebar-brand-main {
    font-family: var(--heading-font);
    font-weight: 700;
    font-size: 0.97rem;
    letter-spacing: -0.02em;
    color: #fff;
}

.app-sidebar .sidebar-brand-sub {
    font-size: 0.73rem;
    font-weight: 500;
    color: rgba(255, 255, 255, .65);
}

.app-sidebar nav {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 0.15rem;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
}

/* The scrollbar's gutter is always reserved (so nothing shifts when it
   appears) but its thumb stays transparent until app.js adds
   .is-scrolling - it then fades back out a moment after scrolling stops. */
.app-sidebar nav.is-scrolling {
    scrollbar-color: rgba(255, 255, 255, .25) transparent;
}

/* Firefox gets its thin scrollbar from the two properties above; this
   covers Chrome, Edge and Safari, which need their own syntax. */
.app-sidebar nav::-webkit-scrollbar {
    width: 6px;
}

.app-sidebar nav::-webkit-scrollbar-track {
    background: transparent;
}

.app-sidebar nav::-webkit-scrollbar-thumb {
    background-color: transparent;
    border-radius: 10px;
    transition: background-color .2s ease;
}

.app-sidebar nav.is-scrolling::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, .25);
}

.app-sidebar .sidebar-heading-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin: 0;
    /* Matches .nav-link's own padding exactly (0.52rem 0.6rem) - this used
       to be a smaller, bottom-heavy value (0.55rem 0.6rem 0.2rem) tuned for
       a plain text label with no icon; left as-is once an icon was added,
       every heading row sat visibly shorter than the nav-link rows above
       and below it. */
    padding: 0.52rem 0.6rem;
    border: none;
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    /* A <button>'s user-agent stylesheet gives it its own font shorthand
       (line-height and all), not the surrounding text's - "font: inherit"
       resets that back to normal before the three lines below pick the
       actual look, so this renders identically to the plain heading <div>
       it replaced instead of sitting at a slightly different baseline. */
    font: inherit;
    font-family: var(--sans);
    font-size: 0.92rem;
    font-weight: 600;
    letter-spacing: -0.005em;
    color: rgba(255, 255, 255, .82);
    white-space: nowrap;
    cursor: pointer;
    position: relative;
    border-radius: 12px;
    transition: color .16s ease, background-color .16s ease;
}

.app-sidebar .sidebar-heading-toggle:hover {
    color: #fff;
    background-color: rgba(255, 255, 255, .06);
}

/* The open group's own heading: a lighter band with an accent bar on its
   left edge, so it reads as the parent of the tree below it. */
.app-sidebar .sidebar-heading-toggle:not(.collapsed) {
    color: #fff;
    background-color: rgba(255, 255, 255, .12);
}

.app-sidebar .sidebar-heading-toggle:not(.collapsed)::before {
    content: "";
    position: absolute;
    left: 0;
    top: 20%;
    bottom: 20%;
    width: 3px;
    border-radius: 3px;
    background: rgba(199, 210, 254, .9);
}

/* A <div> never showed a focus ring; a real <button> does by default
   (:focus-visible included - Firefox and Safari show it on a plain mouse
   click too, not just keyboard nav, unlike Chrome). Dropped outright rather
   than kept subtle, to match the plain-label look this replaced exactly. */
.app-sidebar .sidebar-heading-toggle:focus,
.app-sidebar .sidebar-heading-toggle:focus-visible {
    outline: none;
}

.app-sidebar .sidebar-heading-toggle i {
    font-size: 12px;
    transition: transform .18s ease;
}

.app-sidebar .sidebar-heading-label {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    min-width: 0;
}

.app-sidebar .sidebar-heading-label svg {
    flex: none;
}

.app-sidebar .sidebar-heading-toggle.collapsed i {
    transform: rotate(180deg);
}

/* Scoped to .show, not bare .sidebar-group: Bootstrap's own
   ".collapse:not(.show){display:none}" has the same specificity (two
   classes) as a bare ".app-sidebar .sidebar-group" rule would, and app.css
   loads after bootstrap.min.css, so an unscoped rule here would win that
   tie and force every group permanently open regardless of .show. Requiring
   .show too raises this rule to three classes, which only outranks
   Bootstrap's rule - and only takes effect - once a group is genuinely
   expanded; collapsed groups are left alone to actually collapse. */
.app-sidebar .sidebar-group.show,
.app-sidebar .sidebar-group.collapsing {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

/* A group's items hang off a thin vertical line, each marked by a dot on
   it (see .sidebar-group .nav-link::before). --tree-x is where the line
   sits, measured from the group's left edge; the items start past it. */
.app-sidebar .sidebar-group {
    --tree-x: 1.55rem;
    position: relative;
    padding: 0.05rem 0 0.25rem 2.35rem;
}

.app-sidebar .sidebar-group::before {
    content: "";
    position: absolute;
    left: var(--tree-x);
    top: 0.85rem;
    bottom: 0.85rem;
    width: 2px;
    border-radius: 2px;
    background: rgba(255, 255, 255, .16);
}

.app-sidebar .sidebar-divider {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, .16);
    margin: 0.35rem 0.6rem;
}

/* A top-level row (Dashboard) matches a group heading exactly: sentence
   case, same size, weight and resting colour. */
.app-sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.45rem 0.6rem;
    border-radius: 12px;
    color: rgba(255, 255, 255, .82);
    font-weight: 600;
    font-size: 0.92rem;
    letter-spacing: -0.005em;
    white-space: nowrap;
    transition: background-color .16s ease, color .16s ease;
}

.app-sidebar .nav-link svg {
    flex: none;
    width: 17px;
    height: 17px;
}

/* Top-level icons (Dashboard and each group heading) sit on a rounded
   tile. Drawn on the <svg> itself - padding plus a background - so the
   markup needs no extra wrapper. */
.app-sidebar nav > .nav-link > svg,
.app-sidebar .sidebar-heading-label > svg {
    box-sizing: content-box;
    width: 18px;
    height: 18px;
    padding: 9px;
    border-radius: 10px;
    background: rgba(255, 255, 255, .1);
}

/* A group's own items: lighter type, and a dot on the group's tree line. */
.app-sidebar .sidebar-group .nav-link {
    position: relative;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: rgba(255, 255, 255, .74);
    margin-top: 4px;
}

.app-sidebar .sidebar-group .nav-link::before {
    content: "";
    position: absolute;
    left: calc(var(--tree-x) + 1px - 3px - 2.35rem);
    top: 50%;
    width: 6px;
    height: 6px;
    margin-top: -3px;
    border-radius: 50%;
    background: rgba(165, 180, 252, .85);
}

.app-sidebar .sidebar-group .nav-link.active::before {
    left: calc(var(--tree-x) + 1px - 4.5px - 2.35rem);
    width: 9px;
    height: 9px;
    margin-top: -4.5px;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, .18);
}

.app-sidebar .nav-link-label {
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-sidebar .nav-link:hover {
    background-color: rgba(255, 255, 255, .1);
    color: #fff;
    text-decoration: none;
}

.app-sidebar .nav-link.active {
    background: #ebe9fe;
    color: var(--brand-deep);
    font-weight: 600;
}

.app-sidebar .nav-link.active > svg {
    background: rgba(99, 102, 241, .12);
}

/* A module that is not built yet: same row, but nothing to click. */
.app-sidebar .nav-link-soon {
    cursor: default;
    color: rgba(255, 255, 255, .4);
}

.app-sidebar .nav-link-soon:hover {
    background-color: transparent;
    color: rgba(255, 255, 255, .4);
}

.app-sidebar .sidebar-profile {
    flex: none;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.6rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, .08);
}

.app-sidebar .sidebar-profile-avatar {
    width: 34px;
    height: 34px;
    flex: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, .22);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.78rem;
}

.app-sidebar .sidebar-profile-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
}

.app-sidebar .sidebar-profile-name {
    font-size: 0.83rem;
    font-weight: 600;
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-sidebar .sidebar-profile-role {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, .6);
}

.app-sidebar .sidebar-profile-signout button {
    width: 30px;
    height: 30px;
    flex: none;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: rgba(255, 255, 255, .7);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color .16s ease, color .16s ease;
}

.app-sidebar .sidebar-profile-signout button:hover {
    background: rgba(255, 255, 255, .15);
    color: #fff;
}

/* ================================================================== */
/* 11. The top bar                                                     */
/* ================================================================== */

.app-main {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: 0.85rem 1.6rem;
}

.app-navbar h1 {
    font-size: 1.24rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.navbar-icon-btn {
    width: 38px;
    height: 38px;
    flex: none;
    border-radius: 11px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--body);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: background-color .16s ease, border-color .16s ease, color .16s ease;
}

.navbar-icon-btn:hover {
    background: var(--brand-tint);
    border-color: #dcdefb;
    color: var(--brand-deep);
}

.navbar-search {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 300px;
    background: var(--sunken);
    border: 1px solid var(--line);
    border-radius: 11px;
    padding: 0 12px;
    color: var(--muted);
    transition: border-color .18s ease, background-color .18s ease, box-shadow .18s ease;
}

.navbar-search:focus-within {
    background: var(--surface);
    border-color: var(--brand-soft);
    box-shadow: 0 0 0 3.5px rgba(99, 102, 241, .12);
}

.navbar-search input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    outline: none;
    padding: 0.55rem 0;
    font-family: var(--sans);
    font-size: 0.83rem;
    color: var(--ink);
}

.navbar-search input::placeholder {
    color: var(--muted);
}

.navbar-notify-btn {
    position: relative;
}

.navbar-notify-count {
    position: absolute;
    top: 3px;
    right: 2px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--danger);
    border: 2px solid var(--surface);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 13px;
    text-align: center;
}

/* The bell's dropdown. */
.notify-menu {
    width: 340px;
    max-width: calc(100vw - 24px);
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 18px 40px -16px rgba(30, 27, 46, .3);
}

.notify-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    font-weight: 700;
    font-size: 14px;
}

.notify-read-all {
    border: 0;
    background: none;
    padding: 0;
    color: var(--brand-strong);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
}

.notify-empty {
    padding: 22px 14px;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
}

.notify-menu form + form .notify-item {
    border-top: 1px solid var(--line);
}

.notify-item {
    display: flex;
    gap: 10px;
    width: 100%;
    padding: 11px 14px;
    border: 0;
    background: var(--surface);
    text-align: left;
    cursor: pointer;
}

.notify-item:hover {
    background: var(--sunken);
}

.notify-item.is-unread {
    background: var(--brand-tint);
}

.notify-icon {
    flex: none;
    width: 30px;
    height: 30px;
    border-radius: 9px;
    background: var(--ok-bg);
    color: var(--ok-text);
    display: flex;
    align-items: center;
    justify-content: center;
}

.notify-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    font-size: 13px;
    color: var(--ink);
}

.notify-text span {
    color: var(--body);
}

.notify-text small {
    color: var(--muted);
    font-size: 11.5px;
}

.app-content {
    flex: 1;
    padding: 1.6rem 1.6rem 3.5rem;
}

.app-footer {
    padding: 1rem 1.6rem;
    border-top: 1px solid var(--line);
    background: var(--surface);
    font-family: var(--mono);
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

/* Small screens: the sidebar slides in over the content. */
@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-100%);
        transition: transform 0.2s ease-in-out;
    }

    .app-sidebar.is-open {
        transform: translateX(0);
    }

    .app-main {
        margin-left: 0;
    }

    .app-navbar,
    .app-content,
    .app-footer {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

/* Desktop: the toggle shrinks the sidebar to an icon-only rail and the
   content claims the freed width (body.sidebar-collapsed - see the sidebar
   toggle in app.js). */
@media (min-width: 992px) {
    .app-main {
        transition: margin-left 0.2s ease-in-out;
    }

    body.sidebar-collapsed .app-sidebar {
        width: var(--sidebar-width-collapsed);
    }

    body.sidebar-collapsed .app-sidebar .sidebar-brand,
    body.sidebar-collapsed .app-sidebar .nav-link,
    body.sidebar-collapsed .app-sidebar .sidebar-profile {
        justify-content: center;
    }

    body.sidebar-collapsed .app-sidebar .sidebar-brand-text,
    body.sidebar-collapsed .app-sidebar .sidebar-heading-toggle,
    body.sidebar-collapsed .app-sidebar .sidebar-divider,
    body.sidebar-collapsed .app-sidebar .nav-link-label,
    body.sidebar-collapsed .app-sidebar .sidebar-profile-text,
    body.sidebar-collapsed .app-sidebar .sidebar-profile-signout {
        display: none;
    }

    /* The icon-only rail has no room for a heading to click, so every group
       shows all its icons regardless of which ones a visitor last expanded -
       collapsing a group is a width-mode concern, not something that should
       also hide icons in the other mode. */
    body.sidebar-collapsed .app-sidebar .sidebar-group {
        display: flex !important;
        flex-direction: column;
        padding-left: 0;
    }

    /* No room for the tree line, its dots, or side padding round an icon
       tile in the icon-only rail. */
    body.sidebar-collapsed .app-sidebar .sidebar-group::before,
    body.sidebar-collapsed .app-sidebar .sidebar-group .nav-link::before {
        display: none;
    }

    body.sidebar-collapsed .app-sidebar .nav-link {
        padding-left: 0;
        padding-right: 0;
    }

    body.sidebar-collapsed .app-main {
        margin-left: var(--sidebar-width-collapsed);
    }
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(30, 27, 46, 0.5);
    z-index: 1035;
}

/* ================================================================== */
/* 12. Helpers                                                         */
/* ================================================================== */

.avatar-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--brand-tint);
    color: var(--brand-strong);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    font-weight: 700;
}

.avatar-circle.avatar-lg {
    width: 64px;
    height: 64px;
    font-size: 1.35rem;
}

.avatar-photo {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.avatar-photo.avatar-lg {
    width: 64px;
    height: 64px;
}

/* A little tonal variety for rows of avatars (patients, users) so a long list
   doesn't read as one repeated violet circle - the same five-tone palette
   the appointments page uses for its own avatars. */
.avatar-circle.is-pink  { background: #fce7f3; color: #db2777; }
.avatar-circle.is-blue  { background: var(--info-bg); color: var(--info-text); }
.avatar-circle.is-green { background: var(--ok-bg); color: var(--ok-text); }
.avatar-circle.is-amber { background: var(--warn-bg); color: var(--warn-text); }

/*
 * The header every list/settings screen opens with: an icon chip, a quiet
 * eyebrow and a bold title, with the page's primary actions on the right.
 * Replaces the plain "h6.text-muted" line those screens used to start with -
 * see the appointments page, which set this pattern first.
 */
.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.page-head-icon {
    width: 44px;
    height: 44px;
    flex: none;
    border-radius: 12px;
    background: var(--brand-tint);
    color: var(--brand-deep);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 19px;
}

.page-eyebrow {
    font-size: 13px;
    font-weight: 600;
    color: var(--brand-strong);
}

.page-title {
    font-size: 24px;
    margin: 2px 0 0;
    letter-spacing: -0.015em;
}

.page-head-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* A single-form page (breadcrumb, title, one-line lead, one card), held to
   a readable width and centred instead of stretching edge to edge - see
   admin/leave-applications/create.php. */
.form-page {
    max-width: 960px;
    margin: 0 auto;
}

.breadcrumb {
    --bs-breadcrumb-divider-color: var(--faint);
    --bs-breadcrumb-item-active-color: var(--ink);
    --bs-breadcrumb-margin-bottom: 0.4rem;
    font-size: 0.84rem;
}

.breadcrumb a {
    color: var(--muted);
    text-decoration: none;
}

.breadcrumb a:hover {
    color: var(--brand-strong);
}

.page-lead {
    color: var(--body);
    font-size: 0.92rem;
    margin: 0.35rem 0 1.25rem;
}

.leave-form {
    --leave-control-h: 2.9rem;
}

.leave-form > .card-body {
    padding: 1.6rem;
}

/* Single-line controls on this form are a little taller than the app's
   default; the duration control below is held to the same height so it
   lines up beside a select. */
.leave-form .form-control:not(textarea),
.leave-form .form-select {
    min-height: var(--leave-control-h);
}

.leave-form > .card-footer {
    background: var(--surface);
    padding: 1rem 1.6rem;
}

.leave-form > .card-footer .btn {
    padding: 0.62rem 1.4rem;
    font-weight: 600;
}

/* A field with an icon sitting inside its left edge. The icon is a
   sibling placed before the control inside .input-icon (error text goes
   outside the wrapper, or the icon would centre on the wrong height); the
   control just makes room for it. pointer-events: none lets a click on the
   icon reach the field underneath. */
.input-icon {
    position: relative;
}

.input-icon > .bi {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.05rem;
    color: var(--body);
    pointer-events: none;
}

.input-icon > .form-control,
.input-icon > .form-select {
    padding-left: 2.75rem;
}

/* A row of mutually exclusive choices drawn as one control: radios
   (.btn-check, visually hidden by Bootstrap) each followed by their label,
   the checked one filled with the brand colour. Same height as a
   .form-select so it lines up beside one. */
.segmented {
    display: flex;
    align-items: stretch;
    gap: 2px;
    padding: 3px;
    min-height: var(--leave-control-h, 2.5rem);
    background: var(--sunken);
    border: 1px solid var(--line);
    border-radius: 12px;
}

.segmented-option {
    position: relative;
    flex: 1 1 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin: 0;
    padding: 0 0.6rem;
    border-radius: 9px;
    white-space: nowrap;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--body);
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease, box-shadow .15s ease;
}

.segmented-option .bi {
    font-size: 1.05rem;
}

/* A mirrored copy of an icon (bi-circle-half fills its left half; mirrored
   it fills the right). display: inline-block because a transform does
   nothing to an inline element. */
.icon-flip {
    display: inline-block;
    transform: scaleX(-1);
}

.segmented-option:hover {
    color: var(--ink);
}

/* A hairline between neighbouring options, dropped next to the selected
   one (its own fill is the separator there). */
.segmented-option + .btn-check + .segmented-option::before {
    content: "";
    position: absolute;
    left: -2px;
    top: 28%;
    bottom: 28%;
    width: 1px;
    background: var(--rule);
}

.segmented .btn-check:checked + .segmented-option::before,
.segmented .btn-check:checked + .segmented-option + .btn-check + .segmented-option::before {
    display: none;
}

.segmented .btn-check:checked + .segmented-option {
    background: var(--brand-strong);
    color: #fff;
    box-shadow: var(--shadow-brand);
}

.segmented .btn-check:focus-visible + .segmented-option {
    box-shadow: 0 0 0 3.5px rgba(99, 102, 241, .28);
}

/* A select with nothing to choose from (e.g. no leave types set up yet):
   a soft red edge, with .field-alert underneath saying why. */
.form-select.is-unavailable {
    border-color: #f6c6c6;
}

.field-alert {
    display: flex;
    align-items: flex-start;
    gap: 0.45rem;
    margin-top: 0.45rem;
    font-size: 0.8rem;
    color: var(--danger-text);
}

.field-alert .bi {
    font-size: 0.95rem;
    line-height: 1.15;
}

.field-alert a {
    color: inherit;
    font-weight: 600;
    text-decoration: underline;
}

.permission-group {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 0.95rem 1rem;
    height: 100%;
    background: var(--surface);
}

.patient-picker-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1055;
    max-height: 220px;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    margin-top: 0.3rem;
    box-shadow: 0 20px 44px -26px rgba(30, 27, 46, .35);
}

/* Shown instead of a table when there is nothing to list. */
.empty-state {
    text-align: center;
    padding: 2.75rem 1.25rem;
}

.empty-state-icon {
    width: 52px;
    height: 52px;
    margin: 0 auto 0.9rem;
    border-radius: 16px;
    background: var(--brand-tint);
    color: var(--brand);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.empty-state-message {
    font-size: 0.875rem;
    color: var(--body);
    margin: 0;
}

/* The shell behind the password screens and the error pages: the same dark
   panel the sign-in screen puts the clinic's name on. */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--ink);
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
}

.auth-page::before,
.auth-page::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
}

.auth-page::before {
    width: 520px;
    height: 520px;
    right: -170px;
    bottom: -200px;
    border: 1px solid rgba(255, 255, 255, .07);
}

.auth-page::after {
    /* The same violet glow the dashboard hero uses. */
    width: 420px;
    height: 420px;
    left: -140px;
    top: -160px;
    background: radial-gradient(circle, rgba(139, 92, 246, .32), transparent 70%);
}

.auth-card {
    width: 100%;
    max-width: 430px;
    position: relative;
    z-index: 1;
}

.auth-mark {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: var(--brand-grad);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-brand);
}

.auth-eyebrow {
    font-family: var(--mono);
    font-size: 10.5px;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--brand-soft);
}

/* ================================================================== */
/* 13. The slide-over panel (Bootstrap Offcanvas, widened + retinted)  */
/* ================================================================== */

/* Covers everything except the sidebar - see the "refresh-safe slide-over
   panel" pattern driven by data-slide-open in app.js - instead of
   Bootstrap's own, much narrower default offcanvas width. */
.offcanvas-wide {
    width: calc(100vw - var(--sidebar-width)) !important;
    /* Above .app-sidebar (1050) so the close tab below, which sticks out
       over the sidebar, isn't painted underneath it. The panel itself never
       covers the sidebar, so only the tab is actually affected. */
    z-index: 1055;
}

body.sidebar-collapsed .offcanvas-wide {
    width: calc(100vw - var(--sidebar-width-collapsed)) !important;
}

/* One plain white sheet rather than a grey panel holding a rounded white
   card: the panel turns white, and the card a fragment arrives in (e.g.
   leave-applications/form.php, which needs its card on the full page) is
   flattened so its fields line up with the panel's own title. */
.offcanvas-wide {
    --bs-offcanvas-bg: var(--surface);
    background-color: var(--surface);
}

.offcanvas-wide .offcanvas-header,
.offcanvas-wide .offcanvas-body {
    padding-left: 1.75rem;
    padding-right: 1.75rem;
}

.offcanvas-wide .offcanvas-header {
    border-bottom: 1px solid var(--line);
}

.offcanvas-wide .offcanvas-body {
    padding-top: 1.5rem;
}

.offcanvas-wide .offcanvas-body > .card {
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

.offcanvas-wide .offcanvas-body > .card > .card-body {
    padding: 0 0 1.5rem;
}

.offcanvas-wide .offcanvas-body > .card > .card-footer {
    background: transparent;
    padding: 1rem 0 0;
}

/* A bright blue tab sitting just OUTSIDE the panel's left edge, over the
   sidebar - rounded on its outer (left) end, flat where it meets the panel -
   replacing Bootstrap's small grey "x" in the top right. Deliberately not
   var(--brand-strong) - this one button is a brighter blue than the rest of
   the app's indigo brand. */
.offcanvas-wide .btn-close-slide {
    position: absolute;
    top: 1rem;
    right: 100%;
    width: 3.3rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    border-radius: 999px 0 0 999px;
    background: #3b82f6;
    color: #fff;
    font-size: 0.8rem;
    -webkit-text-stroke: 0.6px currentColor;
}

.offcanvas-wide .btn-close-slide:hover,
.offcanvas-wide .btn-close-slide:focus {
    background: #2563eb;
    color: #fff;
}

/* ================================================================== */
/* 14. User profile (admin/users/show.php + admin/users/profile/*)     */
/* ================================================================== */

/* The name header and the tab bar run edge to edge across the content
   area (cancelling .app-content's padding), like the HRMS layout the
   page is modelled on; the tab body below keeps the normal padding. */
.profile-shell {
    --profile-pad: 1.6rem;
}

.profile-shell .min-w-0 {
    min-width: 0;
}

@media (max-width: 991.98px) {
    .profile-shell {
        --profile-pad: 1rem;
    }
}

.profile-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: .35rem 1rem;
    margin: calc(var(--profile-pad) * -1) calc(var(--profile-pad) * -1) 0;
    padding: 1.25rem var(--profile-pad);
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

/* A flash message above the header: don't pull the header up over it. */
.alert ~ .profile-shell .profile-head {
    margin-top: 0;
}

.profile-name {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--ink);
}

.profile-crumbs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .4rem;
    font-size: .9rem;
    font-weight: 500;
    color: var(--muted);
}

.profile-crumbs a {
    color: var(--muted);
    text-decoration: none;
}

.profile-crumbs a:hover {
    color: var(--brand-strong);
}

.profile-tabs {
    display: flex;
    overflow-x: auto;
    margin: 0 calc(var(--profile-pad) * -1) var(--profile-pad);
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    scrollbar-width: none;
}

.profile-tabs::-webkit-scrollbar {
    display: none;
}

.profile-tab {
    flex: 0 0 auto;
    padding: 1rem 2rem;
    border-right: 1px solid var(--line);
    border-bottom: 3px solid transparent;
    margin-bottom: -1px;
    color: var(--body);
    font-size: .95rem;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    transition: color .15s ease, background-color .15s ease;
}

.profile-tab:hover {
    color: var(--ink);
    background: var(--sunken);
}

.profile-tab.active {
    color: var(--brand-strong);
    border-bottom-color: var(--brand-strong);
}

/* -- Profile tab ---------------------------------------------------- */

.profile-card-grid {
    display: grid;
    grid-template-columns: 9.5rem minmax(0, 1fr);
    gap: 1.5rem;
    align-items: center;
}

@media (max-width: 575.98px) {
    .profile-card-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* A photo-shaped tile; there is no photo column, so it shows initials. */
.profile-photo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 9.5rem;
    aspect-ratio: 1;
    border-radius: 10px;
    background: linear-gradient(160deg, #e4e3ee, #cfcde0);
    color: #fff;
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: .02em;
    text-shadow: 0 2px 6px rgba(30, 27, 46, .15);
}

.profile-card-name {
    margin: 0 0 .35rem;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--ink);
}

.profile-more {
    padding: 0 .25rem;
    color: var(--body);
    font-size: 1.25rem;
    line-height: 1;
}

.profile-more:hover,
.profile-more:focus {
    color: var(--ink);
}

.profile-card-line {
    margin: 0 0 .4rem;
    color: var(--body);
}

.profile-card-login {
    margin: 0;
    font-size: .82rem;
    color: var(--muted);
}

.profile-mini-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
}

.profile-mini-label {
    display: block;
    font-size: .8rem;
    color: var(--body);
}

.profile-mini-value {
    display: block;
    margin-top: .2rem;
    font-size: 1.3rem;
    font-weight: 500;
    color: var(--ink);
}

.profile-card-hint {
    margin: .75rem 0 0;
    font-size: .75rem;
    color: var(--faint);
}

.profile-section-title {
    margin: 0 0 1rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--ink);
}

.profile-section-subtitle {
    margin: 0 0 1rem;
    font-size: .95rem;
    font-weight: 500;
    color: var(--body);
}

.profile-info-list {
    margin: 0;
}

.profile-info-list > div {
    display: grid;
    grid-template-columns: 9rem minmax(0, 1fr);
    gap: 1rem;
    padding: .6rem 0;
    border-bottom: 1px solid var(--line);
}

.profile-info-list > div:last-child {
    border-bottom: 0;
}

.profile-info-list dt {
    font-weight: 400;
    color: var(--muted);
}

.profile-info-list dd {
    margin: 0;
    color: var(--ink);
}

.profile-access-icon {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 2.6rem;
    height: 2.6rem;
    border-radius: 50%;
    background: var(--brand-tint);
    color: var(--brand-strong);
    font-size: 1.15rem;
}

/* "Leaves Taken", "Pending Leave Applications", ... - a title, a muted
   icon on the right and a big brand number, the whole card a link. */
.profile-stat-card {
    color: inherit;
    text-decoration: none;
    transition: transform .15s ease, box-shadow .15s ease;
}

a.profile-stat-card:hover {
    color: inherit;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.profile-stat-card .card-body {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 9.5rem;
    padding: 1.35rem 1.25rem;
}

.profile-stat-title {
    max-width: calc(100% - 2.25rem);
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.35;
    color: var(--ink);
    overflow-wrap: normal;
    word-break: normal;
}

.profile-stat-help {
    margin-left: .2rem;
    font-size: .95rem;
    color: var(--label);
    cursor: help;
}

.profile-stat-icon {
    position: absolute;
    top: 50%;
    right: 1.25rem;
    transform: translateY(-50%);
    font-size: 1.35rem;
    color: var(--faint);
}

.profile-stat-value {
    margin-top: auto;
    padding-top: 1rem;
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--brand-strong);
}

.profile-stat-note {
    margin-left: .5rem;
    font-size: .75rem;
    font-weight: 400;
    color: var(--muted);
}

.profile-activity {
    min-height: 20rem;
}

.profile-activity-head {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--line);
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--ink);
}

.profile-activity-body {
    padding: 1.25rem 1.5rem;
}

.activity-feed {
    margin: 0 0 1rem;
    padding: 0;
    list-style: none;
}

.activity-feed li {
    position: relative;
    display: flex;
    gap: .75rem;
    padding-bottom: 1rem;
}

/* The line joining one entry's dot to the next. */
.activity-feed li:not(:last-child)::before {
    content: "";
    position: absolute;
    top: .9rem;
    bottom: 0;
    left: .3rem;
    border-left: 1px solid var(--line);
}

.activity-feed-dot {
    flex: 0 0 auto;
    width: .65rem;
    height: .65rem;
    margin-top: .35rem;
    border-radius: 50%;
    background: var(--brand-soft);
    box-shadow: 0 0 0 3px var(--brand-tint);
}

.activity-feed-text {
    font-size: .875rem;
    color: var(--ink);
}

.activity-feed-time {
    font-size: .75rem;
    color: var(--muted);
}

/* -- Leaves tab ----------------------------------------------------- */

.profile-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.profile-filter {
    flex: 0 1 15rem;
    min-width: 10rem;
}

.profile-filter-search {
    flex-basis: 16rem;
}

/* -- Leaves Quota tab ----------------------------------------------- */

.quota-manage-link {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    margin-bottom: 1rem;
    font-weight: 500;
    text-decoration: none;
}

.quota-block {
    margin-bottom: 1rem;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.quota-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) repeat(3, minmax(0, 1fr)) 5rem;
    align-items: center;
    gap: 1rem;
    padding: .7rem 1.5rem;
}

.quota-grid-head {
    border-bottom: 1px solid var(--line);
    font-size: .85rem;
    color: var(--muted);
}

.quota-dot {
    display: inline-block;
    flex: 0 0 auto;
    width: .9rem;
    height: .9rem;
    border-radius: 50%;
}

.quota-log-btn {
    min-width: 4.5rem;
    font-weight: 600;
}

.quota-save-btn {
    width: 2.6rem;
    height: 2.6rem;
    padding: 0;
}

@media (max-width: 767.98px) {
    .quota-grid-head {
        display: none;
    }

    .quota-grid {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .quota-grid > [data-label]::before {
        content: attr(data-label) ": ";
        color: var(--muted);
    }
}

/* -- Permissions tab ------------------------------------------------ */

.perm-matrix thead th {
    background: var(--sunken);
    font-weight: 500;
    color: var(--body);
}

.perm-matrix th,
.perm-matrix td {
    padding: .85rem 1rem;
    white-space: nowrap;
}

.perm-module {
    font-weight: 500;
    color: var(--ink);
}

.perm-cell {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    min-width: 10.5rem;
    border-radius: 8px;
}

.perm-cell .form-select {
    border-color: transparent;
    background-color: transparent;
}

.perm-cell .form-select:hover,
.perm-cell .form-select:focus {
    border-color: var(--rule);
}

.perm-cell.is-on .form-select {
    color: var(--ok-text);
}

/* A custom (non role-default) choice. */
.perm-cell.is-overridden .form-select {
    border-color: var(--warn);
    background-color: var(--warn-bg);
    color: var(--warn-text);
    font-weight: 500;
}

.perm-static {
    min-width: 0;
    font-size: .85rem;
}

.perm-static.is-on {
    color: var(--ok-text);
}

.perm-static.is-off {
    color: var(--muted);
}

.perm-static.is-overridden {
    color: var(--warn-text);
}

.perm-none {
    color: var(--faint);
}

.perm-more {
    position: relative;
    color: var(--muted);
    text-decoration: none;
}

.perm-more:hover,
.perm-more.has-custom {
    color: var(--ink);
}

.perm-more-dot {
    position: absolute;
    top: .35rem;
    right: 0;
    width: .45rem;
    height: .45rem;
    border-radius: 50%;
    background: var(--warn);
}

.perm-more-menu {
    min-width: 22rem;
    padding: .5rem 0;
}

.perm-more-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .4rem 1rem;
    white-space: normal;
}

.perm-more-label {
    font-size: .85rem;
    color: var(--body);
}

/* ================================================================== */
/* 15. Holidays (admin/holidays/*)                                     */
/* ================================================================== */

/* The pages reuse section 14's full-width name header (.profile-shell /
   .profile-head). Under it, a second white strip holds the filters, with
   each label inline beside a borderless dropdown, like the reference. */
.holiday-filter-strip {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    margin: 0 calc(var(--profile-pad) * -1) var(--profile-pad);
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.holiday-filter {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin: 0;
    padding: .55rem 1.25rem;
    border-right: 1px solid var(--line);
}

.holiday-filter > span {
    color: var(--body);
    font-weight: 500;
}

.holiday-filter .form-select {
    width: auto;
    min-width: 7.5rem;
    border-color: transparent;
    background-color: transparent;
    font-weight: 500;
    color: var(--ink);
    box-shadow: none;
}

.holiday-filter .form-select:hover,
.holiday-filter .form-select:focus {
    border-color: var(--rule);
}

.holiday-filter-search {
    flex: 0 1 22rem;
}

@media (max-width: 575.98px) {
    .holiday-filter {
        flex: 1 1 50%;
        border-bottom: 1px solid var(--line);
    }

    .holiday-filter-search {
        flex-basis: 100%;
    }
}

/* List / calendar switch: two joined icon buttons, the active one dark. */
.view-toggle {
    display: inline-flex;
    border: 1px solid var(--rule);
    border-radius: 9px;
    overflow: hidden;
    background: var(--surface);
}

.view-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.5rem;
    color: var(--body);
    font-size: 1.1rem;
    text-decoration: none;
}

.view-toggle-btn + .view-toggle-btn {
    border-left: 1px solid var(--rule);
}

.view-toggle-btn:hover {
    color: var(--ink);
    background: var(--sunken);
}

.view-toggle-btn.active {
    background: var(--ink);
    color: #fff;
}

.row-action-btn {
    width: 2.1rem;
    height: 2.1rem;
    padding: 0;
}

.weekday-checks {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem 1rem;
}

.weekday-checks .form-check-inline {
    margin-right: 0;
}

.weekday-checks .form-check-input {
    width: 1.35rem;
    height: 1.35rem;
    margin-top: 0;
    margin-right: .5rem;
}

.weekday-checks .form-check-label {
    line-height: 1.35rem;
}

.holiday-row-remove {
    flex: 0 0 auto;
    width: 2.6rem;
}

.holiday-add-row {
    font-weight: 500;
}

/* The month calendar: 7 columns, Sunday first; holidays tinted. */
.holiday-calendar {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: .4rem;
}

.holiday-calendar-head {
    padding: .35rem 0;
    text-align: center;
    font-size: .8rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.holiday-calendar-cell {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    min-height: 5.75rem;
    padding: .5rem .6rem;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--surface);
}

.holiday-calendar-cell.is-blank {
    border-color: transparent;
    background: transparent;
}

.holiday-calendar-cell.is-holiday {
    border-color: var(--brand-soft);
    background: var(--brand-tint);
}

.holiday-calendar-cell.is-today {
    box-shadow: inset 0 0 0 2px var(--brand-strong);
}

.holiday-calendar-day {
    font-weight: 600;
    color: var(--ink);
}

.holiday-calendar-weekday {
    display: none;
    margin-left: .35rem;
    font-weight: 400;
    color: var(--muted);
}

.holiday-calendar-name {
    font-size: .8rem;
    font-weight: 500;
    line-height: 1.3;
    color: var(--brand-strong);
    text-decoration: none;
    overflow-wrap: anywhere;
}

/* On a phone the grid would be unreadable: show only the holidays, one per
   line, each with its weekday. */
@media (max-width: 575.98px) {
    .holiday-calendar {
        grid-template-columns: minmax(0, 1fr);
    }

    .holiday-calendar-head,
    .holiday-calendar-cell:not(.is-holiday) {
        display: none;
    }

    .holiday-calendar-cell {
        min-height: 0;
        flex-direction: row;
        justify-content: space-between;
    }

    .holiday-calendar-weekday {
        display: inline;
    }
}

/* ================================================================== */
/* 16. Booking an appointment (admin/appointments/create.php)          */
/* ================================================================== */

.booking-head {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid var(--line);
}

.booking-title {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--ink);
}

.booking-subtitle {
    margin: .15rem 0 0;
    font-size: .875rem;
    color: var(--body);
}

/* New patient form: each group of fields in its own bordered section with
   an icon chip heading. */
.booking-section {
    margin-bottom: 1.25rem;
    padding: 1rem 1.25rem 1.25rem;
    border: 1px solid var(--line);
    border-radius: 14px;
}

.booking-section-head {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: 1rem;
}

.booking-section-head h4 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--ink);
}

.booking-section-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 50%;
    background: var(--brand-tint);
    color: var(--brand-strong);
    font-size: 1.1rem;
}

.booking-optional {
    background: var(--brand-tint);
    color: var(--brand-strong);
    font-weight: 500;
}

.booking-section .form-control:not(textarea),
.booking-section .form-select {
    min-height: 2.9rem;
}

/* An icon pinned to the first line of a textarea instead of its middle. */
.input-icon.is-top > .bi {
    top: 1.45rem;
}

/* Separate pill buttons for a short single choice (gender), the chosen
   one filled with the brand colour. */
.choice-pills {
    display: flex;
    gap: .6rem;
}

.choice-pill {
    display: inline-flex;
    flex: 1 1 0;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    min-height: 2.9rem;
    padding: 0 .75rem;
    border: 1px solid var(--rule);
    border-radius: 9px;
    background: var(--surface);
    color: var(--label);
    font-weight: 500;
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}

.choice-pill:hover {
    border-color: var(--brand-soft);
    color: var(--ink);
}

.choice-pills .btn-check:checked + .choice-pill {
    border-color: var(--brand);
    background: var(--brand);
    color: #fff;
    box-shadow: var(--shadow-brand);
}

.choice-pills .btn-check:focus-visible + .choice-pill {
    outline: 2px solid var(--brand-soft);
    outline-offset: 2px;
}

/* Existing / New patient: soft pill tabs with icons, the active one tinted
   and underlined. Plain links - each mode is its own URL. */
.booking-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem;
    margin-bottom: 1.75rem;
    border-bottom: 1px solid var(--line);
}

.booking-tab {
    display: inline-flex;
    align-items: center;
    gap: .6rem;
    margin-bottom: -1px;
    padding: .7rem 1.6rem;
    border-radius: 11px 11px 0 0;
    border-bottom: 2px solid transparent;
    background: var(--sunken);
    color: var(--label);
    font-weight: 500;
    text-decoration: none;
    transition: background-color .15s ease, color .15s ease;
}

.booking-tab .bi {
    font-size: 1.1rem;
}

@media (max-width: 575.98px) {
    .booking-tabs {
        flex-wrap: nowrap;
    }

    .booking-tab {
        flex: 1 1 0;
        justify-content: center;
        padding: .7rem .5rem;
        white-space: nowrap;
    }
}

.booking-tab:hover {
    color: var(--ink);
    background: var(--line);
}

.booking-tab.active {
    background: var(--brand-tint);
    color: var(--brand-strong);
    border-bottom-color: var(--brand-strong);
}

/* The find box: a tall search field joined to a solid button. */
.booking-find-group .input-group-text,
.booking-find-group .form-control,
.booking-find-group .btn {
    min-height: 3rem;
}

.booking-find-group .input-group-text {
    padding: 0 1rem;
    background: var(--surface);
    color: var(--body);
    font-size: 1.1rem;
}

.booking-find-group .form-control {
    padding-left: 1rem;
    border-left: 1px solid var(--line);
}

.booking-find-group .btn {
    padding: 0 1.5rem;
    font-weight: 600;
}

.booking-empty {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    margin-top: 1.5rem;
    padding: 1rem 1.25rem;
    border: 1px dashed var(--rule);
    border-radius: 11px;
    background: var(--sunken);
}

.booking-empty > .bi {
    font-size: 1.6rem;
    color: var(--muted);
}

/* The chosen patient: who they are, then the three things worth a glance
   before booking (an existing booking, the last visit, unpaid bills). */
.booking-patient {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    overflow: hidden;
}

.booking-patient-main {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 1rem 1.25rem;
    padding: 1.25rem;
}

.booking-patient .min-w-0 {
    min-width: 0;
}

.booking-patient-photo {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 3.75rem;
    height: 3.75rem;
    border-radius: 12px;
    background: var(--brand-tint);
    color: var(--brand-strong);
    font-size: 1.25rem;
    font-weight: 700;
    object-fit: cover;
}

.booking-patient-name {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--ink);
}

.booking-patient-meta {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem 1.1rem;
    margin-top: .4rem;
    font-size: .85rem;
    color: var(--body);
}

.booking-patient-meta .bi {
    color: var(--muted);
}

.booking-patient-alert {
    display: inline-flex;
    gap: .4rem;
    margin-top: .6rem;
    padding: .25rem .65rem;
    border-radius: 999px;
    background: var(--danger-bg);
    color: var(--danger-text);
    font-size: .8rem;
    font-weight: 500;
}

.booking-patient-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .25rem;
    margin-left: auto;
}

.booking-patient-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    border-top: 1px solid var(--line);
    background: var(--sunken);
}

.booking-patient-stats > div {
    display: flex;
    flex-direction: column;
    gap: .15rem;
    padding: .85rem 1.25rem;
}

.booking-patient-stats > div + div {
    border-left: 1px solid var(--line);
}

.booking-stat-label {
    font-size: .75rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.booking-stat-value {
    font-weight: 600;
    color: var(--ink);
    text-decoration: none;
}

.booking-stat-note {
    font-size: .75rem;
    color: var(--muted);
}

.booking-patient-stats .is-warning .booking-stat-value,
.booking-patient-stats .is-warning .booking-stat-note {
    color: var(--warn-text);
}

.booking-patient-stats .is-danger .booking-stat-value {
    color: var(--danger-text);
}

@media (max-width: 767.98px) {
    .booking-patient-stats {
        grid-template-columns: minmax(0, 1fr);
    }

    .booking-patient-stats > div + div {
        border-left: 0;
        border-top: 1px solid var(--line);
    }

    .booking-patient-actions {
        margin-left: 0;
    }
}

/* ------------------------------------------------------------------ */
/* Floating toast, top-right (the sign-in welcome). Same look as the   */
/* "Logged out" toast on the login page (.login-toast in login.css).   */
/* ------------------------------------------------------------------ */

@keyframes appToastIn {
    from { opacity: 0; transform: translateX(24px); }
    to   { opacity: 1; transform: none; }
}

@keyframes appToastOut {
    to { opacity: 0; transform: translateX(24px); }
}

/* Its 5s matches TOAST_MS in app.js; both pause while hovered. */
@keyframes appToastTimer {
    from { transform: scaleX(1); }
    to   { transform: scaleX(0); }
}

.app-toast-stack {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 1090;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(360px, calc(100vw - 32px));
    pointer-events: none;
}

/* One accent per message type; success is the default. */
.app-toast {
    --toast-accent: var(--ok);
    --toast-tint: #d1fae5;
    --toast-text: var(--ok-text);
}

.app-toast.is-error {
    --toast-accent: var(--danger);
    --toast-tint: var(--danger-bg);
    --toast-text: var(--danger-text);
}

.app-toast.is-warning {
    --toast-accent: var(--warn);
    --toast-tint: var(--warn-bg);
    --toast-text: var(--warn-text);
}

.app-toast.is-info {
    --toast-accent: var(--info);
    --toast-tint: var(--info-bg);
    --toast-text: var(--info-text);
}

.app-toast {
    position: relative;
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
    padding: 14px 14px 14px 16px;
    border-radius: 14px;
    border-left: 4px solid var(--toast-accent);
    background: var(--surface);
    box-shadow: 0 18px 40px -16px rgba(30, 27, 46, .35), 0 2px 6px rgba(30, 27, 46, .06);
    overflow: hidden;
    animation: appToastIn .45s cubic-bezier(.16, 1, .3, 1) .3s both;
}

.app-toast.is-leaving {
    animation: appToastOut .3s ease forwards;
}

.app-toast__icon {
    flex: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--toast-tint);
    color: var(--toast-text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
}

.app-toast__body {
    flex: 1;
    min-width: 0;
    padding-top: 1px;
}

.app-toast__label {
    display: block;
    margin-bottom: 2px;
    font: 600 10.5px var(--mono);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--toast-text);
}

.app-toast__body p {
    margin: 0;
    font: 400 14px/1.45 var(--sans);
    color: var(--ink);
}

.app-toast__close {
    flex: none;
    width: 28px;
    height: 28px;
    margin: -2px -2px 0 0;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--muted);
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color .15s ease, color .15s ease;
}

.app-toast__close:hover,
.app-toast__close:focus-visible {
    background: var(--line);
    color: var(--ink);
}

.app-toast__timer {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 1.5px;
    background: var(--toast-accent);
    opacity: .75;
    transform-origin: left;
    animation: appToastTimer 5s linear .3s both;
}

.app-toast:hover .app-toast__timer {
    animation-play-state: paused;
}

@media (max-width: 480px) {
    .app-toast-stack {
        top: 16px;
        right: 16px;
    }
}

/* Respect the visitor's motion preference. */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }

    /* The countdown line is a timer, not decoration: keep it running. */
    .app-toast__timer {
        animation-duration: 5s !important;
    }
}

/* ================================================================== */
/* Working hours (Clinic > Working hours, and the booking form hint)   */
/* ================================================================== */

.wh-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 4px 0 16px;
    padding: 7px 14px;
    border-radius: 99px;
    font-size: 0.85rem;
    font-weight: 600;
}

.wh-status.is-open {
    background: var(--ok-bg);
    color: var(--ok-text);
}

.wh-status.is-closed {
    background: var(--danger-bg);
    color: var(--danger-text);
}

.wh-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

.wh-list {
    padding: 4px 0;
}

.wh-row {
    display: grid;
    grid-template-columns: 170px 130px 1fr;
    align-items: center;
    gap: 6px 16px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--line);
}

.wh-row:last-child {
    border-bottom: 0;
}

.wh-row.is-today {
    background: var(--brand-tint);
}

.wh-day {
    display: flex;
    align-items: center;
    gap: 8px;
}

.wh-day strong {
    color: var(--ink);
    font-weight: 600;
}

.wh-today {
    padding: 1px 8px;
    border-radius: 99px;
    background: var(--brand);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
}

.wh-switch {
    margin: 0;
}

.wh-switch .form-check-label {
    font-size: 0.875rem;
    color: var(--body);
}

.wh-times {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 380px;
    transition: opacity .15s ease;
}

.wh-times > div {
    flex: 1;
}

.wh-dash {
    font-size: 0.82rem;
    color: var(--muted);
}

.wh-row.is-closed .wh-times {
    opacity: .35;
}

.wh-errors {
    grid-column: 3;
}

.wh-errors:empty {
    display: none;
}

.wh-label {
    grid-column: 2 / -1;
    color: var(--ink);
}

/* Booking form hint (data-working-hours) */
.wh-hint {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 10px;
    background: var(--paper);
    color: var(--body);
    font-size: 0.85rem;
}

.wh-hint[hidden] {
    display: none;
}

.wh-hint.is-warning {
    background: var(--warn-bg);
    color: var(--warn-text);
}

@media (max-width: 767.98px) {
    .wh-row {
        grid-template-columns: 1fr auto;
        padding: 12px 14px;
    }

    .wh-times,
    .wh-errors,
    .wh-label {
        grid-column: 1 / -1;
        max-width: none;
    }
}

/* Working hours: total per day and per week */
.wh-total {
    flex: none;
    min-width: 92px;
    padding: 4px 10px;
    border-radius: 99px;
    background: var(--brand-tint);
    color: var(--brand-deep);
    font-size: 0.8rem;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
}

.wh-row.is-closed .wh-total {
    background: var(--paper);
    color: var(--muted);
}

.wh-label .wh-total {
    margin-left: 10px;
}

.wh-times {
    max-width: 500px;
}

.wh-week-total {
    font-size: 0.875rem;
    color: var(--muted);
}

.wh-week-total strong {
    color: var(--ink);
}

.wh-row.is-today .wh-total {
    background: #fff;
}

/* Working hours: a time is [8:00 v][PM v] */
.wh-time {
    display: flex;
    gap: 6px;
    flex: 1;
}

.wh-time .wh-time-hm {
    flex: 1;
    min-width: 92px;
}

.wh-time .wh-time-ap {
    flex: none;
    width: 82px;
}

.wh-times {
    max-width: 560px;
}

/* ================================================================== */
/* Doctor details (user form, Doctors list, profile)                   */
/* ================================================================== */

.doctor-box {
    padding: 16px 18px 18px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--paper);
}

.doctor-box-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.doctor-box-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--brand-tint);
    color: var(--brand-deep);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
}

.doctor-box-title {
    font-weight: 600;
    color: var(--ink);
}

.doctor-code {
    display: inline-flex;
    align-items: center;
    height: 38px;
    padding: 0 14px;
    border-radius: 10px;
    background: var(--brand-tint);
    color: var(--brand-deep);
    font: 600 14px var(--mono);
    letter-spacing: .04em;
}

.doctor-code.is-pending {
    background: var(--surface);
    border: 1px dashed var(--rule);
    color: var(--muted);
}

.doctor-code.is-small {
    height: 24px;
    padding: 0 8px;
    border-radius: 7px;
    font-size: 12px;
}

/* ================================================================== */
/* Billing reports (Outstanding, Daily collection)                     */
/* ================================================================== */

.bill-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.bill-card {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
}

.bill-card.is-primary {
    background: var(--brand-tint);
    border-color: transparent;
}

.bill-card-label {
    font: 500 10.5px var(--mono);
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--label);
}

.bill-card-value {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--ink);
}

.bill-card-value small {
    font-size: .8rem;
    font-weight: 500;
    color: var(--muted);
}

.bill-card.is-primary .bill-card-value {
    color: var(--brand-deep);
}

.bill-card-sub {
    font-size: .78rem;
    color: var(--muted);
}

.bill-buckets {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
}

.bill-bucket {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    border-radius: 11px;
    border: 1px solid transparent;
    font-size: .82rem;
    text-decoration: none;
    color: var(--body);
    background: var(--paper);
}

.bill-bucket strong {
    color: var(--ink);
}

.bill-bucket.is-active {
    border-color: currentColor;
    box-shadow: 0 0 0 2px var(--brand-tint);
}

.bill-bucket.is-green,
.bill-age.is-green { background: var(--ok-bg); color: var(--ok-text); }
.bill-bucket.is-amber,
.bill-age.is-amber { background: var(--warn-bg); color: var(--warn-text); }
.bill-bucket.is-orange,
.bill-age.is-orange { background: #ffedd5; color: #c2410c; }
.bill-bucket.is-red,
.bill-age.is-red { background: var(--danger-bg); color: var(--danger-text); }

.bill-age {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 99px;
    font-size: .78rem;
    font-weight: 600;
    white-space: nowrap;
}

.bill-switch {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    border-radius: 11px;
    background: var(--paper);
}

.bill-switch a {
    padding: 6px 14px;
    border-radius: 8px;
    font-size: .85rem;
    font-weight: 500;
    color: var(--body);
    text-decoration: none;
    white-space: nowrap;
}

.bill-switch a.is-active {
    background: #fff;
    color: var(--ink);
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(30, 27, 46, .08);
}

.bill-total-row td {
    font-weight: 700;
    background: var(--paper);
}

/* ------------------------------------------------------------------
   Lab works (admin/lab-works/*, admin/labs/*)
   ------------------------------------------------------------------ */
a.bill-card { color: inherit; transition: border-color .15s, box-shadow .15s; }
a.bill-card:hover { border-color: var(--brand-soft); box-shadow: 0 2px 10px rgba(99, 102, 241, .08); }
.bill-card.is-danger { background: var(--danger-bg); border-color: transparent; }
.bill-card.is-danger .bill-card-value { color: var(--danger); }

.lw-label {
    font: 500 10.5px var(--mono);
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 2px;
}
.lw-note { white-space: normal; background: #f8f8fb; border-radius: 10px; padding: 10px 12px; }

.lw-tooth {
    display: inline-block;
    min-width: 26px;
    padding: 1px 6px;
    margin: 0 3px 3px 0;
    border-radius: 6px;
    background: var(--brand-tint);
    color: var(--brand-deep);
    font-size: 12px;
    font-weight: 600;
    text-align: center;
}

.lw-status {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.lw-status.is-blue  { background: #e0ecff; color: #1d4ed8; }
.lw-status.is-amber { background: #fef3c7; color: #b45309; }
.lw-status.is-green { background: #dcfce7; color: #15803d; }
.lw-status.is-grey  { background: #f1f1f4; color: #6b6880; }

.lw-svc-edit { background: #fafafe; }
.lw-svc-add { background: #fcfcfe; }

/* Teeth picker on the lab work form */
.lw-teeth-switch { display: inline-flex; padding: 2px; border-radius: 8px; background: #f1f1f6; }
.lw-teeth-switch button {
    border: 0;
    background: transparent;
    padding: 2px 12px;
    border-radius: 6px;
    font-size: 12.5px;
    color: var(--label);
}
.lw-teeth-switch button.is-active { background: #fff; color: var(--brand-deep); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }

.lw-teeth { overflow-x: auto; padding-bottom: 2px; }
.lw-teeth-row { display: flex; align-items: center; gap: 4px; margin-bottom: 4px; min-width: max-content; }
.lw-teeth-jaw { width: 46px; font-size: 11.5px; color: var(--muted); }
.lw-teeth-mid { width: 1px; align-self: stretch; margin: 0 4px; background: var(--brand-soft); }
.lw-tooth-pick { margin: 0; cursor: pointer; }
.lw-tooth-pick input { position: absolute; opacity: 0; pointer-events: none; }
.lw-tooth-pick span {
    display: inline-block;
    width: 34px;
    padding: 5px 0;
    border: 1px solid #e4e3ec;
    border-radius: 8px;
    background: #fff;
    text-align: center;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--label);
    transition: background .12s, border-color .12s, color .12s;
}
.lw-tooth-pick:hover span { border-color: var(--brand-soft); }
.lw-tooth-pick input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; }
.lw-tooth-pick input:focus-visible + span { outline: 2px solid var(--brand-soft); outline-offset: 1px; }

/* Lab work progress timeline */
.lw-timeline { list-style: none; padding: 0; margin: 0 0 14px; }
.lw-timeline li { position: relative; display: flex; gap: 12px; padding-bottom: 14px; color: var(--muted); }
.lw-timeline li:not(:last-child)::before {
    content: "";
    position: absolute;
    left: 15px;
    top: 32px;
    bottom: 2px;
    width: 2px;
    background: #ececf2;
}
.lw-timeline li > i {
    flex: 0 0 32px;
    height: 32px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #f1f1f6;
}
.lw-timeline li.is-done { color: var(--ink); }
.lw-timeline li.is-done > i { background: var(--brand-tint); color: var(--brand-deep); }
.lw-timeline li.is-done:not(:last-child)::before { background: var(--brand-soft); }
.lw-timeline li.is-cancelled > i { background: var(--danger-bg); color: var(--danger); }
.lw-timeline li.is-cancelled { color: var(--ink); }
.lw-step-form { border-top: 1px solid var(--line); padding-top: 12px; }
.lw-lab-cell { min-width: 140px; }
.lw-item-cell { min-width: 140px; }

/* ------------------------------------------------------------------ */
/* Date picker (flatpickr on every date field, see app.js)            */
/* ------------------------------------------------------------------ */

.flatpickr-calendar {
    width: 300px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: 0 18px 40px -16px rgba(30, 27, 46, .3), 0 2px 6px rgba(30, 27, 46, .05);
    font-family: var(--sans);
}

.flatpickr-calendar.arrowTop::before,
.flatpickr-calendar.arrowTop::after,
.flatpickr-calendar.arrowBottom::before,
.flatpickr-calendar.arrowBottom::after {
    display: none;
}

.flatpickr-months {
    align-items: center;
    margin-bottom: 6px;
}

.flatpickr-months .flatpickr-month {
    height: 36px;
    color: var(--ink);
    fill: var(--ink);
}

.flatpickr-current-month {
    padding-top: 6px;
    font-size: 15px;
    font-weight: 700;
}

.flatpickr-current-month .flatpickr-monthDropdown-months,
.flatpickr-current-month input.cur-year {
    font-weight: 700;
    color: var(--ink);
    border-radius: 8px;
}

.flatpickr-current-month .flatpickr-monthDropdown-months:hover,
.flatpickr-current-month input.cur-year:hover {
    background: var(--sunken);
}

.flatpickr-months .flatpickr-prev-month,
.flatpickr-months .flatpickr-next-month {
    top: 10px;
    height: 32px;
    width: 32px;
    padding: 9px;
    border-radius: 9px;
    color: var(--body);
    fill: var(--body);
}

.flatpickr-months .flatpickr-prev-month { left: 10px; }
.flatpickr-months .flatpickr-next-month { right: 10px; }

.flatpickr-months .flatpickr-prev-month:hover,
.flatpickr-months .flatpickr-next-month:hover {
    background: var(--brand-tint);
}

.flatpickr-months .flatpickr-prev-month:hover svg,
.flatpickr-months .flatpickr-next-month:hover svg {
    fill: var(--brand-strong);
}

.flatpickr-innerContainer,
.flatpickr-rContainer,
.flatpickr-days,
.dayContainer {
    width: 100%;
    min-width: 0;
    max-width: none;
}

span.flatpickr-weekday {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
}

.flatpickr-day {
    max-width: none;
    height: 38px;
    line-height: 38px;
    border-radius: 10px;
    color: var(--ink);
    font-size: 13.5px;
}

.flatpickr-day:hover,
.flatpickr-day:focus {
    background: var(--brand-tint);
    border-color: var(--brand-tint);
}

.flatpickr-day.today {
    border-color: var(--brand-soft);
    color: var(--brand-strong);
    font-weight: 600;
}

.flatpickr-day.today:hover,
.flatpickr-day.today:focus {
    background: var(--brand-tint);
    border-color: var(--brand-soft);
    color: var(--brand-strong);
}

.flatpickr-day.selected,
.flatpickr-day.selected:hover,
.flatpickr-day.selected:focus {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
    font-weight: 600;
    box-shadow: var(--shadow-brand);
}

.flatpickr-day.prevMonthDay,
.flatpickr-day.nextMonthDay {
    color: var(--faint);
}

.flatpickr-day.flatpickr-disabled,
.flatpickr-day.flatpickr-disabled:hover {
    color: #d6d4df;
    background: none;
    border-color: transparent;
}

/* Time-only picker (input type="time") */
.flatpickr-calendar.noCalendar {
    width: 240px;
    padding: 8px;
}

.flatpickr-calendar.hasTime .flatpickr-time {
    height: 48px;
    max-height: 48px;
    line-height: 48px;
    border-top: 0;
}

.flatpickr-time input,
.flatpickr-time .flatpickr-am-pm {
    font-family: var(--sans);
    font-size: 20px;
    color: var(--ink);
    border-radius: 10px;
}

.flatpickr-time input.flatpickr-hour,
.flatpickr-time input.flatpickr-minute {
    font-weight: 700;
}

.flatpickr-time .flatpickr-time-separator {
    color: var(--muted);
    font-weight: 700;
}

.flatpickr-time .flatpickr-am-pm {
    font-size: 15px;
    font-weight: 600;
    color: var(--brand-strong);
}

.flatpickr-time input:hover,
.flatpickr-time input:focus,
.flatpickr-time .flatpickr-am-pm:hover,
.flatpickr-time .flatpickr-am-pm:focus {
    background: var(--brand-tint);
}

.flatpickr-time .numInputWrapper span.arrowUp::after {
    border-bottom-color: var(--brand-strong);
}

.flatpickr-time .numInputWrapper span.arrowDown::after {
    border-top-color: var(--brand-strong);
}

/* ------------------------------------------------------------------ */
/* New treatment form: one card per treatment row                      */
/* ------------------------------------------------------------------ */

.treatment-row {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 16px 18px 18px;
    margin-bottom: 16px;
    background: var(--surface);
}

.treatment-row-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    min-height: 31px;
}

.treatment-row-title {
    font-weight: 700;
    font-size: 14px;
    color: var(--brand-strong);
}

/* ------------------------------------------------------------------ */
/* Visits: every record belongs to an appointment                      */
/* ------------------------------------------------------------------ */

/* "Visit APT-2026-0009 · 19-10-2026, 12:00 PM" on a record's form/page. */
.visit-badge {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 12px;
    margin-bottom: 14px;
    border-radius: 10px;
    background: var(--brand-tint);
    color: var(--brand-deep);
    font-size: 13px;
}

.visit-badge span {
    font-weight: 600;
}

.visit-badge a {
    color: var(--brand-strong);
    font-weight: 600;
    text-decoration: none;
}

.visit-pick {
    max-width: 720px;
}

.visit-pick-empty {
    padding: 18px;
    border: 1px dashed var(--rule);
    border-radius: 12px;
    text-align: center;
}

/* A record's visit code in a list (e.g. on the patient profile). */
.visit-code {
    display: inline-block;
    font-family: var(--mono);
    font-size: 11.5px;
    color: var(--brand-strong);
    text-decoration: none;
}

/* Appointment page: the visit workspace (admin/appointments/visit.php). */
.visit-closed-note {
    margin: 12px 16px 0;
    padding: 8px 12px;
    border-radius: 10px;
    background: var(--warn-bg);
    color: var(--warn-text);
    font-size: 13px;
}

.visit-upload {
    margin: 12px 16px 16px;
    padding: 14px 16px;
    border: 1px dashed var(--rule);
    border-radius: 12px;
}

.visit-upload-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 10px;
}

/* ------------------------------------------------------------------ */
/* Bulk attendance (admin/attendance/bulk.php)                         */
/* ------------------------------------------------------------------ */

.bulk-att-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 1rem 1.25rem;
}

.bulk-att-filter {
    flex: 0 1 16rem;
}

.bulk-att-intro {
    flex: 1 1 18rem;
    margin: 0;
    color: var(--body);
    font-size: .85rem;
}

/* No staff member chosen yet: a big icon and one chip per employee. */
.bulk-att-pick {
    padding: 2.5rem 1.5rem;
    text-align: center;
}

.bulk-att-pick-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3.25rem;
    height: 3.25rem;
    margin-bottom: .75rem;
    border-radius: 50%;
    background: var(--brand-tint);
    color: var(--brand-strong);
    font-size: 1.4rem;
}

.bulk-att-pick-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: .5rem;
}

.bulk-att-pick-chip {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .3rem .9rem .3rem .3rem;
    border: 1px solid var(--rule);
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink);
    font-weight: 500;
    text-decoration: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.bulk-att-pick-chip:hover {
    border-color: var(--brand-soft);
    box-shadow: var(--shadow-md);
    color: var(--ink);
}

.bulk-att-avatar {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 1.9rem;
    height: 1.9rem;
    border-radius: 50%;
    background: var(--brand-tint);
    color: var(--brand-strong);
    font-size: .72rem;
    font-weight: 700;
}

.bulk-att-avatar.is-lg {
    width: 2.6rem;
    height: 2.6rem;
    font-size: .9rem;
}

/* Who and which month on the left, the "mark all" tools on the right. */
.bulk-att-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--line);
}

.bulk-att-who {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.bulk-att-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
}

.bulk-att-apply {
    display: flex;
    align-items: center;
    gap: .4rem;
    padding: .25rem .25rem .25rem .5rem;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: var(--sunken);
}

.bulk-att-apply .form-control {
    width: 7.5rem;
}

/* The day rows: one grid, with the header row sharing its columns. */
.bulk-att-head,
.bulk-att-row {
    display: grid;
    grid-template-columns: minmax(13rem, 1.6fr) 13rem 8.5rem 8.5rem minmax(8rem, 1.2fr) 4.5rem;
    align-items: center;
    gap: .75rem;
    padding: .65rem 1.25rem;
}

.bulk-att-head {
    padding-block: .55rem;
    background: var(--sunken);
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.bulk-att-row {
    border-bottom: 1px solid var(--line);
    transition: background-color .15s ease;
}

.bulk-att-row:last-child {
    border-bottom: 0;
}

.bulk-att-row.is-closed,
.bulk-att-row.is-holiday {
    background: #fbfbfd;
}

.bulk-att-row.is-changed {
    background: #f7f7ff;
    box-shadow: inset 3px 0 0 var(--brand);
}

.bulk-att-row.is-removing {
    background: #fff7f7;
    box-shadow: inset 3px 0 0 var(--danger);
}

.bulk-att-row.has-error {
    box-shadow: inset 3px 0 0 var(--danger);
}

.bulk-att-date {
    display: flex;
    align-items: center;
    gap: .75rem;
    min-width: 0;
}

.bulk-att-daynum {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 10px;
    background: var(--brand-tint);
    color: var(--brand-strong);
    font-weight: 700;
}

.bulk-att-row.is-off .bulk-att-daynum {
    background: var(--sunken);
    color: var(--muted);
}

.bulk-att-weekday {
    display: block;
    color: var(--ink);
    font-weight: 600;
}

.bulk-att-tags {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem;
    margin-top: .15rem;
}

.bulk-att-tag {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    padding: .05rem .5rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 500;
    white-space: nowrap;
}

.bulk-att-tag[hidden] {
    display: none;
}

.bulk-att-tag.is-holiday  { background: var(--warn-bg);    color: var(--warn-text); }
.bulk-att-tag.is-closed   { background: var(--sunken);     color: var(--body); border: 1px solid var(--line); }
.bulk-att-tag.is-leave    { background: var(--info-bg);    color: var(--info-text); }
.bulk-att-tag.is-saved    { background: var(--ok-bg);      color: var(--ok-text); }
.bulk-att-tag.is-edited   { background: var(--brand-tint); color: var(--brand-strong); }
.bulk-att-tag.is-removing { background: var(--danger-bg);  color: var(--danger-text); }

/* Present / Absent as one segmented control. */
.bulk-att-status {
    display: inline-flex;
    padding: 3px;
    border: 1px solid var(--rule);
    border-radius: 10px;
    background: var(--sunken);
}

.bulk-att-pill {
    display: inline-flex;
    flex: 1 1 0;
    align-items: center;
    justify-content: center;
    gap: .3rem;
    min-width: 5.9rem;
    margin: 0;
    padding: .35rem .6rem;
    border-radius: 8px;
    color: var(--body);
    font-size: .82rem;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    transition: background-color .15s ease, color .15s ease, box-shadow .15s ease;
}

.bulk-att-pill:hover {
    color: var(--ink);
}

.bulk-att-status .btn-check:checked + .bulk-att-pill.is-present {
    background: var(--ok);
    color: #fff;
    box-shadow: 0 6px 14px -8px rgba(16, 185, 129, .8);
}

.bulk-att-status .btn-check:checked + .bulk-att-pill.is-absent {
    background: var(--surface);
    color: var(--danger-text);
    box-shadow: var(--shadow-sm);
}

.bulk-att-status .btn-check:focus-visible + .bulk-att-pill {
    outline: 2px solid var(--brand-soft);
    outline-offset: 1px;
}

.bulk-att-row.is-off .bulk-att-time .form-control,
.bulk-att-row.is-off .bulk-att-note .form-control {
    background: var(--sunken);
    color: var(--faint);
}

.bulk-att-hours {
    color: var(--body);
    font-size: .8rem;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.bulk-att-mobile-label {
    display: none;
}

/* The summary and Save button stay at the bottom of the screen. */
.bulk-att-footer {
    position: sticky;
    bottom: 0;
    z-index: 5;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    margin-top: 1rem;
    padding: .85rem 1.25rem;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255, 255, 255, .96);
    box-shadow: 0 -10px 30px -18px rgba(30, 27, 46, .35);
    backdrop-filter: blur(6px);
}

.bulk-att-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .4rem 1.1rem;
    color: var(--body);
}

.bulk-att-summary strong {
    color: var(--ink);
    font-size: 1.05rem;
    font-variant-numeric: tabular-nums;
}

.bulk-att-summary-changes {
    padding: .15rem .6rem;
    border-radius: 999px;
    background: var(--sunken);
    color: var(--muted);
    font-size: .78rem;
}

.bulk-att-summary-changes.is-pending {
    background: var(--brand-tint);
    color: var(--brand-strong);
    font-weight: 600;
}

/* Below a laptop width, each day becomes a small card. */
@media (max-width: 1100px) {
    .bulk-att-head {
        display: none;
    }

    .bulk-att-row {
        grid-template-columns: 1fr 1fr;
        gap: .6rem .75rem;
        padding: 1rem;
    }

    .bulk-att-date,
    .bulk-att-note,
    .bulk-att-status {
        grid-column: 1 / -1;
    }

    .bulk-att-status {
        justify-self: start;
    }

    .bulk-att-hours {
        display: none;
    }

    .bulk-att-mobile-label {
        display: block;
        margin-bottom: .2rem;
        color: var(--muted);
        font-size: .72rem;
    }
}

/* ------------------------------------------------------------------ */
/* Treatment plans (admin/treatment-plans/*)                           */
/* ------------------------------------------------------------------ */

/* Who the plan is for, and the visit it starts at. */
.plan-for {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .75rem 1rem;
    margin-bottom: 1.5rem;
    padding: .9rem 1rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--sunken);
}

.plan-for-visit {
    padding-left: 1rem;
    border-left: 1px solid var(--rule);
}

/* The form, as numbered sections. */
.plan-section + .plan-section {
    margin-top: 1.75rem;
    padding-top: 1.75rem;
    border-top: 1px solid var(--line);
}

.plan-section-head {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    margin-bottom: 1.1rem;
}

.plan-section-head h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
}

.plan-section-head p {
    margin: .1rem 0 0;
    color: var(--body);
    font-size: .85rem;
}

.plan-section-num {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    background: var(--brand-tint);
    color: var(--brand-strong);
    font-size: .85rem;
    font-weight: 700;
}

.plan-quick {
    display: flex;
    gap: .35rem;
    margin-top: .4rem;
}

.plan-quick-btn {
    padding: .1rem .55rem;
    border: 1px solid var(--rule);
    border-radius: 999px;
    background: var(--surface);
    color: var(--body);
    font-size: .75rem;
}

.plan-quick-btn:hover {
    border-color: var(--brand-soft);
    color: var(--brand-strong);
}

/* The plan page. */
.plan-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    gap: 1rem;
}

.plan-patient {
    display: inline-flex;
    align-items: center;
    gap: .65rem;
    margin-bottom: 1rem;
    color: inherit;
    text-decoration: none;
}

.plan-patient:hover .fw-semibold {
    color: var(--brand-strong);
}

.plan-facts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
    gap: .75rem 1rem;
    margin: 0;
}

.plan-facts dt {
    color: var(--muted);
    font-size: .75rem;
    font-weight: 500;
}

.plan-facts dd {
    margin: 0;
    font-weight: 600;
}

.plan-progress {
    margin-top: 1.1rem;
}

.plan-progress .progress,
.plan-paid-bar {
    height: .5rem;
    border-radius: 999px;
}

.plan-fee {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

.plan-money {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .5rem;
}

.plan-money > div {
    padding: .55rem .7rem;
    border-radius: 10px;
    background: var(--sunken);
}

.plan-money span {
    display: block;
    color: var(--muted);
    font-size: .75rem;
}

.plan-money strong {
    font-variant-numeric: tabular-nums;
}

.plan-visit-num {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: var(--brand-tint);
    color: var(--brand-strong);
    font-size: .8rem;
    font-weight: 700;
}

/* "Ongoing: Metal braces · ..." under a patient's header, and the chip on a
   visit that belongs to a plan. */
.plan-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem 1rem;
    margin-bottom: 1rem;
    padding: .7rem 1rem;
    border: 1px solid #c7d2fe;
    border-radius: 12px;
    background: var(--brand-tint);
}

.plan-banner > .bi {
    color: var(--brand-strong);
    font-size: 1.1rem;
}

.plan-banner a {
    margin-left: auto;
    font-weight: 600;
    text-decoration: none;
}

.plan-chip {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .2rem .65rem;
    border-radius: 999px;
    background: var(--brand-tint);
    color: var(--brand-strong);
    font-size: .8rem;
    font-weight: 600;
    text-decoration: none;
}

.plan-chip:hover {
    color: var(--brand-deep);
}

@media (max-width: 991px) {
    .plan-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 640px) {
    .plan-for-visit {
        padding-left: 0;
        border-left: 0;
    }
}
