﻿/* =============================================================================
 * NLVP — Administrator Portal (Concept C · "Deep Rail")
 * Drop into: wwwroot/css/nlvp.css
 *
 * Layered on top of Bootstrap 5. All component selectors use the
 *   .nlvp-*   prefix (sidebar, topbar, kpi, etc.).
 *
 * Variables intentionally mirror the patient-portal nlvp.css palette so the two
 * stylesheets can co-exist or be merged. Override here only if you want the
 * admin tool to diverge later.
 * ============================================================================= */

:root {
    /* Core brand greens */
    --nlvp-primary:    #6FA86E;
    --nlvp-deep:       #467050;
    --nlvp-sage:       #8EC48A;
    --nlvp-sage-tint:  #E5F2E3;

    /* Supporting blue */
    --nlvp-blue:       #2C7BE5;
    --nlvp-blue-hover: #1F60C2;
    --nlvp-blue-tint:  #E3F2FD;

    /* Neutrals */
    --nlvp-white:      #FFFFFF;
    --nlvp-grey:       #F5F7F9;
    --nlvp-line:       #E5E9EE;
    --nlvp-ink:        #2D3430;
    --nlvp-muted:      rgba(47, 58, 63, 0.62);
    --nlvp-muted-soft: rgba(47, 58, 63, 0.38);

    /* Aliases — resolve var() references elsewhere in this file that predate
       these tokens existing in :root */
    --nlvp-border:  var(--nlvp-line);
    --nlvp-surface: var(--nlvp-grey);

    /* Accents */
    --nlvp-lime:         #8BC34A;
    --nlvp-danger:       #B3261E;
    --nlvp-danger-tint:  #FBEDEB;
    --nlvp-danger-line:  #F1C6C1;

    --nlvp-success:      #2E7D32;
    --nlvp-success-tint: #EDF7EE;
    --nlvp-success-line: #C8E6C9;

    --nlvp-info:         #1565C0;
    --nlvp-info-tint:    #EDF3FF;
    --nlvp-info-line:    #C2D3F9;

    --nlvp-warning:      #B45309;
    --nlvp-warning-tint: #FFF8EE;
    --nlvp-warning-line: #FCD8A8;

    --nlvp-slate:      #64748B;
    --nlvp-slate-tint: #EEF1F4;

    /* Type */
    --nlvp-serif:      "Lora", Georgia, "Times New Roman", serif;
    --nlvp-sans:       "Public Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --nlvp-mono:       ui-monospace, "SF Mono", Menlo, monospace;

    /* Type weight — bold is the only weight that ever needs naming; regular is
       the browser default, so components rely on inheritance instead of a var */
    --nlvp-fw-bold: 600;

    /* Type scale — even px sizes only, odd/half-pixel sizes round up (16px root = 1rem).
       Same set of raw sizes as the patient/prescriber-portal ladder — no 22/24/26
       tiers here even though this file originally had them; those consumers were
       remapped onto this canonical scale instead of keeping a portal-only size. */
    --nlvp-fs-10: 0.625rem;  /* 10px */
    --nlvp-fs-12: 0.75rem;   /* 12px */
    --nlvp-fs-14: 0.875rem;  /* 14px */
    /* no --nlvp-fs-16 — 1rem is the inherited default, don't redeclare it */
    --nlvp-fs-18: 1.125rem;  /* 18px */
    --nlvp-fs-20: 1.25rem;   /* 20px */
    --nlvp-fs-30: 1.875rem;  /* 30px */

    /* Heading-scale aliases — same values as the patient/prescriber-portal ladder
       (h1=30/h2=20px). h1 is the only real heading level anywhere in this portal;
       h2 is kept for cross-portal value parity — several components here share a
       name with a Prescriber component that resolves to this exact size. */
    --nlvp-fs-h1: var(--nlvp-fs-30);
    --nlvp-fs-h2: var(--nlvp-fs-20);

    /* Size-tier aliases — no real <h3>-<h6> tag anywhere uses these; every
       consumer is unrelated UI chrome (labels, badges, chips, form controls)
       that happens to borrow one of these steps, so they're named by size
       instead of implying a heading level. Same values as the other portals. */
    --nlvp-fs-md:  var(--nlvp-fs-18);
    --nlvp-fs-sm:  var(--nlvp-fs-14);
    --nlvp-fs-xs:  var(--nlvp-fs-12);
    --nlvp-fs-xxs: var(--nlvp-fs-10);

    /* Layout */
    --nlvp-radius:      12px;
    --nlvp-radius-sm:   8px;
    --nlvp-radius-pill: 999px;
    --nlvp-shadow:       0 1px 2px rgba(47,58,63,0.04), 0 8px 24px rgba(47,58,63,0.06);
    --nlvp-focus:        0 0 0 3px rgba(76, 175, 80, 0.25);
    --nlvp-focus-danger: 0 0 0 3px rgba(179, 38, 30, 0.12);

    /* Motion */
    --nlvp-transition-fast:   0.1s ease;
    --nlvp-transition:        0.12s ease;
    --nlvp-transition-slow:   0.15s ease;
    --nlvp-transition-slower: 0.2s ease;

    /* Admin-shell sizes */
    --nlvp-sidebar-w:   248px;
    --nlvp-topbar-h:    60px;

    /* Fallback until nlvp-edit-sticky-footer.js measures the footer it is showing. */
    --nlvp-sticky-footer-h: 64px;
}

/* The browser's own [hidden] rule loses to any component that sets its own display — .nlvp-btn and
   friends are inline-flex — so hidden has to be made to stick for the whole stylesheet. */
[hidden] { display: none !important; }

/* =============================================================================
 * SIDEBAR  (Concept C — deep rail, full height)
 * ============================================================================= */

.nlvp-sidebar {
    width: var(--nlvp-sidebar-w);
    flex-shrink: 0;
    background: var(--nlvp-ink);
    color: var(--nlvp-white);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
.nlvp-search__kbd {
    font-family: var(--nlvp-mono);
    font-size: var(--nlvp-fs-xs);
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--nlvp-white);
    border: 1px solid var(--nlvp-line);
    color: var(--nlvp-muted);
}
.nlvp-page-footnote {
    font-family: var(--nlvp-sans);
    font-size: var(--nlvp-fs-sm);
    color: var(--nlvp-muted);
    margin: 0 0 24px;
}

.nlvp-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 22px;
}
@media (max-width: 1100px) {
    .nlvp-kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
/* Risk crest icon */
.nlvp-crest-icon,
.nlvp-flag-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
    margin-right: 8px;
}

/* Primary action button */
/* Pagination nav — right-aligned, matching the list table's font instead of Bootstrap's default */
.nlvp-pagination-nav {
    display: flex;
    justify-content: flex-end;
    padding: 12px 16px;
}
.nlvp-pagination-nav .page-link {
    font-family: var(--nlvp-sans);
    font-weight: var(--nlvp-fw-bold);
    font-size: var(--nlvp-fs-xs);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--nlvp-muted);
}
.nlvp-province-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}
.nlvp-province-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid var(--nlvp-line);
    border-radius: var(--nlvp-radius-sm);
    font-size: var(--nlvp-fs-sm);
}
.nlvp-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: var(--nlvp-fs-xs);
    font-weight: var(--nlvp-fw-bold);
    letter-spacing: 0.03em;
}
.nlvp-tag--html {
    background: var(--nlvp-blue-tint);
    border: 1px solid var(--nlvp-blue);
    color: var(--nlvp-blue-hover);
}
.nlvp-tag--plain-text {
    background: var(--nlvp-grey);
    border: 1px solid var(--nlvp-muted-soft);
    color: var(--nlvp-ink);
}
.nlvp-tag--warning,
.nlvp-audit-diff__sensitive-tag {
    background: var(--nlvp-warning-tint);
    border: 1px solid var(--nlvp-warning-line);
    color: var(--nlvp-warning);
}
/* A doctor record whose doctor is a linked general practitioner rather than a name the patient
   typed, and so is ready to be faxed. */
.nlvp-tag--assigned,
.nlvp-audit-diff__after {
    background: var(--nlvp-success-tint);
    border: 1px solid var(--nlvp-success-line);
    color: var(--nlvp-success);
    cursor: help;
}

/* Read-only summary of what a modal's action will affect — label left, value right */
.nlvp-modal__details {
    width: 100%;
    margin: 4px 0 0;
    padding: 16px 18px;
    border-radius: 10px;
    background: var(--nlvp-grey);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.nlvp-modal__detail-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
}
.nlvp-modal__detail-row dt,
.nlvp-doctor-panel__footer-label {
    font-size: var(--nlvp-fs-sm);
    color: var(--nlvp-muted);
}
.nlvp-modal__detail-row dd {
    margin: 0;
    font-size: var(--nlvp-fs-sm);
    font-weight: var(--nlvp-fw-bold);
    color: var(--nlvp-ink);
    text-align: right;
}

/* Table cell holding a row's action buttons */
.nlvp-table__actions {
    text-align: right;
    white-space: nowrap;
}
.nlvp-overflow-menu__item:hover { color: var(--nlvp-ink); }

/* Content raw/preview split */
.nlvp-content-preview-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.nlvp-content-raw {
    width: 100%;
    height: 600px;
    margin: 0;
    padding: 12px;
    overflow: auto;
    white-space: pre-wrap;
    font-family: monospace;
    font-size: var(--nlvp-fs-sm);
    line-height: 1.5;
    border: 1px solid var(--nlvp-line);
    border-radius: var(--nlvp-radius-sm);
    background: var(--nlvp-white);
    box-sizing: border-box;
}

.nlvp-content-preview-frame {
    width: 100%;
    height: 600px;
    border: 1px solid var(--nlvp-line);
    border-radius: var(--nlvp-radius-sm);
    background: var(--nlvp-white);
}
.nlvp-status--inactive .nlvp-status__dot { background: var(--nlvp-danger); }

.nlvp-np-detail-hero--in-card { margin-bottom: 0; }

.nlvp-np-detail-hero__status-danger { color: var(--nlvp-danger); font-weight: var(--nlvp-fw-bold); }

.nlvp-np-detail-hero__reason,
.nlvp-inbound-fax-header__meta {
    font-size: var(--nlvp-fs-sm);
    color: var(--nlvp-muted);
    margin: 6px 0 0;
}

.nlvp-np-detail-hero__avatar--danger {
    background: var(--nlvp-danger-tint);
    color: var(--nlvp-danger);
    font-size: var(--nlvp-fs-h2); /* matches the non-danger avatar's size */
}

.nlvp-np-detail-hero__actions--stacked {
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

/* Card section title */
.nlvp-card__section-title {
    font-size: var(--nlvp-fs-h2);
    font-weight: var(--nlvp-fw-bold);
    color: var(--nlvp-ink);
    margin: 0 0 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--nlvp-border);
}

/* Card subsections — labeled rows within a card (e.g. one per medication type) */
.nlvp-card__subsection {
    padding: 16px 0;
    border-bottom: 1px solid var(--nlvp-line);
}
.nlvp-card__subsection:first-of-type {
    padding-top: 0;
}
.nlvp-card__subsection:last-of-type {
    padding-bottom: 0;
    border-bottom: none;
}
.nlvp-card__subsection-label {
    font-size: var(--nlvp-fs-xs);
    font-weight: var(--nlvp-fw-bold);
    color: var(--nlvp-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0 0 12px;
}
.nlvp-detail-grid--double,
.nlvp-kpi-grid--two { grid-template-columns: repeat(2, 1fr); }
.nlvp-detail-grid--quad { grid-template-columns: repeat(4, 1fr); }
.nlvp-detail-field--full   { grid-column: 1 / -1; }
.nlvp-span-2 { grid-column: span 2; }

/* Signature preview */
.nlvp-signature-preview {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    padding: 16px;
    background: var(--nlvp-surface);
    border: 1px solid var(--nlvp-border);
    border-radius: var(--nlvp-radius-sm);
}
.nlvp-signature-preview__thumb {
    width: 120px;
    height: 72px;
    object-fit: contain;
    background: var(--nlvp-white);
    border: 1px solid var(--nlvp-border);
    border-radius: 6px;
    padding: 8px;
}

/* Professional membership rows */
.nlvp-membership-row {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 14px 0;
    border-bottom: 1px solid var(--nlvp-border);
}
.nlvp-table--interactive tbody tr:hover { background: var(--nlvp-surface); }

.nlvp-is-hidden { display: none !important; }

.nlvp-toggle-group { display: flex; align-items: center; gap: 16px; margin-top: 20px; }
.nlvp-toggle-row__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex: 1;
    min-width: 0;
    background: rgba(47, 58, 63, 0.04);
    border-radius: var(--nlvp-radius);
    padding: 14px 16px;
}

/* The footer is fixed over the page, so the content it covers has to be pushed clear of it. The room
   goes on the scrolling content rather than on the body: the body is held at height: 100% with
   border-box sizing, so its own padding would sit at the bottom of the viewport instead of at the end
   of the content, leaving whatever scrolled past that point still under the footer. */
body.nlvp-has-sticky-footer .nlvp-shell__content {
    padding-bottom: calc(28px + var(--nlvp-sticky-footer-h));
}

/* =============================================================================
 * Page tabs — sibling views of one page, sitting above the card
 * ============================================================================= */

.nlvp-tabs {
    display: flex;
    align-items: flex-end;
    gap: 28px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--nlvp-line);
}
.nlvp-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 2px 12px;
    margin-bottom: -1px;
    border-bottom: 2px solid transparent;
    font-family: var(--nlvp-sans);
    font-weight: var(--nlvp-fw-bold);
    color: var(--nlvp-muted);
    text-decoration: none;
    transition: color var(--nlvp-transition), border-color var(--nlvp-transition);
}
.nlvp-tab:hover { color: var(--nlvp-ink); }
.nlvp-tab.is-active {
    color: var(--nlvp-deep);
    border-bottom-color: var(--nlvp-primary);
}
.nlvp-tab__badge {
    padding: 1px 8px;
    border-radius: var(--nlvp-radius-pill);
    background: var(--nlvp-danger);
    color: var(--nlvp-white);
    font-size: var(--nlvp-fs-xs);
    font-weight: var(--nlvp-fw-bold);
}

/* =============================================================================
 * Payment + refund status
 * ============================================================================= */

/* Inbound fax not yet viewed. */
.nlvp-pill--unread,
.nlvp-pill--payment-failed,
.nlvp-pill--payment-refund-due,
.nlvp-pill--audit-deleted { background: var(--nlvp-danger-tint); color: var(--nlvp-danger); }
.nlvp-pill--payment-paid,
.nlvp-pill--audit-added { background: var(--nlvp-success-tint); color: var(--nlvp-success); }
.nlvp-pill--payment-pending,
.nlvp-pill--audit-updated { background: var(--nlvp-warning-tint); color: var(--nlvp-warning); }
.nlvp-pill--payment-refunded { background: var(--nlvp-blue-tint); color: var(--nlvp-blue-hover); }
.nlvp-pill--payment-cancelled { background: var(--nlvp-slate-tint); color: var(--nlvp-slate); }
/* =============================================================================
 * Audit log
 * ============================================================================= */

/* Date filter inputs, sized to sit in the toolbar next to the search box and filter selects
   instead of the full-width .nlvp-form-input used on edit forms. */
.nlvp-toolbar-date-input {
    width: 140px;
    height: 36px;
    padding: 0 12px;
    border: 1px solid var(--nlvp-line);
    border-radius: var(--nlvp-radius-sm);
    background: var(--nlvp-white);
    font-family: var(--nlvp-sans);
    font-size: var(--nlvp-fs-sm);
    color: var(--nlvp-ink);
}
.nlvp-toolbar-date-input:focus {
    outline: none;
    border-color: var(--nlvp-primary);
    box-shadow: var(--nlvp-focus);
}

/* Expand/collapse toggle for a table row — plus/minus swap tracks Bootstrap's own
   aria-expanded state on the trigger, no extra JS needed. */
.nlvp-audit-toggle .fa-minus { display: none; }
.nlvp-audit-toggle[aria-expanded="true"] .fa-plus { display: none; }
.nlvp-audit-toggle[aria-expanded="true"] .fa-minus { display: inline; }

/* The detail row's cell holds the collapse div directly, with no cell padding of its own —
   otherwise the closed state would still show a gap above/below the zero-height div. The div
   supplies its own padding once expanded (see .nlvp-audit-diff). */
td.nlvp-audit-detail-cell { padding: 0; }

.nlvp-audit-diff { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.nlvp-audit-diff__description { color: var(--nlvp-muted); margin: 0; }

.nlvp-audit-diff__card { margin-bottom: 0; }
.nlvp-audit-diff__card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}
.nlvp-audit-diff__cascaded-tag { background: var(--nlvp-slate-tint); border: 1px solid var(--nlvp-slate); color: var(--nlvp-slate); }

.nlvp-audit-diff__table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.nlvp-audit-diff__table th.nlvp-audit-diff__col-value:first-child { width: 24%; }
.nlvp-audit-diff__table th.nlvp-audit-diff__col-value:not(:first-child) { width: calc((76% - 32px) / 2); }
.nlvp-audit-diff__table th.nlvp-audit-diff__col-arrow { width: 32px; }
.nlvp-audit-diff__table th {
    text-align: left;
    font-size: var(--nlvp-fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--nlvp-muted);
    padding: 6px 8px;
}
.nlvp-audit-diff__table td { padding: 6px 8px; vertical-align: middle; overflow-wrap: anywhere; }
.nlvp-audit-diff__table th:nth-child(2), .nlvp-audit-diff__table td:nth-child(2) { text-align: right; }
.nlvp-audit-diff__table i.fa-arrow-right { color: var(--nlvp-muted-soft); }

.nlvp-audit-diff__before, .nlvp-audit-diff__after {
    display: inline-block;
    max-width: 100%;
    padding: 2px 8px;
    border-radius: 4px;
    font-family: var(--nlvp-mono);
    font-size: var(--nlvp-fs-xs);
    overflow-wrap: anywhere;
    box-sizing: border-box;
}
.nlvp-audit-diff__before { background: var(--nlvp-danger-tint); border: 1px solid var(--nlvp-danger-line); color: var(--nlvp-danger); }
.nlvp-audit-diff__sensitive-note {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: var(--nlvp-fs-xs);
    color: var(--nlvp-muted);
    margin: 0;
}

/* Money paid back out, distinguished from the payments it reverses */
.nlvp-amount--credit { color: var(--nlvp-blue-hover); font-weight: var(--nlvp-fw-bold); }

/* Danger variant of the info banner — outstanding work, not information */
.nlvp-info-banner--danger {
    padding: 14px 16px;
    background: var(--nlvp-danger-tint);
    border: 1px solid var(--nlvp-danger-line);
    color: var(--nlvp-danger);
}

.nlvp-info-banner--warning {
    padding: 14px 16px;
    background: var(--nlvp-warning-tint);
    border: 1px solid var(--nlvp-warning-line);
    color: var(--nlvp-warning);
}

/* Two-line table cell: primary value with a muted detail underneath */
.nlvp-cell-stack {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* A tag sitting beside text on one line — e.g. a patient's province next to their name. */
.nlvp-cell-inline {
    display: flex;
    align-items: center;
    gap: 8px;
}
.nlvp-cell-stack__meta {
    font-size: var(--nlvp-fs-xs);
    color: var(--nlvp-muted);
}

/* Secondary line that carries bad news rather than detail — e.g. why a fax did not arrive. */
.nlvp-cell-stack__meta--danger { color: var(--nlvp-danger); }

/* The stack is a column flex container, so its children stretch to the full cell width by default.
   A pill has to stay the width of its own label, not the column's. */
.nlvp-cell-stack > .nlvp-pill { align-self: flex-start; }

/* Monospaced inline value (payment references and other opaque identifiers) */
.nlvp-mono {
    font-family: var(--nlvp-mono);
    font-size: var(--nlvp-fs-xs);
    color: var(--nlvp-muted);
}

/* Live-updating results region (see nlvp-live-table.js) — dims while a fetch is in flight so a
   filter/search/page change reads as "updating", not as a frozen table. */
[data-live-results] {
    outline: none;
    transition: opacity var(--nlvp-transition-slow);
}
[data-live-results][aria-busy="true"] {
    opacity: 0.5;
    pointer-events: none;
}

/* =============================================================================
 * RESPONSIVE  —  collapse the rail to icons / hide on small screens
 * (kept minimal; the admin tool is desktop-first)
 * ============================================================================= */

@media (max-width: 900px) {
    .nlvp-shell { flex-direction: column; }
    .nlvp-sidebar {
        width: 100%;
        height: auto;
        position: relative;
        flex-direction: row;
        align-items: center;
        padding: 0 12px;
    }
    .nlvp-sidebar__brand { border-bottom: 0; padding: 12px 6px; }
    .nlvp-sidebar__nav,
    .nlvp-sidebar__footer,
    .nlvp-env-ribbon-wrap { display: none; }
    .nlvp-shell__content { padding: 18px; }
    .nlvp-topbar { padding: 0 14px; gap: 10px; }
    .nlvp-search { width: 160px; }
}
.nlvp-h1 {
    font-family: var(--nlvp-serif);
    font-weight: 400; /* browser bolds <h1> by default; this deliberately un-bolds it */
    font-size: var(--nlvp-fs-h1);
    line-height: 1.15;
    color: var(--nlvp-primary);
    margin: 14px 0 8px;
    text-wrap: pretty;
}

/* Flag icon in Flagged Items table */
.nlvp-patient-header {
    background: var(--nlvp-white);
    border: 1px solid var(--nlvp-line);
    border-radius: var(--nlvp-radius, 12px);
    box-shadow: var(--nlvp-shadow);
    padding: 20px 24px;
    margin-bottom: 20px;
}

.nlvp-patient-header__actions {
    display: flex;
    align-items: center;
    align-self: center;
    gap: 10px;
    flex-shrink: 0;
}

.nlvp-patient-header__status {
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (max-width: 900px) {
    .nlvp-patient-header__top { flex-wrap: wrap; }
    .nlvp-patient-header__inline-stats {
        order: 5;
        flex-basis: 100%;
        padding-left: 72px; /* 56px crest + 16px gap */
    }
    .nlvp-two-col-grid { grid-template-columns: 1fr; }
    .nlvp-three-col-grid { grid-template-columns: 1fr; }
    .nlvp-detail-prescription-info { grid-template-columns: 1fr; }
}

/* --- Inbound fax detail ---------------------------------------------------- */
/* The band above a received fax's document: who it came from and what it is on the
   left, what can be done with it on the right. Sits under the faxing tab strip, so
   its heading is deliberately smaller than the page's own. */
.nlvp-inbound-fax-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.nlvp-inbound-fax-header__title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--nlvp-serif);
    font-weight: 400; /* real <h2> tag, browser bolds it by default; this deliberately un-bolds it */
    font-size: var(--nlvp-fs-h2);
    line-height: 1.2;
    color: var(--nlvp-primary);
    margin: 0;
}

.nlvp-inbound-fax-header__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* The document and, once asked for, the patient search sit side by side, so a fax can be read
   while the patient it belongs to is being looked for. The search column is fixed so the
   document keeps the room it needs; below the breakpoint the two simply stack. */
.nlvp-inbound-fax-body,
.nlvp-doctor-records-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
}

.nlvp-inbound-fax-body:has(#nlvp-inbound-fax-associate-panel:not([hidden])) {
    grid-template-columns: minmax(0, 1fr) 460px;
}

.nlvp-inbound-fax-body__document { min-width: 0; }

/* The search column stretches to the full height of the row, which is what gives the sticky panel
   inside it somewhere to travel. Without it the column is only as tall as the panel and sticky has
   no room to do anything. */
.nlvp-inbound-fax-body__search { min-width: 0; }

/* Nothing to lay out a column for while the panel is closed. */
.nlvp-inbound-fax-body__search:has(> [hidden]) { display: none; }

/* --- Associate a received fax with a patient ------------------------------- */
/* The panel is as tall as the document beside it and no taller — its results scroll rather than
   pushing the page down as more of them match. Sticky so it stays put while a long fax is read. */
.nlvp-patient-search,
.nlvp-doctor-panel {
    padding: 16px;
    margin-bottom: 0;
    position: sticky;
    top: 16px;
    display: flex;
    flex-direction: column;
    /* border-box so the cap counts the card's own padding and border — otherwise the panel stands
       34px taller than asked for and its last result sits under the fold. */
    box-sizing: border-box;
    max-height: calc(100vh - 48px);
    min-height: 0;
}

/* Everything above the scrolling results keeps its full height in the flex column. */
.nlvp-patient-search__title,
.nlvp-patient-search__lede,
.nlvp-patient-search__box { flex-shrink: 0; }

.nlvp-patient-search__title,
.nlvp-doctor-panel__title {
    font-family: var(--nlvp-serif);
    font-weight: 400; /* real <h2> tag, browser bolds it by default; this deliberately un-bolds it */
    font-size: var(--nlvp-fs-md);
    color: var(--nlvp-primary);
    margin: 0;
}

.nlvp-patient-search__lede {
    font-size: var(--nlvp-fs-sm);
    color: var(--nlvp-muted);
    margin: 4px 0 12px;
}

.nlvp-patient-search__box { width: 100%; }

.nlvp-patient-search__hint {
    font-size: var(--nlvp-fs-sm);
    color: var(--nlvp-muted);
    margin: 12px 0 0;
}

/* The "3 MATCHES" line above the results */
.nlvp-patient-search__count {
    font-size: var(--nlvp-fs-xs);
    font-weight: var(--nlvp-fw-bold);
    letter-spacing: 0.06em;
    color: var(--nlvp-muted);
    margin: 14px 0 8px;
}

/* The results region scrolls on its own, so the heading and the search box stay put while the
   matches move under them. */
.nlvp-patient-search__scroll {
    overflow-y: auto;
    min-height: 0;
    /* Room for the results' focus ring, which a flush scroll container would clip. */
    margin: 0 -4px;
    padding: 0 4px;
}

.nlvp-patient-search__results,
.nlvp-doctor-panel__results,
.nlvp-merge-marker-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nlvp-patient-search__result,
.nlvp-doctor-panel__result {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-shrink: 0;
    padding: 12px 14px;
    border: 1px solid var(--nlvp-line);
    border-radius: var(--nlvp-radius-sm);
    background: var(--nlvp-white);
}

.nlvp-patient-search__result-body { min-width: 0; }

.nlvp-patient-search__result-name,
.nlvp-doctor-panel__result-name {
    font-size: var(--nlvp-fs-sm);
    font-weight: var(--nlvp-fw-bold);
    color: var(--nlvp-ink);
    margin: 0;
}

.nlvp-patient-search__result-meta,
.nlvp-doctor-panel__result-meta {
    font-size: var(--nlvp-fs-xs);
    color: var(--nlvp-muted);
    margin: 2px 0 0;
    overflow-wrap: anywhere;
}

/* The confirmation's own fields, under the read-only summary of what is being filed */
.nlvp-associate-form {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 14px;
}

.nlvp-associate-form__field[hidden] { display: none; }

/* Whether the fax is disposed of once the patient has the document. A .nlvp-choice card, as every
   checkbox is, sized down a little for a single line inside a modal. */
.nlvp-associate-form__check {
    align-items: center;
    padding: 12px 14px;
    /* The whole card toggles the box, so a double-click on the label is a double toggle rather than
       a request to select the words it is made of. */
    user-select: none;
}

.nlvp-associate-form__check .nlvp-choice__title { font-size: var(--nlvp-fs-sm); }

@media (max-width: 1100px) {
    .nlvp-inbound-fax-body:has(#nlvp-inbound-fax-associate-panel:not([hidden])) {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* =============================================================================
 * Billing — monthly report
 * ============================================================================= */

/* Three summary figures rather than the dashboard's four, so the row is not left with a gap
   where a fourth would have gone. */
.nlvp-kpi-grid--three {
    grid-template-columns: repeat(3, 1fr);
}
@media (max-width: 1100px) {
    .nlvp-kpi-grid--three { grid-template-columns: repeat(2, 1fr); }
}

/* The currency an amount is in, sitting on the same line as the amount it belongs to. Kept small
   and muted against the serif figure so the number still reads as the headline of the tile. */
.nlvp-kpi__currency {
    font-family: var(--nlvp-sans);
    font-size: var(--nlvp-fs-xs);
    letter-spacing: 0.06em;
    color: var(--nlvp-muted);
    margin-left: 2px;
}

/* Counts and amounts, lined up on their last digit so a column of them can be compared. */
.nlvp-table__numeric,
.nlvp-table th.nlvp-table__numeric {
    text-align: right;
}

/* Trailing cell holding a row's action button. Sized to its own content so the columns carrying the
   data keep the width, and kept on one line so a two-word button label does not wrap. */
.nlvp-table__action-cell,
.nlvp-table th.nlvp-table__action-cell {
    width: 1%;
    text-align: right;
    white-space: nowrap;
}

/* The table's closing total. Not a tfoot, because the table is one page of a longer report and a
   footer would read as the total of the page rather than of the period. */
.nlvp-table__total-row td {
    border-top: 1px solid var(--nlvp-line);
    background: var(--nlvp-grey);
    font-weight: var(--nlvp-fw-bold);
    color: var(--nlvp-deep);
}
.nlvp-table--interactive tbody tr.nlvp-table__total-row {
    cursor: default;
}
.nlvp-table--interactive tbody tr.nlvp-table__total-row:hover {
    background: var(--nlvp-grey);
}

/* The tab's opening state: no period has been picked, so there is nothing to report on yet and the
   picker is the whole card. */
.nlvp-report-prompt {
    padding: 48px 24px 44px;
    text-align: center;
}
.nlvp-report-prompt__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--nlvp-sage-tint);
    color: var(--nlvp-deep);
    font-size: calc(var(--nlvp-fs-h1) - 4px);
    margin-bottom: 20px;
}
.nlvp-report-prompt__title {
    font-family: var(--nlvp-serif);
    font-size: calc(var(--nlvp-fs-h1) - 4px);
    font-weight: var(--nlvp-fw-bold);
    color: var(--nlvp-deep);
    margin: 0 0 10px;
}
.nlvp-report-prompt__lede {
    font-family: var(--nlvp-sans);
    color: var(--nlvp-muted);
    max-width: 46ch;
    margin: 0 auto 24px;
    line-height: 1.5;
}

/* The month/year picker and its run button. Sits centred inside the opening card and right-aligned
   in the page header once a period has been run. */
.nlvp-period-form {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
}
/* The picker is a wrapping flex row, so its validation message has to claim a whole line rather
   than squeezing in beside the selects. Centred, which is where both the card and the header put
   the controls it sits under. */
.nlvp-period-form__validation {
    flex-basis: 100%;
    text-align: center;
    font-size: var(--nlvp-fs-sm);
    color: var(--nlvp-danger);
}
.nlvp-period-form__label {
    font-family: var(--nlvp-sans);
    font-size: var(--nlvp-fs-xs);
    font-weight: var(--nlvp-fw-bold);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--nlvp-muted);
}

/* Two summary figures — one payee's page of the report has a count and a total, and nothing else
   that belongs beside them. */
/* A section title heading a flush card's table has to supply the horizontal padding the card gave
   up, or it sits against the edge while the table below it is inset. */
.nlvp-card--flush .nlvp-card__section-title {
    padding: 14px 16px 10px;
    margin-bottom: 0;
}

/* --- Doctor Records: the list and its associate pane ----------------------- */
/* The list and the pane sit side by side, so the record being processed stays readable while its
   doctor is found. The pane's column is fixed so the list keeps the room it needs; below the
   breakpoint the two simply stack. */
.nlvp-doctor-records-body:has(#nlvp-doctor-record-panel:not([hidden])) {
    grid-template-columns: minmax(0, 1fr) 420px;
}

.nlvp-doctor-records-body__list { min-width: 0; }
.nlvp-doctor-records-body__panel { min-width: 0; }

/* Nothing to lay out a column for while the pane is closed. */
.nlvp-doctor-records-body__panel:has(> [hidden]) { display: none; }

/* The pane is the row's actions for as long as it is open, so the Process column goes away under
   it rather than offering a second way to start over on a different row mid-flow. */
.nlvp-doctor-records-body:has(#nlvp-doctor-record-panel:not([hidden])) .nlvp-table__actions {
    display: none;
}

/* The pane is as tall as the viewport and no taller — its results scroll rather than pushing the
   page down as more of them match. Sticky so it stays put while the list is scrolled. */
.nlvp-doctor-panel__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-shrink: 0;
}

.nlvp-doctor-panel__heading { min-width: 0; }

.nlvp-doctor-panel__subtitle {
    font-size: var(--nlvp-fs-xs);
    color: var(--nlvp-muted);
    margin: 4px 0 0;
}

.nlvp-doctor-panel__close {
    border: 0;
    background: none;
    padding: 0;
    line-height: 1;
    font-size: var(--nlvp-fs-md);
    color: var(--nlvp-muted);
    cursor: pointer;
    flex-shrink: 0;
}

.nlvp-doctor-panel__close:hover { color: var(--nlvp-ink); }

/* What the patient wrote down, kept in front of the admin for as long as the pane is open. */
.nlvp-doctor-panel__entered {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex-shrink: 0;
    margin: 12px 0 0;
    padding: 8px 12px;
    border: 1px solid var(--nlvp-line);
    border-radius: var(--nlvp-radius-sm);
    background: var(--nlvp-grey);
    font-size: var(--nlvp-fs-sm);
    color: var(--nlvp-ink);
}

.nlvp-doctor-panel__entered-label { color: var(--nlvp-muted); }

/* Each body fills what is left under the shared heading, so only the results inside it scroll. */
.nlvp-doctor-panel__body {
    display: flex;
    flex-direction: column;
    min-height: 0;
    margin-top: 12px;
}

.nlvp-doctor-panel__filters { flex-shrink: 0; }

/* The search box is the wider of the two, and .nlvp-search's own 320px would otherwise squeeze the
   province filter down to the width of its arrow. */
.nlvp-doctor-panel__filters { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); }

.nlvp-doctor-panel__filters .nlvp-search { width: 100%; }

/* The province filter sits beside the search box rather than in a form, so it takes the search
   box's height and text size instead of the taller one the form fields share and the smaller
   one a select is given by the browser when nothing sets it. */
.nlvp-doctor-panel__filters .nlvp-form-select {
    height: 36px;
    font-size: var(--nlvp-fs-sm);
}

.nlvp-doctor-panel__hint {
    font-size: var(--nlvp-fs-xs);
    color: var(--nlvp-muted);
    margin: 10px 0 0;
}

/* The "2 MATCHING DOCTORS" line above the results */
.nlvp-doctor-panel__count {
    font-size: var(--nlvp-fs-xs);
    font-weight: var(--nlvp-fw-bold);
    letter-spacing: 0.06em;
    color: var(--nlvp-muted);
    margin: 0 0 8px;
}

/* The results region scrolls on its own, so the search box above it and the "add new doctor" footer
   below it stay put while the matches move between them. */
.nlvp-doctor-panel__scroll {
    overflow-y: auto;
    min-height: 0;
    margin: 12px -4px 0;
    /* Room for the results' focus ring, which a flush scroll container would clip. */
    padding: 0 4px;
}

.nlvp-doctor-panel__result-body { min-width: 0; }

/* Sits under the results on a rule of its own, so "add new doctor" reads as the way out of the
   search rather than as one more match. */
.nlvp-doctor-panel__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-shrink: 0;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--nlvp-line);
}

.nlvp-doctor-panel__footer--actions { justify-content: flex-end; }

.nlvp-doctor-panel__form {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* The new doctor's fields scroll as one, so a form taller than the pane never pushes its buttons
   off the bottom of the screen — they sit below this, as the search body's do below its results. */
.nlvp-doctor-panel__fields {
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    min-height: 0;
    /* Room for the fields' focus rings, which a flush scroll container would clip. */
    margin: 0 -4px;
    padding: 0 4px;
}

/* Nothing but hidden fields — it exists to be submitted, not to be laid out. */
.nlvp-doctor-panel__hidden-form { display: contents; }

@media (max-width: 1100px) {
    .nlvp-doctor-records-body:has(#nlvp-doctor-record-panel:not([hidden])) {
        grid-template-columns: minmax(0, 1fr);
    }

    .nlvp-doctor-panel { position: static; max-height: none; }
}

/* =============================================================================
 * FLYOUT
 * A Bootstrap offcanvas sliding in from the right edge, holding reference material for the page
 * behind it (e.g. the merge markers beside the template editors). Its header and body are
 * Bootstrap's .offcanvas-header and .offcanvas-body; these rules bring them onto the NLVP palette.
 * ============================================================================= */

/* A form label sharing its row with an action, e.g. the flyout toggle beside "Content". */
.nlvp-form-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
}

.nlvp-form-label-row .nlvp-form-label { margin-bottom: 0; }

/* Kept short so that the action does not make the row any taller than the label alone. */
.nlvp-form-label-row .nlvp-btn { height: 24px; }

.nlvp-flyout {
    --bs-offcanvas-width: 440px;
    --bs-offcanvas-padding-x: 24px;
    --bs-offcanvas-padding-y: 16px;
    --bs-offcanvas-bg: var(--nlvp-white);
    --bs-offcanvas-color: var(--nlvp-ink);
    --bs-offcanvas-border-color: var(--nlvp-line);
}

.nlvp-flyout .offcanvas-header {
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding-top: 24px;
    border-bottom: 1px solid var(--nlvp-line);
}

.nlvp-flyout .offcanvas-header .nlvp-icon-btn { flex-shrink: 0; }

/* A search box pinned above the scrolling body. */
.nlvp-flyout__search { padding: var(--bs-offcanvas-padding-y) var(--bs-offcanvas-padding-x) 0; }

.nlvp-flyout__search .nlvp-search { width: 100%; }

.nlvp-flyout__section + .nlvp-flyout__section { margin-top: 20px; }

.nlvp-flyout__footer {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: var(--bs-offcanvas-padding-y) var(--bs-offcanvas-padding-x);
    border-top: 1px solid var(--nlvp-line);
    background: var(--nlvp-grey);
    font-size: var(--nlvp-fs-xs);
    line-height: 1.5;
}

/* The footer carries a caution, so its icon takes the warning colour. */
.nlvp-flyout__footer i { margin-top: 3px; color: var(--nlvp-warning); }

/* =============================================================================
 * MERGE MARKERS
 * The markers listed in the merge marker flyout (Views/Shared/Components/MergeMarkerFlyout).
 * Search and copy live in nlvp-merge-marker-flyout.js.
 * ============================================================================= */

.nlvp-merge-marker {
    padding: 12px;
    border: 1px solid var(--nlvp-line);
    border-radius: var(--nlvp-radius-sm);
    background: var(--nlvp-white);
    transition: background var(--nlvp-transition), border-color var(--nlvp-transition);
}

.nlvp-merge-marker.is-copied { background: var(--nlvp-success-tint); border-color: var(--nlvp-sage); }

.nlvp-merge-marker__main {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.nlvp-merge-marker__text { min-width: 0; }

.nlvp-merge-marker__token {
    display: block;
    padding: 0;
    background: none;
    font-family: var(--nlvp-mono);
    font-size: var(--nlvp-fs-sm);
    font-weight: var(--nlvp-fw-bold);
    color: var(--nlvp-deep);
    overflow-wrap: anywhere;
}

.nlvp-merge-marker__description {
    margin: 2px 0 0;
    font-size: var(--nlvp-fs-xs);
    color: var(--nlvp-muted);
    line-height: 1.45;
}

.nlvp-merge-marker__copy { flex-shrink: 0; }

.nlvp-merge-marker__sample {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dashed var(--nlvp-line);
    font-size: var(--nlvp-fs-sm);
}

.nlvp-merge-marker__sample-value { min-width: 0; overflow-wrap: anywhere; }

/* The "can be blank" tag, pushed to the end of the sample line; its title explains it on hover. */
.nlvp-merge-marker__sample .nlvp-tag { margin-left: auto; white-space: nowrap; cursor: help; }
