﻿/* ==========================================================================
   Precision Interior Products — Purchase Order Panel
   REPLACES the app.css generated by the Visual Studio template.
   ========================================================================== */

:root {
    --nav-bg: #0b1a3a;
    --nav-bg-2: #0f2148;
    --nav-active: #1b2f5c;
    --nav-text: #c9d4ec;
    --bg: #f4f6fb;
    --card: #ffffff;
    --border: #e6eaf2;
    --border-strong: #d5dbe7;
    --text: #0f1a33;
    --text-dim: #5c6b88;
    --text-mute: #8a97b5;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --blue-soft: #e3edff;
    --blue-ink: #1e40af;
    --amber-soft: #fde8c8;
    --amber-ink: #8a5a12;
    --green-soft: #d3f2df;
    --green-ink: #116a3a;
    --red-soft: #fbdcdc;
    --red-ink: #9c1f1f;
    --gray-soft: #e8ecf3;
    --gray-ink: #495467;
    --shadow-sm: 0 1px 2px rgba(15,26,51,.06);
    --shadow-lg: 0 20px 50px rgba(15,26,51,.18);

    /* Surfaces that were hard-coded white and light grey before the dark theme:
       inputs, buttons, dropdowns, table heads, hover rows. Paper things (the label
       sheet, the Microsoft sign-in button, print) deliberately keep #fff. */
    --surface: #ffffff;
    --surface-2: #f7f9fc;

    /* Added for the theme picker, so a theme can change more than colour. Each one
       replaces a value that used to be written straight into a rule below; the
       defaults here are those original values, so Classic looks exactly as before. */
    --font: 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, Helvetica, Arial, sans-serif;
    --heading-font: var(--font);
    --heading-weight: 700;
    --heading-spacing: normal;
    --on-primary: #ffffff;
    --nav-hover: rgba(255,255,255,.05);
    --nav-text-strong: #ffffff;
    --nav-sub-text: #a8b6d4;
    --nav-foot-text: #8a97b5;
    --nav-foot-link: #9db3e0;
    --nav-divider: rgba(255,255,255,.05);
    --page-pattern: none;
}

/* ==========================================================================
   THEMES
   Picked from the palette button in the sidebar footer (js/footer-tools.js) and
   applied to <html> as data-theme before first paint by the head script in
   App.razor. data-mode="light|dark" travels with it and carries the rules that
   depend only on light vs dark, so a new dark theme gets them without repeating
   them. Every theme keeps a dark sidebar: the logo artwork (logo-light.png,
   mark-light.png) is drawn light-on-dark. Fonts are ones Windows ships, so no
   theme downloads anything.

   Status colours (blue = moving, amber = waiting, green = done, red = stopped)
   keep their meaning in every theme; only their shade changes.
   ========================================================================== */

/* ---- Workshop: warm walnut and copper, condensed industrial type ---- */
:root[data-theme="workshop"] {
    --nav-bg: #1f1a15;
    --nav-bg-2: #2b231c;
    --nav-active: #3d3127;
    --nav-text: #dccbb5;
    --nav-sub-text: #bba68c;
    --nav-foot-text: #a08e78;
    --nav-foot-link: #e2a36f;
    --bg: #f5efe6;
    --card: #fffcf7;
    --border: #e7ddcf;
    --border-strong: #d8cab6;
    --text: #2a2119;
    --text-dim: #6c5c4b;
    --text-mute: #9a8975;
    --primary: #c2410c;
    --primary-hover: #9a3412;
    --blue-soft: #dcebf1;
    --blue-ink: #1d5a73;
    --amber-soft: #fbe6c2;
    --amber-ink: #8a5310;
    --green-soft: #dcefd9;
    --green-ink: #2f6a2a;
    --red-soft: #f8dcd6;
    --red-ink: #9b2c1a;
    --gray-soft: #ece4d8;
    --gray-ink: #5a4d40;
    --surface: #fffcf7;
    --surface-2: #f9f3ea;
    --shadow-sm: 0 1px 2px rgba(42,33,25,.08);
    --shadow-lg: 0 20px 50px rgba(42,33,25,.22);
    --font: 'Bahnschrift', 'Segoe UI', Arial, sans-serif;
    --heading-weight: 600;
    --heading-spacing: .3px;
    --h1-spacing: .3px;
}

/* ---- Sage: calm greens and soft paper, for a long day at the screen ---- */
:root[data-theme="sage"] {
    --nav-bg: #18261f;
    --nav-bg-2: #1f3128;
    --nav-active: #2c4639;
    --nav-text: #c5d6cb;
    --nav-sub-text: #a3b8aa;
    --nav-foot-text: #87a091;
    --nav-foot-link: #9fd1b2;
    --bg: #f1f4ef;
    --card: #ffffff;
    --border: #dfe6dc;
    --border-strong: #cbd6c7;
    --text: #1b261f;
    --text-dim: #56675b;
    --text-mute: #879589;
    --primary: #2f7d5b;
    --primary-hover: #246548;
    --blue-soft: #dfeaf2;
    --blue-ink: #285a78;
    --amber-soft: #f6e7c4;
    --amber-ink: #7d5a12;
    --green-soft: #d6eedd;
    --green-ink: #1c6a40;
    --red-soft: #f6dcda;
    --red-ink: #932a25;
    --gray-soft: #e5ebe3;
    --gray-ink: #4c5a50;
    --surface: #ffffff;
    --surface-2: #f6f8f4;
    --shadow-sm: 0 1px 2px rgba(27,38,31,.06);
    --shadow-lg: 0 20px 50px rgba(27,38,31,.18);
    --font: 'Segoe UI Variable Text', 'Segoe UI', Arial, sans-serif;
    --heading-font: Georgia, 'Times New Roman', serif;
    --heading-weight: 600;
}

/* ---- Blueprint: drafting-table blue on a faint grid, mono headings ---- */
:root[data-theme="blueprint"] {
    --nav-bg: #0b355c;
    --nav-bg-2: #0e416f;
    --nav-active: #15588f;
    --nav-text: #cde2f6;
    --nav-sub-text: #a9c8e6;
    --nav-foot-text: #8fb1d3;
    --nav-foot-link: #bfe0ff;
    --nav-hover: rgba(255,255,255,.08);
    --nav-divider: rgba(255,255,255,.1);
    --bg: #eef4fa;
    --card: #ffffff;
    --border: #d3e1ef;
    --border-strong: #b8cee4;
    --text: #0a2440;
    --text-dim: #48637f;
    --text-mute: #7c94ae;
    --primary: #0b6bcb;
    --primary-hover: #0957a6;
    --blue-soft: #dcebfb;
    --blue-ink: #0b4f94;
    --amber-soft: #fcecc8;
    --amber-ink: #85590c;
    --green-soft: #d8f0e2;
    --green-ink: #126b3d;
    --red-soft: #fbdede;
    --red-ink: #9a2222;
    --gray-soft: #e4ecf4;
    --gray-ink: #44566b;
    --surface: #ffffff;
    --surface-2: #f4f8fc;
    --heading-font: 'Cascadia Mono', Consolas, ui-monospace, monospace;
    --heading-weight: 600;
    --heading-spacing: -.2px;
    --h1-spacing: -.2px;
    --page-pattern:
        linear-gradient(rgba(11,107,203,.05) 1px, transparent 1px) 0 0 / 24px 24px,
        linear-gradient(90deg, rgba(11,107,203,.05) 1px, transparent 1px) 0 0 / 24px 24px;
}

/* ---- Brass: near-black with polished brass, the night shift's dark theme ---- */
:root[data-theme="brass"] {
    color-scheme: dark;
    --nav-bg: #0b0a08;
    --nav-bg-2: #12100c;
    --nav-active: #2a2417;
    --nav-text: #cdbf9c;
    --nav-sub-text: #a89c7e;
    --nav-foot-text: #857b63;
    --nav-foot-link: #d8b24a;
    --bg: #121110;
    --card: #1b1916;
    --border: #2c2822;
    --border-strong: #3c362c;
    --text: #eee7d6;
    --text-dim: #b3a98f;
    --text-mute: #82795f;
    --primary: #c9a227;
    --primary-hover: #dcb840;
    --on-primary: #1a1505;
    --blue-soft: #1b2733;
    --blue-ink: #9cc3e4;
    --amber-soft: #3a2c0e;
    --amber-ink: #efc865;
    --green-soft: #15291b;
    --green-ink: #85cf98;
    --red-soft: #3a1a17;
    --red-ink: #f0a197;
    --gray-soft: #26231e;
    --gray-ink: #c3b9a0;
    --surface: #201d19;
    --surface-2: #26221d;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.45);
    --shadow-lg: 0 20px 50px rgba(0,0,0,.6);
    --heading-font: Georgia, 'Times New Roman', serif;
    --heading-weight: 600;
    --heading-spacing: .2px;
    --h1-spacing: .2px;
}

/* ---------- DARK THEME ----------
   Switched by the moon button in the sidebar footer (js/footer-tools.js), remembered
   in localStorage, applied to <html> before first paint by the inline script in
   App.razor. Everything below is the same tokens with night values; the sidebar was
   already dark and only gets a shade deeper so the page beside it still reads as the
   lighter of the two. color-scheme:dark turns native pieces (date pickers, selects,
   scrollbars) dark without styling each one. */
:root[data-theme="dark"] {
    color-scheme: dark;
    --nav-bg: #070e1f;
    --nav-bg-2: #0a1430;
    --nav-active: #172a57;
    --nav-text: #b9c6e4;
    --bg: #0e1322;
    --card: #161d30;
    --border: #252f47;
    --border-strong: #33405c;
    --text: #e7ecf7;
    --text-dim: #a2aec8;
    --text-mute: #7482a3;
    --primary: #5b8cff;
    --primary-hover: #7aa0ff;
    --blue-soft: #1b2a4d;
    --blue-ink: #a9c1ff;
    --amber-soft: #3a2a10;
    --amber-ink: #f1c266;
    --green-soft: #10301d;
    --green-ink: #6fd396;
    --red-soft: #3d1b1b;
    --red-ink: #f39a9a;
    --gray-soft: #222b40;
    --gray-ink: #b8c2d8;
    --surface: #1a2237;
    --surface-2: #1f2940;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
    --shadow-lg: 0 20px 50px rgba(0,0,0,.55);
}

/* The few places that used their own pastel rather than a token. */
:root[data-mode="dark"] .stat.open .stat-ico { background: var(--blue-soft); color: var(--blue-ink); }
:root[data-mode="dark"] .stat.ship .stat-ico { background: var(--blue-soft); color: var(--blue-ink); }
:root[data-mode="dark"] .stat.back .stat-ico { background: var(--amber-soft); color: var(--amber-ink); }
:root[data-mode="dark"] .stat.back .stat-value { color: var(--amber-ink); }
:root[data-mode="dark"] .stat.recv .stat-ico { background: var(--green-soft); color: var(--green-ink); }
:root[data-mode="dark"] .stat.recv .stat-value { color: var(--green-ink); }
:root[data-mode="dark"] .update-banner { background: var(--amber-soft); color: var(--amber-ink); border-color: #7a5a1a; }
:root[data-mode="dark"] .draft-notice { background: var(--blue-soft); color: var(--blue-ink); border-color: #2f4a8a; }
:root[data-mode="dark"] .toast { background: #e7ecf7; color: #0f1a33; }
:root[data-mode="dark"] .alert-danger { background: var(--red-soft); color: var(--red-ink); border-color: #5a2a2a; }
:root[data-mode="dark"] .alert-success { background: var(--green-soft); color: var(--green-ink); border-color: #1f4a30; }
:root[data-mode="dark"] .file-preview iframe { background: #fff; }   /* a PDF page is paper */

* { box-sizing: border-box; }

html, body {
    height: 100%;
    margin: 0;
    font-family: var(--font);
    background: var(--page-pattern), var(--bg);
    color: var(--text);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); }

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

/* ---------- LAYOUT ----------

   Heights are written twice on purpose: 100vh first as the floor, 100dvh second
   for anything that understands it. On a phone 100vh is the address-bar-EXPANDED
   height, which is taller than what you can actually see — and since .app-shell
   is overflow:hidden with .main-area scrolling inside it, the bottom of every
   page sat underneath the browser chrome with no way to scroll to it. */
.app-shell {
    display: flex;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

.sidebar {
    width: 236px;
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--nav-bg) 0%, var(--nav-bg-2) 100%);
    color: var(--nav-text);
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
}

.brand {
    padding: 18px 20px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--nav-divider);
}

/* The full lockup, at the sidebar's whole usable width (236 - 40px of padding).
   Anything narrower and the PRECISION INTERIOR PRODUCTS line stops being legible —
   it is the width, not the height, that decides whether the wordmark reads.

   logo-light.png is a recoloured derivative of logo.png: the artwork ships with black
   ink, which is invisible against #0b1a3a. Regenerate both derivatives if the logo
   ever changes; the original stays in the repo as the source. */
.brand-logo {
    width: 100%;
    aspect-ratio: 392 / 241;
    background: url('logo-light.png') no-repeat center;
    background-size: contain;
}

.nav-menu { padding: 14px 12px; flex: 1; overflow-y: auto; }

.nav-menu .nav-link {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 14px; border-radius: 8px;
    color: var(--nav-text); text-decoration: none;
    font-weight: 500; font-size: 14px; margin-bottom: 2px;
    transition: background .15s ease, color .15s ease;
}

.nav-menu .nav-link:hover { background: var(--nav-hover); color: var(--nav-text-strong); }

.nav-menu .nav-link.active {
    background: var(--nav-active); color: var(--nav-text-strong);
    box-shadow: inset 3px 0 0 var(--primary);
}

.nav-menu .nav-link svg { width: 18px; height: 18px; stroke-width: 1.8; flex-shrink: 0; }

/* ---- The count on the Stock Requests nav item ----
   Same red pill as .bell-badge, pushed to the far edge of the link. The nav-link
   is the positioning context for the rail rule below, where the pill becomes a
   dot on the icon's corner because there is no room for a number. */
.nav-menu .nav-link { position: relative; }

.nav-badge {
    margin-left: auto;
    min-width: 18px; padding: 1px 5px; border-radius: 999px;
    background: #e74c3c; color: #fff;
    font-size: 10.5px; font-weight: 700; text-align: center;
    font-variant-numeric: tabular-nums;
}

.sidebar-foot {
    padding: 14px 20px;
    border-top: 1px solid var(--nav-divider);
    font-size: 12px;
    color: var(--nav-foot-text);
}

.sidebar-foot a { color: var(--nav-foot-link); text-decoration: none; }
.sidebar-foot a:hover { text-decoration: underline; }

.sidebar-foot .who { font-weight: 600; color: #e6ecf8; margin-bottom: 6px; }
.sidebar-foot .foot-links { display: flex; gap: 12px; align-items: center; }
.sidebar-foot form { display: inline; margin: 0; }

/* The sign-out control has to be a form button (it POSTs), but it should read as
   the link next to it. */
.sidebar-foot .linkish {
    background: none; border: 0; padding: 0;
    color: var(--nav-foot-link); font: inherit; font-size: 12px; cursor: pointer;
}

.sidebar-foot .linkish:hover { text-decoration: underline; }

.main-area {
    flex: 1; min-width: 0; overflow-y: auto; padding: 0 32px 40px;
    height: 100vh;
    height: 100dvh;
}

/* Both exist only on a phone, where the sidebar slides in over the page instead of
   sitting beside it. Everywhere else the sidebar is simply there and neither the
   hamburger nor the scrim behind it has anything to do. See RESPONSIVE. */
.mobile-bar { display: none; }
.nav-scrim { display: none; }

.page-head {
    padding: 22px 0;
    display: flex; align-items: center; justify-content: space-between;
}

.page-head h1 {
    margin: 0; font-size: 26px;
    font-family: var(--heading-font); font-weight: var(--heading-weight);
    /* Classic keeps the original tight -.3px; a theme that sets a spacing gets its own. */
    letter-spacing: var(--h1-spacing, -.3px);
}

/* ---------- BUTTONS ---------- */
.primary-btn {
    background: var(--primary); color: var(--on-primary); border: none; border-radius: 10px;
    padding: 11px 20px; font-weight: 600; font-size: 14px; cursor: pointer;
    display: inline-flex; align-items: center; gap: 8px;
    box-shadow: 0 4px 12px color-mix(in srgb, var(--primary) 28%, transparent);
}

.primary-btn:hover:not(:disabled) { background: var(--primary-hover); }
.primary-btn:disabled { opacity: .55; cursor: not-allowed; }
.primary-btn svg { width: 16px; height: 16px; }

.ghost-btn {
    background: var(--surface); color: var(--text); border: 1px solid var(--border-strong);
    border-radius: 10px; padding: 10px 18px; font-weight: 500; font-size: 13px; cursor: pointer;
}

.ghost-btn:hover:not(:disabled) { background: var(--surface-2); }
.ghost-btn:disabled { opacity: .55; cursor: not-allowed; }

/* Cancel in a drawer footer: red, and pushed to the far left so it sits away from
   the primary action instead of right beside it. */
.ghost-btn.cancel-btn { color: var(--red-ink); border-color: var(--red-ink); }
.ghost-btn.cancel-btn:hover:not(:disabled) { background: var(--red-soft); }
.drawer-foot .cancel-btn { margin-right: auto; }

.icon-x {
    background: transparent; border: none; color: var(--text-dim);
    font-size: 24px; line-height: 1; cursor: pointer;
    width: 32px; height: 32px; border-radius: 8px;
}

.icon-x:hover { background: var(--surface-2); color: var(--text); }

/* ---------- STAT TILES ---------- */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 22px; }

.stat {
    background: var(--card); border: 1px solid var(--border); border-radius: 14px;
    padding: 20px 22px; display: flex; align-items: center; gap: 16px; box-shadow: var(--shadow-sm);
}

.stat .stat-ico {
    width: 52px; height: 52px; border-radius: 50%;
    display: grid; place-items: center; flex-shrink: 0;
}

.stat .stat-ico svg { width: 22px; height: 22px; }
.stat .stat-label { font-size: 13px; color: var(--text-dim); margin-bottom: 2px; font-weight: 500; }
.stat .stat-value { font-size: 26px; font-weight: 700; color: var(--primary); line-height: 1; font-family: var(--heading-font); }

.stat.open .stat-ico { background: color-mix(in srgb, var(--primary) 12%, var(--card)); color: var(--primary); }
.stat.ship .stat-ico { background: #e0efff; color: #1e6ac9; }
.stat.back .stat-ico { background: #fde8c8; color: #d97706; }
.stat.back .stat-value { color: #d97706; }
.stat.recv .stat-ico { background: #d3f2df; color: #116a3a; }
.stat.recv .stat-value { color: #116a3a; }

/* ---------- PANEL + TABLE ---------- */
.panel {
    background: var(--card); border: 1px solid var(--border);
    border-radius: 14px; box-shadow: var(--shadow-sm); overflow: hidden;
}

.panel-tools {
    padding: 16px 20px; display: flex; align-items: center; gap: 12px;
    flex-wrap: wrap; border-bottom: 1px solid var(--border);
}

.search { flex: 1; min-width: 240px; position: relative; }

.search svg {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    width: 16px; height: 16px; color: var(--text-mute);
}

.search input {
    width: 100%; padding: 10px 12px 10px 36px; border-radius: 10px;
    border: 1px solid var(--border-strong); font-size: 13px;
    color: var(--text); background: var(--surface); outline: none;
}

.search input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent); }

.select-wrap {
    display: inline-flex; align-items: center;
    border: 1px solid var(--border-strong); border-radius: 10px;
    background: var(--surface); padding: 0 6px;
}

.select-wrap select {
    border: none; background: transparent; font: inherit; font-size: 13px;
    color: var(--text); padding: 10px 8px; outline: none; cursor: pointer;
}

.checkbox {
    display: inline-flex; align-items: center; gap: 7px;
    font-size: 13px; color: var(--text-dim); cursor: pointer; user-select: none;
}

/* A typed filter with a datalist behind it, dressed like the selects beside it. */
.filter-text input {
    width: 170px; padding: 10px 12px; border-radius: 10px;
    border: 1px solid var(--border-strong); font: inherit; font-size: 13px;
    color: var(--text); background: var(--surface); outline: none;
}

.filter-text input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent); }

/* A from/to pair of date inputs, dressed to sit beside the selects as one control. */
.date-range {
    display: inline-flex; align-items: center; gap: 6px;
    border: 1px solid var(--border-strong); border-radius: 10px;
    background: var(--surface); padding: 0 8px;
    font-size: 12.5px; color: var(--text-mute);
}

.date-range input {
    border: none; background: transparent; font: inherit; font-size: 13px;
    color: var(--text); padding: 9px 2px; outline: none; min-width: 0;
}

.date-range input:focus { color: var(--primary); }

/* Sits at the end of the filter row, a size down from the page buttons so it reads
   as part of the row rather than as an action. */
.filter-clear { padding: 9px 14px; margin-left: auto; }

.table-wrap { overflow-x: auto; }

table.po { width: 100%; border-collapse: collapse; font-size: 13.5px; }

table.po thead th {
    text-align: left; font-weight: 600; color: var(--text-dim);
    padding: 14px 12px; font-size: 12.5px;
    border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap;
}

table.po tbody td {
    padding: 15px 12px; border-bottom: 1px solid var(--border);
    color: var(--text); white-space: nowrap;
}

table.po tbody tr:hover { background: var(--surface-2); }
table.po td:first-child, table.po th:first-child { padding-left: 20px; }
table.po td:last-child, table.po th:last-child { padding-right: 20px; }
table.po td.mono { font-variant-numeric: tabular-nums; color: var(--text-dim); font-weight: 500; }
table.po td.po-num { font-weight: 600; }
table.po td.empty { padding: 40px; text-align: center; color: var(--text-mute); }

/* ---------- STATUS PILLS ---------- */
.pill {
    display: inline-flex; align-items: center;
    padding: 4px 10px; border-radius: 999px;
    font-size: 12px; font-weight: 500; white-space: nowrap;
}

.pill.blue  { background: var(--blue-soft);  color: var(--blue-ink); }
.pill.amber { background: var(--amber-soft); color: var(--amber-ink); }
.pill.green { background: var(--green-soft); color: var(--green-ink); }
.pill.red   { background: var(--red-soft);   color: var(--red-ink); }
.pill.gray  { background: var(--gray-soft);  color: var(--gray-ink); }

/* ---------- PAGINATION ---------- */
.pager {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 20px; color: var(--text-dim); font-size: 13px;
}

.pager-mid { display: flex; align-items: center; gap: 12px; }

.pg-btn {
    padding: 7px 14px; border-radius: 8px; border: 1px solid var(--border-strong);
    background: var(--surface); color: var(--text); cursor: pointer; font-weight: 500; font-size: 13px;
}

.pg-btn:hover:not(:disabled) { background: var(--surface-2); }
.pg-btn:disabled { opacity: .45; cursor: not-allowed; }
.pg-current { font-variant-numeric: tabular-nums; }

/* ---------- PO DETAIL ---------- */
.back-link {
    display: inline-block; font-size: 12px; color: var(--text-dim);
    text-decoration: none; margin-bottom: 4px;
}

.back-link:hover { color: var(--primary); }

.detail-title { display: flex; align-items: center; gap: 12px; }

.head-actions { display: flex; align-items: center; gap: 10px; }

/* minmax(0,1fr) rather than 1fr: without it a long unbroken value — a pasted URL,
   a 200-character job name — pushes the main column past the viewport. */
.detail-grid {
    display: grid; grid-template-columns: minmax(0, 1fr) 340px;
    gap: 20px; align-items: start;
}

/* The closing splits nearer to even than the rest of the app. The left side is four
   narrow numeric columns with nothing long in them, while the right side has to lay out
   twenty batch amounts — so the usual "wide main column, fixed sidebar" is backwards
   here and starves the half that actually needs the width. */
.closing-detail .detail-grid { grid-template-columns: minmax(0, 0.8fr) minmax(0, 1fr); }

/* Placed explicitly, because the card batches come FIRST in the markup now — the printed
   card sheet has to be page one, and print order follows the DOM. On screen the cash side
   still belongs on the left. */
/* grid-row is not optional here. Auto-placement only moves forward, so with the cards
   column first in the markup it takes row 1 column 2 and the cash column - wanting
   column 1 - is pushed down to row 2, landing under the totals instead of beside them. */
.closing-detail .col-cash  { grid-column: 1; grid-row: 1; }
.closing-detail .col-cards { grid-column: 2; grid-row: 1; }

/* Screen must not show the printed headings and signature lines. This lived just above
   the print block and was lost when that block moved to the end of the file, which put
   a second "Conroe Daily Closing" title in the middle of the page. */
.print-only { display: none; }

.detail-col { display: flex; flex-direction: column; gap: 20px; min-width: 0; }

/* Same visual tokens as .panel, but a separate class: .panel sets overflow:hidden
   for its edge-to-edge table, which would clip anything that needs to escape. */
.card {
    background: var(--card); border: 1px solid var(--border);
    border-radius: 14px; box-shadow: var(--shadow-sm);

    /* Explicit, because Bootstrap also has a .card and it sets color to Bootstrap's
       fixed near-black body colour. That was invisible in light mode (same ink) and
       turned every card heading and label dark-on-dark the day the theme switched. */
    color: var(--text);
}

.card-head {
    padding: 14px 20px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
}

.card-head h2 { margin: 0; font-size: 14px; font-weight: 700; font-family: var(--heading-font); letter-spacing: var(--heading-spacing); }
.card-body { padding: 18px 20px; }

.notice {
    padding: 40px 20px; text-align: center; color: var(--text-dim);
}

.notice p { margin: 0 0 16px; }

/* auto-fit gives 3 columns wide, 2 medium and 1 on mobile from one declaration. */
.kv-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 16px 24px;
}

.kv { min-width: 0; }
.kv.wide { grid-column: 1 / -1; }

.kv-label {
    font-size: 12px; font-weight: 600; color: var(--text-dim); margin-bottom: 3px;
}

.kv-value { font-size: 14px; color: var(--text); overflow-wrap: anywhere; }
.kv-value.mono { font-variant-numeric: tabular-nums; }
.kv-value.empty { color: var(--text-mute); }
.kv-value.notes { white-space: pre-wrap; line-height: 1.55; }

.field-hint { margin: 6px 0 0; font-size: 12px; color: var(--text-mute); }

/* The inline note prompt that every status change goes through. */
.confirm-bar {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 12px 20px; border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}

.confirm-bar .confirm-label { font-size: 13px; font-weight: 600; white-space: nowrap; }

.confirm-bar input {
    flex: 1; min-width: 180px; padding: 9px 12px; border-radius: 8px;
    border: 1px solid var(--border-strong); font: inherit; font-size: 13px;
    color: var(--text); background: var(--surface); outline: none;
}

.confirm-bar input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent); }

/* The one-line warning under a manager's shortcut. Takes the full row beneath the
   controls so the sentence is never squeezed between the note box and the buttons. */
.confirm-bar .confirm-hint {
    flex: 1 1 100%; margin: 0; font-size: 12.5px; color: var(--text-mute);
}

/* ---------- STATUS TIMELINE ---------- */
.timeline { list-style: none; margin: 0; padding: 0 0 0 24px; position: relative; }

.tl-item { position: relative; padding-bottom: 18px; }
.tl-item:last-child { padding-bottom: 0; }

.tl-item::before {
    content: ''; position: absolute; left: -24px; top: 3px;
    width: 11px; height: 11px; border-radius: 50%;
    background: var(--gray-soft); border: 2px solid var(--gray-ink); box-sizing: border-box;
}

/* Rail drawn per item rather than on the <ol>, so no stub hangs past the last dot. */
.tl-item:not(:last-child)::after {
    content: ''; position: absolute; left: -19px; top: 16px; bottom: 0;
    width: 2px; background: var(--border);
}

/* Dot colour comes from PoStatusExtensions.PillClass() — one status-to-colour
   function, two renderings, so the pill and the dot cannot drift apart. */
.tl-item.blue::before  { background: var(--blue-soft);  border-color: var(--blue-ink); }
.tl-item.amber::before { background: var(--amber-soft); border-color: var(--amber-ink); }
.tl-item.green::before { background: var(--green-soft); border-color: var(--green-ink); }
.tl-item.red::before   { background: var(--red-soft);   border-color: var(--red-ink); }
.tl-item.gray::before  { background: var(--gray-soft);  border-color: var(--gray-ink); }

.tl-what { font-size: 13px; font-weight: 600; }

/* The activity feed puts a sentence on the .tl-what line — "Dana moved C205 to
   Shipping" — so the name and the link stay bold and the verb between them does not. */
.tl-what .tl-verb { font-weight: 400; color: var(--text-dim); }

/* Up to 50 events, so the list scrolls inside the card rather than stretching the
   dashboard row to the length of the busiest afternoon. Padding on the right keeps the
   scrollbar off the text; the left padding is the timeline rail's. */
.activity-feed { max-height: 420px; overflow-y: auto; padding-right: 8px; }
.tl-when { font-size: 12px; color: var(--text-mute); font-variant-numeric: tabular-nums; }
.tl-note { font-size: 12.5px; color: var(--text-dim); margin-top: 3px; white-space: pre-wrap; }

/* ---------- COMMENTS ---------- */
.comment {
    border-left: 2px solid var(--border); padding-left: 12px; margin-bottom: 16px;
}

.comment-head { display: flex; align-items: baseline; gap: 8px; font-size: 12px; }
.comment-who { font-weight: 600; color: var(--text); }
.comment-when { color: var(--text-mute); font-variant-numeric: tabular-nums; }

/* pre-wrap because pasted vendor emails otherwise collapse into one paragraph;
   overflow-wrap because a single pasted tracking URL otherwise widens the card. */
.comment-body {
    font-size: 13.5px; line-height: 1.55; margin-top: 4px;
    white-space: pre-wrap; overflow-wrap: anywhere;
}

.comment-empty { color: var(--text-mute); font-size: 13px; margin: 0 0 16px; }

.comment-new { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.comment-new textarea {
    width: 100%; padding: 10px 12px; border-radius: 8px;
    border: 1px solid var(--border-strong); font: inherit; font-size: 13px;
    color: var(--text); background: var(--surface); outline: none; resize: vertical; min-height: 70px;
}

.comment-new textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent); }

/* ---------- ATTACHMENTS ---------- */
.file {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 0; border-bottom: 1px solid var(--border);
}

.file:last-child { border-bottom: none; }

.file-ico {
    width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0;
    background: var(--gray-soft); color: var(--gray-ink);
    display: grid; place-items: center;
}

.file-ico svg { width: 16px; height: 16px; }

.file-main { min-width: 0; flex: 1; }

.file-name {
    color: var(--primary); font-weight: 600; font-size: 13px;
    text-decoration: none; overflow-wrap: anywhere;
}

.file-name:hover { text-decoration: underline; }
.file-meta { font-size: 12px; color: var(--text-mute); margin-top: 2px; }
.file-empty { color: var(--text-mute); font-size: 13px; margin: 0; }

.upload-row {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border);
}

.upload-row input[type=file] { font: inherit; font-size: 12px; max-width: 100%; }
.upload-hint { flex-basis: 100%; margin: 0; font-size: 12px; color: var(--text-mute); }

/* ---------- BARE SHELL (error page) ---------- */
.bare-shell { max-width: 620px; margin: 80px auto; padding: 0 24px; }

/* ---------- ADMIN SCREENS ---------- */
.row-actions { display: flex; gap: 8px; justify-content: flex-end; }

.mini-btn {
    padding: 4px 10px; font-size: 12px; border-radius: 6px; font: inherit; font-size: 12px;
    border: 1px solid var(--border-strong); background: var(--surface);
    color: var(--text); cursor: pointer; white-space: nowrap;
}

.mini-btn:hover:not(:disabled) { background: var(--surface-2); }
.mini-btn:disabled { opacity: .5; cursor: not-allowed; }
.mini-btn.danger { color: var(--red-ink); border-color: var(--red-soft); }
.mini-btn.danger:hover:not(:disabled) { background: var(--red-soft); }

/* Two-up inside the drawer, for pairs like Name + Code. */
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* A checkbox that reads as a field rather than as stray form furniture. */
.field .field-check {
    display: flex; align-items: center; gap: 8px;
    font-size: 13px; font-weight: 500; cursor: pointer;
}

.field .field-check input { width: auto; }

/* ---------- CLICKABLE TABLE ROWS ---------- */
table.po tbody tr.row-link { cursor: pointer; }

/* The focusable element is the anchor inside the cell, so surface its focus at
   row level — otherwise keyboard users get a ring around three words of a wide row. */
table.po tbody tr.row-link:focus-within {
    outline: 2px solid var(--primary); outline-offset: -2px;
}

/* ---------- DRAWER ---------- */
.drawer-scrim {
    position: fixed; inset: 0; background: rgba(15,26,51,.28);
    opacity: 0; pointer-events: none; transition: opacity .2s ease; z-index: 40;
}

.drawer-scrim.open { opacity: 1; pointer-events: auto; }

.drawer {
    position: fixed; top: 0; right: 0; height: 100vh; width: 400px; max-width: 96vw;
    background: var(--surface); box-shadow: var(--shadow-lg);
    transform: translateX(100%); transition: transform .25s ease; z-index: 50;
    display: flex; flex-direction: column;
}

.drawer.open { transform: translateX(0); }

.drawer-head {
    padding: 22px 24px 14px; display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.drawer-head h2 { margin: 0; font-size: 17px; font-weight: 700; font-family: var(--heading-font); letter-spacing: var(--heading-spacing); }

.drawer-body { padding: 20px 24px; overflow-y: auto; flex: 1; }

.drawer-foot {
    padding: 14px 24px; border-top: 1px solid var(--border);
    display: flex; justify-content: flex-end; gap: 10px;
}

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field .req { color: #dc2626; }

.field input, .field select, .field textarea {
    width: 100%; padding: 10px 12px; border-radius: 8px;
    border: 1px solid var(--border-strong); font: inherit; font-size: 13px;
    color: var(--text); background: var(--surface); outline: none;
}

.field input:focus, .field select:focus, .field textarea:focus {
    border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent);
}

.field textarea { resize: vertical; min-height: 78px; }
.field select:disabled { background: var(--bg); color: var(--text-mute); }

.form-error {
    background: var(--red-soft); color: var(--red-ink);
    padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 16px;
}

/* ---------- TOAST ---------- */
.toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
    background: #0f1a33; color: #fff; padding: 11px 18px; border-radius: 10px;
    font-size: 13px; z-index: 60; box-shadow: var(--shadow-lg);
}

/* ---------- UPDATE BANNER + RESTORED DRAFT ---------- */
/* Shown by UpdateNotice the moment the server begins stopping for a deploy. Fixed and
   above everything, because the circuit is about to go and the page will reload. */
.update-banner {
    position: fixed; top: 12px; left: 50%; transform: translateX(-50%);
    background: #fef3c7; color: #78350f; border: 1px solid #f59e0b;
    padding: 10px 16px; border-radius: 10px; font-size: 13px; z-index: 1001;
    box-shadow: var(--shadow-lg); max-width: min(92vw, 560px);
}

/* Shown by a page that has just put back what somebody was typing before a reload. */
.draft-notice {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    background: #eff6ff; color: #1e3a8a; border: 1px solid #bfdbfe;
    padding: 8px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 14px;
}

.draft-notice button {
    background: none; border: 0; padding: 0; cursor: pointer; font: inherit;
    color: inherit; text-decoration: underline; white-space: nowrap;
}

/* ---------- BLAZOR ERROR UI (from the template, restyled) ---------- */
#blazor-error-ui {
    background: #fef0c7; bottom: 0; box-shadow: 0 -1px 2px rgba(0,0,0,.2);
    display: none; left: 0; padding: 14px 20px; position: fixed; width: 100%; z-index: 1000;
}

#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 18px; top: 12px; }

.blazor-error-boundary {
    background: var(--red-soft); color: var(--red-ink);
    padding: 14px 20px; border-radius: 8px; margin: 16px 0;
}

/* ---------- SHARED PO COUNTER ---------- */
.counter-panel { padding: 18px 20px; margin-bottom: 16px; }

.counter-row {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
    flex-wrap: wrap;
}

.counter-value { font-size: 22px; font-weight: 700; margin: 2px 0 4px; }

.counter-edit { display: flex; align-items: center; gap: 8px; }
.counter-edit input { width: 130px; }

/* ---------- REFERENCES CARD ---------- */
.refs-foot {
    display: flex; align-items: center; justify-content: flex-end; gap: 10px;
    margin-top: 4px;
}

.refs-ok { font-size: 12px; color: var(--green-ink); font-weight: 600; }

/* ---------- HELP TIPS ---------- */
/* Shown on hover AND focus-within: hover alone is unreachable by keyboard and invisible
   on a touch screen, where tapping is the only gesture available. */
.helptip {
    position: relative; display: inline-flex; vertical-align: middle;
    margin-left: 5px; cursor: help;
}

.helptip-icon {
    width: 15px; height: 15px; border-radius: 50%;
    background: var(--border-strong); color: #fff;
    font-size: 10px; font-weight: 700; line-height: 15px; text-align: center;
    user-select: none;
}

.helptip:hover .helptip-icon,
.helptip:focus-within .helptip-icon { background: var(--primary); }

.helptip-bubble {
    position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
    width: 230px; padding: 9px 11px; z-index: 40;
    background: var(--text); color: #fff;
    border-radius: 8px; box-shadow: var(--shadow-lg);
    font-size: 12px; font-weight: 400; line-height: 1.5; text-align: left;
    white-space: normal; text-transform: none; letter-spacing: normal;
    opacity: 0; visibility: hidden; transition: opacity .12s ease;
    pointer-events: none;
}

.helptip.wide .helptip-bubble { width: 300px; }
.helptip-bubble strong { display: block; margin-bottom: 3px; color: #fff; }

.helptip:hover .helptip-bubble,
.helptip:focus-within .helptip-bubble { opacity: 1; visibility: visible; }

/* Bubbles near the right edge would otherwise be clipped by the panel. */
.helptip-bubble::after {
    content: ""; position: absolute; top: 100%; left: 50%; margin-left: -5px;
    border: 5px solid transparent; border-top-color: var(--text);
}

/* ---- Inside a scrolling container ----
   .drawer-body sets overflow-y:auto, and a scroll container clips BOTH axes — overflow-x
   cannot stay visible next to it, it computes to auto. So a bubble centred on the icon
   loses whatever sticks out past the drawer's left edge, which is what happened to the
   Stock tip: the drawer is 400px wide and the bubble was 300.

   Inside the drawer the bubble therefore anchors to the field instead of the icon,
   spanning its full width and sitting below it. It cannot overflow horizontally because
   it is exactly as wide as the thing it belongs to. */
.drawer-body .field label,
.drawer-body .field-check { position: relative; }

.drawer-body .helptip { position: static; }

.drawer-body .helptip-bubble {
    left: 0; right: 0; width: auto; max-width: none;
    transform: none;
    bottom: auto; top: calc(100% + 7px);
}

/* The pointer has to move to the top edge now the bubble sits below. */
.drawer-body .helptip-bubble::after {
    top: auto; bottom: 100%; left: 18px; margin-left: 0;
    border-top-color: transparent; border-bottom-color: var(--text);
}

.helptip:focus { outline: none; }
.helptip:focus-visible .helptip-icon { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- EMPTY STATES ---------- */
/* An empty table that only says "no results" leaves somebody stuck. These say what to
   do next instead. */
.empty-help { padding: 34px 20px !important; text-align: center; }
.empty-help .empty-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.empty-help .empty-body { color: var(--text-dim); font-size: 13.5px; max-width: 460px; margin: 0 auto; }
.empty-help .empty-body + .empty-body { margin-top: 8px; }

/* ---------- STATUS LEGEND ---------- */
.status-legend { border-top: 1px solid var(--border); padding: 14px 20px; }
.status-legend > summary {
    cursor: pointer; font-size: 13px; color: var(--text-dim); font-weight: 500;
    list-style: none; display: inline-flex; align-items: center; gap: 6px;
}
.status-legend > summary::-webkit-details-marker { display: none; }
/* Drawn with borders rather than a triangle character. The unicode escape for one
   renders as a tofu box in the Segoe/Inter stack on Windows, and writing the escape
   itself through a script turned it into a literal control byte once already. */
.status-legend > summary::before {
    content: ""; width: 0; height: 0;
    border-left: 5px solid currentColor;
    border-top: 4px solid transparent; border-bottom: 4px solid transparent;
    transition: transform .15s ease;
}
.status-legend[open] > summary::before { transform: rotate(90deg); }
.status-legend > summary:hover { color: var(--primary); }

.legend-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 10px 22px; margin-top: 14px;
}
.legend-item { display: flex; gap: 10px; align-items: baseline; font-size: 13px; }
.legend-item .pill { flex-shrink: 0; }
.legend-item span { color: var(--text-dim); }

/* ---------- DAILY CLOSING ---------- */
/* table.po tbody td is 0-1-3; .count-table td is only 0-1-1, so the plain class never
   won and these tables have been rendering at the full 15px row padding. Matching the
   base selector's shape is what makes the compact version apply. */
table.po.count-table thead th,
table.po.count-table tbody td { padding: 6px 10px; }
table.po.count-table td:first-child, table.po.count-table th:first-child { padding-left: 10px; }
table.po.count-table td:last-child, table.po.count-table th:last-child { padding-right: 10px; }
.count-table .num { text-align: right; }

/* Fixed layout, or the label column takes every spare pixel and leaves a hand's width of
   nothing between "Nickel" and "0.05". The four columns are all short — a denomination
   name, two small numbers and a total — so sizing them to content is the wrong instinct. */
table.po.drawer-table { table-layout: fixed; }
.drawer-table th:nth-child(1), .drawer-table td:nth-child(1) { width: 40%; }
.drawer-table th:nth-child(2), .drawer-table td:nth-child(2) { width: 17%; }
.drawer-table th:nth-child(3), .drawer-table td:nth-child(3) { width: 18%; }
.drawer-table th:nth-child(4), .drawer-table td:nth-child(4) { width: 25%; }

/* table.po only sets nowrap on tbody, so footer totals were wrapping mid-number —
   "$24,780." on one line and "33" on the next. */
.count-table tfoot td, .count-table td.num, .count-table th.num { white-space: nowrap; }

.count-table tfoot td { font-weight: 600; border-top: 1px solid var(--border-strong); }
.count-table tfoot tr.grand td { font-size: 15px; border-top: 2px solid var(--border-strong); }

.count-input, .money-input {
    width: 100%; max-width: 110px; text-align: right;
    padding: 5px 8px; font-size: 13px;
}

/* Fixed layout so a long batch list cannot widen the table past its card. Without it the
   browser sizes columns to their content and the total ends up outside the panel. */
.batch-table { table-layout: fixed; width: 100%; }
.batch-table th:nth-child(1), .batch-table td:nth-child(1) { width: 19%; }
.batch-table th:nth-child(2), .batch-table td:nth-child(2) { width: 8%; }
.batch-table th:nth-child(4), .batch-table td:nth-child(4) { width: 22%; }

.batch-chips { display: flex; flex-wrap: wrap; gap: 4px; }

.batch-chip {
    background: var(--gray-soft); color: var(--gray-ink);
    padding: 1px 6px; border-radius: 5px; font-size: 11.5px; white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* A refund reads as a mistake unless it is marked as deliberate. */
.batch-chip.negative { background: var(--red-soft); color: var(--red-ink); }

.empty-dash { color: var(--text-mute); }

.card-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.card-column { border: 1px solid var(--border); border-radius: 8px; padding: 10px; }
.card-column-head {
    display: flex; justify-content: space-between; align-items: baseline;
    font-size: 12px; margin-bottom: 8px; gap: 8px;
}
.card-batch-row { display: flex; gap: 4px; margin-bottom: 5px; }
.ghost-btn.tiny { padding: 3px 10px; font-size: 12px; }

.closing-summary .kv { display: flex; justify-content: space-between; align-items: baseline; padding: 5px 0; }
.closing-summary hr { border: 0; border-top: 1px solid var(--border); margin: 10px 0; }
.closing-summary .grand-total { font-size: 17px; font-weight: 700; padding-top: 10px; border-top: 2px solid var(--border-strong); }

/* The one number the count exists to produce. Zero is the good outcome, so it is the
   only state that reads as calm — over and short both want somebody's attention. */
.over-short { padding: 8px 10px !important; border-radius: 8px; margin: 8px 0; }
.over-short.balanced { background: var(--green-soft); color: var(--green-ink); }
.over-short.over { background: var(--amber-soft); color: var(--amber-ink); }
.over-short.short { background: var(--red-soft); color: var(--red-ink); }
.over-short .kv-value { font-weight: 700; }

.saved-banner {
    display: flex; align-items: baseline; gap: 10px; padding: 12px 16px; margin-bottom: 16px;
    background: var(--green-soft); color: var(--green-ink); border: 1px solid var(--green-ink);
}

.warn-panel {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 16px; margin-bottom: 16px;
    background: var(--amber-soft); color: var(--amber-ink);
}

.field.inline { display: flex; align-items: center; gap: 8px; margin: 0; }
.field.inline label { margin: 0; font-size: 12px; white-space: nowrap; }
.field.inline input { width: auto; }



/* ==========================================================================
   RESPONSIVE

   Three bands, and the middle one is the reason this is not a single
   breakpoint:

     ≤1080   wide window — loosen the multi-column grids
     641-720 narrow window on a real screen — sidebar collapses to an icon rail
     ≤640    a phone — the rail becomes an off-canvas drawer and tables
             become cards

   The rail rules carry a min-width because a 64px rail is the wrong answer on a
   390px screen: it is permanently 16% of the display, spent on icons nobody can
   read without their labels. Scoping them to the band means the phone block
   below starts from a clean sidebar instead of unpicking the rail rule by rule.
   ========================================================================== */
@media (max-width: 1080px) {
    .stat-row { grid-template-columns: repeat(2, 1fr); }
    .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
    .stat-row { grid-template-columns: 1fr; }
    .main-area { padding: 0 16px 40px; }
}

/* ---- Icon rail: narrow windows only, never a phone ---- */
@media (max-width: 720px) and (min-width: 641px) {
    .sidebar { width: 64px; }
    .nav-menu .nav-link span:not(.nav-badge) { display: none; }

    /* No room for a number in the rail — the badge collapses to a dot on the
       icon's shoulder, the way every phone app marks an inbox. */
    .nav-badge {
        position: absolute; top: 7px; right: 16px;
        min-width: 0; width: 8px; height: 8px; padding: 0;
        font-size: 0;
    }

    /* 20px of side padding leaves 24px in a 64px rail, which the lockup cannot use and
       the wordmark could not be read at anyway. Drop to the house mark alone. */
    .brand { padding: 18px 8px; justify-content: center; }

    .brand-logo {
        width: 30px;
        aspect-ratio: 61 / 76;
        background-image: url('mark-light.png');
    }
}

/* ==========================================================================
   PHONE (≤640)
   ========================================================================== */
@media (max-width: 640px) {

    /* ---- Nav becomes an off-canvas drawer ----
       Opened by .nav-toggle in the mobile bar, which adds .nav-open to .app-shell.
       The toggle is plain JS in App.razor and not an @@onclick, because this layout
       renders static SSR — same constraint the health light works under. */
    .sidebar {
        position: fixed; top: 0; left: 0; z-index: 60;
        width: 264px; max-width: 82vw;
        transform: translateX(-100%);
        transition: transform .22s ease;
        box-shadow: var(--shadow-lg);
    }

    .app-shell.nav-open .sidebar { transform: translateX(0); }

    .nav-scrim {
        display: block; position: fixed; inset: 0; z-index: 55;
        border: 0; padding: 0; width: 100%;
        background: rgba(15,26,51,.45);
        opacity: 0; pointer-events: none; transition: opacity .22s ease;
    }

    .app-shell.nav-open .nav-scrim { opacity: 1; pointer-events: auto; }

    /* Taps land on 44px of target, the smallest a finger reliably hits. */
    .nav-menu .nav-link { padding: 13px 14px; font-size: 15px; }

    /* Dark, matching the sidebar it stands in for. Not a white bar: the only house
       mark in the repo is mark-light.png, drawn for a dark ground — the artwork's
       own ink is black and there is no dark-on-light derivative to use. */
    .mobile-bar {
        display: flex; align-items: center; gap: 12px;
        position: sticky; top: 0; z-index: 20;
        margin: 0 -12px; padding: 6px 12px;
        background: var(--nav-bg);
    }

    .nav-toggle {
        display: inline-flex; align-items: center; justify-content: center;
        width: 44px; height: 44px; flex-shrink: 0;
        border: 0; border-radius: 10px;
        background: transparent; color: #fff; cursor: pointer;
    }

    .nav-toggle:active { background: rgba(255,255,255,.10); }
    .nav-toggle svg { width: 22px; height: 22px; }

    .mobile-bar .brand-logo {
        width: 22px; flex-shrink: 0;
        aspect-ratio: 61 / 76;
        background-image: url('mark-light.png');
    }

    /* ---- Page chrome ---- */
    .main-area { padding: 0 12px 32px; }

    .page-head { padding: 16px 0 14px; flex-wrap: wrap; gap: 12px; }
    .page-head h1 { font-size: 21px; }

    /* A "Request PO" button that is 40% of the width and a "Purchase Orders"
       heading that is 60% both come out squeezed. Full width for the action. */
    .page-head .primary-btn { width: 100%; justify-content: center; }

    .panel { border-radius: 12px; }
    .panel-tools { padding: 12px; gap: 10px; }

    /* Every control on its own line. .search already claims flex:1 with a 240px
       floor, which on a 390px screen leaves the status select nowhere to go. */
    .panel-tools > * { flex: 1 1 100%; min-width: 0; }
    .select-wrap { display: flex; }
    .select-wrap select { flex: 1; }
    .date-range { display: flex; }
    .date-range input { flex: 1; min-height: 44px; }
    .filter-text input { width: 100%; }
    .filter-clear { margin-left: 0; }

    /* ---- 16px, and it has to be exactly that ----
       iOS Safari zooms the page whenever a focused control is under 16px, and does
       not zoom back out afterwards. Every text control in the app was 12-13px, so
       every tap into a form left the layout scaled up and drifting.

       Written as a blanket rule over the two containers rather than a list of the
       wrappers that exist today. The first pass named .field / .search / .catalog-search
       and missed the comment box on a PO and the catalog file input — the next field
       added would have been missed the same way. Checkboxes and radios are excluded
       because they are sized below, in touch targets, not typed into. */
    .main-area input:not([type=checkbox]):not([type=radio]),
    .main-area select,
    .main-area textarea,
    .drawer input:not([type=checkbox]):not([type=radio]),
    .drawer select,
    .drawer textarea {
        font-size: 16px;
    }

    .field input, .field select, .field textarea { padding: 11px 12px; }
    .search input { padding: 11px 12px 11px 36px; }

    /* ---- Touch targets ---- */
    .primary-btn, .ghost-btn { min-height: 44px; padding: 12px 20px; }
    .icon-btn { width: 40px; height: 40px; }
    .pg-btn { min-height: 40px; padding: 9px 16px; }
    .icon-x { min-width: 44px; min-height: 44px; }

    /* A checkbox renders at 13px and its label row at 20 — a quarter of a fingertip.
       The label is what you actually tap, so it is the label that has to be 44 tall;
       the box grows to 20 alongside it so the two still read as one control. */
    .field .field-check, .checkbox { min-height: 44px; align-items: center; }

    .field .field-check input[type=checkbox],
    .checkbox input[type=checkbox] { width: 20px; height: 20px; flex-shrink: 0; }

    /* ---- The request drawer is the whole screen ---- */
    .drawer {
        width: 100%; max-width: 100%;
        height: 100vh;
        height: 100dvh;
    }

    .drawer-head { padding: 14px 16px; }
    .drawer-body { padding: 16px; }
    .drawer-foot { padding: 12px 16px; gap: 10px; }
    .drawer-foot button { flex: 1; }

    /* ---- Tables become cards ----
       .table-wrap is overflow-x:auto, which on a phone turns a nine-column table
       into a sideways scroll: you can reach every column, one at a time, never
       knowing which row you are on. One card per row instead, each cell labelled
       from its data-label so the markup stays an ordinary table everywhere else.

       OPT-IN, via .stacks — table.po is not just the list tables. The money-count
       grids on the dashboard and the closing screens carry it too (.po.count-table),
       and those are dense numeric entry grids that a card stack would ruin. A table
       also needs a data-label on every cell before it can fold; without one the
       labels come out empty. PurchaseOrders is the only table set up for it so far;
       the rest keep their sideways scroll until they are given labels and this class. */
    .table-wrap:has(> .stacks) { overflow-x: visible; }

    table.po.stacks thead { display: none; }

    table.po.stacks,
    table.po.stacks tbody,
    table.po.stacks tr,
    table.po.stacks td { display: block; width: auto; }

    table.po.stacks tbody tr {
        border: 1px solid var(--border); border-radius: 12px;
        padding: 12px 14px; margin: 10px 12px;
        box-shadow: var(--shadow-sm);
    }

    table.po.stacks tbody tr:hover { background: transparent; }

    /* The side margin insets the cards from a .panel, which has no padding of its own.
       A .card-body already provides that inset, so inside one the cards go flush. */
    .card-body table.po.stacks tbody tr { margin-left: 0; margin-right: 0; }

    table.po.stacks tbody td {
        display: flex; align-items: baseline; justify-content: space-between; gap: 14px;
        padding: 4px 0; border-bottom: 0;
        white-space: normal; text-align: right;
    }

    table.po.stacks tbody td::before {
        content: attr(data-label);
        flex: 0 0 auto; text-align: left;
        color: var(--text-dim); font-size: 12px; font-weight: 600;
    }

    /* The card's title: no label, no second column, and the full width to itself.
       .po-num on the order lists, .cell-title where the heading is something else —
       a person's name on Users, the business date on Closings.

       :first-child matters. .po-num is a "this is an order number" style, not a
       "this is the heading" one, and Ack Inbox's handled list carries it on the
       fifth cell — the PO an email was matched to. Without the constraint that
       table grew an 18px heading in the middle of every card. */
    table.po.stacks tbody td.po-num:first-child,
    table.po.stacks tbody td.cell-title {
        display: block; text-align: left;
        font-size: 18px; padding: 0 0 8px;
    }

    table.po.stacks tbody td.po-num:first-child::before,
    table.po.stacks tbody td.cell-title::before { content: none; }

    /* A cell that is the whole row — a colspan'd error or notice belonging to the
       card above it. No label, no card framing of its own. */
    table.po.stacks tbody tr:has(> td.cell-full) {
        border: 0; box-shadow: none; padding: 0; margin: 0 12px 10px;
    }

    table.po.stacks tbody td.cell-full { display: block; text-align: left; }
    table.po.stacks tbody td.cell-full::before { content: none; }

    /* The row's buttons, which are a footer to the card rather than one more
       label/value pair. Ruled off, full width, and each button grown to something
       a thumb can hit — .mini-btn is 12px type in 4px of padding, about 24 tall. */
    table.po.stacks tbody td.cell-actions {
        display: block; padding: 10px 0 0; margin-top: 8px;
        border-top: 1px solid var(--border);
    }

    table.po.stacks tbody td.cell-actions::before { content: none; }

    table.po.stacks tbody td.cell-actions .row-actions {
        flex-wrap: wrap; justify-content: flex-start; gap: 8px;
    }

    table.po.stacks tbody td.cell-actions .mini-btn {
        flex: 1 1 auto; min-height: 40px; font-size: 13px; padding: 8px 14px;
    }

    /* A control sitting in a card cell rather than a .field — Ack Inbox's assign box.
       It keeps whatever width it was given, but not a 30px height. */
    table.po.stacks tbody td input { min-height: 40px; padding: 6px 10px; }

    table.po.stacks td:first-child { padding-left: 0; }
    table.po.stacks td:last-child { padding-right: 0; }

    table.po.stacks tbody td.col-secondary { display: none; }

    /* colspan is meaningless once the cells are blocks; these are the empty and
       loading rows, which want the panel's full width and no card framing. */
    table.po.stacks tbody tr:has(td.empty) {
        border: 0; box-shadow: none; margin: 0; padding: 0;
    }

    table.po.stacks tbody td.empty { display: block; text-align: center; padding: 32px 16px; }
    table.po.stacks tbody td.empty::before { content: none; }

    .pager { flex-direction: column; align-items: stretch; gap: 10px; text-align: center; }
    .pager-mid { justify-content: space-between; }
}

/* ==========================================================================
   PRINT — the daily closing on one sheet.

   LAST IN THE FILE ON PURPOSE. A printed US Letter page is about 816px wide, so
   @media (max-width: 1080px) above matches while printing too — and at equal
   specificity the later rule wins. With the print block sitting above it, that
   responsive single-column .detail-grid silently overrode the print layout and
   every closing came out three pages instead of one.
   ========================================================================== */
@media print {
    @page { size: letter portrait; margin: 10mm; }

    /* Release the fixed-height shell. .app-shell is 100vh with overflow hidden and
       .main-area scrolls inside it — right on screen, and on paper it hands the
       printer exactly one viewport and clips the rest. Every container in the chain
       has to be released, not just the scrolling one. */
    html, body {
        height: auto !important; overflow: visible !important;
        background: #fff; font-size: 8pt;
    }

    .app-shell { display: block !important; height: auto !important; overflow: visible !important; }
    .main-area { height: auto !important; overflow: visible !important; padding: 0 !important; }
    .panel, .table-wrap, .card { overflow: visible !important; }

    .sidebar, .no-print, .panel-tools, .pager,
    .drawer, .drawer-scrim, .toast { display: none !important; }

    .print-only { display: block; }

    /* ---- Heading ---- */
    .print-head { margin-bottom: 3mm; border-bottom: 1.2pt solid #000; padding-bottom: 1.5mm; }
    .print-head h1 { font-size: 13pt; margin: 0 0 0.5mm; }
    .print-head .print-sub { font-size: 8.5pt; color: #000; }

    /* ---- Two columns ----
       Two real wrapper divs, NOT display:contents over a grid and NOT column-count.
       Both of those were tried and measured: Chrome's print path ignores
       display:contents for grid participation, so every card fell back into one
       stream, and multicol fragments across pages instead of balancing within one.
       Either way the sheet came out on two pages. Ordinary grid items work. */
    /* Two sheets, on purpose. They leave with different people: the cash page goes to
       the bank in the deposit bag, the card page goes to accounting. Cramming both onto
       one sheet meant whoever needed half of it carried the other half around.

       The break is driven by DOM order rather than flex `order`, because fragmentation
       follows visual order only patchily inside a flex container — the cards column is
       simply first in the markup, and screen puts it back on the right with grid-column. */
    .print-sheet .detail-grid { display: block !important; }

    .print-sheet .col-cards { break-after: page; }

    /* Each sheet lays itself out in two columns of its own. */
    .print-sheet .col-cards,
    .print-sheet .col-cash {
        display: grid;
        column-gap: 6mm;
        align-items: start;
    }

    .print-sheet .col-cards { grid-template-columns: 1.55fr 1fr; }
    .print-sheet .col-cash  { grid-template-columns: 1fr 1fr; }

    .c-cards { grid-column: 1; }
    .c-totals { grid-column: 2; }
    .c-drawer { grid-column: 1; }
    .c-invoices, .c-checks { grid-column: 2; }

    /* Full width across whichever sheet they sit on. */
    .print-head-2, .print-sheet .sign-off { grid-column: 1 / -1; }

    /* The repeated heading on sheet two needs the separation the first one gets. */
    .print-head-2 { margin-bottom: 3mm; }

    .card {
        border: 0.75pt solid #999; border-radius: 0; box-shadow: none;
        margin: 0 0 2.5mm;
        break-inside: avoid;
    }

    .card-head { padding: 1mm 2mm; border-bottom: 0.75pt solid #999; }
    .card-head h2 { font-size: 8.5pt; margin: 0; }
    .card-head .pill { display: none; }   /* the total repeats in the table footer */
    .card-body { padding: 1.5mm 2mm; }

    /* Same specificity trap as on screen, and this is what made the printout three
       pages: these rules lost to table.po tbody td, so every row printed at 15px
       padding and 13.5px type — 44pt per row where 12pt will do. */
    table.po { font-size: 7.5pt; }

    table.po thead th,
    table.po tbody td {
        padding: 0.5mm 1.5mm; font-size: 7.5pt; line-height: 1.25;
        white-space: normal;      /* nowrap would stop the batch list wrapping */
        background: none;
    }

    table.po td:first-child, table.po th:first-child { padding-left: 1.5mm; }
    table.po td:last-child, table.po th:last-child { padding-right: 1.5mm; }

    table.po.count-table tfoot tr.grand td { font-size: 8pt; font-weight: 700; }

    .kv-grid { gap: 1.5mm; }
    .kv-label { font-size: 6.5pt; margin: 0; }
    .kv-value { font-size: 8pt; }

    /* Chips are screen furniture — on paper they are ink around numbers. */
    .batch-chips { display: block; }
    .batch-chip {
        background: none !important; color: #000 !important;
        padding: 0; font-size: 7pt; white-space: normal;
    }
    .batch-chip::after { content: ", "; }
    .batch-chip:last-child::after { content: ""; }
    .batch-chip.negative { font-weight: 700; }

    .closing-summary .kv { padding: 0.8mm 0; }
    .closing-summary hr { margin: 1.5mm 0; }
    .closing-summary .grand-total { font-size: 10pt; padding-top: 1.5mm; }

    /* Colour is unreliable on office printers, so the one figure that matters gets a
       border as well as a background. */
    .over-short { border: 1pt solid #000; padding: 1.2mm 2mm !important; margin: 1.2mm 0; }

    /* A 13-row drawer count is worth keeping whole; a closing with forty invoices has
       to be allowed to break rather than overflow the sheet. */
    .count-table tr, .count-table tfoot { break-inside: avoid; }
    .count-table thead { display: table-header-group; }

    .sign-off { display: flex; gap: 10mm; margin-top: 4mm; break-inside: avoid; }
    .sign-line {
        flex: 1; border-top: 0.75pt solid #000;
        margin-top: 9mm; padding-top: 1mm; font-size: 7.5pt;
    }

    a[href]::after { content: none !important; }
}

/* ==========================================================================
   SIGN IN
   Its own layout, so none of the app chrome applies. Split screen on a desktop,
   stacked on a phone — where the brand panel collapses to a slim header rather than
   eating the fold before anyone can reach the button.
   ========================================================================== */
.signin-shell { display: flex; min-height: 100vh; }

.signin-brand {
    width: 42%; max-width: 520px; flex-shrink: 0;
    background: linear-gradient(160deg, var(--nav-bg) 0%, #16295a 55%, #241d4d 100%);
    color: #fff; display: flex; align-items: center; justify-content: center;
    padding: 40px;
}

.signin-brand-inner { max-width: 340px; }

.signin-logo {
    width: 100%; max-width: 300px; aspect-ratio: 392 / 241;
    background: url('logo-light.png') no-repeat left center;
    background-size: contain; margin-bottom: 26px;
}

.signin-brand h1 { font-size: 23px; margin: 0 0 10px; letter-spacing: -.2px; }
.signin-brand p { margin: 0; color: #a9baDD; font-size: 14px; line-height: 1.65; }

.signin-main {
    flex: 1; display: flex; align-items: center; justify-content: center;
    padding: 40px 24px; background: var(--bg);
}

.signin-card {
    width: 100%; max-width: 400px;
    background: var(--card); border: 1px solid var(--border);
    border-radius: 16px; box-shadow: var(--shadow-sm); padding: 32px;
}

.signin-card h2 { margin: 0 0 4px; font-size: 22px; letter-spacing: -.2px; }
.signin-sub { margin: 0 0 22px; color: var(--text-dim); font-size: 14px; }

/* The primary action. Microsoft's own guidance is a white button with their mark, which
   people recognise faster than anything we could style ourselves. */
.provider-btn {
    width: 100%; display: flex; align-items: center; justify-content: center; gap: 12px;
    background: #fff; color: #1b1b1b;
    border: 1px solid #c8c8c8; border-radius: 10px;
    padding: 13px 16px; font: inherit; font-size: 15px; font-weight: 600;
    cursor: pointer; transition: background .15s ease, border-color .15s ease;
}

.provider-btn:hover { background: #f6f7f9; border-color: #a8a8a8; }   /* stays Microsoft-white in dark mode too */
.provider-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.provider-mark { width: 20px; height: 20px; flex-shrink: 0; }

/* Password sign-in, folded away. <details> rather than a Blazor toggle because this page
   renders static SSR — there is no circuit here to hold a boolean. */
.signin-alt { margin-top: 22px; border-top: 1px solid var(--border); padding-top: 16px; }

.signin-alt > summary {
    cursor: pointer; font-size: 13.5px; color: var(--text-dim);
    list-style: none; display: inline-flex; align-items: center; gap: 7px;
}

.signin-alt > summary::-webkit-details-marker { display: none; }

.signin-alt > summary::before {
    content: ""; width: 0; height: 0;
    border-left: 5px solid currentColor;
    border-top: 4px solid transparent; border-bottom: 4px solid transparent;
    transition: transform .15s ease;
}

.signin-alt[open] > summary::before { transform: rotate(90deg); }
.signin-alt > summary:hover { color: var(--primary); }

.signin-alt-note {
    font-size: 12.5px; color: var(--text-mute); margin: 12px 0 16px; line-height: 1.55;
}

.signin-remember { margin-bottom: 16px; font-size: 13px; }
.signin-submit { width: 100%; justify-content: center; }

.signin-passkey { margin-top: 12px; text-align: center; }
.signin-passkey .linkish {
    background: none; border: 0; padding: 0; cursor: pointer;
    color: var(--text-mute); font: inherit; font-size: 12.5px; text-decoration: underline;
}
.signin-passkey .linkish:hover { color: var(--primary); }

.signin-foot {
    margin: 22px 0 0; padding-top: 16px; border-top: 1px solid var(--border);
    font-size: 12.5px; color: var(--text-mute); line-height: 1.6;
}

.signin-card .field-error { color: var(--red-ink); font-size: 12px; display: block; margin-top: 4px; }
.signin-card .form-error:empty { display: none; }

@media (max-width: 820px) {
    .signin-shell { flex-direction: column; min-height: 100dvh; }

    /* A slim header, not half the screen. On a phone the sign-in button has to be
       reachable without scrolling. */
    .signin-brand {
        width: 100%; max-width: none; padding: 22px 24px;
        align-items: flex-start;
    }

    /* width:100% of a shrink-to-fit parent is zero, and align-items:flex-start above
       makes this parent exactly that — which left the mobile header an empty navy strip
       with no logo in it. An explicit width is what actually sizes it. */
    .signin-brand-inner { max-width: none; width: 100%; }
    .signin-logo { width: 180px; max-width: 55%; margin-bottom: 0; }
    .signin-brand h1, .signin-brand p { display: none; }
    .signin-main { padding: 28px 18px 44px; }
    .signin-card { padding: 26px 22px; border: 0; box-shadow: none; background: transparent; }
}

/* ==========================================================================
   DASHBOARD
   Charts are plain divs sized by percentage — no script library on the landing
   page for bars two CSS rules can draw.
   ========================================================================== */
.dash-grid {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 20px; align-items: start;
}

.dash-wide { grid-column: 1 / -1; }

/* Two cards pinned side by side inside one wide row. Same gap as the outer grid so the
   seam is invisible; collapses with it on a phone. */
.dash-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }

/* Vertical bars: 12 weeks of volume. */
.chart-cols { display: flex; align-items: stretch; gap: 8px; height: 170px; }

.chart-col {
    flex: 1; display: flex; flex-direction: column; justify-content: flex-end;
    min-width: 0;
}

.chart-count {
    text-align: center; font-size: 11px; color: var(--text-dim);
    font-variant-numeric: tabular-nums; margin-bottom: 3px;
}

.chart-bar {
    background: linear-gradient(180deg, color-mix(in srgb, var(--primary) 72%, #ffffff), var(--primary));
    border-radius: 5px 5px 0 0; min-height: 2px;
}

.chart-x {
    text-align: center; font-size: 10px; color: var(--text-mute);
    margin-top: 6px; white-space: nowrap;
}

/* Horizontal bars: status mix and vendor share. */
.hbar-row {
    display: grid; grid-template-columns: 128px 1fr 34px;
    align-items: center; gap: 10px; margin-bottom: 9px;
}

.hbar-label {
    font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.hbar-track { background: var(--gray-soft); border-radius: 5px; height: 10px; }

.hbar-fill {
    height: 100%; border-radius: 5px; min-width: 3px;
    background: linear-gradient(90deg, color-mix(in srgb, var(--primary) 72%, #ffffff), var(--primary));
}

.hbar-n { text-align: right; font-size: 12.5px; color: var(--text-dim); }

@media (max-width: 1080px) {
    .dash-grid { grid-template-columns: 1fr; }
    .dash-pair { grid-template-columns: 1fr; }
}

/* ==========================================================================
   ATTACHMENT BADGES + PREVIEW LIGHTBOX
   ========================================================================== */
.file-badge {
    flex-shrink: 0; width: 44px; text-align: center;
    padding: 5px 0; border-radius: 7px;
    font-size: 10.5px; font-weight: 700; letter-spacing: .5px;
}

.file-badge.red   { background: var(--red-soft);   color: var(--red-ink); }
.file-badge.blue  { background: var(--blue-soft);  color: var(--blue-ink); }
.file-badge.green { background: var(--green-soft); color: var(--green-ink); }
.file-badge.gray  { background: var(--gray-soft);  color: var(--gray-ink); }

/* ---------- INLINE ATTACHMENT PREVIEW ---------- */
/* The wrapper takes over the row separator from .file, because a preview panel now
   sits between the row and the border and :last-child on .file stopped meaning
   "last in the card". */
.file-item { border-bottom: 1px solid var(--border); }
.file-item:last-of-type { border-bottom: none; }
.file-item .file { border-bottom: none; }

/* A dark stage for both kinds of content: photos read better on it, and it stops a
   white PDF page melting into a white panel. The height is a reading pane, not a
   thumbnail — the PDF viewer's own toolbar handles zoom and fullscreen from here. */
.file-preview {
    margin: 0 0 12px;
    border: 1px solid var(--border); border-radius: 10px;
    overflow: hidden;
    display: flex; align-items: center; justify-content: center;
    background: #1c2536;
}

.file-preview img { max-width: 100%; max-height: 420px; object-fit: contain; }
.file-preview iframe { width: 100%; height: 420px; border: 0; background: #fff; }

/* ---------- VERSION + HEALTH (sidebar footer) ---------- */
.foot-status {
    display: flex; align-items: center; gap: 8px;
    margin-top: 10px; padding-top: 10px;
    border-top: 1px solid var(--nav-divider);
    font-size: 11px; color: var(--nav-foot-text);
}

.health-dot {
    width: 9px; height: 9px; border-radius: 50%;
    background: #55627e;                       /* unknown, before the first check */
    flex-shrink: 0;
}

.health-dot.ok { background: #2ecc71; animation: heartbeat 2.6s ease-in-out infinite; }
.health-dot.bad { background: #e74c3c; animation: none; }

/* ---------- FOOTER TOOLS: dark mode + pricing calculator ---------- */
.foot-status { flex-wrap: wrap; }

.foot-tool {
    width: 26px; height: 26px; border-radius: 7px; border: 0; padding: 0;
    background: rgba(255,255,255,.06); color: var(--nav-foot-link); cursor: pointer;
    display: inline-grid; place-items: center; flex-shrink: 0;
}

.foot-tool:hover { background: rgba(255,255,255,.12); color: #fff; }
.foot-tool:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.foot-tool svg { width: 15px; height: 15px; }
.foot-tool[aria-expanded="true"] { background: var(--primary); color: var(--on-primary); }


/* The calculator pop-up. Fixed at the bottom-left, over the page, so it can sit beside
   whatever is being priced. On a phone it takes the full width above the thumb. */
.calc-pop {
    position: fixed; left: 16px; bottom: 16px; z-index: 70;
    width: 320px; max-width: calc(100vw - 32px);
    background: var(--card); color: var(--text);
    border: 1px solid var(--border-strong); border-radius: 14px;
    box-shadow: var(--shadow-lg); padding: 14px 16px 12px;
}

.calc-pop[hidden] { display: none; }

.calc-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 10px; font-size: 14px;
}

.calc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }

.calc-grid label { display: flex; flex-direction: column; gap: 3px; font-size: 11.5px; color: var(--text-dim); }

.calc-grid input {
    width: 100%; padding: 8px 10px; border-radius: 8px;
    border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
    font: inherit; font-size: 14px; font-variant-numeric: tabular-nums; outline: none;
}

.calc-grid input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent); }

.calc-out {
    margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border);
    display: grid; gap: 4px; font-size: 13px;
}

.calc-out > div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.calc-out span { color: var(--text-dim); }
.calc-out b { font-variant-numeric: tabular-nums; }
.calc-out .calc-total { margin-top: 4px; padding-top: 6px; border-top: 1px solid var(--border); font-size: 15px; }
.calc-out .calc-total b { color: var(--primary); }

.calc-foot {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    margin-top: 10px; font-size: 11.5px; color: var(--text-mute);
}

.calc-clear {
    background: none; border: 1px solid var(--border-strong); border-radius: 7px;
    padding: 5px 10px; color: var(--text-dim); font: inherit; font-size: 12px; cursor: pointer;
}

.calc-clear:hover { background: var(--surface-2); color: var(--text); }

@media (max-width: 640px) {
    .calc-pop { left: 12px; right: 12px; bottom: 12px; width: auto; max-width: none; }
}

@keyframes heartbeat {
    0%, 100% { box-shadow: 0 0 0 0 rgba(46, 204, 113, .45); }
    50%      { box-shadow: 0 0 0 5px rgba(46, 204, 113, 0); }
}

/* The collapsed rail keeps the dot; the version text has no room. */
@media (max-width: 720px) {
    .foot-status .mono { display: none; }
    .foot-status { justify-content: center; }
}

/* ---------- CLOSING DRAFT STATE ---------- */
.draft-banner {
    display: flex; align-items: center; padding: 12px 16px; margin-bottom: 16px;
    background: var(--amber-soft); color: var(--amber-ink);
    font-size: 13.5px; line-height: 1.5;
}

.void-banner {
    display: flex; align-items: center; padding: 12px 16px; margin-bottom: 16px;
    background: var(--red-soft); color: var(--red-ink);
    font-size: 13.5px; line-height: 1.5;
}

/* The paper equivalent of the Voided pill: a voided cash sheet pulled from a binder
   must announce itself before anybody reads its numbers. */
.void-print-mark {
    border: 3px solid #b91c1c; color: #b91c1c;
    padding: 8px 12px; margin-bottom: 12px;
    font-weight: 700; letter-spacing: .02em;
}

/* On screen the stamp is a small tag beside the printed heading (visible only in print
   preview); on paper it is the thing that stops a mid-day print being mistaken for the
   record. Outlined, not filled — office printers on draft mode eat solid blocks. */
.draft-stamp {
    display: inline-block; vertical-align: middle; margin-left: 10px;
    padding: 1px 10px; border: 2.5px solid #b91c1c; border-radius: 6px;
    color: #b91c1c; font-size: 0.7em; font-weight: 800; letter-spacing: 2px;
    transform: rotate(-3deg);
}

@media print {
    .draft-stamp { border-color: #000; color: #000; }
}

/* ---------- CHAT ---------- */
/* Height is pinned so the thread scrolls, never the page: viewport minus the
   page-head above and the main-area's bottom padding. */
.chat-layout {
    display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 16px;
    height: calc(100vh - 120px);
}

.chat-rooms { display: flex; flex-direction: column; overflow: hidden; }

.chat-dm-picker { padding: 12px; border-bottom: 1px solid var(--border); }

.chat-dm-picker select {
    width: 100%; padding: 9px 12px; border-radius: 8px;
    border: 1px solid var(--border-strong); font: inherit; font-size: 13px;
    color: var(--text); background: var(--surface); outline: none;
}

.chat-room-list { flex: 1; overflow-y: auto; padding: 6px; }

.chat-room-list .empty { padding: 24px 12px; text-align: center; color: var(--text-mute); font-size: 13px; }

.chat-room {
    padding: 10px 12px; border-radius: 8px; cursor: pointer; margin-bottom: 2px;
}

.chat-room:hover { background: var(--surface-2); }
.chat-room.active { background: var(--blue-soft); }

.chat-room-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.chat-room-name {
    display: flex; align-items: center; gap: 8px; min-width: 0;
    font-weight: 600; font-size: 13.5px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.chat-room-name svg { width: 15px; height: 15px; flex-shrink: 0; color: var(--text-mute); }

.unread-pill {
    flex-shrink: 0; min-width: 20px; padding: 1px 6px; border-radius: 999px;
    background: var(--primary); color: var(--on-primary);
    font-size: 11px; font-weight: 700; text-align: center;
    font-variant-numeric: tabular-nums;
}

.chat-room-preview {
    display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
    margin-top: 3px; font-size: 12px; color: var(--text-mute);
}

.chat-room-snippet { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.chat-room-when { flex-shrink: 0; font-variant-numeric: tabular-nums; }

.chat-thread { display: flex; flex-direction: column; overflow: hidden; }

.chat-thread-empty {
    flex: 1; display: grid; place-items: center;
    color: var(--text-mute); font-size: 13.5px; padding: 24px;
}

.chat-thread-head {
    padding: 14px 16px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
}

.chat-thread-head h2 { margin: 0; font-size: 16px; font-weight: 700; }

/* column-reverse keeps the scroll pinned to the newest message with no
   JavaScript: the first DOM child (the newest) renders at the bottom, and
   prepending older history above does not move what is on screen. */
.chat-messages {
    flex: 1; overflow-y: auto; padding: 16px;
    display: flex; flex-direction: column-reverse;
}

.chat-messages .comment { flex-shrink: 0; }

.chat-messages .comment.mine { border-left-color: var(--primary); }
.chat-messages .comment.mine .comment-who { color: var(--blue-ink); }

.chat-load-older { text-align: center; padding: 4px 0 12px; flex-shrink: 0; }

.chat-compose {
    display: flex; gap: 10px; padding: 12px 16px;
    border-top: 1px solid var(--border); margin: 0;
}

.chat-compose input {
    flex: 1; min-width: 0; padding: 10px 12px; border-radius: 8px;
    border: 1px solid var(--border-strong); font: inherit; font-size: 13px;
    color: var(--text); background: var(--surface); outline: none;
}

.chat-compose input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent); }

/* The member checklist in the manager drawer. */
.chat-member-list {
    border: 1px solid var(--border); border-radius: 8px;
    max-height: 300px; overflow-y: auto; padding: 6px 10px;
}

.chat-member-list .field-check { padding: 5px 0; }

.chat-member-loc { color: var(--text-mute); font-size: 12px; font-weight: 400; }

.chat-delete-confirm { font-size: 12.5px; color: var(--red-ink); align-self: center; }
.chat-foot-gap { flex: 1; }

/* ---- The bell in the sidebar foot ---- */
.chat-bell {
    position: relative;
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 10px; padding-bottom: 10px;
    border-bottom: 1px solid var(--nav-divider);
    color: var(--nav-foot-link); text-decoration: none; font-size: 12px; font-weight: 600;
}

.chat-bell:hover { color: #fff; text-decoration: none; }

.chat-bell svg { width: 16px; height: 16px; flex-shrink: 0; }

.bell-badge {
    min-width: 18px; padding: 1px 5px; border-radius: 999px;
    background: #e74c3c; color: #fff;
    font-size: 10.5px; font-weight: 700; text-align: center;
    font-variant-numeric: tabular-nums;
}

/* The narrow rail keeps the bell and its badge; the label goes. */
@media (max-width: 720px) {
    .chat-bell span:not(.bell-badge) { display: none; }
    .chat-bell { justify-content: center; }
    .chat-layout { grid-template-columns: 1fr; height: auto; }
    .chat-thread { min-height: 60vh; }
}

/* ---------- VENDOR CATALOGS ---------- */
/* Two panes, same skeleton as .chat-layout: the vendor list has to scale to a
   vendor a day, which a stack of cards never would. */
.catalog-layout {
    display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 16px;
    align-items: start;
}

.catalog-vendors {
    display: flex; flex-direction: column; overflow: hidden;
    max-height: calc(100vh - 140px);
}

.catalog-search { padding: 12px; border-bottom: 1px solid var(--border); }

.catalog-search input {
    width: 100%; padding: 9px 12px; border-radius: 8px;
    border: 1px solid var(--border-strong); font: inherit; font-size: 13px;
    color: var(--text); background: var(--surface); outline: none;
}

.catalog-vendor-list { flex: 1; overflow-y: auto; padding: 6px; }

.catalog-vendor-list .empty {
    padding: 24px 12px; text-align: center; color: var(--text-mute); font-size: 13px;
}

.catalog-vendor {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 10px 12px; border-radius: 8px; cursor: pointer; margin-bottom: 2px;
    font-size: 13.5px; font-weight: 600;
}

.catalog-vendor:hover { background: var(--surface-2); }
.catalog-vendor.active { background: var(--blue-soft); }

.catalog-vendor-name {
    min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.catalog-count {
    min-width: 18px; padding: 1px 6px; border-radius: 999px;
    background: var(--gray-soft); color: var(--gray-ink);
    font-size: 10.5px; font-weight: 700; text-align: center;
    font-variant-numeric: tabular-nums;
}

.catalog-detail-title { display: flex; align-items: center; gap: 10px; min-width: 0; }

/* A small square button drawn as a label so a hidden InputFile can sit behind it. */
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
    border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
    cursor: pointer;
}

.icon-btn:hover { background: var(--surface-2); }
.icon-btn.disabled { opacity: .5; pointer-events: none; }
.icon-btn svg { width: 15px; height: 15px; }

/* display:none would work today, but keeping the input focusable is what lets a
   keyboard reach the upload at all. */
.visually-hidden-input {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

@media (max-width: 720px) {
    .catalog-layout { grid-template-columns: 1fr; }
    .catalog-vendors { max-height: 40vh; }
}

/* ==========================================================================
   STOCK REQUESTS

   Sits at the end with its own phone block, the same way the chat and catalog
   sections do — the shared PHONE block above is about the shell and the tables,
   not about one screen's furniture.
   ========================================================================== */

/* ---------- The item type-ahead ---------- */
.picker { position: relative; }

.picker-input {
    width: 100%; padding: 10px 12px; border-radius: 8px;
    border: 1px solid var(--border-strong); font: inherit; font-size: 13px;
    color: var(--text); background: var(--surface); outline: none;
}

.picker-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent); }

/* The list overlays whatever is under it rather than pushing the form down. A form
   that reflows on every keystroke is unusable, and on a phone it moves the box out
   from under the thumb that is typing into it. */
.picker-list {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 40;
    margin: 0; padding: 4px; list-style: none;
    max-height: 320px; overflow-y: auto;
    background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px;
    box-shadow: var(--shadow-lg);
}

.picker-option {
    display: grid; gap: 1px; padding: 9px 10px; border-radius: 7px; cursor: pointer;
}

.picker-option:hover, .picker-option.active { background: var(--blue-soft); }

.picker-name { font-weight: 600; font-size: 13.5px; color: var(--text); }

.picker-desc {
    font-size: 12px; color: var(--text-dim);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.picker-meta { display: flex; gap: 8px; align-items: baseline; font-size: 11px; }

/* The categories QuickBooks files an item under. Present because two items can share
   a leaf name and the path is the only thing telling them apart, dimmed because it is
   never the thing being searched for. */
.picker-path {
    color: var(--text-mute);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.picker-unit {
    flex-shrink: 0; padding: 1px 6px; border-radius: 999px;
    background: var(--gray-soft); color: var(--gray-ink); font-weight: 600;
}

.picker-none {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 40;
    padding: 10px 12px; font-size: 12.5px; color: var(--text-dim);
    background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px;
    box-shadow: var(--shadow-lg);
}

.picker-spinner {
    position: absolute; right: 10px; top: 50%; margin-top: -7px;
    width: 14px; height: 14px; border-radius: 50%;
    border: 2px solid var(--border-strong); border-top-color: var(--primary);
    animation: picker-spin .6s linear infinite;
}

@keyframes picker-spin { to { transform: rotate(360deg); } }

/* ---------- Adding a line ---------- */
/* overflow:visible, overriding .panel's overflow:hidden: the item picker's suggestion
   list is absolutely positioned below its input and must be allowed to hang past the
   bottom of this card. With the panel default it was cut off at the card edge, leaving
   the last few matches unreachable. The rounded corners lose nothing — no child here
   has a background that could bleed past them. */
.add-line { margin-top: 20px; overflow: visible; }

.add-line-row {
    display: grid;
    grid-template-columns: minmax(0, 3fr) 90px 90px minmax(0, 2fr) auto;
    gap: 12px; align-items: end; padding: 16px 20px;
}

.add-line-row label {
    display: block; font-size: 12px; font-weight: 600;
    color: var(--text-dim); margin-bottom: 5px;
}

.add-line-row input {
    width: 100%; padding: 10px 12px; border-radius: 8px;
    border: 1px solid var(--border-strong); font: inherit; font-size: 13px;
    color: var(--text); background: var(--surface); outline: none;
}

.add-line-row input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent); }

.add-line-foot {
    display: flex; gap: 12px; align-items: flex-end;
    padding: 0 20px 18px; border-top: 1px solid var(--border); padding-top: 16px;
}

.add-line-foot .field { flex: 1; }
.add-line-foot textarea { min-height: 60px; }

/* ---------- The list itself ---------- */

/* A resolved line is still on the list — the warehouse needs to see that it was dealt
   with — but it is no longer what anybody is scanning for. */
table.po tbody tr.line-done td { color: var(--text-dim); }
table.po tbody tr.line-done td.cell-title { text-decoration: line-through; }

.line-note { font-size: 11.5px; margin-top: 3px; }

.request-notes {
    padding: 14px 20px; border-top: 1px solid var(--border);
    font-size: 13px; color: var(--text);
}

.request-notes-label {
    font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .04em; color: var(--text-mute); margin-bottom: 5px;
}

.detail-foot {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; margin-top: 20px;
}

.steps { margin: 0; padding-left: 20px; font-size: 13px; }
.steps li { margin-bottom: 5px; }

/* ---------- Printing a request ----------
   The whole point of the screen: purchasing walks off with the list on paper. Only
   what is on the list survives — the add-line form, the toolbar and the per-line
   buttons are all .no-print. */
@media print {
    .stock-print-hide, .add-line { display: none !important; }

    .print-sheet { border: 0 !important; box-shadow: none !important; }
    .print-sheet .table-wrap { overflow: visible !important; }

    table.po tbody tr.line-done td { color: #000; }
}

/* ---------- Phone ---------- */
@media (max-width: 640px) {
    /* One control per line. The five-column grid is unreadable at 375px, and the item
       box is the one that needs the width. */
    .add-line-row {
        grid-template-columns: 1fr 1fr;
        gap: 10px; padding: 12px;
    }

    .add-line-item, .add-line-note, .add-line-btn { grid-column: 1 / -1; }

    .add-line-row input, .picker-input { font-size: 16px; min-height: 44px; }

    .add-line-btn { min-height: 46px; }

    /* Bigger rows, and taller before it scrolls: this is a list being chosen from with
       a thumb, and 320px of it on a phone leaves nothing else visible anyway. */
    .picker-option { padding: 12px 12px; }
    .picker-name { font-size: 15px; }
    /* --picker-room is the space between the box and the on-screen keyboard, measured
       in js/footer-tools.js: vh does not shrink when the keyboard opens, so 50vh alone
       ran the list on behind it. The list scrolls inside itself, not the page. */
    .picker-list { max-height: min(50vh, var(--picker-room, 50vh)); overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
    .picker-input { scroll-margin-top: 72px; }

    .add-line-foot { flex-direction: column; align-items: stretch; padding: 16px 12px; }

    .detail-foot { flex-direction: column; align-items: stretch; gap: 14px; }
    .detail-foot .mini-btn { min-height: 44px; }

    .head-actions { width: 100%; flex-wrap: wrap; }
    .head-actions .ghost-btn, .head-actions .primary-btn { flex: 1; }
}

/* The branch selector under the request's heading, sitting inline with the "raised by"
   line rather than becoming a form of its own. */
.head-meta { display: flex; align-items: center; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
.head-meta .select-wrap { background: var(--surface); }
.head-meta .muted { font-size: 13px; }

/* Unit rides with the quantity: "50000 pc". Dimmed and a shade smaller so the number
   still reads first, which is what the column is scanned for. */
.qty-unit { margin-left: 5px; font-size: 12px; color: var(--text-dim); font-weight: 500; }

@media (max-width: 640px) {
    /* The select is a real target, and the "raised by" line drops beneath it rather
       than being squeezed alongside. */
    .head-meta { gap: 8px; }
    .head-meta .select-wrap { width: 100%; }
    .head-meta .select-wrap select { flex: 1; min-height: 44px; }
    .head-meta .muted { flex: 1 1 100%; }
}

/* ---------- Utilities nav group ----------
   A native <details>, because this layout renders static SSR and has no circuit to
   hang a click handler on. Styling a <summary> means killing the default marker in
   two places: list-style covers Firefox and most engines, ::-webkit-details-marker
   is still needed for Safari. */
.nav-group { margin-bottom: 2px; }

.nav-group > summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
}

.nav-group > summary::-webkit-details-marker { display: none; }

.nav-group > summary:hover { background: var(--nav-hover); color: var(--nav-text-strong); }

/* Pushed to the right-hand end, and turned a quarter-turn when the group is open. */
.nav-chevron {
    margin-left: auto;
    width: 14px !important; height: 14px !important;
    transition: transform .15s ease;
}

.nav-group[open] > summary .nav-chevron { transform: rotate(90deg); }

/* Indented under the summary, and dimmed a shade so the group reads as one thing
   with a heading rather than five equal links. */
.nav-menu .nav-link.nav-sub {
    padding-left: 30px;
    font-size: 13.5px;
    color: var(--nav-sub-text);
}

.nav-menu .nav-link.nav-sub.active { color: var(--nav-text-strong); }

/* In the 64px rail every label is hidden anyway, so the summary is already just an
   icon you can press to reveal four more. That is the right behaviour and it needed
   no help — an earlier attempt to hide the summary and force the links open never
   applied at all: `.nav-group > summary` is 0-1-1 and loses to `.nav-menu .nav-link`
   at 0-2-0. Left as a disclosure; only the chevron goes, having nowhere to sit once
   the label is gone, and the indent flattens because there is nothing to indent from. */
@media (max-width: 720px) and (min-width: 641px) {
    .nav-chevron { display: none; }
    .nav-menu .nav-link.nav-sub { padding-left: 14px; }
    .nav-group { margin-bottom: 0; }
}

/* One-time setup instructions, folded away on the Item List screen. */
.setup-note { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 12px; }
.setup-note > summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--primary); }
.setup-note > summary::-webkit-details-marker { color: var(--text-mute); }
.setup-note .steps { margin-top: 10px; }

/* ---------- RESTOCK SCAN PAGE ----------
   The page a warehouse phone lands on after scanning a rack label. Phone-first:
   one column, big type, 16px controls (iOS zooms anything smaller), two fat
   buttons for Out / Running low, and one full-width submit. See Restock.razor. */
.scan-shell {
    min-height: 100vh; min-height: 100dvh;
    display: flex; flex-direction: column; background: var(--bg);
}

.scan-brand {
    display: flex; align-items: center; gap: 14px;
    padding: 12px 16px; background: var(--nav-bg); color: #fff;
    font-weight: 600; letter-spacing: .3px;
}

.scan-brand .brand-logo { width: 84px; }

.scan-main { flex: 1; width: 100%; max-width: 460px; margin: 0 auto; padding: 16px; }

.scan-card {
    background: var(--card); border: 1px solid var(--border); border-radius: 14px;
    padding: 20px 18px; box-shadow: var(--shadow-sm);
}

.scan-branch {
    font-size: 12px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase;
    color: var(--text-dim); margin-bottom: 6px;
}

.scan-item { font-size: 26px; font-weight: 700; line-height: 1.15; margin: 0 0 4px; overflow-wrap: anywhere; }
.scan-path { font-size: 13px; color: var(--text-mute); margin-bottom: 6px; overflow-wrap: anywhere; }
.scan-desc { font-size: 14px; color: var(--text-dim); margin: 0 0 14px; }

.scan-form { margin-top: 16px; }
.scan-form .field input { font-size: 16px; padding: 12px; }
.scan-form .field-error { display: block; margin-top: 4px; font-size: 12px; color: var(--red-ink); }

.scan-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }

.scan-choice label {
    position: relative; display: flex; align-items: center; justify-content: center;
    min-height: 58px; border: 2px solid var(--border-strong); border-radius: 12px;
    background: var(--surface); font-size: 16px; font-weight: 700; cursor: pointer;
    user-select: none;
}

.scan-choice input { position: absolute; opacity: 0; width: 0; height: 0; }

.scan-choice label:has(input:checked) { border-color: var(--primary); background: var(--blue-soft); color: var(--blue-ink); }
.scan-choice label.out:has(input:checked) { border-color: #dc2626; background: var(--red-soft); color: var(--red-ink); }
.scan-choice label:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 2px; }

.scan-submit { width: 100%; justify-content: center; min-height: 52px; font-size: 16px; }

.scan-done { text-align: center; padding: 8px 0 4px; }

.scan-done .tick {
    width: 72px; height: 72px; border-radius: 50%; margin: 0 auto 14px;
    display: flex; align-items: center; justify-content: center;
    background: var(--green-soft); color: var(--green-ink);
}

.scan-done .tick svg { width: 40px; height: 40px; }
.scan-done h2 { font-size: 22px; margin: 0 0 8px; }
.scan-done p { color: var(--text-dim); font-size: 15px; margin: 0 0 8px; line-height: 1.5; }
.scan-note { font-size: 13px; color: var(--text-mute); margin-top: 14px; }

/* ---------- RACK SCANNER (/scan) ----------
   Camera on top, a number-pad sheet that slides up after each read, and the list of
   what this phone has sent underneath. See Scan.razor and js/scan.js. The pad is
   on-screen buttons rather than the phone's keyboard: an iPhone will not raise its
   keyboard for a field focused by script, and big keys work in gloves. */
#scan-app [hidden] { display: none !important; }
#scan-app .field-error { display: block; margin-top: 4px; font-size: 12px; color: var(--red-ink); }
#scan-app .field input[type=text] { font-size: 16px; padding: 12px; }

.scan-cam {
    position: relative; overflow: hidden; border-radius: 14px; background: #000;
    aspect-ratio: 3 / 4; max-height: 58vh; max-height: 58dvh; width: 100%;
}
.scan-cam video { width: 100%; height: 100%; object-fit: cover; display: block; }

/* The guide: a wide box across the middle, the shape of a label's barcode, with the
   red line a laser scanner would show. ZXing reads the middle half of the frame. */
.scan-reticle {
    position: absolute; left: 7%; right: 7%; top: 38%; height: 24%;
    border: 3px solid rgba(255,255,255,.85); border-radius: 10px;
    box-shadow: 0 0 0 100vmax rgba(0,0,0,.35);
}
.scan-reticle span { position: absolute; left: 6px; right: 6px; top: 50%; height: 2px; background: #ef4444; opacity: .85; }

.scan-status {
    position: absolute; left: 12px; right: 12px; bottom: 12px; text-align: center;
    padding: 8px 12px; border-radius: 999px; font-size: 14px; font-weight: 600;
    background: rgba(0,0,0,.6); color: #fff;
}
.scan-status.bad { background: rgba(185,28,28,.9); }

.scan-cam-btn {
    position: absolute; top: 10px; right: 10px; width: 44px; height: 44px; border-radius: 50%;
    border: 0; background: rgba(0,0,0,.55); color: #fff; display: flex; align-items: center; justify-content: center;
}
.scan-cam-btn svg { width: 22px; height: 22px; }
.scan-cam-btn[aria-pressed=true] { background: #facc15; color: #000; }

#scan-next { margin-top: 12px; }

.scan-bar { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 14px; flex-wrap: wrap; }

.scan-manual { display: flex; gap: 8px; margin-top: 10px; }
.scan-manual input {
    flex: 1; min-width: 0; font-size: 16px; padding: 10px 12px;
    border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); color: var(--text);
}

.scan-sent { margin-top: 18px; }
.scan-sent h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-dim); margin: 0 0 8px; }
.scan-sent ul { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: 12px; background: var(--card); }
.scan-sent li { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--border); }
.scan-sent li:first-child { border-top: 0; }
.scan-sent li.undone .scan-sent-main { opacity: .5; text-decoration: line-through; }
.scan-sent-main { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 14px; }
.scan-sent-main strong { overflow-wrap: anywhere; }
.scan-sent-main .muted { font-size: 12px; }

.scan-sheet {
    position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center;
    background: rgba(0,0,0,.45);
}
.scan-sheet-card {
    width: 100%; max-width: 460px; max-height: 100%; overflow-y: auto;
    background: var(--card); border-radius: 18px 18px 0 0; padding: 18px 16px calc(16px + env(safe-area-inset-bottom));
    box-shadow: 0 -8px 30px rgba(0,0,0,.25);
}
.scan-sheet-card .scan-item { font-size: 22px; }

.scan-urg {
    min-height: 50px; border: 2px solid var(--border-strong); border-radius: 12px;
    background: var(--surface); color: var(--text); font-size: 16px; font-weight: 700;
}
.scan-urg[aria-pressed=true] { border-color: var(--primary); background: var(--blue-soft); color: var(--blue-ink); }
.scan-urg.out[aria-pressed=true] { border-color: #dc2626; background: var(--red-soft); color: var(--red-ink); }

.scan-qty {
    display: flex; align-items: baseline; gap: 8px; padding: 10px 14px; margin-bottom: 10px;
    border: 1px solid var(--border-strong); border-radius: 12px; background: var(--surface);
}
.scan-qty-label { font-size: 14px; color: var(--text-dim); }
.scan-qty-value { margin-left: auto; font-size: 30px; font-weight: 700; font-family: ui-monospace, Consolas, monospace; }
.scan-qty-value.empty { color: var(--text-mute); }
.scan-qty-unit { font-size: 15px; color: var(--text-dim); }

.scan-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.scan-pad button {
    min-height: 54px; border: 1px solid var(--border); border-radius: 12px;
    background: var(--surface-2); color: var(--text); font-size: 24px; font-weight: 600;
    display: flex; align-items: center; justify-content: center;
    touch-action: manipulation;   /* no double-tap zoom on a fast "11" */
}
.scan-pad button:active { background: var(--border); }
.scan-pad svg { width: 26px; height: 26px; }

.scan-sheet-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; margin-top: 12px; }
.scan-sheet-actions button { min-height: 54px; justify-content: center; font-size: 16px; }
#sheet-error { margin-top: 10px; }

.scan-toast {
    position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
    z-index: 60; max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 12px;
    font-size: 14px; font-weight: 600; color: #fff; box-shadow: var(--shadow-sm);
}
.scan-toast.good { background: #15803d; }
.scan-toast.bad { background: #b91c1c; }

/* ---------- STOCK REQUEST LINES, EDITABLE IN THE ROW ----------
   Quantity and note typed straight into the table on a request whose lines are
   still open. Sized to the row, not the .field rules, which are built for forms. */
.qty-edit { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }

.qty-edit input, .note-edit {
    font: inherit; font-size: 13px; padding: 5px 8px;
    border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface);
    color: var(--text);
}

.qty-edit input { width: 88px; text-align: right; font-family: ui-monospace, Consolas, monospace; }
.note-edit { width: 100%; min-width: 140px; }
.qty-edit input:focus, .note-edit:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent); }

/* The "back to the list" button at the top of a detail screen. */
.back-btn {
    display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
    padding: 5px 12px 5px 8px; font-size: 12px; margin-bottom: 8px;
}
.back-btn svg { width: 14px; height: 14px; }

/* ---------- LABELS PICKER (Print labels screen) ---------- */
.labels-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; align-items: start; }

@media (max-width: 900px) {
    .labels-grid { grid-template-columns: 1fr; }
}

/* ---------- LABEL SHEET ----------
   Every size is a custom property set inline by StockLabelsPrint.razor from the
   query string, so one stylesheet serves any sheet or roll. Millimetres throughout:
   the browser's print path honours them, which is what puts a label on a die-cut. */
.sheet-tools {
    position: sticky; top: 0; z-index: 2;
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    padding: 12px 16px; font-size: 13px;
    background: var(--card); border-bottom: 1px solid var(--border);
}

.sheet { background: #9aa3b5; padding: 16px 0; }

.sheet-page {
    width: var(--pw); height: var(--ph);
    margin: 0 auto 16px; background: #fff; box-shadow: var(--shadow-sm);   /* paper, in any theme */
    padding: var(--mt) 0 0 var(--ml);
    display: grid;
    grid-template-columns: repeat(var(--cols), var(--lw));
    grid-auto-rows: var(--lh);
    column-gap: var(--gx); row-gap: var(--gy);
    align-content: start;
    overflow: hidden;
}

.label {
    width: var(--lw); height: var(--lh);
    padding: 3mm; display: flex; gap: 3mm; overflow: hidden;
    color: #000; background: #fff;   /* paper, in any theme */
    font-family: 'Inter', 'Segoe UI', Arial, sans-serif;
    outline: 1px dashed #c7cdd9; outline-offset: -1px;   /* screen preview only */
}

/* The item's picture, square, sized by the Picture size setting (--qr) on a label
   without a barcode. contain, not cover: a hinge photographed on its side must not be cropped away. */
.label-img {
    height: var(--qr, 100%); aspect-ratio: 1 / 1; flex-shrink: 0;
    object-fit: contain; border-radius: 1mm;
}

/* No barcode and no picture: the name gets the whole label, so it can be bigger still. */
.label-textonly .label-name.n1 { font-size: calc(var(--lh) * 0.22); }
.label-textonly .label-name.n2 { font-size: calc(var(--lh) * 0.18); }
.label-textonly .label-name.n3 { font-size: calc(var(--lh) * 0.15); }

/* Barcode labels: name (and picture) on top, the bars in a strip across the full
   width along the bottom. The bars stretch with the label (the SVG has no fixed
   aspect), so a wider label prints wider bars, which a phone reads from further off.
   The strip is a third of the label's height but never under 7mm — shorter than that
   and a phone held at an angle runs off the top or bottom of the bars. */
.label-hasbar { flex-direction: column; gap: 1.5mm; }
.label-row { flex: 1; min-height: 0; display: flex; gap: 3mm; }
/* --imgk and --bark are the Picture size and Barcode size choices, as multipliers. A
   smaller picture sits centred in the height it gave up. The bars never go under 5mm. */
.label-row .label-img { height: calc(100% * var(--imgk, 1)); align-self: center; }
.label-barcode { flex-shrink: 0; height: max(5mm, calc((var(--lh) - 6mm) * 0.33 * var(--bark, 1))); }
.label-barcode svg { display: block; width: 100%; height: 100%; }
.label-hasbar .label-name.n1 { font-size: calc(var(--lh) * 0.13); }
.label-hasbar .label-name.n2 { font-size: calc(var(--lh) * 0.11); }
.label-hasbar .label-name.n3 { font-size: calc(var(--lh) * 0.09); }
.label-hasbar .label-name.n4 { font-size: calc(var(--lh) * 0.075); }
.label-hasbar .label-name.n5 { font-size: calc(var(--lh) * 0.065); }
.label-hasbar .label-path { font-size: calc(var(--lh) * 0.06); }
.label-hasbar .label-meta { font-size: calc(var(--lh) * 0.07); }
.label-hasbar .label-foot { font-size: calc(var(--lh) * 0.07); }

.label-text { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }

/* Sized by length — n1 for a short name, n5 for a very long one — so a name wraps to
   lines that fit instead of being cut through the middle of a letter. The class is
   chosen in StockLabelsPrint.razor. Breaks fall at hyphens and slashes first
   ("BPL-VIT-" / "1/2-SoftClose"); anywhere only when a single run has no break in it. */
.label-name {
    font-weight: 700; line-height: 1.15;
    overflow-wrap: anywhere;
    /* No overflow:hidden and no line clamp here. The clamp box shaved descenders off
       "y" and "/" even on one-line names, and a cut-through letter is worse than a
       footer nudged down. The size tiers keep the whole name inside the label; the
       label's own overflow:hidden is the last resort. */
}

.label-name.n1 { font-size: calc(var(--lh) * 0.17); }
.label-name.n2 { font-size: calc(var(--lh) * 0.14); }
.label-name.n3 { font-size: calc(var(--lh) * 0.115); }
.label-name.n4 { font-size: calc(var(--lh) * 0.095); }
.label-name.n5 { font-size: calc(var(--lh) * 0.08); }

/* The item's Size, right under the name and a step smaller: "11/16 X 1 1/8". */
/* The ticked items on the rack labels page, listed above the search results. */
.ticked-list { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 12px; }
.ticked-cap { font-size: 12px; font-weight: 600; color: var(--text-mute); margin-right: 2px; }
.ticked-chip {
    border: 1px solid var(--border); background: var(--surface-2); color: inherit;
    border-radius: 999px; padding: 3px 10px; font: inherit; font-size: 12.5px; cursor: pointer;
}
.ticked-chip:hover { background: var(--red-soft); color: var(--red-ink); }

.label-size { margin-top: .6mm; font-weight: 600; font-size: calc(var(--lh) * 0.1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.label-hasbar .label-size { font-size: calc(var(--lh) * 0.08); }

.label-path, .label-meta {
    margin-top: 1mm; color: #333;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.label-path { font-size: calc(var(--lh) * 0.075); }
.label-meta { font-size: calc(var(--lh) * 0.085); }

.label-foot {
    margin-top: auto; display: flex; justify-content: space-between; gap: 2mm;
    font-family: ui-monospace, Consolas, monospace; letter-spacing: .5px;
    font-size: calc(var(--lh) * 0.09);
}


/* ---------- PLYWOOD AND DOOR LABELS (LabelMakerPrint.razor) ----------
   Read from across the yard, so the type is as big as the label allows. Every size is
   a multiple of --u, a hundredth of the label's width — or of one and a half times its
   height when that is smaller, which keeps a wide, short sticker from overflowing.
   The same rules then serve a 4×2 sticker and a full letter page. */
.plabel {
    --u: calc(min(var(--lw), var(--lh) * 1.5) / 100);
    width: var(--lw); height: var(--lh);
    padding: calc(var(--u) * 4.5); display: flex; flex-direction: column; overflow: hidden;
    color: #000; background: #fff;   /* paper, in any theme */
    font-family: 'Inter', 'Segoe UI', Arial, sans-serif; line-height: 1.12;
    outline: 1px dashed #c7cdd9; outline-offset: -1px;   /* screen preview only */
}

/* A door's unit number, "#4", big in the top right corner where it is seen first.
   Out of the flow so it costs no height; the name beside it keeps clear of it. */
.plabel { position: relative; }
.plabel-unit {
    position: absolute; top: calc(var(--u) * 3.5); right: calc(var(--u) * 4.5);
    font-size: calc(var(--u) * 13 * var(--k-unit, 1)); font-weight: 800; line-height: 1; white-space: nowrap;
}
.plabel.has-unit .plabel-name { padding-right: calc(var(--u) * 24 * var(--k-unit, 1)); }

/* The top row: the company logo first, then the black heading. */
.plabel-top {
    display: flex; align-items: center; gap: calc(var(--u) * 2.5); flex-shrink: 0;
    margin-bottom: calc(var(--u) * 1.5);
}

.plabel-kind {
    flex-shrink: 0;
    font-size: calc(var(--u) * 3); font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
    color: #fff; background: #000; padding: calc(var(--u) * .7) calc(var(--u) * 1.6);
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
}

.plabel-name { font-weight: 800; overflow-wrap: anywhere; flex-shrink: 0; }
.plabel-name.n1 { font-size: calc(var(--u) * 16 * var(--k-name, 1)); }
.plabel-name.n2 { font-size: calc(var(--u) * 12 * var(--k-name, 1)); }
.plabel-name.n3 { font-size: calc(var(--u) * 9 * var(--k-name, 1)); }
.plabel-name.n4 { font-size: calc(var(--u) * 8 * var(--k-name, 1)); }
.plabel-name.n5 { font-size: calc(var(--u) * 6 * var(--k-name, 1)); }
.plabel-name.n6 { font-size: calc(var(--u) * 4.6 * var(--k-name, 1)); }

.plabel-size { font-size: calc(var(--u) * 9 * var(--k-size, 1)); font-weight: 700; margin-top: calc(var(--u) * 1); flex-shrink: 0; }
.plabel-size.long { font-size: calc(var(--u) * 6.5 * var(--k-size, 1)); }

.plabel-details { font-size: calc(var(--u) * 4.6 * var(--k-details, 1)); margin-top: calc(var(--u) * 1.2); color: #222; flex-shrink: 0; }

/* A door's other specs, one per line as typed. Takes what height is left and hides
   the overflow, so a long list never pushes the date off the label. */
.plabel-specs {
    font-size: calc(var(--u) * 4 * var(--k-specs, 1)); line-height: 1.25; margin-top: calc(var(--u) * 1.5);
    white-space: pre-line; overflow: hidden; flex: 0 1 auto; min-height: 0;
}

/* On a label wider than it is tall the specs run in two columns: eight lines fit
   where four would. */
.plabel.wide .plabel-specs { column-count: 2; column-gap: calc(var(--u) * 4); }

.plabel-foot {
    margin-top: auto; flex-shrink: 0;
    padding-top: calc(var(--u) * 1.5); border-top: calc(var(--u) * .5) solid #000;
    display: flex; justify-content: space-between; align-items: flex-end; gap: calc(var(--u) * 3);
}

.plabel-cap { font-size: calc(var(--u) * 2.8); font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.plabel-date { font-size: calc(var(--u) * 3.5 * var(--k-date, 1)); font-weight: 800; white-space: nowrap; }
.plabel-ref { font-size: calc(var(--u) * 4 * var(--k-ref, 1)); text-align: right; margin-left: auto; overflow-wrap: anywhere; min-width: 0; }

/* A door order's settings (DoorLabelStyle): the PO on its own line over the builder and
   job, bold by choice, and the date plain by choice. */
.plabel-po { font-size: calc(var(--u) * 4 * var(--k-po, 1)); white-space: nowrap; }
.sheet.po-bold .plabel-po { font-weight: 800; }
.sheet.date-plain .plabel-date { font-weight: 500; }

/* The company logo, first on the top row. The file is a square with white space
   round the mark, so it is shown as a background, shifted, to crop to the mark
   itself. Printed even when the browser's "background graphics" is off. */
.plabel-logo {
    flex-shrink: 0; width: calc(var(--u) * 13 * var(--k-logo, 1)); height: calc(var(--u) * 8 * var(--k-logo, 1));
    background: url('logo-label.webp') 50% 42% / 100% auto no-repeat;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
/* ---------- DOOR BUILD FORM (DoorOrderBuildForm.razor) ----------
   A letter page on its side for the back shop. On screen it is drawn as paper on the
   label sheets' grey; printed, @page's margin does the framing and the column headings
   repeat on every page (a thead does that in print by itself). Black on white in any
   theme, like the labels. */
.bf-page {
    width: 279.4mm; min-height: 215.9mm; margin: 0 auto; padding: 9mm; box-sizing: border-box;
    background: #fff; color: #000; box-shadow: var(--shadow-sm);
    font-family: 'Inter', 'Segoe UI', Arial, sans-serif; font-size: 10.5pt;
}

.bf-head {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 8mm;
    padding-bottom: 3mm; border-bottom: 2px solid #000; margin-bottom: 3mm;
}
.bf-brand { display: flex; align-items: center; gap: 4mm; }
.bf-logo {
    width: 26mm; height: 16mm; flex-shrink: 0;
    background: url('logo-label.webp') 50% 42% / 100% auto no-repeat;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.bf-title { font-size: 11pt; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.bf-po { font-size: 22pt; font-weight: 800; line-height: 1.1; }

.bf-facts { display: grid; grid-template-columns: repeat(3, auto); gap: 1.5mm 7mm; margin: 0; }
.bf-facts div { min-width: 0; }
.bf-facts dt { font-size: 7.5pt; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: #444; }
.bf-facts dd { margin: 0; font-weight: 600; max-width: 70mm; overflow-wrap: anywhere; }

.bf-notes { margin-bottom: 3mm; white-space: pre-line; }

.bf-table { width: 100%; border-collapse: collapse; }
.bf-table th {
    text-align: left; font-size: 7.5pt; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
    border-bottom: 1.5px solid #000; padding: 1.5mm 2mm;
}
.bf-table td { border-bottom: 1px solid #999; padding: 2mm; vertical-align: top; }
.bf-table tr { break-inside: avoid; }
.bf-table tr.bf-alt td { background: #f0f0f0; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.bf-table .bf-tick { width: 11mm; text-align: center; }
.bf-table .bf-num { width: 9mm; font-size: 14pt; font-weight: 800; text-align: right; }
.bf-box { display: inline-block; width: 5.5mm; height: 5.5mm; border: 1.5px solid #000; background: #fff; }
.bf-strong { font-weight: 700; white-space: nowrap; }
.bf-small { font-size: 8.5pt; color: #333; }
.bf-notes-cell { white-space: pre-line; min-width: 40mm; max-width: 60mm; font-size: 9.5pt; }

.bf-foot { display: flex; gap: 10mm; margin-top: 8mm; break-inside: avoid; }
.bf-foot > div { flex: 1; display: flex; align-items: flex-end; gap: 2mm; white-space: nowrap; }
.bf-line { flex: 1; border-bottom: 1px solid #000; height: 5mm; }

@media print {
    .bf-page { width: auto; min-height: 0; padding: 0; box-shadow: none; }
}

@media print {
    .sheet { background: none; padding: 0; }
    .sheet-page { margin: 0; box-shadow: none; break-after: page; }
    .sheet-page:last-child { break-after: auto; }
    .sheet-tools { display: none; }
    .label, .plabel { outline: none; }
}

/* ==========================================================================
   COLLAPSIBLE SIDEBAR
   The button at the foot of the menu folds the sidebar to a 64px icon rail and
   back. Remembered per browser in localStorage ('pp-nav') and put on <html> as
   data-nav="collapsed" by the head script in App.razor, so a collapsed menu never
   flashes open on load. The rail itself is the same one narrow windows (641–720px)
   already fall into on their own; these rules repeat it for the chosen state.

   Never applies on a phone (≤640px): there the sidebar is a slide-in drawer, which
   takes no room while shut, so there is nothing to collapse.
   ========================================================================== */
.nav-collapse {
    width: 100%;
    background: none; border: 0; cursor: pointer;
    font: inherit; text-align: left;
    margin-top: 8px;
}

.nav-collapse svg { transition: transform .2s ease; }

/* Labels that only make sense when the menu is collapsed or expanded. */
.nav-collapse .when-collapsed { display: none; }

@media (min-width: 641px) {
    .sidebar { transition: width .18s ease; }

    :root[data-nav="collapsed"] .sidebar { width: 64px; }
    :root[data-nav="collapsed"] .nav-menu { padding: 14px 8px; }
    :root[data-nav="collapsed"] .nav-menu .nav-link { justify-content: center; padding: 11px 0; gap: 0; }
    :root[data-nav="collapsed"] .nav-menu .nav-link span:not(.nav-badge) { display: none; }

    :root[data-nav="collapsed"] .nav-badge {
        position: absolute; top: 7px; right: 14px;
        min-width: 0; width: 8px; height: 8px; padding: 0;
        font-size: 0;
    }

    :root[data-nav="collapsed"] .brand { padding: 18px 8px; justify-content: center; }

    :root[data-nav="collapsed"] .brand-logo {
        width: 30px;
        aspect-ratio: 61 / 76;
        background-image: url('mark-light.png');
    }

    :root[data-nav="collapsed"] .nav-chevron { display: none; }
    :root[data-nav="collapsed"] .nav-menu .nav-link.nav-sub { padding-left: 0; }
    :root[data-nav="collapsed"] .nav-group { margin-bottom: 0; }

    /* An open Utilities group in the rail gets a faint backing, so its five icons
       read as belonging to the spanner above them rather than to the main list. */
    :root[data-nav="collapsed"] .nav-group[open] { background: var(--nav-hover); border-radius: 8px; }

    /* The point-left arrow turns round to point right: "this way to open it". */
    :root[data-nav="collapsed"] .nav-collapse svg { transform: rotate(180deg); }
    :root[data-nav="collapsed"] .nav-collapse .when-expanded { display: none; }

    /* Footer: name, Account / Sign out and the version have no room in 64px. The
       bell, the tools and the health light stack in a column. Expand the menu to
       reach Account and Sign out. */
    :root[data-nav="collapsed"] .sidebar-foot { padding: 12px 8px; }
    :root[data-nav="collapsed"] .sidebar-foot .who,
    :root[data-nav="collapsed"] .sidebar-foot .foot-links,
    :root[data-nav="collapsed"] .foot-status .mono { display: none; }
    :root[data-nav="collapsed"] .foot-status { flex-direction: column; justify-content: center; gap: 8px; }
    :root[data-nav="collapsed"] .chat-bell { justify-content: center; }
    :root[data-nav="collapsed"] .chat-bell span:not(.bell-badge) { display: none; }
}

/* The narrow-window rail is forced by the width, so a collapse button there could
   only ever do nothing. Hidden, along with on the phone drawer. */
@media (max-width: 720px) {
    .nav-collapse { display: none !important; }
}

/* ==========================================================================
   THEME PICKER
   The palette button in the sidebar footer opens this panel; each card is a
   miniature of its theme drawn from that theme's own colours, so what you see is
   what you get. Rendered by MainLayout, not inside the sidebar, for the same reason
   as the calculator: the phone sidebar is a transformed drawer and would drag a
   fixed pop-up off screen with it. Wiring is in js/footer-tools.js.
   ========================================================================== */
.theme-pop {
    position: fixed; left: 16px; bottom: 16px; z-index: 70;
    width: 380px; max-width: calc(100vw - 32px);
    background: var(--card); color: var(--text);
    border: 1px solid var(--border-strong); border-radius: 14px;
    box-shadow: var(--shadow-lg); padding: 14px 16px 16px;
}

.theme-pop[hidden] { display: none; }

.theme-pop-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 4px; font-size: 14px;
}

.theme-pop-note { margin: 0 0 12px; font-size: 12px; color: var(--text-dim); }

.theme-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.theme-card {
    display: flex; flex-direction: column; gap: 6px;
    padding: 6px; border-radius: 10px; cursor: pointer;
    border: 2px solid transparent; background: var(--surface-2);
    font: inherit; color: var(--text); text-align: left;
}

.theme-card:hover { border-color: var(--border-strong); }
.theme-card:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.theme-card[aria-checked="true"] { border-color: var(--primary); }

.theme-card .tc-name { font-size: 12.5px; font-weight: 600; padding: 0 2px; }
.theme-card .tc-desc { font-size: 11px; color: var(--text-dim); padding: 0 2px 2px; line-height: 1.3; }

/* The miniature: a sidebar strip, a heading bar, two rows and a button. */
.tc-mini {
    display: grid; grid-template-columns: 22px 1fr; height: 62px;
    border-radius: 7px; overflow: hidden; border: 1px solid rgba(0,0,0,.08);
}

.tc-mini .tc-side { background: var(--m-nav); display: flex; flex-direction: column; gap: 4px; padding: 8px 5px; }
.tc-mini .tc-side i { display: block; height: 3px; border-radius: 2px; background: var(--m-navtext); opacity: .55; }
.tc-mini .tc-side i:first-child { opacity: 1; background: var(--m-primary); }

.tc-mini .tc-page { background: var(--m-bg); padding: 7px 8px; display: flex; flex-direction: column; gap: 5px; }
.tc-mini .tc-title { height: 6px; width: 55%; border-radius: 2px; background: var(--m-text); }
.tc-mini .tc-row { height: 9px; border-radius: 3px; background: var(--m-card); border: 1px solid var(--m-border); }
.tc-mini .tc-btn { height: 8px; width: 34%; border-radius: 3px; background: var(--m-primary); align-self: flex-end; }

/* Each miniature's colours, copied from its theme block above. */
.theme-card[data-theme-choice="light"]     { --m-nav: #0b1a3a; --m-navtext: #c9d4ec; --m-bg: #f4f6fb; --m-card: #ffffff; --m-border: #e6eaf2; --m-text: #0f1a33; --m-primary: #2563eb; }
.theme-card[data-theme-choice="dark"]      { --m-nav: #070e1f; --m-navtext: #b9c6e4; --m-bg: #0e1322; --m-card: #161d30; --m-border: #252f47; --m-text: #e7ecf7; --m-primary: #5b8cff; }
.theme-card[data-theme-choice="workshop"]  { --m-nav: #1f1a15; --m-navtext: #dccbb5; --m-bg: #f5efe6; --m-card: #fffcf7; --m-border: #e7ddcf; --m-text: #2a2119; --m-primary: #c2410c; }
.theme-card[data-theme-choice="sage"]      { --m-nav: #18261f; --m-navtext: #c5d6cb; --m-bg: #f1f4ef; --m-card: #ffffff; --m-border: #dfe6dc; --m-text: #1b261f; --m-primary: #2f7d5b; }
.theme-card[data-theme-choice="blueprint"] { --m-nav: #0b355c; --m-navtext: #cde2f6; --m-bg: #eef4fa; --m-card: #ffffff; --m-border: #d3e1ef; --m-text: #0a2440; --m-primary: #0b6bcb; }
.theme-card[data-theme-choice="brass"]     { --m-nav: #0b0a08; --m-navtext: #cdbf9c; --m-bg: #121110; --m-card: #1b1916; --m-border: #2c2822; --m-text: #eee7d6; --m-primary: #c9a227; }

@media (max-width: 640px) {
    .theme-pop { left: 12px; right: 12px; bottom: 12px; width: auto; max-width: none; }
}

/* ==========================================================================
   PERMISSIONS: the Users drawer's groups and individual settings, and the
   Groups screen's area-by-group table. See Data/Permissions.cs.
   ========================================================================== */
.page-intro { max-width: 820px; margin: -6px 0 16px; line-height: 1.5; }

.view-only-note {
    margin-bottom: 14px; padding: 10px 14px; border-radius: 10px;
    background: var(--blue-soft); color: var(--blue-ink); font-size: 13px;
}

/* The drawers that hold a permission table need more than the usual 400px. */
.drawer:has(.perm-table) { width: 520px; }

.group-picks { display: grid; gap: 6px; }

.field .field-check.group-pick {
    align-items: flex-start; gap: 10px; padding: 8px 10px;
    border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2);
}

.group-pick input { margin-top: 3px; }
.group-pick > span { display: flex; flex-direction: column; gap: 2px; }
.group-pick-desc { font-size: 12px; color: var(--text-dim); font-weight: 400; }

.perm-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.perm-table td, .perm-table th { padding: 7px 6px; border-bottom: 1px solid var(--border); vertical-align: middle; text-align: left; }
.perm-table th { font-size: 11.5px; color: var(--text-mute); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.perm-table select { width: 100%; min-width: 150px; }
.perm-table td:last-child { white-space: nowrap; }

.perm-section td {
    padding-top: 14px; font-size: 11.5px; font-weight: 700; color: var(--text-mute);
    text-transform: uppercase; letter-spacing: .5px; border-bottom: 1px solid var(--border-strong);
}

.perm-means { display: block; font-size: 11.5px; color: var(--text-mute); margin-top: 2px; line-height: 1.35; }

.perm-presets { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; font-size: 12px; }

/* None / View / Edit as one segmented control. */
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; }

.seg-btn {
    border: 0; background: var(--surface); color: var(--text-dim);
    padding: 5px 10px; font: inherit; font-size: 12px; cursor: pointer;
}

.seg-btn + .seg-btn { border-left: 1px solid var(--border-strong); }
.seg-btn:hover { background: var(--surface-2); color: var(--text); }
.seg-btn.on { background: var(--primary); color: var(--on-primary); }
.seg-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }

.perm-matrix td:not(:first-child), .perm-matrix th:not(:first-child) { text-align: center; }
.perm-matrix-head { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.perm-matrix-count { font-size: 11px; font-weight: 400; text-transform: none; letter-spacing: 0; }

.danger-text { color: var(--red-ink); }

@media (max-width: 640px) {
    .drawer:has(.perm-table) { width: 100%; }
}

/* ==========================================================================
   LINE CHART (Components/Shared/LineChart.razor, hover in js/line-chart.js)

   Line colours are a validated colour-blind-safe categorical palette, assigned in
   a fixed order by entity (slot 1 = the total, 2+ = branches by location id), with
   their own steps for dark themes rather than an automatic flip. Deliberately NOT
   the theme's primary colour: status and brand colours stay out of the data, and
   a branch keeps its colour whichever theme someone picks.
   ========================================================================== */
:root {
    --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
    --series-5: #e87ba4; --series-6: #008300; --series-7: #6250d6; --series-8: #e34948;
}

:root[data-mode="dark"] {
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
}

.lc-s1 { stroke: var(--series-1); fill: var(--series-1); }
.lc-s2 { stroke: var(--series-2); fill: var(--series-2); }
.lc-s3 { stroke: var(--series-3); fill: var(--series-3); }
.lc-s4 { stroke: var(--series-4); fill: var(--series-4); }
.lc-s5 { stroke: var(--series-5); fill: var(--series-5); }
.lc-s6 { stroke: var(--series-6); fill: var(--series-6); }
.lc-s7 { stroke: var(--series-7); fill: var(--series-7); }
.lc-s8 { stroke: var(--series-8); fill: var(--series-8); }

.lc-wrap { position: relative; }
.lc-svg { display: block; width: 100%; height: auto; overflow: visible; }

.lc-grid { stroke: var(--border); stroke-width: 1; }
.lc-ytick, .lc-xtick { fill: var(--text-mute); font-size: 11px; font-variant-numeric: tabular-nums; }

.lc-line { fill: none !important; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.lc-line.lc-total { stroke-width: 2.5; }
.lc-line.lc-dashed { stroke-dasharray: 6 4; opacity: .75; }

/* A ring in the card colour keeps dots legible where lines cross. */
.lc-dot { stroke: var(--card) !important; stroke-width: 2; }

.lc-cross { stroke: var(--text-mute); stroke-width: 1; stroke-dasharray: 3 3; pointer-events: none; }
.lc-hit { fill: transparent; cursor: crosshair; }

.lc-end {
    position: absolute; transform: translateY(-50%);
    font-size: 11.5px; color: var(--text-dim); white-space: nowrap; pointer-events: none;
}

.lc-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 8px; font-size: 12px; color: var(--text-dim); }
.lc-key { display: inline-flex; align-items: center; gap: 6px; }
.lc-key svg { width: 22px; height: 8px; }
.lc-key line, .lc-tip-row line { stroke-width: 2.5; stroke-linecap: round; fill: none; }

.lc-tip {
    position: absolute; top: 8px; z-index: 5; min-width: 170px;
    background: var(--card); color: var(--text);
    border: 1px solid var(--border-strong); border-radius: 10px;
    box-shadow: var(--shadow-lg); padding: 8px 10px; font-size: 12px; pointer-events: none;
}

.lc-tip[hidden] { display: none; }
.lc-tip-head { font-weight: 600; margin-bottom: 4px; color: var(--text-dim); }
.lc-tip-row { display: grid; grid-template-columns: 14px auto 1fr; align-items: center; gap: 7px; padding: 1px 0; }
.lc-tip-row svg { width: 14px; height: 6px; }
.lc-tip-row strong { font-variant-numeric: tabular-nums; text-align: right; min-width: 24px; }
.lc-tip-row span { color: var(--text-dim); }

.lc-table { margin-top: 10px; }
.lc-table > summary { cursor: pointer; font-size: 12.5px; color: var(--primary); }
.lc-table .table-wrap { max-height: 260px; overflow: auto; margin-top: 8px; }

.chart-settings-link { font-size: 12px; margin-left: 8px; font-weight: 500; font-family: var(--font); }

/* Stacked columns (Components/Shared/StackedColumnChart.razor) */
.sc-seg { stroke: none !important; }
.sc-swatch { width: 12px !important; height: 12px !important; }
.sc-swatch rect, .sc-tip-swatch rect { stroke: none !important; }
.sc-tip-swatch { width: 12px !important; height: 12px !important; }

/* Last year's total: a dark tick across the column, in text ink, not a series colour. */
.sc-ly { stroke: var(--text); stroke-width: 2.5; stroke-linecap: round; opacity: .7; }

.sc-band { fill: var(--text); opacity: .06; pointer-events: none; }

/* The all-branches total above each column: text ink, never a series colour. */
.sc-total { fill: var(--text-dim); font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums; }

.lc-tip-total { font-weight: 700; border-bottom: 1px solid var(--border); padding-bottom: 4px !important; margin-bottom: 2px; }
.lc-tip-total span { color: var(--text) !important; }

/* ---- Stock requests: view switch, by-item view, double-order warnings ---- */
.sr-viewbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.sr-viewhint { font-size: 13px; }

.sr-chip {
    display: inline-block; margin: 2px 4px 2px 0; padding: 1px 7px; border-radius: 6px;
    background: var(--surface-2); border: 1px solid var(--border);
    font-size: 12px; font-family: ui-monospace, Consolas, monospace; text-decoration: none; color: var(--primary);
}
.sr-chip:hover { border-color: var(--primary); }

.sr-recent {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 2px 8px; border-radius: 999px;
    background: var(--amber-soft); color: var(--amber-ink);
    font-size: 12px; font-weight: 600; line-height: 1.5;
}
.sr-recent svg { width: 13px; height: 13px; flex-shrink: 0; }
.sr-recent { max-width: 220px; border-radius: 10px; }
.sr-recent a { color: inherit; text-decoration: underline; }

.sr-warn-row td:first-child { box-shadow: inset 3px 0 0 var(--amber-ink); }

/* The warning shown while adding an item, before it is added. */
.sr-heads-up {
    display: flex; gap: 10px; align-items: flex-start;
    margin: 10px 0 0; padding: 10px 12px; border-radius: 10px;
    background: var(--amber-soft); color: var(--amber-ink); font-size: 13px; line-height: 1.45;
}
.sr-heads-up svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.sr-heads-up a { color: inherit; font-weight: 600; }
.sr-heads-up ul { margin: 4px 0 0; padding-left: 18px; }

.sr-line-flags { display: flex; flex-wrap: wrap; gap: 4px 6px; margin-top: 4px; }

/* ---- Item List: label pictures and display names ---- */
.item-cell { display: flex; align-items: center; gap: 10px; }
.item-thumb { width: 36px; height: 36px; object-fit: contain; border-radius: 6px; background: #fff; border: 1px solid var(--border); flex-shrink: 0; }
.item-image-edit { display: flex; gap: 14px; align-items: flex-start; }
.item-image-preview { width: 96px; height: 96px; object-fit: contain; border-radius: 10px; background: #fff; border: 1px solid var(--border); flex-shrink: 0; }
.item-image-empty { display: grid; place-items: center; font-size: 12px; color: var(--text-mute); background: var(--surface-2); }
.item-image-actions { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; min-width: 0; }
.item-image-actions input[type="file"] { max-width: 100%; font-size: 12.5px; }

/* Utilities → Settings */
.settings-card { max-width: 760px; }
.settings-stamp { font-size: 12px; }
.settings-grid { display: grid; gap: 4px 28px; grid-template-columns: 1fr 1fr; }
.settings-grid .field input[type="number"] { max-width: 120px; }
.settings-grid .settings-wide { grid-column: 1 / -1; }
.settings-inline { display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.settings-inline input[type="number"] { max-width: 90px; }
.settings-actions { display: flex; align-items: center; gap: 10px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.settings-view-link { margin-left: auto; font-size: 13px; }

@media (max-width: 720px) {
    .settings-grid { grid-template-columns: 1fr; }
}

/* On a phone the end labels crowd the plot; the legend above already names every line. */
@media (max-width: 640px) {
    .lc-end { display: none; }
}

/* The ticked items on the Item List, as a bar between the filters and the table. */
.bulk-bar { margin: 0; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.bulk-bar .primary-btn { margin-left: auto; }
