* { box-sizing: border-box; margin: 0; padding: 0; }
/* One font everywhere (token --font-sans in components.css): form controls inherit it instead of the UA's Arial / 13px default. */
body { font-family: var(--font-sans, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif); }
button, input, select, textarea { font: inherit; }

.layout { display: flex; min-height: 100vh; }

.sidebar { width: 220px; background: var(--brand, #37BBA1); color: var(--brand-ink, #0B2E27); padding: 1rem; display: flex; flex-direction: column; gap: 0.25rem; flex-shrink: 0; }
.sidebar .brand { font-size: 1.4rem; font-weight: 700; color: var(--brand-ink, #0B2E27); }
.sidebar-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; padding-bottom: 0.75rem; border-bottom: 1px solid rgba(11,46,39,0.35); }
.nav-toggle { display: none; background: none; border: 0; color: var(--brand-ink, #0B2E27); font-size: 1.6rem; line-height: 1; cursor: pointer; padding: 0; }
/* Desktop hide/show of the whole sidebar (#37). Hidden by default so they never appear on
   mobile — the desktop rules that show them live in the min-width:769px block below. */
.nav-hide { display: none; }
.nav-show { display: none; }
.sidebar .nav-link { color: var(--brand-ink, #0B2E27); font-weight: 500; text-decoration: none; padding: 0.5rem 0.75rem; border-radius: 6px; display: block; }
.sidebar .nav-link:hover { background: var(--brand-hover, #5FCFB9); color: var(--brand-ink, #0B2E27); text-decoration: none; }
.sidebar-footer { margin-top: auto; padding-top: 1rem; border-top: 1px solid rgba(11,46,39,0.35); }
.sidebar-footer .user-name { display: block; color: var(--brand-ink, #0B2E27); font-size: 0.85rem; padding: 0.25rem 0.75rem; }
.sidebar-footer .sidebar-version { display: block; color: var(--brand-ink, #0B2E27); font-size: 0.75rem; line-height: 1.3; padding: 0.5rem 0.75rem 0; }

.content { flex: 1; min-width: 0; padding: 1.5rem 2rem; background: #f5f6fa; overflow-y: auto; }

h1 { margin-bottom: 1rem; }
h2 { margin: 1.5rem 0 0.75rem; }

a { color: #0052cc; }
a:hover { text-decoration: underline; }

.table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.1); margin: 1rem 0; }
.table th, .table td { padding: 0.6rem 1rem; text-align: left; border-bottom: 1px solid #eee; }
.table th { background: #f8f9fa; font-weight: 600; font-size: 0.85rem; color: #555; text-transform: uppercase; letter-spacing: 0.03em; }
.table tbody tr:hover { background: #f0f4ff; }

/* Buttons carry a fixed meaning (all white-on-colour pairs >= 4.5:1):
   primary = the one commit action; secondary (white, blue outline) = navigation / Save row / Add / Cancel / Edit / Back / Filter;
   success = Verify / Sign off only; danger (filled) = destructive confirmations and "Save as deviation"; danger-outline = Void / Delete / Remove / Turn off / Retire. */
.btn { display: inline-block; padding: 0.45rem 1rem; border: 1px solid transparent; border-radius: 6px; cursor: pointer; font-size: 1rem; line-height: 1.2; text-decoration: none; color: #fff; }
.btn:hover { text-decoration: none; }
.btn-primary { background: #0052cc; }
.btn-primary:hover { background: #003d99; }
.btn-secondary, .btn-outline { background: #fff; color: #0052cc; border-color: #0052cc; }
.btn-secondary:hover, .btn-outline:hover { background: #e8f0fe; color: #003d99; }
.btn-neutral { background: #334155; }
.btn-neutral:hover { background: #1e293b; }
.btn-success { background: #15803d; }
.btn-success:hover { background: #166534; }
.btn-danger { background: #b91c1c; }
.btn-danger:hover { background: #991b1b; }
/* Written after .btn-danger and also matched by the legacy `btn-danger btn-outline` markup, so that combination is red-outline, not teal. */
.btn-danger-outline, .btn-danger.btn-outline { background: #fff; color: #b91c1c; border-color: #b91c1c; }
.btn-danger-outline:hover, .btn-danger.btn-outline:hover { background: #fef2f2; color: #991b1b; }
.btn-sm { padding: 0.25rem 0.6rem; font-size: 0.875rem; }

.card { background: #fff; border-radius: 8px; padding: 1.25rem; box-shadow: 0 1px 3px rgba(0,0,0,0.1); margin: 1rem 0; }

.form-group { margin-bottom: 0.75rem; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.25rem; color: #333; }
.form-control { width: 100%; padding: 0.4rem 0.6rem; border: 1px solid #ccc; border-radius: 4px; font-size: 0.9rem; }
.form-control:focus { outline: none; border-color: #0052cc; box-shadow: 0 0 0 2px rgba(0,82,204,0.2); }
.form-control.is-readonly { background: #f5f5f5; color: #555; cursor: not-allowed; }
.form-control.is-readonly:focus { box-shadow: none; border-color: #ccc; }
.form-row { display: flex; gap: 1rem; }
.form-row .form-group { flex: 1; }
.form-actions { display: flex; gap: 0.5rem; margin-top: 1rem; }

/* ── Non-editable fields ── */
/* Informational / auto-filled (permanently readonly) — soft tint, plain border, still
   focusable/copyable (click-to-select rows on Admin/SamlSettings depend on that). Written first
   so the disabled rule below wins by source order while a field is both readonly and inside a
   disabled fieldset. */
.form-control[readonly] { background: #f4f6f8; border: 1px solid #d8dde2; color: #666; cursor: default; }
.form-control[readonly]:focus { outline: none; border-color: #0052cc; box-shadow: 0 0 0 2px rgba(0,82,204,0.2); }

/* Locked (temporarily disabled) — visibly barred: hatched fill, dashed border, not-allowed cursor. */
.form-control:disabled {
    background-color: #d9dcdf;
    background-image: repeating-linear-gradient(45deg, rgba(0,0,0,0.08) 0, rgba(0,0,0,0.08) 4px, transparent 4px, transparent 8px);
    border: 1px dashed #99a1a8;
    color: #5a6268;
    cursor: not-allowed;
    opacity: 1;
    -webkit-text-fill-color: #5a6268;
}

.btn:disabled, .btn:disabled:hover {
    background: #e5e7eb;
    color: #4b5563; /* 6.1:1 on the grey */
    border-color: #9ca3af;
    cursor: not-allowed;
    opacity: 1;
    -webkit-text-fill-color: #4b5563;
}

/* #137: pre-start check announcement — banner, locked-section note, missing-row flag. */
.preop-banner {
    background: #ffebee;
    border-left: 4px solid #c62828;
    color: #b71c1c;
    font-weight: bold;
    padding: 1rem;
}
.preop-locked-note {
    font-size: 0.8rem;
    color: #b71c1c;
    border-top: 1px dashed #99a1a8;
    padding: 0.4rem 0;
}

.text-danger { color: #b91c1c; }
.validation-summary-errors ul { color: #b91c1c; margin: 0.5rem 0; padding-left: 1.25rem; }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-top: 1rem; }
.detail-card { background: #fff; border-radius: 8px; padding: 1.25rem; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.detail-card h3 { margin-bottom: 0.75rem; }
dl { display: grid; grid-template-columns: auto 1fr; gap: 0.3rem 1rem; }
dt { font-weight: 600; color: #555; font-size: 0.85rem; }
dd { margin: 0; }

/* Navigation groups */
.nav-group { margin-top: 0.5rem; }
.nav-group-header { display: flex; align-items: center; justify-content: space-between; padding: 0.5rem 0.75rem; color: var(--brand-ink, #0B2E27); font-size: 0.85rem; font-weight: 700; cursor: pointer; border-radius: 6px; user-select: none; }
.nav-group-header:hover { background: var(--brand-hover, #5FCFB9); }
.nav-group-header .chevron { font-size: 0.6rem; transition: transform 0.15s; }
.nav-group.collapsed .chevron { transform: rotate(-90deg); }
.nav-group.collapsed .nav-group-body { display: none; }
.nav-group-body { padding-left: 0.5rem; }
.nav-sub-header { display: block; font-size: 0.65rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--brand-ink, #0B2E27); padding: 0.4rem 0.75rem 0.15rem; margin-top: 0.25rem; }
.nav-group-body .nav-link { font-size: 0.85rem; padding: 0.35rem 0.75rem; }
.sidebar .nav-link.active, .sidebar .nav-link.active:hover { background: #fff; color: var(--brand-ink, #0B2E27); font-weight: 700; box-shadow: inset 4px 0 0 var(--brand-ink, #0B2E27); }
/* Focus ring on the teal sidebar: the page-wide blue ring is only 2.4:1 against it, the ink is 6.1:1. */
.sidebar a:focus-visible, .sidebar button:focus-visible, .nav-group-header:focus-visible, .nav-show:focus-visible { outline: 3px solid var(--brand-ink, #0B2E27); outline-offset: 2px; }
/* QA Evaluation grid */
.eval-grid { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.1); margin: 1rem 0; }
.eval-grid th, .eval-grid td { padding: 0.4rem 0.6rem; text-align: center; border-bottom: 1px solid #eee; border-right: 1px solid #eee; font-size: 0.85rem; }
.eval-grid th { background: #f8f9fa; font-weight: 600; font-size: 0.75rem; color: #555; text-transform: uppercase; letter-spacing: 0.03em; }
.eval-grid td:first-child, .eval-grid th:first-child { text-align: left; min-width: 180px; }
.eval-grid .section-header { background: #e8eaf6; font-weight: 700; text-align: center; font-size: 0.8rem; color: #3949ab; }

/* NCR panel */
.ncr-panel { background: #fff8e1; border: 1px solid #ffe082; border-radius: 6px; padding: 1rem; margin: 0.5rem 0; }
.ncr-card { background: #fff; border: 1px solid #e0e0e0; border-radius: 6px; padding: 0.75rem; margin: 0.5rem 0; display: flex; gap: 1rem; align-items: flex-start; }
.ncr-card .ncr-info { flex: 1; }
.ncr-card .ncr-info p { margin: 0.25rem 0; font-size: 0.85rem; }
.ncr-indicator { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #c62828; margin-right: 0.25rem; vertical-align: middle; }

/* QA Calendar */
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.1); margin: 1rem 0; }
.calendar-header { background: #f8f9fa; padding: 0.5rem; text-align: center; font-weight: 600; font-size: 0.8rem; color: #555; }
.calendar-day { min-height: 80px; padding: 0.4rem; border: 1px solid #eee; position: relative; }
.calendar-day .day-number { font-size: 0.8rem; font-weight: 600; color: #333; }
.calendar-day.empty { background: #fafafa; }
.calendar-day.has-ncr { border: 2px solid #c62828; }
.calendar-day .day-status { font-size: 0.7rem; margin-top: 0.25rem; }

/* Demand calendar */
.calendar-day.has-override { background: #fff8e1; border-color: #ffe082; }

/* QA Stats */
.stats-row { display: flex; gap: 1rem; margin: 1rem 0; }
.stat-card { background: #fff; border-radius: 8px; padding: 1rem 1.25rem; box-shadow: 0 1px 3px rgba(0,0,0,0.1); flex: 1; text-align: center; }
.stat-card .stat-value { font-size: 1.5rem; font-weight: 700; color: #333; }
.stat-card .stat-label { font-size: 0.8rem; color: #777; margin-top: 0.25rem; }

/* Tabs */
.tab-bar { display: flex; gap: 0; border-bottom: 2px solid #ddd; margin-bottom: 1rem; }
.tab { padding: 0.6rem 1.25rem; text-decoration: none; color: #555; font-weight: 600; font-size: 0.9rem; border-bottom: 2px solid transparent; margin-bottom: -2px; }
.tab:hover { color: #333; border-bottom-color: #aaa; text-decoration: none; }
.tab-active { color: #0052cc; border-bottom-color: #0052cc; }
.tab-count { font-size: 0.75rem; font-weight: 400; color: #888; margin-left: 0.25rem; }
.tab-active .tab-count { color: #0052cc; }

/* Filter bar */
.filter-bar { display: flex; gap: 0.75rem; align-items: end; margin-bottom: 1rem; flex-wrap: wrap; }
.filter-bar .form-group { margin-bottom: 0; }
.filter-bar .form-control { min-width: 150px; }

.login-container { display: flex; justify-content: center; align-items: center; min-height: 100vh; background: #f5f6fa; }
.login-card { background: #fff; border-radius: 8px; padding: 2rem; box-shadow: 0 2px 8px rgba(0,0,0,0.1); width: 100%; max-width: 400px; }
.login-card h1 { text-align: center; margin-bottom: 1.5rem; }

@media (max-width: 900px) {
    .layout { flex-direction: column; }
    /* Same 2rem side padding as .content so the brand lines up with the page below it. */
    .sidebar { width: 100%; flex-direction: column; padding: 0.5rem 2rem; gap: 0; }
    .sidebar-header { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }
    .nav-toggle { display: block; min-width: 44px; min-height: 44px; }
    /* Foldable menu: at tablet-portrait width and below the sidebar collapses to just the top bar
       (brand + ☰). Everything else is hidden until the toggle opens it. Only when JS is running
       (the layout adds .js to <html>): with JS off there is no toggle, so the whole menu stays
       visible as a stacked bar above the page. */
    html:not(.js) .nav-toggle { display: none; }
    html.js .sidebar > *:not(.sidebar-header) { display: none; }
    html.js .sidebar.open > *:not(.sidebar-header):not(.nav-link) { display: block; }
    html.js .sidebar.open > .nav-link { display: flex; }
    .detail-grid { grid-template-columns: 1fr; }
    .form-row { flex-direction: column; gap: 0; }
}

/* Desktop-only sidebar hide/show (#37). 901px so it never overlaps the max-width:900px
   tablet/mobile rules above (which own the .nav-toggle hamburger). */
@media (min-width: 901px) {
    .nav-hide { display: block; background: none; border: 0; color: var(--brand-ink, #0B2E27); font-size: 1.4rem; line-height: 1; cursor: pointer; padding: 0; min-width: 44px; min-height: 44px; }
    .layout.sidebar-collapsed .sidebar { display: none; }
    .layout.sidebar-collapsed .nav-show {
        display: block;
        position: fixed;
        top: 0.75rem;
        left: 0.75rem;
        z-index: 1000;
        background: var(--brand, #37BBA1);
        color: var(--brand-ink, #0B2E27);
        box-shadow: 0 1px 4px rgba(0,0,0,0.3);
        border: 0;
        border-radius: 6px;
        font-size: 1.4rem;
        line-height: 1;
        padding: 0.25rem 0.5rem;
        min-width: 44px;
        min-height: 44px;
        cursor: pointer;
    }
}

/* Page banners (saved / warning / error / note). */
.alert { padding: 0.65rem 0.9rem; border: 1px solid transparent; border-radius: 6px; margin: 0 0 0.75rem; }
.alert-success { background: #e8f5e9; border-color: #a5d6a7; color: #2e7d32; }
.alert-danger  { background: #ffebee; border-color: #ef9a9a; color: #c62828; }
.alert-warning { background: #fff8e1; border-color: #ffe082; color: #8a6d00; }
.alert-info    { background: #e3f2fd; border-color: #90caf9; color: #1565c0; }

/* Desktop shows table, hides cards. Mobile shows cards, hides table. */
@media (min-width: 768px) {
    .d-desktop-none { display: none !important; }
}
@media (max-width: 767px) {
    .d-mobile-none { display: none !important; }
}

.impersonation-banner {
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.5rem 1rem;
    background: #b45309;
    color: #fff;
    font-weight: 600;
}
.impersonation-banner .impersonation-stop {
    background: #fff;
    color: #b45309;
    border: none;
    border-radius: 4px;
    padding: 0.25rem 0.75rem;
    cursor: pointer;
    font-weight: 600;
}

/* #92: inline corrective-actions field error */
.corrective-field-error {
    color: #c62828;
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

/* Typeable date entry (date-entry.js) — a visible text box + calendar button in front of the
   native date/datetime-local input, which stays in the DOM (so it still posts, still carries
   min/max/data-corrective/data-recorded) but is visually hidden. */
.date-entry {
    position: relative;
    display: flex;
    width: 100%;
}
.date-entry .date-entry-text {
    flex: 1 1 auto;
    min-width: 0;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}
.date-entry .date-entry-text.is-invalid {
    border-color: #c62828;
}
/* NOT display:none/visibility:hidden — either would stop showPicker() working. A 1px box with
   opacity 0 still has a render box, so the picker can anchor to it, but it's invisible and out of
   the flex flow. */
.date-entry .date-entry-native {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: 0;
    border: 0;
    opacity: 0;
    pointer-events: none;
}
.date-entry .date-entry-btn {
    flex: 0 0 auto;
    padding: 0.4rem 0.6rem;
    border: 1px solid #ccc;
    border-left: 0;
    border-radius: 0 4px 4px 0;
    background: #f8f9fa;
    cursor: pointer;
    font-size: 0.95rem;
    line-height: 1.2;
}
.date-entry .date-entry-btn:hover {
    background: #eef1f4;
}
/* "Now" button (date-entry.js): fills the site's current time. At least 44px tall for gloved tablet
   use (the text box and calendar button stretch to match, being flex siblings). Default: its own
   full-width row under the field (works at every width). */
.date-entry.has-now {
    flex-wrap: wrap;
}
.date-entry.has-now .date-entry-text,
.date-entry.has-now .date-entry-btn,
.date-entry-now {
    min-height: 44px;
}
.date-entry.has-now .date-entry-text {
    flex: 1 1 0; /* not the input's 100% basis, or the calendar button would wrap onto its own row */
}
.date-entry.has-now .date-entry-btn {
    min-width: 44px;
}
.date-entry-now {
    flex: 1 0 100%;
    margin-top: 0.35rem;
    padding: 0.4rem 1rem;
    border: 1px solid #0052cc;
    border-radius: 6px;
    background: #fff;
    color: #0052cc;
    font-weight: 400;
    font-size: 1rem;
    line-height: 1.2;
    cursor: pointer;
}
.date-entry-now:hover:not(:disabled) {
    background: #e8f0fe;
    color: #003d99;
}
.date-entry-now:disabled {
    border-color: #9ca3af;
    background: #e5e7eb;
    color: #4b5563;
    cursor: not-allowed;
}
/* Inline (beside the calendar button) once the field itself is >= 220px wide: date-entry.js adds .now-inline from a ResizeObserver, whatever the viewport.
   Narrower than that the button is its own full-width row under the field. */
.date-entry.has-now.now-inline {
    flex-wrap: nowrap;
}
.date-entry.has-now.now-inline .date-entry-btn {
    border-radius: 0;
}
.date-entry.has-now.now-inline .date-entry-now {
    flex: 0 0 auto;
    margin-top: 0;
    margin-left: 0.35rem;
    min-width: 56px;
    padding: 0.4rem 0.6rem;
}
.date-entry-error {
    color: #c62828;
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

/* ── On-screen validation feedback (validation-feedback.js) ──
   Per-field callout styled like Chrome's native validation bubble — white box, small arrow
   pointing up at the field, a square orange/red "!" icon, then the message — except it stays
   visible until the value changes/is fixed (the native bubble auto-dismisses; this doesn't).
   `.form-error` is the same visual language for an error that isn't tied to one field (rendered
   at the action bar, or wherever the existing alert already lived) — no arrow, since it isn't
   anchored to a control. */
.field-error, .form-error {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    background: #fff;
    border: 1px solid #c62828;
    border-radius: 4px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    padding: 0.5rem 0.65rem;
    font-size: 0.85rem;
    color: #333;
    margin: 0.35rem 0;
}
.field-error { position: relative; margin-top: 0.35rem; }
.field-error::before {
    content: '';
    position: absolute;
    top: -7px;
    left: 14px;
    width: 12px;
    height: 12px;
    background: #fff;
    border-left: 1px solid #c62828;
    border-top: 1px solid #c62828;
    transform: rotate(45deg);
}
/* A handful of *Error properties render before a shared inline row of several bare inputs (no
   per-field wrapper to anchor an arrow to) rather than directly under one field's own .form-group
   — the arrow would point at the wrong control there, so it's dropped for those. */
.field-error--loose::before { display: none; }
.field-error-icon {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    background: #e8590c;
    color: #fff;
    font-weight: 700;
    font-size: 0.8rem;
    border-radius: 3px;
}
.field-error-text { flex: 1; }

/* A field currently carrying an error (server-rendered, date-entry.js, or a native constraint
   failure) gets the same red border the callout points at. */
.form-control.is-invalid { border-color: #c62828; }

/* On-screen validation summary dialog. Plain <dialog>; ::backdrop needs no vendor prefix in any
   browser this app targets (Chrome/Edge on Windows and Android). */
dialog.validation-dialog {
    border: 1px solid #ccc;
    border-radius: 8px;
    padding: 0;
    /* The global `* { margin: 0 }` reset at the top of this file strips the UA's
       `dialog { margin: auto }`, which is what centres a showModal() dialog (position:fixed;
       inset:0). Restore it explicitly. */
    margin: auto;
    width: min(560px, calc(100vw - 32px));
    max-width: none;
    max-height: 80vh;
    box-shadow: 0 4px 20px rgba(0,0,0,0.25);
}
dialog.validation-dialog[open] { display: flex; flex-direction: column; }
dialog.validation-dialog::backdrop { background: rgba(0,0,0,0.4); }
.validation-dialog-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.85rem 1rem;
    background: #ffebee;
    border-bottom: 1px solid #f0c0c0;
    font-weight: 700;
    color: #b71c1c;
}
.validation-dialog-body { padding: 0.25rem 0.5rem; flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.validation-dialog-list { list-style: none; }
.validation-dialog-list li { border-bottom: 1px solid #eee; }
.validation-dialog-list li:last-child { border-bottom: 0; }
.validation-dialog-item {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    width: 100%;
    text-align: left;
    background: none;
    border: 0;
    padding: 0.6rem 0.25rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: #333;
}
.validation-dialog-item:hover { background: #fafafa; }
.validation-dialog-item .field-error-icon { margin-top: 0.1rem; flex-shrink: 0; }
.validation-dialog-footer { display: flex; justify-content: flex-end; padding: 0.75rem 1rem; border-top: 1px solid #eee; }
.confirm-dialog-message { padding: 0.75rem 0.5rem; font-size: 0.95rem; }

/* Bootstrap-style helpers the Razor pages already use but the stylesheet never defined (filter bars, outline buttons, badges). */
.row.g-2 { display: flex; flex-wrap: wrap; gap: 0.5rem 0.75rem; }
.row.align-items-end { align-items: flex-end; }
.col-auto { flex: 0 0 auto; }
.form-check { display: flex; align-items: center; gap: 0.4rem; min-height: 2.3rem; }
/* Wide QA record tables scroll inside their own box at tablet width instead of running off the page. */
.table-scroll { overflow-x: auto; max-width: 100%; }
.table-scroll > .table { min-width: 720px; }

/* ── Refused Submit / Release: the gap list on the page and where the dialog takes you (validation-feedback.js) ── */
.gap-list { margin: 1rem 0; }
.gap-list-body { flex: 1; min-width: 0; }
.gap-list-items { list-style: disc; margin: 0.35rem 0 0 1.1rem; padding: 0; }
.gap-list-items li { margin: 0.15rem 0; }
/* The element the dialog just took the operator to: a 2 s outline flash. Reduced-motion users get a steady outline instead of a pulse. */
@keyframes gap-flash-pulse {
    0%   { outline-color: rgba(198, 40, 40, 0); }
    15%  { outline-color: #c62828; }
    70%  { outline-color: #c62828; }
    100% { outline-color: rgba(198, 40, 40, 0); }
}
.gap-flash {
    outline: 3px solid #c62828;
    outline-offset: 3px;
    border-radius: 3px;
    animation: gap-flash-pulse 2s ease-out 1;
}
@media (prefers-reduced-motion: reduce) {
    .gap-flash { animation: none; }
}

/* ── Tablet layout (targets 1280x800 landscape and 800x1280 portrait) ── */

/* Touch targets: every control is at least 44px in both directions, for gloved hands. */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; }
.form-control { min-height: 44px; }
.form-check { min-height: 44px; }
.form-check input[type="checkbox"], .form-check input[type="radio"],
label:not([class]):has(> input[type="checkbox"], > input[type="radio"]) input { width: 24px; height: 24px; flex: 0 0 auto; }
label:not([class]):has(> input[type="checkbox"], > input[type="radio"]) { display: inline-flex; align-items: center; gap: 0.5rem; min-height: 44px; }
.table td a:not(.btn) { display: inline-flex; align-items: center; justify-content: flex-start; min-height: 44px; padding: 0.25rem 0; }
.sidebar .nav-link { min-height: 44px; display: flex; align-items: center; }
/* QA form links: document id (small, grey) on its own line above the name. Colours are the darkest greys that still pass 4.5:1 on teal #37BBA1 (#123B33 ~5.2) and on the white active pill (#4A5B57 ~7). */
.sidebar .nav-link:has(.nav-doc) { flex-direction: column; align-items: flex-start; justify-content: center; gap: 0; line-height: 1.2; }
.sidebar .nav-doc { display: block; font-size: 0.7rem; font-weight: 500; letter-spacing: 0.02em; color: #123B33; }
.sidebar .nav-link.active .nav-doc, .sidebar .nav-link.active:hover .nav-doc { color: #4A5B57; }
.sidebar .nav-name { display: block; }
.nav-group-header { min-height: 44px; }
.impersonation-banner .impersonation-stop { min-height: 44px; min-width: 44px; }
.back-link, .content > p > a:only-child { display: inline-flex; align-items: center; min-height: 44px; }
.tab { display: inline-flex; align-items: center; min-height: 44px; }

/* Shared responsive table (table-stack.js labels the cells from the header row). At tablet-portrait
   width and below a `.table-stack` table turns into one card per row, each cell on its own line
   with its column name in front, so no column is ever off-screen and nothing needs a sideways scroll.
   Without JS the cells are stacked without their labels (still reachable, just unlabelled). */
@media (max-width: 900px) {
    .table.table-stack, .table-stack > tbody, .table-stack > thead, .table-stack > tfoot, .table-stack > tbody > tr, .table-stack > tbody > tr > td, .table-stack > tbody > tr > th { display: block; width: 100%; }
    .table.table-stack { background: transparent; box-shadow: none; border-radius: 0; overflow: visible; min-width: 0; }
    .table-stack > thead { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
    .table-stack > tbody > tr { background: #fff; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); margin: 0 0 0.75rem; padding: 0.4rem 0.75rem; }
    .table-stack > tbody > tr:hover { background: #fff; }
    .table-stack > tbody > tr > td, .table-stack > tbody > tr > th { position: relative; border-bottom: 1px solid #f0f0f0; padding: 0.4rem 0; min-width: 0; overflow-wrap: anywhere; }
    .table-stack > tbody > tr > td:last-child { border-bottom: 0; }
    .table-stack > tbody > tr > td[data-label]:not([data-label=""]) { padding-left: 9.25rem; min-height: 2.8rem; }
    .table-stack > tbody > tr > td[data-label]:not([data-label=""])::before { content: attr(data-label); position: absolute; left: 0; top: 0.5rem; width: 8.5rem; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; color: #666; }
    .table-stack > tbody > tr > td:empty { display: none; }
    /* Forms and fields inside a stacked cell never exceed it. */
    .table-stack td .ac-form-wide, .table-stack td form, .table-stack td .form-control { max-width: 100%; }
    .table-stack td .ac-form-wide { width: 100%; }
    .table-scroll > .table.table-stack { min-width: 0; }
}

/* Landscape tablet (1280 wide, 220px sidebar): tighter cells so the widest list tables (Pre-op checks) fit without clipping. */
@media (min-width: 901px) and (max-width: 1400px) {
    .table th, .table td { padding: 0.5rem 0.6rem; }
    .table td .btn-sm { min-width: 44px; }
}
.table td a:not(.btn) { min-width: 44px; }
/* summary keeps display:list-item (its disclosure marker needs it); 44px comes from padding. */
.table td summary:not(.btn) { cursor: pointer; min-height: 44px; padding: 0.6rem 0.25rem; }
.back-link, .content > a:first-child, .content > p > a:first-child:last-child { min-height: 44px; }
.form-check-label { display: inline-flex; align-items: center; min-height: 44px; }
.ac-summary a, [data-qa-summary] a { display: inline-flex; align-items: center; min-height: 44px; }
.date-entry .date-entry-btn { min-width: 44px; }

/* One check = one card: in a table whose rows are a main reading row plus follow-on rows (notes, deviation / locked / alert
   banners, hold readings, the Edit disclosure), the follow-on rows attach to the main row instead of floating as their own cards. */
@media (max-width: 900px) {
    .table-stack:has(> tbody > tr:is([data-cook-row], [data-chill-row], [data-component-row], [data-packaging-row])) > tbody > tr {
        margin: 0; border-radius: 0; box-shadow: none; border: 1px solid #dfe3e8; border-top: 0;
    }
    .table-stack:has(> tbody > tr:is([data-cook-row], [data-chill-row], [data-component-row], [data-packaging-row])) > tbody > tr:is([data-cook-row], [data-chill-row], [data-component-row], [data-packaging-row]) {
        margin-top: 0.75rem; border-top: 1px solid #dfe3e8; border-radius: 8px 8px 0 0;
    }
    .table-stack:has(> tbody > tr:is([data-cook-row], [data-chill-row], [data-component-row], [data-packaging-row])) > tbody > tr:first-child { margin-top: 0; }
    .table-stack:has(> tbody > tr:is([data-cook-row], [data-chill-row], [data-component-row], [data-packaging-row])) > tbody > tr:last-child,
    .table-stack:has(> tbody > tr:is([data-cook-row], [data-chill-row], [data-component-row], [data-packaging-row])) > tbody > tr:has(+ tr:is([data-cook-row], [data-chill-row], [data-component-row], [data-packaging-row])) {
        border-radius: 0 0 8px 8px; box-shadow: 0 2px 3px rgba(0,0,0,0.08);
    }
    .table-stack:has(> tbody > tr:is([data-cook-row], [data-chill-row], [data-component-row], [data-packaging-row])) > tbody > tr:is([data-cook-row], [data-chill-row], [data-component-row], [data-packaging-row]):last-child,
    .table-stack:has(> tbody > tr:is([data-cook-row], [data-chill-row], [data-component-row], [data-packaging-row])) > tbody > tr:is([data-cook-row], [data-chill-row], [data-component-row], [data-packaging-row]):has(+ tr:is([data-cook-row], [data-chill-row], [data-component-row], [data-packaging-row])) {
        border-radius: 8px;
    }
}

/* ---------------------------------------------------------------------------------------------------------------------
   Floor UI sidebar drawer (B3 / T7). Only on a QA form's pages (_Layout adds body.floor-ui from QaFormRegistry.FormForPath), only with JS
   (html.js), only below 1100 px. At >=1100 px the desktop « hide / ☰ show is unchanged; with JS off none of this matches and the pre-existing
   stacked bar (<=900 px) / fixed sidebar stays. nav.js opens / closes it by toggling .drawer-open (and html.nav-open, .content[inert]).
   Closed = off screen AND visibility:hidden, so its links are out of the tab order. It also undoes the <=900 px "fold to a top bar" rules.
   --------------------------------------------------------------------------------------------------------------------- */
.nav-scrim { display: none; }

@media (max-width: 1099.98px) {
    html.js body.floor-ui .layout { flex-direction: row; }

    html.js body.floor-ui .sidebar {
        position: fixed; top: 0; bottom: 0; left: 0;
        width: min(320px, 85vw);
        z-index: 1100;
        padding: 1rem; gap: 0.25rem;
        flex-direction: column;
        overflow-y: auto;
        overscroll-behavior: contain;
        transform: translateX(-100%);
        visibility: hidden;
        transition: transform 0.2s ease, visibility 0s linear 0.2s;
        box-shadow: none;
    }
    html.js body.floor-ui .sidebar.drawer-open {
        transform: none;
        visibility: visible;
        transition: transform 0.2s ease, visibility 0s;
        box-shadow: 4px 0 16px rgba(0, 0, 0, 0.35);
    }
    @media (prefers-reduced-motion: reduce) {
        html.js body.floor-ui .sidebar, html.js body.floor-ui .sidebar.drawer-open { transition: none; }
    }
    /* the desktop "hide" must not take the drawer away below 1100 px; ☰ is the way in */
    html.js body.floor-ui .layout.sidebar-collapsed .sidebar { display: flex; }

    /* undo the <=900 px folded top bar: the drawer shows its whole menu */
    html.js body.floor-ui .sidebar > *:not(.sidebar-header) { display: block; }
    html.js body.floor-ui .sidebar > .nav-link { display: flex; }
    html.js body.floor-ui .sidebar-header { margin-bottom: 1.5rem; padding-bottom: 0.75rem; border-bottom: 1px solid rgba(11, 46, 39, 0.35); }
    html.js body.floor-ui .nav-toggle { display: none; }
    html.js body.floor-ui .nav-hide { display: block; background: none; border: 0; color: var(--brand-ink, #0B2E27); font-size: 1.4rem; line-height: 1; cursor: pointer; padding: 0; min-width: 44px; min-height: 44px; }

    /* the fixed ☰ */
    html.js body.floor-ui .nav-show {
        display: block;
        position: fixed; top: 0.75rem; left: 0.75rem;
        z-index: 1001;
        background: var(--brand, #37BBA1); color: var(--brand-ink, #0B2E27);
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
        border: 0; border-radius: 6px;
        font-size: 1.4rem; line-height: 1;
        padding: 0.25rem 0.5rem; min-width: 44px; min-height: 44px;
        cursor: pointer;
    }

    html.js body.floor-ui .nav-scrim:not([hidden]) {
        display: block;
        position: fixed; inset: 0;
        z-index: 1050;
        border: 0; padding: 0;
        background: rgba(0, 0, 0, 0.45);
        cursor: pointer;
    }

    /* the page behind: 16 px side padding, clear of the fixed ☰ (12 px + 44 px) at the top; no scrolling while the drawer is open */
    html.js body.floor-ui .content { padding: 4rem 1rem 1.5rem; }
    html.js body.floor-ui .impersonation-banner { padding-left: 4rem; }
    /* scroll-margin-top (components.css) adds this: a row landing or a gap-dialog jump must clear the fixed ☰ (12-56 px) as well as the sticky banner + section tabs
       (components.css --banner-h / --tabs-h). The ☰ floats over the banner's and the tabs' left padding, so it is an allowance (a floor), not an addend. */
    html.js:has(body.floor-ui) { --sticky-top-h: max(3.5rem, calc(var(--banner-h, 0px) + var(--tabs-h, 0px))); }
    html.js body.floor-ui .section-tabs { padding-left: 3.25rem; }
    html.js.nav-open { overflow: hidden; }
}

/* ---------------------------------------------------------------------------------------------------------------------
   Floor UI touch targets (B3 / T8). Every control on a QA form's pages (body.floor-ui, set by _Layout from QaFormRegistry.FormForPath) is at least
   48 px tall with 16 px text (16 px also stops iOS zooming the page on focus). The sidebar / drawer buttons (outside .content) stay at 44 px.
   Dialogs sit under <body>, not .content, so they are listed on their own. `.floor-ui.floor-ui` doubles the class on purpose: components.css loads
   after this file and has per-component rules such as `.start-card .card-actions .btn { min-height: 44px }` that a single class would lose to.
   Nothing here widens a control, so the 1280 px layouts only grow taller; the render proof (tools/render-proof, t8-*) checks height and overflow.
   --------------------------------------------------------------------------------------------------------------------- */
body.floor-ui.floor-ui :is(.content, dialog) :is(
    input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=hidden]), select, textarea, button,
    .btn, .btn-sm, a.page-link, a.filter-clear, .save-add-clear, summary, .disclosure > summary, .add-reveal > summary,
    .seg__opt span, .seg > a.seg__opt, .date-entry-now, .date-entry-btn) {
    min-height: 48px;
    font-size: 16px;
}
body.floor-ui.floor-ui :is(.content, dialog) :is(.btn, .btn-sm, a.page-link, a.filter-clear, .save-add-clear, summary, .seg > a.seg__opt, .seg > button.seg__opt, .date-entry-now) {
    display: inline-flex; align-items: center; justify-content: center;
}
body.floor-ui.floor-ui .seg > button.seg__opt, body.floor-ui.floor-ui .seg--lg > button.seg__opt { min-height: 48px; font-size: 16px; }
/* a stand-alone <summary> is a disclosure toggle: keep its marker-less, left-aligned look */
body.floor-ui.floor-ui :is(.disclosure, .add-reveal) > summary { justify-content: flex-start; }
body.floor-ui.floor-ui dialog :is(button, .btn) { min-height: 48px; font-size: 16px; }
/* the sidebar's own buttons (the « hide, the group headers, the fixed ☰) */
body.floor-ui .sidebar :is(button, .nav-group-header), body.floor-ui .nav-show { min-height: 44px; }
