/* Vendsmith Cloud console.
   Design rules followed here (see docs/ui-iso-checklist.md):
   - ISO 9241-110/-112/-125: one task per page, consistent placement, status never by colour alone;
   - ISO 9241-143: labels above fields, required fields marked, related fields grouped;
   - ISO/IEC 40500 (WCAG 2.1 AA): text contrast >= 4.5:1, control borders >= 3:1, visible focus, 24px+ targets,
     reflow to one column, no motion for users who ask for less. */
* { box-sizing: border-box; }
:root {
  --ink: #10242f; --ink-2: #3d5560; --line: #d6e2e6; --line-strong: #6b8792;
  --bg: #f2f6f8; --surface: #fff; --head: #eef4f6;
  --brand: #086a61; --brand-dark: #06524b; --brand-soft: #e3f2ef;
  --nav: #11272f; --nav-hover: #1d3a45; --nav-current: #0b7a6f; --nav-muted: #a9c4cb;
  /* Console sidebar: a light tint, not a dark slab (the sign-in page keeps --nav). */
  --side: #f4f8f9; --side-hover: #e7eff1; --side-line: #dbe5e8;
  --row-hover: #eef3f5; --mono: "IBM Plex Mono", "Cascadia Mono", Consolas, "SFMono-Regular", Menlo, monospace;
  --danger: #a32121; --danger-soft: #fdecec; --warn: #7a4a00; --warn-soft: #fff3d6;
  --ok: #0b5c2e; --ok-soft: #e3f4e8; --info: #0b4a7a; --info-soft: #e4f0fb; --muted-soft: #e9eef0;
  --focus: #1a5fd0; --radius: 8px; --bar-h: 52px;
  color: var(--ink); background: var(--bg);
  font: 14px/1.5 Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
}
[hidden] { display: none !important; }
body { margin: 0; }
h1, h2, h3, p { margin: 0; }
a { color: var(--brand); text-underline-offset: .2em; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.skip-link { position: absolute; z-index: 20; inset-inline-start: 12px; top: -60px; padding: 8px 16px; background: var(--surface);
  color: var(--ink); border: 2px solid var(--focus); border-radius: 8px; font-weight: 600; }
.skip-link:focus { top: 8px; }
#workspace:focus { outline: none; }

/* ---- Controls ---- */
input, select, button { font: inherit; min-height: 36px; max-width: 100%; padding: 4px 12px; border: 1px solid var(--line-strong);
  border-radius: 6px; background: var(--surface); color: var(--ink); }
input:hover, select:hover { border-color: var(--ink-2); }
input:disabled, select:disabled { background: var(--muted-soft); color: var(--ink-2); }
input[type="file"] { padding: 4px; }
input[type="checkbox"], input[type="radio"] { min-height: 0; width: 16px; height: 16px; padding: 0; accent-color: var(--brand); }
button { cursor: pointer; font-weight: 500; white-space: nowrap; transition: background-color 80ms, border-color 80ms; }
button:hover { background: var(--row-hover); border-color: var(--ink-2); }
button:not([type="button"]), button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button:not([type="button"]):hover, button.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
button.danger { background: var(--surface); border-color: var(--danger); color: var(--danger); }
button.danger:hover { background: var(--danger); color: #fff; }
button:disabled { opacity: .55; cursor: not-allowed; }
.link-button { min-height: 24px; padding: 0 4px; border: 0; border-radius: 4px; background: transparent; color: var(--brand); font-weight: 500;
  text-decoration: underline; text-underline-offset: .2em; }
.link-button:hover { background: var(--brand-soft); }
label { display: grid; gap: 4px; font-weight: 500; font-size: 13px; }
label:has(:required) > span::after { content: " *"; color: var(--danger); }
form { display: grid; gap: 12px; }
.required-note, .hint { color: var(--ink-2); font-size: 12px; }
.tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* ---- Top bar ---- */
.bar { position: sticky; z-index: 10; top: 0; display: flex; align-items: center; gap: 8px; min-height: var(--bar-h);
  padding: 8px clamp(12px, 3vw, 24px); background: var(--surface); border-bottom: 1px solid var(--line); }
.bar a { margin-inline-end: auto; display: flex; }
.bar img { display: block; width: min(160px, 40vw); height: auto; }
.bar select, .bar button { min-height: 32px; padding: 4px 8px; font-size: 13px; }

/* ---- Messages: a thin outlined line with a tone mark, no thick side bar ---- */
#notice:empty { display: none; }
#notice, .callout { padding: 8px 12px; border: 1px solid color-mix(in srgb, var(--info) 35%, var(--line)); border-radius: 6px;
  background: var(--info-soft); color: var(--ink); font-size: 13px; font-weight: 500; overflow-wrap: anywhere; }
#notice { margin: 12px clamp(12px, 3vw, 24px) 0; }
#notice[data-tone="ok"] { border-color: color-mix(in srgb, var(--ok) 35%, var(--line)); background: var(--ok-soft); }
#notice[data-tone="error"] { border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); background: var(--danger-soft); color: var(--danger); }
.callout { margin-bottom: 12px; }
.callout-warn { border-color: color-mix(in srgb, var(--warn) 35%, var(--line)); background: var(--warn-soft); color: var(--warn); }
.empty-state { padding: 24px 16px; border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--surface);
  color: var(--ink-2); font-size: 13px; text-align: center; }

/* ---- Sign-in pages ---- */
/* A plain page: the form on a bordered card, no picture behind it. */
.auth-foot { display: none; }
body.auth { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-rows: auto 1fr auto; background: var(--bg); }
.auth .bar { position: static; }
.auth main { align-self: center; justify-self: center; width: min(400px, calc(100% - 32px)); margin: 32px 0 max(32px, 12vh);
  padding: 32px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 1px 2px #10242f0a, 0 12px 32px -12px #10242f29; display: grid; gap: 16px; }
.auth h1 { margin-bottom: 4px; font-size: 22px; font-weight: 600; line-height: 1.3; letter-spacing: -.01em; }
.auth #notice { margin: 0; }
.auth #workspace:empty { display: none; }
.auth form { gap: 16px; }
.auth label { gap: 6px; color: var(--ink-2); }
.auth input { min-height: 44px; color: var(--ink); font-size: 15px; }
.auth input:focus-visible { outline-offset: 0; border-color: var(--focus); }
.auth #submit { min-height: 44px; margin-top: 4px; font-size: 15px; font-weight: 600; }
.auth #links { margin-top: 4px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 13px; }
.auth .auth-foot { display: block; padding: 16px; color: var(--ink-2); font-size: 12px; text-align: center; }
@media (max-width: 480px) { .auth main { padding: 24px 20px; margin-block: 16px 24px; align-self: start; } }
/* Wide screens: the form in the left column, a dark panel with a sample machine list on the right. */
.auth-brand { display: none; }
@media (min-width: 960px) {
  body.auth { grid-template-columns: minmax(440px, 5fr) 7fr; background: var(--surface); }
  .auth .bar { grid-column: 1; border-bottom: 0; padding-inline: clamp(24px, 4vw, 56px); }
  .auth main { grid-column: 1; width: min(360px, calc(100% - 48px)); padding: 0; border: 0; border-radius: 0; box-shadow: none; }
  .auth h1 { margin-bottom: 12px; font-size: 28px; }
  .auth .auth-foot { grid-column: 1; }
  .auth .auth-brand { grid-column: 2; grid-row: 1 / 4; display: flex; flex-direction: column; justify-content: center; gap: 40px;
    padding: 56px 0 56px clamp(40px, 5vw, 88px); overflow: hidden; color: #fff;
    background: radial-gradient(120% 90% at 100% 0%, #0b7a6f 0%, #0b7a6f00 60%), linear-gradient(160deg, #143640, var(--nav) 70%); }
  .auth-brand__name { font-size: clamp(32px, 3.2vw, 48px); font-weight: 600; line-height: 1.15; letter-spacing: -.02em; }
  .auth-brand__line { margin-top: 12px; color: var(--nav-muted); font-size: 16px; }
  .auth-shot { margin: 0; padding: 0; border-radius: 12px 0 0 12px; background: var(--surface); color: var(--ink);
    box-shadow: 0 24px 60px -20px #000a; overflow: hidden; }
  .auth-shot__head { display: flex; align-items: baseline; gap: 8px; padding: 14px 20px; border-bottom: 1px solid var(--line); font-weight: 600; font-size: 15px; }
  .auth-shot__head span { color: var(--ink-2); font-weight: 400; font-size: 13px; font-variant-numeric: tabular-nums; }
  .auth-shot table { width: 100%; border-collapse: collapse; font-size: 14px; }
  .auth-shot th { padding: 10px 20px; background: var(--head); color: var(--ink-2); font-size: 12px; font-weight: 600; text-align: start; white-space: nowrap; }
  .auth-shot td { padding: 12px 20px; border-top: 1px solid var(--line); white-space: nowrap; font-variant-numeric: tabular-nums; }
  .auth-shot td:first-child { font-family: var(--mono); font-size: 13px; }
  .auth-shot .dot { display: inline-block; width: 8px; height: 8px; margin-inline-end: 8px; border-radius: 50%; background: var(--ok); }
  .auth-shot .dot.off { background: transparent; box-shadow: inset 0 0 0 2px var(--line-strong); }
  .auth-shot .stock { display: flex; align-items: center; gap: 12px; }
  .auth-shot progress { appearance: none; width: 120px; height: 6px; border: 0; border-radius: 3px; background: var(--muted-soft); overflow: hidden; }
  .auth-shot progress::-webkit-progress-bar { background: var(--muted-soft); }
  .auth-shot progress::-webkit-progress-value { background: var(--brand); }
  .auth-shot progress::-moz-progress-bar { background: var(--brand); }
  .auth-shot progress.low::-webkit-progress-value { background: var(--warn); }
  .auth-shot progress.low::-moz-progress-bar { background: var(--warn); }
}
#links { display: flex; flex-wrap: wrap; gap: 6px 18px; }
#links:empty { display: none; }
#links a { padding: 8px 0; }

/* ---- Console shell ---- */
.ops-console #title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.ops-console main { display: block; }
.ops-console #workspace { display: grid; grid-template-columns: 224px minmax(0, 1fr); grid-template-rows: auto auto 1fr;
  min-height: calc(100vh - var(--bar-h)); align-items: start; }
.work-nav { grid-column: 1; grid-row: 1 / span 3; position: sticky; top: var(--bar-h); align-self: start; height: calc(100vh - var(--bar-h));
  overflow-y: auto; overscroll-behavior: contain; padding: 16px 8px 24px; background: var(--side); color: var(--ink);
  border-inline-end: 1px solid var(--side-line); }
.work-nav .nav-toggle { display: none; }
/* Groups are separated by a rule; the group name is a small muted label and its pages sit indented under it in
   full-strength ink, so a heading is never mistaken for a page. */
.nav-group + .nav-group { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--side-line); }
.work-nav h2 { margin: 0 8px 4px; font-size: 12px; font-weight: 500; letter-spacing: .06em; color: var(--ink-2); }
.work-nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.work-nav li button { width: 100%; min-height: 32px; padding: 4px 8px 4px 20px; border: 0; border-radius: 6px; background: transparent; color: var(--ink);
  font-weight: 400; font-size: 14px; text-align: start; white-space: normal; transition: background-color 80ms, color 80ms; }
.work-nav li button:hover { background: var(--side-hover); }
.work-nav li button[aria-current] { background: var(--brand); color: #fff; font-weight: 600; }
.work-nav li button[aria-current]:hover { background: var(--brand-dark); }
.work-nav :focus-visible { outline-color: var(--focus); outline-offset: -2px; }
.page-head, .context-bar, .fleet-content, .admin-content { grid-column: 2; min-width: 0; }
.page-head { padding: 16px 24px 12px; background: var(--surface); }
.crumbs { color: var(--ink-2); font-size: 12px; }
.page-head h2 { font-size: 20px; font-weight: 600; line-height: 1.3; letter-spacing: -.01em; margin-top: 4px; }
.page-desc { margin-top: 4px; max-width: 78ch; color: var(--ink-2); font-size: 13px; }
.context-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 24px; background: var(--surface);
  border-block: 1px solid var(--line); }
.context-bar label { display: flex; align-items: center; gap: 8px; color: var(--ink-2); }
.context-bar select { min-width: 200px; }
.context-note { margin-inline-start: auto; color: var(--ink-2); font-size: 12px; font-variant-numeric: tabular-nums; }
.fleet-content, .admin-content { padding: 16px 24px 48px; }

/* ---- Panels, cards, tiles ---- */
section { margin: 0 0 16px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
section > h2, .card > h3, .chart > h3 { margin-bottom: 12px; font-size: 15px; font-weight: 600; line-height: 1.3; }
section > button, section > .tools { margin-top: 12px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 16px; margin-bottom: 16px; align-items: start; }
.card { margin: 0; display: grid; gap: 12px; align-content: start; }
.card > h3 { margin: 0; }
.card > p { color: var(--ink-2); font-size: 13px; }
.ops-console form > button { justify-self: start; min-width: 120px; }
/* Figures sit in one strip with hairline dividers (1px gaps over the line colour). An alert is the red figure with a
   triangle; the card itself stays neutral, no coloured edge. */
.kpi-grid { display: flex; flex-wrap: wrap; gap: 1px; margin-bottom: 16px; background: var(--line); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; }
.kpi { flex: 1 1 160px; padding: 12px 16px; background: var(--surface); }
.kpi-label { color: var(--ink-2); font-size: 13px; font-weight: 500; }
.kpi-value { margin-top: 4px; font-size: 24px; font-weight: 600; line-height: 1.25; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.kpi.is-alert .kpi-value, .stat.is-alert dd { color: var(--danger); }
.kpi.is-alert .kpi-value::before, .stat.is-alert dd::before { content: ""; display: inline-block; width: .5em; height: .5em; margin-inline-end: .3em;
  vertical-align: .1em; background: currentColor; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
section > .kpi-grid { margin: 12px 0; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1px; margin: 0; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.stat { padding: 8px 16px 12px; box-shadow: 1px 0 var(--line), 0 1px var(--line); }   /* dividers; an unfilled last row stays white */
.stat dt { color: var(--ink-2); font-size: 12px; font-weight: 500; }
.stat dd { margin: 4px 0 0; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat .badge { margin-top: 4px; }
.chart { margin-top: 8px; }
.segmented { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.segmented button[aria-pressed="true"] { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-dark); font-weight: 600; }

/* ---- Status: a small shape plus coloured text on a neutral ground (never colour alone, no filled pills) ---- */
.badge { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; line-height: 1.5; color: var(--ink-2);
  white-space: nowrap; max-width: 100%; }
.badge::before { content: ""; flex: none; width: 8px; height: 8px; border: 2px solid currentColor; border-radius: 50%; }
.badge-ok { color: var(--ok); }
.badge-ok::before { background: currentColor; }
.badge-danger { color: var(--danger); }
.badge-danger::before { width: 10px; height: 9px; border: 0; border-radius: 0; background: currentColor; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.badge-warn { color: var(--warn); }
.badge-warn::before { border: 0; border-radius: 0; background: currentColor; transform: rotate(45deg); }
.badge-info { color: var(--info); }
.badge.has-tip { cursor: help; text-decoration: underline dotted; text-underline-offset: 3px; }
.badge.has-tip:focus-visible { outline: 2px solid var(--danger); outline-offset: 2px; }
.fault-tip { position: fixed; z-index: 50; max-width: min(420px, calc(100vw - 16px)); padding: 10px 12px; border-radius: 8px;
  background: #14212b; color: #fff; border: 1px solid #ffffff33; font-size: 13px; line-height: 1.55; white-space: pre-line; pointer-events: none;
  box-shadow: 0 6px 18px #0004; }
.fault-tip[hidden] { display: none; }

/* ---- Tables ---- */
.table { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; text-align: start; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; text-align: start; overflow-wrap: break-word; }
th { background: var(--head); font-size: 12px; font-weight: 600; white-space: nowrap; color: var(--ink-2); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background-color 80ms; }
tbody tr:hover { background: var(--row-hover); }   /* hover is neutral; the brand tint is kept for "selected" */
td button:not(.link-button) { min-height: 28px; padding: 0 8px; font-size: 13px; }   /* row actions stay inside the row height */
.fleet-content > p:not([class]), .admin-content > p:not([class]) { color: var(--ink-2); font-size: 13px; }
.mono { font-family: var(--mono); font-size: .94em; font-variant-numeric: tabular-nums slashed-zero; }
.num { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
td pre { max-width: min(60vw, 480px); white-space: pre-wrap; margin: 0; }
td img { border-radius: 6px; border: 1px solid var(--line); }
.readable { white-space: pre-line; }
.fleet-machines :is(td, th):nth-child(3) { white-space: nowrap; }

/* ---- Forms inside the console ---- */
.admin-form { width: min(100%, 440px); }
.admin-form input, .admin-form select { min-width: 0; width: 100%; }
.card .admin-form { width: 100%; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); align-items: end; }
.card .admin-form > button, .card .admin-form > p { grid-column: 1 / -1; }
.card .admin-form > button, .card > button { justify-self: start; min-width: 160px; }
.inline-form { width: 100%; display: flex; flex-wrap: wrap; align-items: end; gap: 12px; }
.inline-form label { flex: 1 1 170px; max-width: 240px; }
.inline-form .required-note { flex-basis: 100%; }
.admin-toolbar-actions { display: flex; align-items: center; gap: 8px; min-width: 0; max-width: 100%; }
.roster-search { position: relative; width: 260px; min-width: 0; }
.roster-search input { width: 100%; }
.roster-suggestions { position: absolute; z-index: 2; inset-inline: 0; top: calc(100% + 4px); max-height: 240px; overflow: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 16px #11263820; }
.roster-suggestions button, .owner-results button { display: block; width: 100%; border: 0; border-radius: 6px; background: var(--surface);
  color: var(--ink); text-align: start; white-space: normal; overflow-wrap: anywhere; font-weight: 500; }
.roster-suggestions button:hover, .roster-suggestions button:focus-visible, .owner-results button:hover,
.owner-results button[aria-pressed="true"] { background: var(--brand-soft); }
.account-table { min-width: 720px; }
.account-table td { vertical-align: middle; }
.account-table td:first-child { width: 36%; }
.account-table td:nth-child(3) { width: 28%; }
.account-table input { width: 100%; }
.account-table td:nth-child(2), .account-actions { white-space: nowrap; }
.account-actions { display: flex; gap: 8px; }
.machine-roster { padding: 0; border: 0; background: transparent; }
.machine-roster .table { background: var(--surface); }

/* ---- Dialogs ---- */
.machine-dialog { width: min(480px, calc(100% - 32px)); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px; overflow-wrap: anywhere; box-shadow: 0 16px 48px #0005; }
.machine-dialog::backdrop { background: #11263899; }
.machine-dialog h2 { margin-bottom: 12px; font-size: 16px; font-weight: 600; }
.machine-dialog .tools { margin-top: 16px; }
.machine-dialog dl { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 16px; }
.machine-dialog dd { margin: 0; }
.owner-search input { width: 100%; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
/* Signal strength: phone-style bars + words */
.sig { display: inline-flex; align-items: center; gap: 8px; }
.sig svg { width: 26px; height: 20px; flex: none; }
.sig rect.off { fill: #c9d4d8; }
.sig-good rect.on { fill: #2e7d32; }
.sig-fair rect.on { fill: #ef8f00; }
.sig-poor rect.on { fill: #c62828; }
/* ---- Sales report ----
   Dense back-office rules (ui-craft-dense-dashboard): 4/8px spacing only, one hero figure, area chart for the
   time series, plain signed deltas, neutral row hover, mono for IDs and dates, sticky table heads. */
.sales-panel > h2 { margin-bottom: 12px; }
.sales-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 6px; overflow: hidden; }
.seg button { min-height: 36px; padding: 4px 12px; border: 0; border-radius: 0; background: var(--surface); color: var(--ink); font-weight: 500; font-size: 14px; }
.seg button + button { border-inline-start: 1px solid var(--line); }
.seg button:hover { background: var(--row-hover); }
.seg button[aria-pressed="true"] { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; box-shadow: inset 0 -2px var(--brand); }
.sales-range { display: flex; align-items: center; gap: 8px; }
.sales-range input { min-height: 36px; padding: 4px 8px; border-radius: 6px; font-size: 14px; }
.sales-range .sep { color: var(--ink-2); }
.sales-range button { min-height: 36px; padding: 4px 16px; border-radius: 6px; font-size: 14px; }
.sales-export { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-inline-start: auto; }
.sales-export button { min-height: 36px; padding: 4px 12px; border-radius: 6px; font-size: 14px; font-weight: 500; }
.month-export { display: flex; align-items: center; gap: 8px; padding-inline-start: 8px; border-inline-start: 1px solid var(--line); }
.month-export input { min-height: 36px; padding: 4px 8px; border-radius: 6px; font-size: 14px; }
/* Summary: hero figure on the left, supports in a strip; 1px gaps over the line colour draw the dividers. */
.sum-caption { margin-top: 16px; color: var(--ink-2); font-size: 12px; font-variant-numeric: tabular-nums; text-align: end; }
.sales-sum { display: flex; flex-wrap: wrap; gap: 1px; margin: 8px 0 0; background: var(--line); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.sales-sum .supports { flex: 3 1 480px; display: flex; flex-wrap: wrap; gap: 1px; }
.sales-sum .cell { flex: 1 1 128px; padding: 12px 16px; background: var(--surface); }
.sales-sum .cell.main { flex: 1 1 240px; display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto auto; column-gap: 16px;
  background: color-mix(in srgb, var(--brand) 5%, var(--surface)); }
.sales-sum .main dt, .sales-sum .main dd, .sales-sum .main .delta { grid-column: 1; }
.sales-sum .main .spark { grid-column: 2; grid-row: 1 / span 3; align-self: end; width: 120px; height: 32px; }
.sales-sum dt { color: var(--ink-2); font-size: 13px; font-weight: 500; }
.sales-sum dd { margin: 4px 0 0; font-size: 20px; font-weight: 600; line-height: 1.25; letter-spacing: -.01em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sales-sum .main dd { font-size: 32px; font-weight: 700; letter-spacing: -.02em; color: var(--brand-dark); }
.sales-sum .is-alert dd { color: var(--danger); }
.sales-sum .is-alert dd::before { content: ""; display: inline-block; width: .5em; height: .5em; margin-inline-end: .3em; vertical-align: .1em;
  background: currentColor; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.sales-sum .delta { display: block; margin-top: 4px; color: var(--ink-2); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sales-sum .delta.good { color: var(--ok); }
.sales-sum .delta.bad { color: var(--danger); }
.spark-line { fill: none; stroke: var(--brand); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.spark-fill { fill: var(--brand); fill-opacity: .1; stroke: none; }
/* Loading skeleton: same shape as the strip and the chart. */
.sales-skeleton { margin-top: 16px; display: grid; gap: 16px; }
.sk-strip { display: flex; gap: 1px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--line); }
.sk-cell { flex: 1; height: 72px; background: var(--surface); position: relative; }
.sk-cell::before, .sk-cell::after { content: ""; position: absolute; left: 16px; border-radius: 4px; background: var(--muted-soft); }
.sk-cell::before { top: 12px; width: 48%; height: 12px; }
.sk-cell::after { top: 36px; width: 64%; height: 20px; }
.sk-chart { height: 220px; border-radius: 8px; background: linear-gradient(var(--surface), var(--muted-soft)); opacity: .7; }
@media (prefers-reduced-motion: no-preference) {
  .sk-cell::before, .sk-cell::after, .sk-chart { animation: sk-pulse 1.2s ease-in-out infinite alternate; }
}
@keyframes sk-pulse { to { opacity: .45; } }
/* Trend chart: area for the time series, horizontal dashed grid, neutral reference line, values only on hover. */
.sales-panel .chart { margin-top: 16px; }
.chart-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.chart-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.chart-head span { color: var(--ink-2); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart-empty { padding: 24px 16px; border: 1px dashed var(--line-strong); border-radius: 8px; color: var(--ink-2); font-size: 13px; }
.chart-plot { position: relative; }
.sales-chart { display: block; width: 100%; height: auto; font-size: 12px; }
.sales-chart .grid { stroke: var(--line); stroke-dasharray: 3 3; }
.sales-chart .axis { stroke: var(--line-strong); }
.sales-chart .tick { fill: var(--ink-2); font-variant-numeric: tabular-nums; pointer-events: none; }
.sales-chart .line { fill: none; stroke: var(--brand); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; pointer-events: none; }
.sales-chart .area { pointer-events: none; }
.sales-chart .fill-top { stop-color: var(--brand); stop-opacity: .15; }
.sales-chart .fill-bottom { stop-color: var(--brand); stop-opacity: 0; }
.sales-chart .avg { stroke: var(--line-strong); stroke-dasharray: 4 4; pointer-events: none; }
.sales-chart .avg-label { fill: var(--ink-2); font-size: 11px; pointer-events: none; }
.sales-chart .guide { stroke: var(--line-strong); pointer-events: none; }
.sales-chart .dot { fill: var(--surface); stroke: var(--brand); stroke-width: 2; pointer-events: none; }
.sales-chart .hit { fill: transparent; cursor: crosshair; }
.chart-tip { position: absolute; z-index: 5; min-width: 152px; padding: 8px 12px; background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: 6px; box-shadow: 0 4px 12px #10242f1f; font-size: 12px; line-height: 1.6; pointer-events: none; }
.chart-tip strong { display: block; margin-bottom: 4px; padding-bottom: 4px; border-bottom: 1px solid var(--line); font-family: var(--mono); font-size: 12px; font-weight: 600; }
.chart-tip .row { display: flex; justify-content: space-between; gap: 16px; }
.chart-tip .row span { color: var(--ink-2); }
.chart-tip .row b { font-weight: 600; font-variant-numeric: tabular-nums; }
.sales-foot { margin-top: 12px; padding-top: 8px; border-top: 1px solid var(--line); color: var(--ink-2); font-size: 12px; }
/* Overview pair below the summary */
.sales-split { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; margin-bottom: 16px; align-items: start; }
.sales-split > section { margin: 0; }
.sales-mini > h2 { margin-bottom: 8px; font-size: 15px; font-weight: 600; }
.sales-mini td { vertical-align: middle; }
.sales-mini .rank { width: 48px; color: var(--ink-2); text-align: center; font-variant-numeric: tabular-nums; }
.sales-mini th.rank { text-align: center; }
.sales-mini tbody tr:nth-child(-n+3) .rank { color: var(--brand-dark); font-weight: 700; }
.pname { display: grid; line-height: 1.35; }
.pname small { color: var(--ink-2); font-size: 12px; }
.share-col { width: 34%; }
.share { display: flex; align-items: center; gap: 8px; }
.share-track { flex: 1; height: 8px; background: var(--muted-soft); border-radius: 2px; overflow: hidden; }
.share-track i { display: block; height: 100%; background: var(--brand); }
.share span { min-width: 3.6em; text-align: end; font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
@media (max-width: 1100px) { .sales-split { grid-template-columns: minmax(0, 1fr); } }
/* Detail tables: title line with export, sticky head inside a bounded scroll area, totals row. */
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.section-head > h2 { margin: 0; font-size: 15px; font-weight: 600; }
button.small { min-height: 32px; padding: 4px 12px; border-radius: 6px; font-size: 13px; font-weight: 500; }
.sales-table .table { max-height: 560px; overflow: auto; scrollbar-gutter: stable; }
.sales-table thead th { position: sticky; top: 0; z-index: 1; box-shadow: inset 0 -1px var(--line); }
.sales-table tfoot td { position: sticky; bottom: 0; background: var(--head); border-top: 2px solid var(--line-strong); border-bottom: 0; font-weight: 700; }
.sales-table th { font-weight: 600; }
.admin-sales { margin-bottom: 20px; }
.admin-sales-head { display: flex; justify-content: flex-end; margin-bottom: -8px; }
.link-button.current { background: var(--brand-soft); }
/* Stock table: edit a slot in its own row */
td.row-edit { white-space: nowrap; text-align: right; }
tr.editing td { background: #f7fbfa; }
input.cell-input { width: var(--w, 6em); min-height: 0; height: 28px; padding: 2px 6px; border: 1px solid #b9c9cf;
  border-radius: 3px; font-size: inherit; background: #fff; }
input.cell-input:hover { border-color: var(--ink-2); }
input.cell-input:focus-visible { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
td.num > input.cell-input { text-align: right; }
table input.cell-input { margin: -4px 0; }
/* Machine model on the stock page */
.vm { margin-bottom: 16px; }
/* Machine model drawn like the real vending machine: painted cabinet with a lit header, a dark lit interior behind glass,
   products on spirals with price labels on the tray lip, a control panel and a pickup door. Sizes follow the screen, so
   the whole machine fits on one screen. Colours are fixed (it is a picture of hardware), not theme tokens. */
.vm-body { display: grid; grid-template-columns: minmax(0, 1fr) 104px; grid-template-areas: "head head" "front side"; gap: 8px 12px;
  width: min(100%, 1320px); margin: 0 auto; padding: 8px 12px 12px; border-radius: 14px;
  background: linear-gradient(90deg, #1d262b 0%, #2c3940 6%, #34434b 50%, #2c3940 94%, #1d262b 100%);
  box-shadow: 0 1px 0 #4a5c65 inset, 0 12px 24px -12px #0b141866, 0 2px 4px #0b141833; }
.vm-head { grid-area: head; display: grid; place-items: center; height: 32px; border-radius: 6px;
  background: linear-gradient(180deg, #0f6b62 0%, #0b5a52 100%); box-shadow: 0 0 0 1px #0a3f3a inset, 0 0 16px #2fb7a133; }
.vm-brand { color: #eafaf6; font-size: 15px; font-weight: 600; letter-spacing: 0.02em; text-shadow: 0 0 8px #b9fff1aa; }
.vm-front { grid-area: front; min-width: 0; display: grid; gap: 8px; }
.vm-glass { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); min-width: 0; padding: 8px 12px 4px;
  border: 6px solid #11181c; border-radius: 6px; background: radial-gradient(120% 40% at 50% 0%, #3b4a52 0%, #1a2328 55%, #121a1e 100%);
  box-shadow: 0 0 0 1px #4a5c65, 0 8px 18px #00000040 inset; overflow: hidden; }
/* glass reflection, drawn over the products but never catching clicks */
.vm-glass::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(115deg, #ffffff1a 0%, #ffffff08 18%, transparent 19%, transparent 62%, #ffffff0d 63%, transparent 72%); }
.vm-shelf { position: relative; display: flex; justify-content: center; align-items: flex-end; min-width: 0; min-height: 56px; padding: 4px 0 0; }
/* tray: a metal lip under each shelf */
.vm-shelf::after { content: ""; position: absolute; left: 0; right: 0; bottom: 14px; height: 4px; border-radius: 1px;
  background: linear-gradient(180deg, #c9d2d6 0%, #8f9ca2 100%); box-shadow: 0 2px 3px #00000059; }
.vm-empty { flex: 1; align-self: center; padding-bottom: 24px; color: #8b9ba2; font-size: 12px; text-align: center; }
.vm-slot { position: relative; z-index: 1; display: grid; justify-items: center; gap: 0; flex: 0 0 calc(var(--span, 1) * 100% / var(--cols, 10));
  min-width: 0; min-height: 0; height: auto; padding: 4px 4px 0; border: 1px solid transparent; border-radius: 4px; background: transparent;
  color: #dfe8eb; font-weight: 400; white-space: nowrap; transition: background-color .08s; }
/* grid children default to min-width:auto, so a long name would widen the slot and overlap its neighbour */
.vm-slot > * { min-width: 0; max-width: 100%; }
.vm-tag { overflow: hidden; }
.vm-tag > * { overflow: hidden; text-overflow: ellipsis; }
/* narrow slots: the label keeps the price only (slot number and stock are in the tooltip and the editor) */
.vm-slot { container-type: inline-size; }
@container (max-width: 92px) { .vm-tag .vm-no, .vm-tag .vm-stock { display: none; } }
@container (max-width: 64px) { .vm-tag .vm-cur { display: none; } .vm-tag { padding: 0 2px; } }
.vm-slot:hover { background: #ffffff12; border-color: #ffffff1f; }
.vm-slot.picked { background: #2fb7a126; border-color: #2fb7a1; }
.vm-slot:focus-visible { outline: 2px solid #2fb7a1; outline-offset: 1px; }
.vm-pic { width: clamp(28px, min(55%, calc((100vh - 440px) / 6 - 40px)), 72px); height: auto; aspect-ratio: 5 / 6; object-fit: contain;
  filter: drop-shadow(0 3px 3px #00000066); }
/* no picture: a coloured pack with the first letters, lit from the top like the real packs under the cabinet light */
span.vm-pic { display: grid; place-items: center; border-radius: 4px 4px 2px 2px; color: #fff; font-size: 12px; font-weight: 600;
  background: linear-gradient(105deg, #ffffff40 0%, #ffffff00 38%), var(--pack, #56656c); box-shadow: 0 -2px 0 #00000026 inset; filter: drop-shadow(0 3px 3px #00000066); }
.vm-name { width: 100%; max-width: 180px; overflow: hidden; text-overflow: ellipsis; margin-top: 4px; font-size: 11px; line-height: 14px; color: #b7c6cc; text-align: center; }
/* price label stuck on the tray lip */
.vm-tag { position: relative; z-index: 1; display: flex; justify-content: center; align-items: baseline; gap: 4px; width: 100%; max-width: 132px; margin: 2px 0 6px;
  padding: 0 4px; border-radius: 2px; background: #f7f9fa; color: #172227; font-size: 11px; line-height: 16px; box-shadow: 0 1px 1px #0000004d;
  font-variant-numeric: tabular-nums; }
.vm-no { padding: 0 4px; margin-left: -4px; border-radius: 2px 0 0 2px; background: #172227; color: #fff; font-family: var(--mono); font-size: 10px; }
.vm-price { font-weight: 600; }
.vm-stock { color: #5a6a71; }
.vm-tag.low { background: #fff3dc; }
.vm-tag.low .vm-stock { color: #a35d00; font-weight: 600; }
.vm-tag.out { background: #fde4e1; }
.vm-tag.out .vm-stock { color: #b3261e; font-weight: 600; }
/* pickup door */
.vm-bin { display: grid; place-items: center; height: 44px; padding: 6px 15%; border-radius: 6px; background: #11181c; box-shadow: 0 0 0 1px #4a5c65; }
.vm-bin-flap { display: grid; place-items: center; width: 100%; height: 100%; border-radius: 4px; background: linear-gradient(180deg, #2a363c 0%, #1b2429 100%);
  box-shadow: 0 2px 0 #3d4d55 inset; color: #8fa2aa; font-size: 11px; font-weight: 600; letter-spacing: 0.12em; }
/* control panel */
.vm-side { grid-area: side; display: grid; align-content: start; gap: 12px; padding: 12px 8px; border-radius: 6px;
  background: linear-gradient(180deg, #232e33 0%, #1a2328 100%); box-shadow: 0 0 0 1px #4a5c65; }
.vm-screen { min-height: 52px; padding: 4px 8px; border-radius: 4px; background: #0b2e2a; color: #8ef0d6; font-family: var(--mono); font-size: 10px; line-height: 1.4;
  word-break: break-all; box-shadow: 0 0 0 2px #0b1215, 0 0 10px #2fb7a133 inset; }
.vm-keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.vm-keys i { display: grid; place-items: center; height: 16px; border-radius: 3px; background: linear-gradient(180deg, #c8d2d6 0%, #9eabb1 100%);
  color: #1c262b; font-style: normal; font-family: var(--mono); font-size: 9px; font-weight: 600; box-shadow: 0 1px 0 #0000004d; }
.vm-card { display: grid; place-items: center; height: 36px; border-radius: 4px; background: #11181c; color: #8fa2aa; box-shadow: 0 0 0 1px #3d4d55; }
.vm-card svg { width: 18px; height: 18px; }
.vm-coin { height: 20px; margin: 0 24px; border-radius: 3px; background: linear-gradient(180deg, #b7c3c8, #7d8b91);
  box-shadow: inset 0 0 0 7px #8e9ca2, inset 0 0 0 8px #0b1215; }
.vm-note { height: 12px; margin: 0 8px; border-radius: 2px; background: #0b1215; box-shadow: 0 0 0 3px #3d4d55; }
.vm-return { height: 20px; margin: 4px 28px 0; border-radius: 3px 3px 8px 8px; background: #0b1215; box-shadow: 0 0 0 2px #3d4d55; }
@media (max-width: 700px) { .vm-body { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "front"; } .vm-side { display: none; } .vm-glass { overflow-x: auto; } .vm-shelf { min-width: calc(var(--cols, 10) * 80px); } }
.vm-editor { margin-top: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.vm-editor-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.vm-editor-body { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.vm-pic-button { display: grid; justify-items: center; gap: 4px; min-height: 0; padding: 6px; border: 1px dashed #b9c9cf; border-radius: 4px;
  background: #fff; color: var(--brand); font-size: 12px; font-weight: 600; }
.vm-editor-pic { width: 96px; height: 96px; object-fit: contain; }
span.vm-editor-pic { display: grid; place-items: center; background: #eef2f4; color: #6b7d85; font-weight: 400; }
.vm-fields { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: flex-end; }
.vm-fields label { display: grid; gap: 4px; font-size: 12px; color: var(--ink-2); }
.vm-fields label .warn-mark { position: relative; top: -2px; }
.vm-fields label:has(.warn-mark) { grid-template-columns: auto auto; }
.vm-fields label:has(.warn-mark) > span:first-child { grid-column: 1 / -1; }
.vm-fields input.cell-input { margin: 0; }
.vm-actions { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
.vm-actions button { min-height: 0; height: 30px; padding: 2px 14px; border-radius: 3px; font-size: 13px; }
/* The editor as a small popup next to the clicked slot */
.vm-pop { position: fixed; z-index: 40; margin: 0; width: 400px; max-width: calc(100vw - 16px); padding: 10px 12px;
  border: 1px solid #b9c9cf; box-shadow: 0 6px 20px #10242f33; }
.vm-pop .vm-editor-head { margin-bottom: 8px; font-size: 14px; }
.vm-pop .vm-editor-body { flex-wrap: nowrap; gap: 12px; }
.vm-pop .vm-editor-pic { width: 64px; height: 64px; }
.vm-pop .vm-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 10px; flex: 1; min-width: 0; }
.vm-pop .vm-fields label.wide { grid-column: 1 / -1; }
.vm-pop .vm-fields input.cell-input { width: 100%; }
.vm-pop .vm-fields label:has(.warn-mark) { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
.vm-pop .vm-fields label .warn-mark { top: 0; }
.vm-pop .vm-actions { margin-top: 10px; }
.warn-mark { display: inline-grid; place-items: center; width: 16px; height: 16px; margin-left: 6px; border-radius: 50%;
  background: #c62828; color: #fff; font-size: 11px; font-weight: 800; line-height: 1; vertical-align: middle; cursor: help; }
td.row-edit button { min-height: 0; height: 28px; margin: -4px 0; padding: 2px 10px; border-radius: 3px; font-size: 13px; }
td.row-edit .row-cancel { margin-left: 4px; }
.machine-dialog form .machine-name { display: grid; gap: 4px; }
.machine-dialog form .machine-name input { width: 100%; }
.machine-dialog .name-row { display: flex; gap: 8px; align-items: flex-end; margin: 4px 0 14px; }
.machine-dialog .machine-name { flex: 1; display: grid; gap: 4px; }
.machine-dialog .machine-name input { width: 100%; }
.machine-dialog .keep-history {display: flex; gap: 8px; align-items: flex-start; margin-top: 12px; line-height: 1.5; }
.machine-dialog .keep-history[hidden] { display: none; }
.machine-dialog .keep-history input { margin-top: 4px; flex: none; }
.owner-dropdown { border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); }
.owner-dropdown summary { padding: 9px 12px; min-height: 40px; cursor: pointer; }
.owner-dropdown .owner-search { padding: 8px 12px; border-top: 1px solid var(--line); }
.owner-results { max-height: 190px; overflow-y: auto; padding: 0 8px 8px; }
.owner-results p { margin: 8px; }
.owner-dropdown:not([open]) > :not(summary) { display: none; }

/* ---- Narrow screens: one column, menu behind a button (WCAG 1.4.10 reflow) ---- */
@media (max-width: 900px) {
  .ops-console #workspace { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; min-height: 0; }
  .work-nav, .page-head, .context-bar, .fleet-content, .admin-content { grid-column: 1; grid-row: auto; }
  .work-nav { position: static; height: auto; padding: 8px 12px; }
  .work-nav .nav-toggle { display: block; width: 100%; background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
  .work-nav:not(.is-open) .nav-group { display: none; }
  .work-nav.is-open .nav-group:first-of-type { margin-top: 12px; }
  .page-head, .context-bar, .fleet-content, .admin-content { padding-inline: 12px; }
  .context-note { margin-inline-start: 0; flex-basis: 100%; }
  .context-bar label, .context-bar select { flex: 1 1 auto; min-width: 0; }
  input, select, button { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
@media (forced-colors: active) {
  .kpi, .stat, section, .work-nav li button[aria-current] { border: 1px solid CanvasText; }
}
