/* Light by default; dark when the computer prefers it, unless the header switch chose one
   (html[data-theme="light" | "dark"], set before the app loads). */
:root {
  --bg: #f4f6f8; --card: #fff; --text: #1f2933; --muted: #616e7c; --line: #d9e2ec;
  --accent: #0b5cad; --accent-text: #fff; --ok: #1f7a3a; --bad: #b42318; --notice: #fff7e6;
  --logo-backing: transparent;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111418; --card: #1b1f24; --text: #e6e9ed; --muted: #9aa5b1; --line: #2e353d;
    --accent: #4c9be8; --accent-text: #0b1622; --ok: #5cc97b; --bad: #ff7b72; --notice: #2b2410;
    --logo-backing: #f1f5f9; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111418; --card: #1b1f24; --text: #e6e9ed; --muted: #9aa5b1; --line: #2e353d;
  --accent: #4c9be8; --accent-text: #0b1622; --ok: #5cc97b; --bad: #ff7b72; --notice: #2b2410;
  --logo-backing: #f1f5f9; color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
.boot { padding: 96px 48px; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 14px; }
.boot img { animation: qs-pulse 1.4s ease-in-out infinite; }
@keyframes qs-pulse { 50% { transform: translateY(-4px); opacity: .75; } }
.pill { background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; }
main { max-width: 960px; margin: 0 auto; padding: 24px 16px; }
h1 { font-size: 24px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 0 0 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 18px 20px; margin-bottom: 16px; }
.card.narrow { max-width: 440px; margin: 32px auto; }
label { display: block; margin: 12px 0 4px; font-weight: 600; }
label.check { display: inline-flex; gap: 6px; align-items: center; margin: 0; font-weight: 400; }
input, select { width: 100%; padding: 8px 10px; font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 6px; }
input[type=checkbox], input[type=radio] { width: auto; }
button { font: inherit; padding: 8px 14px; border-radius: 6px; border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer; margin-top: 12px; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
a.button { display: inline-block; text-decoration: none; padding: 8px 14px; border-radius: 6px; border: 1px solid var(--line); }
button.no-margin { margin-top: 0; }
a.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.link { border: none; background: none; color: var(--accent); padding: 0; margin: 0; }
button:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row select { flex: 1; min-width: 200px; }
.row button { margin-top: 0; }
.error { color: var(--bad); }
.notice { background: var(--notice); border-radius: 6px; padding: 8px 12px; }
.hint { color: var(--muted); font-size: 13px; margin: 4px 0; }
dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0 0 8px; }
dt { color: var(--muted); }
.weight { font-size: 40px; font-weight: 700; font-variant-numeric: tabular-nums; margin: 8px 0; color: var(--muted); }
.weight.stable { color: var(--ok); }
/* Forms that only exist so Enter (or Go on a phone keyboard) submits: they don't affect the layout */
.enter-form { display: contents; }
.home-title { text-align: center; }
/* Home page: tiles centred in their rows, contents centred in each tile */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.home-tiles { display: flex; flex-wrap: wrap; justify-content: center; max-width: 1040px; margin: 0 auto; }
.home-tiles .tile { flex: 0 1 218px; align-items: center; text-align: center; }
@media (max-width: 560px) { .home-tiles .tile { flex-basis: 100%; } }
.tile { display: flex; flex-direction: column; gap: 6px; padding: 18px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; color: var(--text); text-decoration: none; }
.tile { --hue: 210; transition: border-color .15s, transform .15s, box-shadow .15s; }
.tile:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 6px 18px rgba(15, 23, 42, .12); }
.tile.disabled { opacity: .6; }
.tile span { color: var(--muted); font-size: 14px; }
/* Home page icons: a line icon in a tinted square, one colour per tile (--hue on the tile) */
.tile .tile-icon { display: grid; place-items: center; width: 46px; height: 46px; margin-bottom: 6px; border-radius: 12px;
  color: var(--tile-icon); background: var(--tile-icon-bg); --tile-icon: hsl(var(--hue) 70% 40%); --tile-icon-bg: hsl(var(--hue) 80% 50% / .12); }
.tile .tile-icon svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
:root[data-theme="dark"] .tile .tile-icon { --tile-icon: hsl(var(--hue) 80% 70%); --tile-icon-bg: hsl(var(--hue) 70% 60% / .16); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tile .tile-icon { --tile-icon: hsl(var(--hue) 80% 70%); --tile-icon-bg: hsl(var(--hue) 70% 60% / .16); } }
#blazor-error-ui { display: none; position: fixed; bottom: 0; left: 0; right: 0; padding: 10px 16px; background: var(--notice); }
#blazor-error-ui .dismiss { float: right; cursor: pointer; }
h1:focus { outline: none; }
label.inline { display: inline-flex; gap: 8px; align-items: center; font-weight: 600; }
label.inline select { width: auto; }
.scan-input { font-size: 18px; flex: 1; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0 12px; }
.fields label { font-weight: 500; font-size: 13px; color: var(--muted); }
.fields label.wide { grid-column: 1 / -1; }
.fields label input { margin-top: 2px; color: var(--text); font-size: 15px; }
.fields label.check { color: var(--text); margin-top: 28px; }
.row.tight { gap: 6px; flex-wrap: nowrap; }
.row.tight button { padding: 8px 10px; }
fieldset { border: 1px solid var(--line); border-radius: 6px; margin: 12px 0; padding: 8px 12px; display: flex; flex-wrap: wrap; gap: 6px 16px; }
legend { font-weight: 600; padding: 0 4px; }
input.warn { border-color: var(--bad); color: var(--bad); font-weight: 700; }
.messages p { margin: 0 0 8px; padding: 8px 12px; border-radius: 6px; background: var(--card); border: 1px solid var(--line); }
.messages p.error { border-color: var(--bad); }
.messages p.ok { border-color: var(--ok); color: var(--ok); }
.price { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.price .amount { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ship-button { width: 100%; font-size: 17px; padding: 12px; }
table.grid { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 14px; }
table.grid th, table.grid td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.grid td input { padding: 4px 6px; }
table.grid .num { text-align: right; font-variant-numeric: tabular-nums; }
ul.picker { list-style: none; padding: 0; margin: 6px 0; max-height: 220px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; }
ul.picker li { padding: 6px 10px; border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.tabs button { margin: 0; border: none; border-bottom: 2px solid transparent; border-radius: 0; background: none; }
.tabs button.active { border-bottom-color: var(--accent); font-weight: 600; }
td.actions { white-space: nowrap; }
/* Returns: six columns, with a second line in a cell, so the actions fit beside the sidebar at 1280 px; long numbers wrap. */
#returnsTable td { overflow-wrap: break-word; }
#returnsTable .original, #returnsTable .line2 a { overflow-wrap: anywhere; }
#returnsTable .line2 { display: block; color: var(--muted); font-size: 13px; }
td.actions.stack .link { display: block; margin: 2px 0; }
td.actions .link { margin-right: 10px; }
tr.voided td { color: var(--muted); text-decoration: line-through; }
tr.voided td.actions { text-decoration: none; }
.scroll-x { overflow-x: auto; }
.dialog-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
.dialog { max-width: 520px; width: 100%; margin: 0; max-height: calc(100vh - 32px); overflow-y: auto; }

/* Reports, BOL and admin (phase 2b/2c) */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 760px) { .two-col { grid-template-columns: 1fr; } }
textarea { width: 100%; padding: 8px 10px; font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 6px; box-sizing: border-box; }
.checks { display: flex; flex-wrap: wrap; gap: 10px 20px; margin-top: 14px; }
.dialog.wide { max-width: 760px; }
/* Admin › Users: shipping stations, by site */
.station-group { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: baseline; }
.station-group strong { flex-basis: 100%; font-size: .9em; color: var(--muted); }
#userStations .hint { flex-basis: 100%; margin: 0; }
.narrow-form { max-width: 420px; }
tr.detail td { background: var(--bg); }
tr.detail ul { margin: 4px 0 8px; padding-left: 18px; }
.tabs a[role=tab] { padding: 8px 14px; color: var(--muted); text-decoration: none; }

.report h2 { font-size: 18px; margin: 0 0 4px; }
.report-meta { display: flex; flex-wrap: wrap; gap: 4px 20px; color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.report-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.report-table th { text-align: left; border-bottom: 2px solid var(--text); padding: 4px 6px; }
.report-table td { vertical-align: top; border-bottom: 1px solid var(--line); padding: 6px; break-inside: avoid; }
.report-table tr { break-inside: avoid; page-break-inside: avoid; }
.report-table dl { display: grid; grid-template-columns: auto 1fr; gap: 0 8px; margin: 0; }
.report-table dt { color: var(--muted); }
.report-table dd { margin: 0; }
.report-table tr.voided td { text-decoration: line-through; color: var(--muted); }
.report-foot { margin-top: 12px; }
.report-foot .signature { margin-top: 28px; }

.print-only { display: none; }
.bol h2 { font-size: 20px; margin: 0; text-transform: uppercase; }
.bol-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin-bottom: 10px; }
.bol table { width: 100%; border-collapse: collapse; margin-bottom: 10px; font-size: 12px; }
.bol th, .bol td { border: 1px solid #000; padding: 4px 6px; text-align: left; vertical-align: top; }
.bol .bol-box th { width: 22%; font-size: 10px; text-transform: uppercase; }
.bol .num { text-align: right; }
.bol-sign { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; font-size: 12px; margin-top: 16px; line-height: 1.6; }

@media print {
    @page { margin: 12mm; }
    .topbar, .no-print, .messages, .sidebar { display: none !important; }
    .print-only { display: block !important; }
    body, main, .card { background: #fff !important; color: #000 !important; }
    main { max-width: none !important; padding: 0 !important; }
    .card { border: none !important; padding: 0 !important; margin: 0 !important; box-shadow: none !important; }
    .report-meta, .report-table dt { color: #333 !important; }
}

/* Ship page: laid out to fit one screen (1366x768 and up) without scrolling. */
main:has(.ship-page) { max-width: 1680px; padding: 12px 16px; }
.ship-page .card { padding: 12px 14px; margin-bottom: 10px; }
.ship-page h1 { font-size: 18px; margin: 0; white-space: nowrap; }
.ship-page h2 { font-size: 15px; margin: 0 0 4px; }
.ship-page h2:not(:first-child) { margin-top: 10px; }
.ship-page label { margin: 4px 0 2px; font-size: 13px; }
.ship-page input, .ship-page select { padding: 5px 8px; }
.ship-page button { margin-top: 0; padding: 6px 12px; }
.ship-page fieldset { margin: 6px 0; padding: 4px 10px 6px; }
.ship-page fieldset .check { margin-right: 14px; }
.ship-page .hint { margin: 2px 0; }
.ship-page .messages { margin-bottom: 10px; }
.scan-bar { display: flex; align-items: center; gap: 10px; }
.scan-bar label.inline { margin: 0; white-space: nowrap; }
.scan-input { font-size: 17px; flex: 1; min-width: 240px; }
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 2px; }
.card-head h2 { margin: 0; flex: 1; }

/* A 12-column field grid, so short fields (province, package numbers) take less room. */
.f12 { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 0 10px; }
.f12 > label { grid-column: span 12; font-weight: 500; color: var(--muted); }
.f12 > label input, .f12 > label select, .f12 > label .row { margin-top: 2px; color: var(--text); font-size: 14px; }
.f12 > .s3 { grid-column: span 3; } .f12 > .s4 { grid-column: span 4; } .f12 > .s6 { grid-column: span 6; }
.f12 > .s9 { grid-column: span 9; } .f12 > .s12 { grid-column: span 12; }
.f12 .row.tight button { padding: 5px 10px; }
.cod-check { width: auto; flex: none; }
.ship-page .checks { margin-top: 8px; gap: 6px 18px; }

.ship-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr); gap: 10px; align-items: start; }
.ship-grid > .card { margin-bottom: 0; }
.ship-page .price { margin-top: 10px; padding-top: 8px; }
.ship-page .price .amount { font-size: 24px; }
.ship-page .ship-button { margin-top: 8px; padding: 10px; font-size: 16px; }
.ship-page .bol-button { margin-top: 6px; width: 100%; }

/* Narrower screens: Service stays on the right, Ship to and Package stack on the left. */
/* Container queries: the page's width beside the sidebar, not the window's (.content, Layout/MainLayout.razor). */
@container content (max-width: 1180px) {
    .ship-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "to svc" "pkg svc"; }
    .ship-to { grid-area: to; } .ship-package { grid-area: pkg; } .ship-service { grid-area: svc; }
}
@container content (max-width: 760px) {
    .ship-grid { grid-template-columns: 1fr; grid-template-areas: "to" "pkg" "svc"; }
    .scan-bar { flex-wrap: wrap; }
}

/* ---- Header ---- */
.topbar {
    position: sticky; top: 0; z-index: 50;
    display: flex; align-items: center; gap: 16px; height: var(--top-h, 60px); padding: 0 18px 0 20px;
    background: linear-gradient(100deg, #0b1730 0%, #0f2347 55%, #10335f 100%);
    color: #dbe7ff; box-shadow: 0 1px 0 rgba(255,255,255,.04), 0 8px 24px -12px rgba(5, 15, 35, .55);
}
.topbar::after {   /* thin glowing accent line */
    content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px;
    background: linear-gradient(90deg, transparent, #3b82f6 20%, #06b6d4 60%, transparent);
    opacity: .85;
}
.brand { display: flex; align-items: center; text-decoration: none; flex: none; border-radius: 10px; }
.brand:focus-visible { outline: 2px solid #67e8f9; outline-offset: 4px; }
.brand-lockup { display: inline-flex; align-items: center; gap: 10px; }
.brand-mark { flex: none; filter: drop-shadow(0 4px 10px rgba(6, 182, 212, .35)); transition: transform .25s ease; }
.brand:hover .brand-mark { transform: translateX(2px) rotate(-3deg); }
.brand-word { font-size: 20px; letter-spacing: -0.02em; line-height: 1; white-space: nowrap; }
.brand-quick { font-weight: 800; color: #fff; }
.brand-shipper { font-weight: 500; color: #7dd3fc; }
/* QuickShipper 3.0: the "3.0" in the same font, a step lighter than "Shipper", in its colour (here and wherever .brand-shipper is recoloured). */
.brand-version { font-weight: 400; color: #7dd3fc; letter-spacing: 0; }

.who { margin-left: auto; display: flex; gap: 10px; align-items: center; flex: none; }
.station-chip {
    display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px 5px 10px; border-radius: 999px;
    background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.12);
    color: #c9d6ef; font-size: 13px; text-decoration: none; white-space: nowrap;
}
.station-chip strong { color: #fff; font-weight: 600; }
.station-chip svg { color: #67e8f9; }
.station-chip:hover { background: rgba(255,255,255,.12); }
.avatar {
    display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #06b6d4); color: #fff; font-size: 13px; font-weight: 700;
    text-decoration: none; letter-spacing: .02em; box-shadow: 0 0 0 2px rgba(255,255,255,.18);
}
.avatar:hover { box-shadow: 0 0 0 2px #67e8f9; }
.logout {
    display: inline-flex; align-items: center; gap: 6px; margin: 0; padding: 6px 10px; border-radius: 8px;
    background: transparent; border: 1px solid transparent; color: #b9c8e6; font-size: 13px;
}
.logout:hover { color: #fff; background: rgba(255,255,255,.07); border-color: rgba(255,255,255,.12); }

.login-brand { display: flex; justify-content: center; margin: 4px 0 18px; }
.login-brand .brand-word { font-size: 26px; }
.login-brand .brand-quick { color: var(--text); }
.login-brand .brand-shipper { color: var(--accent); }
.login-brand .brand-version { color: var(--accent); }

/* Top bar on narrower screens: the station chip shrinks to its name, then to its pin. */
@media (max-width: 1100px) { .station-chip .chip-site { display: none; } }
@media (max-width: 560px) {
    .topbar { gap: 10px; padding: 0 12px; }
    .station-chip .chip-text { display: none; }
    .station-chip { padding: 7px; }
    .brand-word { font-size: 18px; }
}

/* Skip to content: the first thing Tab reaches, shown only then */
.skip-link { position: fixed; left: 12px; top: 10px; z-index: 90; margin: 0; padding: 8px 14px; transform: translateY(-160%);
    background: var(--card); color: var(--text); border: 2px solid var(--accent); border-radius: 8px; font-weight: 600; }
.skip-link:focus { transform: none; }
main:focus { outline: none; }

/* ---- Menu button (phones and tablets) and the user menu ---- */
.menu-button { display: none; place-items: center; width: 40px; height: 40px; margin: 0 -6px 0 -8px; padding: 0; border-radius: 10px;
    background: transparent; border: 1px solid transparent; color: #dbe7ff; }
.menu-button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.menu-button:hover { background: rgba(255,255,255,.08); }
.menu-button:focus-visible, .avatar:focus-visible, .station-chip:focus-visible { outline: 2px solid #67e8f9; outline-offset: 2px; }
button.avatar { margin: 0; padding: 0; border: none; cursor: pointer; }
.avatar[aria-expanded="true"] { box-shadow: 0 0 0 2px #67e8f9; }
.user-menu { position: relative; }
.user-panel {
    position: absolute; right: 0; top: calc(100% + 10px); width: 264px; z-index: 60;
    background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 12px;
    box-shadow: 0 16px 40px -12px rgba(15, 23, 42, .35); padding: 6px; font-size: 14px;
}
.user-panel[hidden] { display: none; }
.user-head { display: flex; align-items: center; gap: 10px; padding: 10px 10px 12px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.user-head strong { display: block; overflow-wrap: anywhere; }
.user-head .hint { display: block; margin: 0; }
.avatar.small { width: 30px; height: 30px; font-size: 12px; flex: none; box-shadow: none; }
.user-panel ul { list-style: none; margin: 0; padding: 0; }
.user-panel li > a, .user-panel li > button {
    display: flex; align-items: center; gap: 10px; width: 100%; margin: 0; padding: 9px 10px; border: none; border-radius: 8px;
    background: none; color: var(--text); text-decoration: none; font: inherit; text-align: left; cursor: pointer;
}
.user-panel li > a:hover, .user-panel li > button:hover { background: var(--nav-hover); }
.user-panel li > a:focus-visible, .user-panel li > button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.user-panel li svg { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--muted); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.user-panel .theme-row { display: flex; align-items: center; justify-content: space-between; padding: 6px 10px; margin: 4px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.user-panel .theme-row > span { color: var(--muted); }
.user-panel .theme-switch { color: var(--text); }
.user-panel .theme-switch .track { background: var(--line); border-color: var(--line); }
.user-panel .theme-switch .label { display: inline; }
.user-panel .theme-switch:focus-visible .track { outline-color: var(--accent); }

/* ---- Sidebar (Layout/NavSidebar.razor): 240 px, or a 64 px icon rail (html[data-nav="rail"]); a drawer below 1024 px ---- */
:root { --nav-w: 240px; --nav-rail: 64px; --top-h: 60px;
    --nav-hover: color-mix(in srgb, var(--text) 6%, transparent);
    --nav-active: color-mix(in srgb, var(--accent) 13%, transparent); --nav-active-text: var(--accent); --pin: #d97706; }
.frame { display: flex; flex: 1 0 auto; align-items: stretch; min-width: 0; }
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; container-type: inline-size; container-name: content; }
.content > main { flex: 1 0 auto; width: 100%; }
.sidebar {
    position: sticky; top: var(--top-h); align-self: flex-start; flex: none;
    width: var(--nav-w); height: calc(100vh - var(--top-h)); height: calc(100dvh - var(--top-h));
    display: flex; flex-direction: column;
    background: var(--card); border-right: 1px solid var(--line);
}
/* Animate the width only while the user collapses or expands it (qs.nav.setRail): never on a window resize, which would
   restart it from a passing width and show the full menu squeezed into a sliver. */
:root[data-nav-anim] .sidebar { transition: width .18s ease; }
:root[data-nav="rail"] .sidebar { width: var(--nav-rail); }
.nav-scroll { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 10px 10px 16px; scrollbar-width: thin; overscroll-behavior: contain; }
.nav-group { margin-top: 14px; }
.nav-group:first-child { margin-top: 2px; }
.nav-group.untitled { margin-top: 6px; }
.nav-group.admin { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.nav-group ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }
.nav-heading, .nav-subheading { margin: 0 0 4px; padding: 0 10px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-subheading { margin: 10px 0 2px; padding-left: 12px; font-size: 10.5px; letter-spacing: .05em; opacity: .9; }
.favourites .nav-heading { color: var(--pin); }
.nav-item { position: relative; display: flex; align-items: center; border-radius: 8px; }
.nav-link {
    flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; height: 38px; padding: 0 10px; border-radius: 8px;
    color: var(--text); text-decoration: none; font-size: 14px; font-weight: 500; white-space: nowrap;
    transition: background .12s ease, color .12s ease;
}
.nav-item:has(.nav-pin) .nav-link { padding-right: 34px; }
.nav-item:has(.nav-expand) .nav-link { padding-right: 64px; }
.nav-link:hover { background: var(--nav-hover); }
.nav-link.active { background: var(--nav-active); color: var(--nav-active-text); font-weight: 600; }
.nav-link.active::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav-link:focus-visible, .nav-pin:focus-visible, .nav-expand:focus-visible, .nav-collapse:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.nav-icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; opacity: .85; }
.nav-link.active .nav-icon { opacity: 1; }
.nav-label { overflow: hidden; text-overflow: ellipsis; }
.nav-sub .nav-link { height: 32px; font-size: 13.5px; padding-left: 12px; gap: 10px; }
.nav-sub .nav-icon { width: 17px; height: 17px; }

/* Pin (star): on hover or focus, always on touch screens, and always when pinned in Favourites */
.nav-pin {
    position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
    display: grid; place-items: center; width: 28px; height: 28px; margin: 0; padding: 0; border: none; border-radius: 6px;
    background: none; color: var(--muted); cursor: pointer; opacity: 0; transition: opacity .12s ease, color .12s ease;
}
.nav-pin svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; }
.nav-pin:hover { color: var(--pin); background: var(--nav-hover); }
.nav-pin.on { color: var(--pin); }
.nav-pin.on svg { fill: currentColor; }
.nav-item:hover .nav-pin, .nav-item:focus-within .nav-pin, .nav-pin:focus-visible { opacity: 1; }
@media (hover: none) { .nav-pin { opacity: 1; } }
.nav-expand {
    position: absolute; right: 34px; top: 50%; transform: translateY(-50%);
    display: grid; place-items: center; width: 28px; height: 28px; margin: 0; padding: 0; border: none; border-radius: 6px;
    background: none; color: var(--muted); cursor: pointer;
}
.nav-expand:hover { background: var(--nav-hover); color: var(--text); }
.nav-expand svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s ease; }
.nav-expand[aria-expanded="true"] svg { transform: rotate(90deg); }

.nav-notice { margin: 0 10px 8px; padding: 8px 10px; display: flex; gap: 8px; align-items: flex-start; border-radius: 8px; background: var(--notice); font-size: 12.5px; }
.nav-notice .link { color: var(--muted); }
.nav-collapse {
    flex: none; display: flex; align-items: center; gap: 12px; margin: 0; padding: 0 20px; height: 44px;
    border: none; border-top: 1px solid var(--line); border-radius: 0; background: none; color: var(--muted); font-size: 13px; white-space: nowrap;
}
.nav-collapse:hover { color: var(--text); background: var(--nav-hover); }
.nav-collapse svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* The rail: icons only, each with a tooltip (qs.nav), labels kept for screen readers */
:root[data-nav="rail"] .nav-scroll { padding: 10px 8px 16px; }
:root[data-nav="rail"] .nav-link { justify-content: center; padding: 0; gap: 0; }
:root[data-nav="rail"] .nav-label, :root[data-nav="rail"] .nav-heading {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:root[data-nav="rail"] .nav-group { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
:root[data-nav="rail"] .nav-group:first-child { margin-top: 0; padding-top: 0; border-top: none; }
:root[data-nav="rail"] .nav-pin, :root[data-nav="rail"] .nav-expand, :root[data-nav="rail"] .nav-sub, :root[data-nav="rail"] .nav-notice { display: none; }
:root[data-nav="rail"] .nav-item .nav-link { padding-right: 0; }
:root[data-nav="rail"] .nav-link.active::before { left: -8px; }
:root[data-nav="rail"] .nav-collapse { justify-content: center; padding: 0; }
.nav-tip {
    position: fixed; z-index: 80; transform: translateY(-50%); pointer-events: none;
    padding: 5px 9px; border-radius: 6px; background: #0f172a; color: #f8fafc; font-size: 12.5px; font-weight: 500; white-space: nowrap;
    box-shadow: 0 6px 16px -6px rgba(0,0,0,.4);
}
.nav-tip[hidden] { display: none; }

/* Phones and tablets: the sidebar is a drawer over the page, from the menu button */
.nav-overlay, .drawer-head { display: none; }
.drawer-head { align-items: center; justify-content: space-between; gap: 10px; height: var(--top-h); flex: none; padding: 0 8px 0 16px; border-bottom: 1px solid var(--line); }
.drawer-head .brand-quick { color: var(--text); }
.drawer-head .brand-shipper { color: var(--accent); }
.drawer-head .brand-version { color: var(--accent); }
.drawer-head .brand-word { font-size: 18px; }
.drawer-close { display: grid; place-items: center; width: 40px; height: 40px; margin: 0; padding: 0; border: none; border-radius: 10px; background: none; color: var(--muted); }
.drawer-close:hover { background: var(--nav-hover); color: var(--text); }
.drawer-close:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.drawer-close svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
@media (max-width: 1023.98px) {
    .menu-button { display: grid; }
    .drawer-head { display: flex; }
    .sidebar, :root[data-nav="rail"] .sidebar {
        position: fixed; z-index: 70; top: 0; left: 0; bottom: 0; height: 100%; width: min(300px, 86vw);
        transform: translateX(-100%); visibility: hidden; box-shadow: none;
        transition: transform .22s ease, visibility 0s linear .22s;
        padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom);
    }
    .sidebar.open, :root[data-nav="rail"] .sidebar.open { transform: none; visibility: visible; box-shadow: 12px 0 40px -12px rgba(15, 23, 42, .45); transition: transform .22s ease; }
    .nav-overlay { display: block; position: fixed; inset: 0; z-index: 65; background: rgba(15, 23, 42, .45); opacity: 0; pointer-events: none; transition: opacity .2s ease; }
    .nav-overlay.open { opacity: 1; pointer-events: auto; }
    /* in the drawer the rail never applies */
    :root[data-nav="rail"] .nav-scroll { padding: 10px 10px 16px; }
    :root[data-nav="rail"] .nav-link { justify-content: flex-start; padding: 0 10px; gap: 12px; }
    :root[data-nav="rail"] .nav-sub .nav-link { padding-left: 12px; gap: 10px; }
    :root[data-nav="rail"] .nav-label, :root[data-nav="rail"] .nav-heading { position: static; width: auto; height: auto; clip: auto; overflow: hidden; }
    :root[data-nav="rail"] .nav-group { margin-top: 14px; padding-top: 0; border-top: none; }
    :root[data-nav="rail"] .nav-group.admin { padding-top: 10px; border-top: 1px solid var(--line); }
    :root[data-nav="rail"] .nav-pin, :root[data-nav="rail"] .nav-expand { display: grid; }
    :root[data-nav="rail"] .nav-sub { display: block; }
    :root[data-nav="rail"] .nav-notice { display: flex; }
    :root[data-nav="rail"] .nav-item:has(.nav-pin) .nav-link { padding-right: 34px; }
    :root[data-nav="rail"] .nav-item:has(.nav-expand) .nav-link { padding-right: 64px; }
    .nav-collapse { display: none; }
    .nav-link { height: 42px; }
}
@media (prefers-reduced-motion: reduce) { .sidebar, .nav-overlay, .nav-pin, .nav-expand svg { transition: none !important; } }
@media print { .sidebar, .nav-overlay, .nav-tip, .menu-button, .user-menu { display: none !important; } .content { container-type: normal; } }

/* ---- Admin page: sections in groups, and the filter ---- */
.admin-head { display: flex; align-items: center; gap: 12px 20px; flex-wrap: wrap; margin-bottom: 16px; }
.admin-head h1 { margin: 0; }
.admin-filter { position: relative; flex: 0 1 320px; margin: 0 0 0 auto; font-weight: 400; }
.admin-filter svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; }
.admin-filter input { padding-left: 34px; }
@media (max-width: 560px) { .admin-filter { flex-basis: 100%; margin-left: 0; } }
.admin-group { margin-bottom: 22px; }
.admin-group h2 { font-size: 13px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; }
.admin-tile { position: relative; padding: 0; }
.admin-tile > a { display: flex; flex-direction: column; gap: 6px; padding: 16px 40px 16px 16px; color: inherit; text-decoration: none; border-radius: 8px; height: 100%; }
.admin-tile > a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tile .admin-tile-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--nav-active); color: var(--accent); }
.admin-tile-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.admin-tile .nav-pin { top: 10px; right: 8px; transform: none; }
.admin-tile:hover .nav-pin, .admin-tile:focus-within .nav-pin, .admin-tile.pinned .nav-pin { opacity: 1; }

/* ---- Footer: maker, support, version ---- */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.shell > main { flex: 1 0 auto; width: 100%; }
.appfooter {
    display: flex; align-items: center; gap: 12px 22px; flex-wrap: wrap;
    padding: 8px 22px; border-top: 1px solid var(--line); background: var(--card);
    color: var(--muted); font-size: 13px;
}
.appfooter .maker { display: inline-flex; align-items: center; padding: 3px 6px; border-radius: 6px; }
.appfooter .maker img { display: block; height: 32px; width: auto; }
.appfooter .support { display: flex; align-items: center; gap: 6px 16px; flex-wrap: wrap; }
.appfooter .support-label { font-weight: 600; color: var(--text); }
.appfooter .support a { display: inline-flex; align-items: center; gap: 5px; color: var(--accent); text-decoration: none; font-weight: 500; }
.appfooter .support a:hover { text-decoration: underline; }
.appfooter .version { margin-left: auto; font-variant-numeric: tabular-nums; white-space: nowrap; }
.appfooter .maker { background: var(--logo-backing); }   /* in dark mode the logo's grey lettering needs a light backing */
@media (max-width: 760px) { .appfooter { padding: 10px 14px; } .appfooter .version { margin-left: 0; } }
/* The footer stays at the bottom of the window while long pages scroll under it (below dialogs, menus and the drawer).
   On phones it wraps to several lines, so there it stays at the end of the page instead of covering the screen. */
@media (min-width: 761px) { .appfooter { position: sticky; bottom: 0; z-index: 5; } }
@media print { .appfooter { display: none !important; } }

/* Box scan field and box size buttons (Ship page) */
.f12 > .box-scan .hint { font-weight: 400; }
.box-sizes { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 2px; }
.ship-page .chip { padding: 3px 10px; border-radius: 999px; font-size: 13px; }
.ship-page .chip span { color: var(--muted); margin-left: 4px; font-variant-numeric: tabular-nums; }

.live-weight { display: block; margin-top: 2px; font-size: 12px; color: var(--ok); font-variant-numeric: tabular-nums; }
.recent-tag { margin-left: 8px; font-size: 11px; padding: 1px 6px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); }
.after-ship { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 6px; }
.after-ship .bol-button { margin-top: 0; }

/* Phones: tables marked "cards" show each row as a card, every value labelled with its column. */
@media (max-width: 640px) {
    table.grid.cards, table.grid.cards tbody, table.grid.cards tr, table.grid.cards td { display: block; width: 100%; }
    table.grid.cards thead { display: none; }
    table.grid.cards tr { border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; margin-bottom: 10px; background: var(--card); }
    table.grid.cards td { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; padding: 4px 0; border: none; text-align: right; }
    table.grid.cards td::before { content: attr(data-label); font-weight: 600; color: var(--muted); text-align: left; flex: none; }
    table.grid.cards td[data-label=""]::before { content: none; }
    table.grid.cards td.actions { justify-content: flex-start; flex-wrap: wrap; gap: 4px 14px; padding-top: 8px; white-space: normal; }
    table.grid.cards td.actions.stack .link { display: inline; margin: 0; }
    table.grid.cards tr.detail { border-style: dashed; }
    .scroll-x:has(table.cards) { overflow-x: visible; }
}

/* Ship page: the price, Ship button and BOL stay in view while the rest scrolls (two-column screens). */
@container content (min-width: 761px) { .ship-service { position: sticky; top: 72px; } }

/* Without the station host: where labels print, and the camera scanner */
.print-target { margin: 6px 0 8px; padding: 8px 10px; border-radius: 8px; background: var(--bg); border: 1px solid var(--line); }
.print-target.unset { border-color: #d97706; background: var(--notice); }
.print-target label { margin-top: 0; }
.qs-camera { position: fixed; inset: 0; z-index: 1000; background: #000; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.qs-camera video { width: 100%; height: 100%; object-fit: cover; }
.qs-camera-frame { position: absolute; width: 72vw; max-width: 420px; height: 30vh; border: 3px solid #67e8f9; border-radius: 12px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
.qs-camera button { position: absolute; bottom: 28px; padding: 10px 26px; font-size: 16px; border-radius: 999px; background: #fff; color: #111; border: none; }
.camera-button { padding: 6px 10px; display: none; }
.camera-button.available { display: inline-block; }
@media (pointer: coarse), (max-width: 820px) { .camera-button { display: inline-block; } }
.live-weight.muted { color: var(--muted); }

/* Light/dark switch in the header */
.theme-switch { display: inline-flex; align-items: center; gap: 6px; margin: 0; padding: 0; background: none; border: none; color: #b9c8e6; cursor: pointer; }
.theme-switch .track { position: relative; width: 44px; height: 24px; border-radius: 999px; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.18); transition: background .2s ease; }
.theme-switch .thumb { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fde68a; display: grid; place-items: center; transition: transform .2s ease, background .2s ease; }
.theme-switch[aria-checked="true"] .track { background: linear-gradient(90deg, #3b82f6, #06b6d4); }
.theme-switch[aria-checked="true"] .thumb { transform: translateX(20px); background: #0b1730; }
.theme-switch svg { width: 12px; height: 12px; }
.theme-switch:focus-visible .track { outline: 2px solid #67e8f9; outline-offset: 2px; }
.theme-switch .label { font-size: 12px; }
@media (max-width: 1100px) { .theme-switch .label { display: none; } }

/* Login: "or", then Microsoft sign-in (Microsoft's button style: white, grey border, four-square logo) */
.login-or { display: flex; align-items: center; gap: 10px; margin: 18px 0 12px; color: var(--muted); font-size: 13px; }
.login-or::before, .login-or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.microsoft-signin { display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%; padding: 10px 12px;
  background: #fff; color: #5e5e5e; border: 1px solid #8c8c8c; border-radius: 4px; font-weight: 600; font-size: 15px; }
.microsoft-signin:hover:not(:disabled) { background: #f3f3f3; }
:root[data-theme="dark"] .microsoft-signin { background: #2f2f2f; color: #fff; border-color: #2f2f2f; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .microsoft-signin { background: #2f2f2f; color: #fff; border-color: #2f2f2f; } }

/* Ship page: dangerous goods lines */
.hazmat-add { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0; }
.hazmat-add select { flex: 1 1 320px; min-width: 0; }
.hazmat-lines input, .hazmat-lines select { width: 100%; min-width: 0; }
.hazmat-lines .w-un { width: 84px; } .hazmat-lines .w-name { min-width: 200px; } .hazmat-lines .w-class { width: 56px; }
.hazmat-lines .w-qty { width: 84px; } .hazmat-lines .w-units { width: 64px; } .hazmat-lines .w-pack { min-width: 130px; } .hazmat-lines .w-count { width: 60px; }
.hazmat-lines input[type=checkbox] { width: auto; }
/* The packing group and level pickers: wide enough for "III" and "LQ" with the arrow (width: 100% alone shrinks them to nothing in the table). */
.hazmat-lines select.w-pg, .hazmat-lines select.w-level { width: auto; min-width: 5em; }

/* Admin › Microsoft sign-in */
.sso-state { font-size: 18px; margin: 0 0 8px; }
.sso-state.on strong { color: var(--ok); }
.sso-state.off strong { color: var(--muted); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0 0 14px; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; word-break: break-all; }
.steps { padding-left: 20px; line-height: 1.6; }
.sso-code .code { font: 600 28px/1.2 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: 3px; }
.sso-code .waiting { color: var(--muted); }
.appfooter .change-server { margin-left: 10px; font-size: inherit; }
pre.command { white-space: pre-wrap; word-break: break-all; background: var(--surface-2, rgba(127,127,127,.12)); padding: 10px 12px; border-radius: 8px; font-size: 13px; user-select: all; }
.health-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: baseline; }
.health-dot.ok { background: var(--ok); }
.health-dot.warn { background: #d97706; }
.health-dot.bad { background: var(--bad); }
.bad-text { color: var(--bad); font-weight: 700; }
.w-short { width: 7em; }
.w-dim { width: 4.2em; }
td.dims { white-space: nowrap; }
.freight-units input[type=checkbox] { margin: 0 auto; display: block; }
tr.selected td { background: rgba(76, 155, 232, .14); }
table.cards tbody tr[class=""] { cursor: default; }
tr.voided td { opacity: .55; text-decoration: line-through; }
textarea.rates-paste { width: 100%; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
details > summary { cursor: pointer; margin: 8px 0; color: var(--accent); }
select.w-type { width: 7.5em; }
input.w-pro { width: 24em; max-width: 100%; }
span.tag { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 9px; font-size: 0.75em; background: var(--notice); vertical-align: middle; }
.fields label input.w-short { display: block; }

/* Returns and claims */
table.grid tr.selected td { background: color-mix(in srgb, var(--notice) 12%, transparent); }
.claim-photo { margin: 0 .75rem .75rem 0; max-width: 160px; }
.claim-photo img { display: block; max-width: 160px; max-height: 120px; border: 1px solid var(--line); border-radius: 4px; }
.claim-photo figcaption { font-size: .85em; color: var(--muted); }
/* Dashboards (Pages/Dashboard.razor, Pages/AdminDashboard.razor; docs/Dashboards.md). Chart colours follow the data-viz
   palette: one accent blue for the measure, gray for the period it's compared with, hairline gridlines one step off the
   card, text in the text tokens (never the series colour). Dark mode has its own steps, checked against the dark card. */
:root {
  --series-1: #2a78d6; --series-prev: #9a988f; --chart-grid: #e8e7e1; --chart-base: #c3c2b7; --chart-hover: rgba(42, 120, 214, .08);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --series-1: #3987e5; --series-prev: #7c7b74; --chart-grid: #2c3036; --chart-base: #464b52; --chart-hover: rgba(57, 135, 229, .14); }
}
:root[data-theme="dark"] { --series-1: #3987e5; --series-prev: #7c7b74; --chart-grid: #2c3036; --chart-base: #464b52; --chart-hover: rgba(57, 135, 229, .14); }
/* Categorical slots for charts with several series (the stations dashboard's voids by status), in this fixed order: blue,
   orange, aqua, yellow. Validated with the dataviz palette checks against the light and dark cards (adjacent pairs pass
   CVD and normal vision). Aqua and yellow are under 3:1 on the light card, so those charts always have a legend, totals at
   the bar tips and "View as table". */
:root { --cat-1: #2a78d6; --cat-2: #eb6834; --cat-3: #1baf7a; --cat-4: #eda100; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --cat-1: #3987e5; --cat-2: #d95926; --cat-3: #199e70; --cat-4: #c98500; }
}
:root[data-theme="dark"] { --cat-1: #3987e5; --cat-2: #d95926; --cat-3: #199e70; --cat-4: #c98500; }

main:has(.dash-filters) { max-width: 1180px; }
.dash-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 16px; margin-bottom: 16px; }
.dash-filters .fields { display: flex; flex-wrap: wrap; gap: 0 12px; margin: 0; }
.dash-filters label { margin-top: 0; }
.dash-filters select, .dash-filters input { width: auto; min-width: 150px; }
.dash-filters .hint { flex-basis: 100%; }
.dash-asof { margin: 0 0 8px; }
.segmented { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--card); }
.segmented button { margin: 0; border: none; border-radius: 0; border-right: 1px solid var(--line); background: none; padding: 7px 12px; }
.segmented button:last-child { border-right: none; }
.segmented button.selected { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.dash-body { transition: opacity .2s; }
.dash-body.refreshing { opacity: .6; }   /* a refresh keeps the last figures in place */
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.dash-grid > .card { min-width: 0; }
@media (max-width: 860px) { .dash-grid { grid-template-columns: 1fr; } }
.dash-card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.dash-card-head h2 { margin: 0 0 6px; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
.stat-label { color: var(--muted); font-size: 13px; }
.stat-value { font-size: 26px; font-weight: 650; line-height: 1.15; }
.stat.hero { grid-column: span 2; }
.stat.hero .stat-value { font-size: 48px; }
.stat-note { color: var(--muted); font-size: 13px; }
.stat-delta { font-size: 13px; color: var(--muted); }
.stat-delta.worse { color: var(--bad); }
.stat-delta.better { color: var(--ok); }
.stat-delta-vs { color: var(--muted); }
@media (max-width: 560px) { .stat-row { grid-template-columns: 1fr 1fr; } .stat.hero { grid-column: 1 / -1; } .stat.hero .stat-value { font-size: 40px; } }

.chart { margin: 0; }
.chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; min-height: 24px; }
.chart-readout { margin: 0; font-size: 14px; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.chart-readout span { color: var(--muted); }
.chart-readout strong { color: var(--text); font-variant-numeric: tabular-nums; }
.chart-readout .key { display: inline-flex; align-items: center; gap: 6px; }
.key-line { display: inline-block; width: 14px; height: 2px; border-radius: 1px; background: var(--series-1); }
.key-line.previous { background: var(--series-prev); }
.chart-toggle { font-size: 13px; white-space: nowrap; }
.chart svg { display: block; overflow: visible; }
/* Each chart is drawn at three widths so its text stays near 11-13px: the one closest to the card's width shows. */
.chart-medium, .chart-narrow { display: none; }
@media (max-width: 1000px) { .chart-wide { display: none; } .chart-medium { display: block; } }
@media (max-width: 600px) { .chart-medium { display: none; } .chart-narrow { display: block; } }
.chart-grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart-base { stroke: var(--chart-base); stroke-width: 1; }
.chart-axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-value { fill: var(--text); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.chart-bar { fill: var(--series-1); }
.chart-hit { fill: transparent; }
.chart-mark { outline: none; cursor: default; }
.chart-mark.hover .chart-hit, .chart-mark:focus-visible .chart-hit { fill: var(--chart-hover); }
.chart-mark.hover .chart-bar { filter: brightness(1.12); }
rect.chart-hit:focus-visible { outline: none; fill: var(--chart-hover); }
.chart-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-line.current { stroke: var(--series-1); }
.chart-line.previous { stroke: var(--series-prev); }
.chart-dot { stroke: var(--card); stroke-width: 2; }
.chart-dot.current { fill: var(--series-1); }
.chart-dot.previous { fill: var(--series-prev); }
.chart-crosshair { stroke: var(--chart-base); stroke-width: 1; }
.chart-table { margin-top: 8px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

table.ranked td { vertical-align: middle; }
.ranked-name { display: block; }
.ranked-detail { display: block; color: var(--muted); font-size: 12px; }
.ranked-bar-col { width: 24%; }
.ranked-track { display: block; height: 8px; border-radius: 4px; background: var(--chart-grid); overflow: hidden; }
.ranked-bar { display: block; height: 100%; border-radius: 4px; background: var(--series-1); min-width: 2px; }
@media (max-width: 640px) {
  table.grid.cards.ranked td.ranked-bar-col { display: block; width: 100%; padding: 2px 0 6px; }
  table.grid.cards.ranked td:first-child { display: block; text-align: left; }
  table.grid.cards.ranked td:first-child::before { content: none; }
}
@media (forced-colors: active) { .chart-bar, .ranked-bar { fill: CanvasText; background: CanvasText; } .chart-line.current { stroke: CanvasText; } .chart-line.previous { stroke: GrayText; } }
/* Invoice audit */
.pill.flag { display: inline-block; max-width: 100%; box-sizing: border-box; margin: 1px 4px 1px 0; font-size: 12px; border-color: var(--bad); color: var(--bad); }
span.flag-list { min-width: 0; }
#packageDetail { max-height: 92vh; overflow-y: auto; }
#flagFilters { align-items: flex-end; flex-wrap: wrap; }
#flagFilters label { margin: 0 0 0 auto; }
/* Batch shipping (Pages/Batch.razor) */
#batchPaste { width: 100%; font-family: ui-monospace, Consolas, monospace; }
label.link { color: var(--accent); cursor: pointer; font-size: 14px; }
label.link input[type=file] { display: block; margin-top: 4px; font-size: 13px; color: var(--muted); }
.batch-progress { display: flex; gap: 12px; align-items: center; margin: 8px 0; }
.batch-progress progress { flex: 1; max-width: 420px; height: 14px; }
.batch-lines td input.w-short { max-width: 110px; }
.batch-lines td select { min-width: 96px; max-width: 140px; }
.batch-lines tr.current td { background: var(--notice); }
.batch-lines tr.batch-shipped .batch-status { color: var(--ok); font-weight: 600; }
.batch-lines tr.batch-failed .batch-status, .batch-lines tr.batch-blocked .batch-status { color: var(--bad); font-weight: 600; }
.batch-lines tr.batch-skipped td { color: var(--muted); }
.pill.error { border-color: var(--bad); }
/* Products (Admin › Products) and the Ship page's packing panels: verify items, box suggestion, photos */
.grow { flex: 1 1 260px; min-width: 0; }
.import-preview tr.import-error td { color: var(--bad); }
.import-preview tr.import-new td:nth-child(3) { color: var(--ok); font-weight: 600; }
.pack-lines td.num, .pack-lines th.num { text-align: right; font-variant-numeric: tabular-nums; }
.pack-lines tr.done td { color: var(--ok); }
.pack-lines tr.over td { color: var(--bad); }
.pack-progress { font-weight: 600; }
.pack-scan { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.pack-scan input { flex: 1 1 260px; min-width: 0; }
.box-suggestion { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 6px 0; }
.photo-strip { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.photo-strip img { width: 120px; height: 90px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.photo-add input[type=file] { max-width: 100%; }
.photo-add label.button { display: inline-block; cursor: pointer; padding: 8px 14px; border-radius: 6px; border: 1px solid var(--line); margin: 0; font-weight: 600; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* Ship page: the ship-to address check (docs/AddressValidation.md) */
.address-banner { margin-top: 10px; padding: 8px 12px; border-radius: 6px; border-left: 4px solid #d97706; }
.address-banner p { margin: 4px 0; }
.address-banner .row { margin-top: 6px; }
.address-banner.bad { border-left-color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); }
.address-banner .picker { margin: 6px 0; }
.address-check { margin: 8px 0 0; }
/* Shipping rules on the Ship page and Admin › Shipping rules */
.rule-choice { background: var(--notice); border-radius: 6px; padding: 6px 10px; margin: 6px 0; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.rule-choice.overridden { background: transparent; border: 1px dashed var(--line); }
.rule-notes { border-left: 4px solid var(--bad); }
.rule-notes p { margin: 4px 0; }
.rule-checks { list-style: none; padding: 0; margin: 4px 0; }
.rule-checks li { margin: 2px 0; }
.rule-checks .pass { color: var(--ok); }
.rule-checks .fail { color: var(--bad); }
.rule-trace { border-top: 1px solid var(--line); padding: 8px 0; }
.rule-trace.matched h3 { color: var(--ok); }
.rule-trace h3 { font-size: 15px; margin: 0 0 4px; }
.rule-option-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 4px 0; }
/* The footer's session countdown (Shared/SessionCountdown.razor) */
.session-clock { font-size: 0.85em; color: var(--muted, #6b7280); white-space: nowrap; }
.session-clock .link { margin-left: 6px; }
.session-extended { margin-left: 6px; color: var(--ok); }
.session-warning {
    position: fixed; right: 16px; bottom: 16px; z-index: 50; display: flex; gap: 12px; align-items: center;
    background: var(--notice); border: 1px solid #d97706; border-radius: 8px; padding: 10px 14px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
}
@media (max-width: 600px) { .session-warning { left: 16px; right: 16px; flex-wrap: wrap; } }
/* Troubleshooting pages (Admin › Carrier log, Logs, System) */
pre.code-block { max-height: 420px; overflow: auto; background: var(--notice); border-radius: 6px; padding: 8px 10px; font-size: 0.8em; white-space: pre-wrap; word-break: break-word; }
.error-text { color: var(--bad); }
table.log-lines td.message { white-space: pre-wrap; word-break: break-word; font-family: ui-monospace, monospace; font-size: 0.85em; }
table.log-lines tr.level-Error td, table.log-lines tr.level-Fatal td { color: var(--bad); }
table.log-lines tr.level-Warn td { color: #b45309; }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0; }
dl.facts dt { font-weight: 600; }
dl.facts dd { margin: 0; word-break: break-word; }
tr.group td { background: var(--notice); }
ul.problems { margin: 0; padding-left: 18px; }

/* Admin › Stations › ERP companies: each user's saved ERP login */
ul.erp-logins { list-style: none; margin: 0; padding: 0; text-align: left; }
ul.erp-logins li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; padding: 2px 0; }
ul.erp-logins li + li { border-top: 1px solid var(--line); }
/* Stations dashboard (Pages/StationsDashboard.razor) */
.chart-bar.cat-1, .key-swatch.cat-1 { fill: var(--cat-1); background: var(--cat-1); }
.chart-bar.cat-2, .key-swatch.cat-2 { fill: var(--cat-2); background: var(--cat-2); }
.chart-bar.cat-3, .key-swatch.cat-3 { fill: var(--cat-3); background: var(--cat-3); }
.chart-bar.cat-4, .key-swatch.cat-4 { fill: var(--cat-4); background: var(--cat-4); }
.key-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.chart-label { fill: var(--text); font-size: 12px; }
.dash-card-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.dash-card-head .hint { margin: 0; }
.dash-check { margin-top: 28px; }
.period-picker { position: relative; display: flex; flex-direction: column; }
.period-picker-label { color: var(--muted); font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.period-picker-button { margin: 0; min-width: 200px; text-align: left; display: flex; justify-content: space-between; gap: 10px; }
.period-picker-menu { position: absolute; top: 100%; left: 0; z-index: 20; margin-top: 4px; width: 280px; max-width: calc(100vw - 32px);
  background: var(--card); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.18); padding: 10px 12px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; }
.period-picker-menu > .hint, .period-picker-menu > .period-custom, .period-picker-menu > button { grid-column: 1 / -1; }
.period-picker-menu label.check { margin: 0; color: var(--text); }
.period-custom { display: flex; gap: 8px; }
.period-custom label { margin: 0; flex: 1; }
.period-custom input { min-width: 0 !important; width: 100% !important; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.station-table { font-size: 13px; }
table.station-table th, table.station-table td { white-space: nowrap; }
table.station-table thead th { font-size: 12px; color: var(--muted); font-weight: 600; vertical-align: bottom; }
table.station-table .period-head { text-align: center; color: var(--text); border-left: 1px solid var(--line); }
table.station-table .period-dates { display: block; font-weight: 400; color: var(--muted); font-size: 11px; }
table.station-table .station-name { position: sticky; left: 0; background: var(--card); z-index: 1; min-width: 130px; font-weight: 400; color: var(--text); }
table.station-table .station-name .link { padding: 0; margin: 0; font: inherit; text-align: left; }
table.station-table tr.idle td, table.station-table tr.idle .station-name .link { color: var(--muted); }
table.station-table tr.idle td { opacity: .7; }
table.station-table tr.subtotal th, table.station-table tr.subtotal td { font-weight: 650; background: var(--bg); }
table.station-table tr.total th, table.station-table tr.total td { font-weight: 700; border-top: 2px solid var(--chart-base); }
.stat-value small { font-size: 15px; font-weight: 400; color: var(--muted); }
.station-detail h3 { margin: 16px 0 4px; font-size: 15px; }
.station-detail .ranked-detail { display: inline; margin-left: 4px; }
td .ranked-detail { display: block; }
.dash-filters input[type="checkbox"] { min-width: 0; width: auto; }
table.station-table th.part-of, table.station-table td.part-of { font-style: italic; color: var(--muted); }
table.station-table thead th.part-of::before { content: "↳ "; font-style: normal; }
.void-key { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; margin: 4px 0 0; font-size: 13px; }
.void-key dt { font-weight: 600; color: var(--text); }
.void-key dd { margin: 0; }
@media (max-width: 600px) { .void-key { grid-template-columns: 1fr; } .void-key dd { margin-bottom: 6px; } }
.station-detail .card { border: none; box-shadow: none; padding: 0; margin: 0; background: none; }

/* Admin › Station carriers: stations down, carriers across; each cell lists the warehouses. The station column stays put while the grid scrolls sideways. */
.station-carriers table { width: auto; min-width: 100%; }
.station-carriers th[scope="row"] { position: sticky; left: 0; background: var(--card); text-align: left; white-space: nowrap; z-index: 1; }
.station-carriers th[scope="row"] .hint { font-weight: normal; margin: 0; }
.station-carriers thead th { white-space: nowrap; }
.station-carriers td { text-align: center; white-space: nowrap; }
.station-carriers td.on { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.station-carriers td .pill { margin: 1px 2px; font-size: 12px; font-variant-numeric: tabular-nums; }
.station-carriers td .none { color: var(--muted); }
.sc-rows { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; max-height: 50vh; overflow: auto; margin: 8px 0; }
.sc-row { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px 8px; margin: 0; }
.sc-row.on { border-color: var(--accent); }
.sc-row legend { font-weight: 600; padding: 0 4px; }
.sc-row label.check { display: inline-flex; margin-right: 12px; }
.sc-warnings { margin: 4px 0 0; padding-left: 20px; }
.sc-add label.inline { white-space: nowrap; }
/* Admin › Scheduled emails: weekday chips, the recipients' chip input and the email preview */
.schedules-head { justify-content: space-between; margin-bottom: 6px; }
.schedules-head h2 { margin: 0; }
td.schedule-to { min-width: 170px; }
td.schedule-to span { display: block; overflow-wrap: anywhere; }
tr.muted td { color: var(--muted); }
.day-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip-toggle { margin: 0; padding: 6px 12px; border-radius: 999px; min-width: 52px; }
.chip-toggle.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.chip-toggle:focus-visible, .email-chip button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.day-presets { display: inline-flex; gap: 12px; margin-left: 8px; font-size: 14px; }
.email-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); cursor: text; }
.email-chips input { flex: 1; min-width: 180px; border: none; padding: 4px; background: transparent; }
.email-chips input:focus { outline: none; }
.email-chips:focus-within { border-color: var(--accent); }
.email-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 10px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); font-size: 14px; max-width: 100%; overflow-wrap: anywhere; }
.email-chip button { font-size: 16px; line-height: 1; padding: 0 6px; color: var(--muted); }
.report-preview dl { font-size: 14px; }
.report-frame { width: 100%; height: 55vh; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
@media (max-width: 560px) {
    .day-presets { margin-left: 0; flex-basis: 100%; }
    .chip-toggle { min-width: 0; flex: 1 0 12%; padding: 6px 4px; }
    td.schedule-to { min-width: 0; flex-direction: column; align-items: flex-end; }
    .report-frame { height: 50vh; }
}
/* The license banner (Shared/LicenseBanner.razor, docs/Licensing.md) */
.license-banner { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; margin: 0 0 12px; padding: 8px 12px; border-radius: 6px;
  border-left: 4px solid #d97706; background: var(--notice); }
.license-banner.bad { border-left-color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); }
.license-sites td ul { margin: 0; padding-left: 18px; }
.license-sites tr.over td { color: var(--bad); }

/* Admin › Carriers: write-only credentials (Shared/CredentialField.razor) and a service's special services. */
.credential { display: flex; flex-direction: column; margin-bottom: 8px; }
.credential > label:first-child { font-weight: 500; font-size: 13px; color: var(--muted); }
.credential input[type=password] { margin-top: 2px; }
.credential .credential-status { margin: 2px 0 0; }
.credential label.check { margin-top: 2px; font-size: 13px; }
.service-options h3 { font-size: 15px; margin: 4px 0 8px; }

/* First-run set-up (Pages/FirstRun.razor) and Home's "what next" checklist after it */
.card.first-run { max-width: 640px; margin: 32px auto; }
.wizard-steps { list-style: none; display: flex; flex-wrap: wrap; gap: 8px 20px; padding: 0; margin: 12px 0 18px; color: var(--muted); }
.wizard-steps li { display: inline-flex; align-items: center; gap: 8px; }
.wizard-steps li.current { color: var(--text); font-weight: 600; }
.wizard-number { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--line); font-size: 13px; }
.wizard-steps li.current .wizard-number { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.wizard-steps li.done .wizard-number { border-color: var(--ok); color: var(--ok); }
.erp-choices { border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px 10px; margin: 14px 0 6px; }
.erp-choices legend { font-weight: 600; padding: 0 4px; }
label.erp-choice { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; margin: 8px 0; cursor: pointer; }
label.erp-choice input { margin-top: 4px; }
label.erp-choice .hint { display: block; margin: 2px 0 0; }
.first-run .fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 16px; }
.wizard-buttons { margin-top: 20px; justify-content: flex-end; }
.first-run-next { max-width: 720px; margin: 0 auto 20px; border-left: 4px solid var(--ok); }
.first-run-next .ok { color: var(--ok); margin: 0 0 8px; }
.checklist { padding-left: 22px; margin: 0; line-height: 1.7; }

/* The browser extension and station host install prompt (Shared/StationPrompt.razor, docs/BrowserExtension.md) */
.station-prompt { display: flex; gap: 12px; align-items: flex-start; margin: 0 0 12px; padding: 12px 14px; border-radius: 8px;
  border: 1px solid var(--line); border-left: 4px solid var(--accent); background: var(--card); }
.station-prompt.ok { border-left-color: var(--ok); }
.station-prompt-icon { flex: none; width: 28px; height: 28px; fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.station-prompt.ok .station-prompt-icon { stroke: var(--ok); }
.station-prompt-body { flex: 1; min-width: 0; }
.station-prompt-body p { margin: 4px 0 8px; }
.station-prompt-body .row { margin-top: 4px; }
.station-prompt-close { flex: none; background: none; border: none; padding: 4px; margin: -4px -4px 0 0; cursor: pointer; color: var(--muted); }
.station-prompt-close svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.install-steps li { margin: 6px 0; }

/* Support (Pages/Support.razor): tickets to QuickShipper support and their threads. */
.support-text { display: block; margin-top: 12px; }
.support-text textarea { margin-top: 4px; }
.ticket-status { display: inline-block; border: 1px solid var(--line); border-radius: 999px; padding: 1px 10px; font-size: 13px; }
.ticket-status.open { border-color: var(--accent); color: var(--accent); }
.ticket-status.waiting { border-color: var(--bad); color: var(--bad); }
.ticket-status.done { color: var(--ok); border-color: var(--ok); }
.thread { list-style: none; padding: 0; margin: 12px 0; }
.thread li { border-left: 3px solid var(--line); padding: 6px 12px; margin: 10px 0; }
.thread li.support { border-left-color: var(--accent); background: var(--bg); }
.thread li.event { border-left-color: transparent; padding-top: 0; padding-bottom: 0; }
.thread .who { font-weight: 600; font-size: 13px; }
.thread .text { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 2px; }
