/* Command centre — the page's only stylesheet (the CSP allows no inline styles).
   Layout: sticky header + filter bar, tabbed wide body; lane tiles three across,
   panels two or three across, all stacking to one column on a phone. */

@font-face { font-family: "Archivo"; font-weight: 700; font-display: swap; src: url("/archivo-700.woff2") format("woff2"); }
@font-face { font-family: "Archivo"; font-weight: 800; font-display: swap; src: url("/archivo-800.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 400; font-display: swap; src: url("/plex-sans-400.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 500; font-display: swap; src: url("/plex-sans-500.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 600; font-display: swap; src: url("/plex-sans-600.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 400; font-display: swap; src: url("/plex-mono-400.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 500; font-display: swap; src: url("/plex-mono-500.woff2") format("woff2"); }

:root {
  --bg: #f3f5f8; --panel: #ffffff; --ink: #18212e; --muted: #5b6778; --line: #dde3ea; --soft: #eef2f6;
  --accent: #1f5fbf; --accent-soft: #e3ecfa;
  --ok: #1d8a5a; --ok-soft: #e1f3ea; --bad: #c2392b; --bad-soft: #fbe7e4; --warn: #b7791f; --warn-soft: #fbf1dd; --idle: #7a8596; --idle-soft: #e9edf2;
  --v-etips: #1f5fbf; --v-retinue: #8a4fbf; --v-matrix: #0f8b8d;
  --s1: #1f5fbf; --s2: #c2392b; --s3: #8a4fbf; --s4: #0f8b8d; --s5: #b7791f; --s6: #5b6778; --s7: #d16ba5;
  --f-display: "Archivo", system-ui, sans-serif; --f-body: "IBM Plex Sans", system-ui, sans-serif; --f-mono: "IBM Plex Mono", ui-monospace, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f141b; --panel: #171e28; --ink: #e6ebf2; --muted: #9aa6b7; --line: #2a3443; --soft: #1e2733;
    --accent: #6ea2f5; --accent-soft: #1d2b44; --ok: #43b883; --ok-soft: #163327; --bad: #f07a6c; --bad-soft: #3a1d1a; --warn: #e3a94a; --warn-soft: #3a2d15; --idle: #8a96a8; --idle-soft: #232c38;
    --v-etips: #6ea2f5; --v-retinue: #b98ae6; --v-matrix: #41b9bb;
    --s1: #6ea2f5; --s2: #f07a6c; --s3: #b98ae6; --s4: #41b9bb; --s5: #e3a94a; --s6: #9aa6b7; --s7: #e58fc0;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f141b; --panel: #171e28; --ink: #e6ebf2; --muted: #9aa6b7; --line: #2a3443; --soft: #1e2733;
  --accent: #6ea2f5; --accent-soft: #1d2b44; --ok: #43b883; --ok-soft: #163327; --bad: #f07a6c; --bad-soft: #3a1d1a; --warn: #e3a94a; --warn-soft: #3a2d15; --idle: #8a96a8; --idle-soft: #232c38;
  --v-etips: #6ea2f5; --v-retinue: #b98ae6; --v-matrix: #41b9bb;
  --s1: #6ea2f5; --s2: #f07a6c; --s3: #b98ae6; --s4: #41b9bb; --s5: #e3a94a; --s6: #9aa6b7; --s7: #e58fc0;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 14px; line-height: 1.45; overflow-x: hidden; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); }
.wrap { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── header ─────────────────────────────────────────────────────────────── */
header { position: sticky; top: 0; z-index: 5; background: var(--panel); border-bottom: 1px solid var(--line); }
.top { display: flex; align-items: center; gap: 8px 16px; flex-wrap: wrap; padding-block: 10px; }
.brand { font-family: var(--f-display); font-weight: 800; font-size: 18px; letter-spacing: -.01em; white-space: nowrap; }
nav { display: flex; gap: 2px; flex-wrap: wrap; }
nav button { font-weight: 500; font-size: 14px; color: var(--muted); background: none; border: 0; padding: 8px 12px; border-radius: 6px; cursor: pointer; }
nav button[aria-selected="true"] { color: var(--accent); background: var(--accent-soft); }
nav button:hover { color: var(--ink); }
.right { margin-left: auto; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.asof { font: 400 12px var(--f-mono); color: var(--muted); display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: 999px; }
.asof .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.asof.amber { color: var(--warn); background: var(--warn-soft); } .asof.amber .dot { background: var(--warn); }
.asof.red { color: var(--bad); background: var(--bad-soft); } .asof.red .dot { background: var(--bad); }
.link { font-weight: 500; font-size: 12px; color: var(--accent); background: none; border: 0; cursor: pointer; padding: 3px 4px; text-decoration: none; }
.link:hover { text-decoration: underline; }
.who-am-i { font-size: 12px; color: var(--muted); }

/* ── filter bar ─────────────────────────────────────────────────────────── */
.filters { border-top: 1px solid var(--line); padding-block: 8px; }
.ftoggle { display: none; }
.fgrid { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.fgrid label { display: flex; flex-direction: column; font-size: 11px; color: var(--muted); gap: 2px; }
select, input[type="search"], input[type="date"] { font-size: 13px; color: var(--ink); background: var(--soft); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; max-width: 170px; min-width: 0; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; background: var(--soft); padding: 5px 9px; font-size: 12px; cursor: pointer; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.chip { font-size: 12px; background: var(--accent-soft); color: var(--accent); border: 0; border-radius: 999px; padding: 3px 10px; cursor: pointer; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip::after { content: " ✕"; }
.note { font-size: 12px; color: var(--muted); }

/* ── body ───────────────────────────────────────────────────────────────── */
main { padding-block: 16px 40px; display: flex; flex-direction: column; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 12px; }
.grid2.even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 1100px) { .grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 860px) { .grid3, .grid2, .grid2.even, .grid4 { grid-template-columns: minmax(0, 1fr); } }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; min-width: 0; }
.panel h2 { font: 700 14px var(--f-display); margin: 0 0 10px; letter-spacing: .01em; display: flex; justify-content: space-between; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.panel h2 small { font: 400 12px var(--f-body); color: var(--muted); }
.panel h3 { font: 700 13px var(--f-display); margin: 12px 0 6px; }
[data-action] { cursor: pointer; }
[data-action]:focus-visible, button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* lane tiles */
.tile { border-left: 4px solid var(--idle); transition: box-shadow .15s; }
.tile:hover { box-shadow: 0 2px 10px rgb(0 0 0 / .08); }
.tile.ok { border-left-color: var(--ok); } .tile.bad { border-left-color: var(--bad); } .tile.warn { border-left-color: var(--warn); }
.tile .name { font: 700 16px var(--f-display); display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.state { font: 600 12px var(--f-body); padding: 2px 8px; border-radius: 999px; }
.state.ok { background: var(--ok-soft); color: var(--ok); } .state.bad { background: var(--bad-soft); color: var(--bad); } .state.warn { background: var(--warn-soft); color: var(--warn); } .state.idle { background: var(--idle-soft); color: var(--muted); }
.kv { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-top: 10px; }
.kv > div { background: var(--soft); border-radius: 6px; padding: 6px 8px; min-width: 0; }
.kv b { display: block; font: 500 17px var(--f-mono); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kv span { font-size: 11px; color: var(--muted); }
.kv .bad b { color: var(--bad); } .kv .warn b { color: var(--warn); }
.tile .foot { font-size: 12px; color: var(--muted); margin-top: 8px; display: flex; gap: 6px 12px; flex-wrap: wrap; }
.tile .foot .bad { color: var(--bad); font-weight: 600; }

/* KPI tiles */
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-width: 0; }
.kpi b { display: block; font: 500 22px var(--f-mono); font-variant-numeric: tabular-nums; }
.kpi span { font-size: 12px; color: var(--muted); }
.kpi.ok b { color: var(--ok); } .kpi.bad b { color: var(--bad); } .kpi.warn b { color: var(--warn); }
.kpi:hover { border-color: var(--accent); }

/* charts */
.chart { height: 260px; width: 100%; min-width: 0; }
.chart.tall { height: 340px; }
.chart.short { height: 200px; }
.chart.xtall { height: 560px; }
.chartbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin: -4px 0 6px; }
.tt-h { font-weight: 600; margin-bottom: 4px; }
.tt-r { display: flex; justify-content: space-between; gap: 16px; font-size: 12px; }
.tt-r b { font-family: var(--f-mono); }
.tt-n { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* bar lists (HTML bars; widths set from script through the CSSOM) */
.bars { display: flex; flex-direction: column; gap: 4px; }
.bar { display: grid; grid-template-columns: minmax(0, 9rem) minmax(0, 1fr) 3.2rem; gap: 8px; align-items: center; padding: 4px 6px; border-radius: 6px; }
.bar:hover, .bar.on { background: var(--accent-soft); }
.bar .l { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.bar .track { display: flex; height: 12px; background: var(--soft); border-radius: 3px; overflow: hidden; }
.bar .seg-done { background: var(--ok); } .bar .seg-notSent { background: var(--bad); } .bar .seg-check { background: var(--warn); } .bar .seg-skipped, .bar .seg-running { background: var(--idle); }
.bar .seg-accent { background: var(--accent); }
.bar .n { font: 500 13px var(--f-mono); text-align: right; font-variant-numeric: tabular-nums; }
.bars.long .bar { grid-template-columns: minmax(0, 1fr) 3.2rem; row-gap: 2px; }
.bars.long .bar .l { grid-column: 1 / -1; white-space: normal; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 11px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.legend .k-done { background: var(--ok); } .legend .k-notSent { background: var(--bad); } .legend .k-check { background: var(--warn); } .legend .k-skipped { background: var(--idle); }

/* tables */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th button { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; }
td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
td.mono { white-space: nowrap; }
tr[data-action]:hover td { background: var(--soft); }
td .cell { border-bottom: 1px dotted var(--muted); }
td .cell:hover { color: var(--accent); }
.mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.res { font-weight: 600; }
.res.ok { color: var(--ok); } .res.bad { color: var(--bad); } .res.warn { color: var(--warn); } .res.idle { color: var(--muted); }
.stuck { color: var(--bad); font-weight: 600; }
.more { margin-top: 10px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.btn { font-weight: 600; font-size: 13px; color: var(--accent); background: var(--accent-soft); border: 0; border-radius: 6px; padding: 6px 12px; cursor: pointer; }

/* reasons */
.reasons { display: flex; flex-direction: column; gap: 6px; }
.reason { display: grid; grid-template-columns: minmax(0, 1fr) auto 90px; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px; background: var(--soft); }
.reason:hover { background: var(--accent-soft); }
.reason .t { font-weight: 600; }
.reason .w { font-size: 12px; color: var(--muted); }
.reason .n { font: 500 16px var(--f-mono); }
.spark { width: 90px; height: 28px; display: block; }
.spark path.line { fill: none; stroke: var(--accent); stroke-width: 1.5; }
.spark path.area { fill: var(--accent-soft); stroke: none; }
.whohead { font: 700 12px var(--f-display); margin: 16px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.rgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 1350px) { .rgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) { .rgrid { grid-template-columns: minmax(0, 1fr); } }
.morecards { margin-top: 8px; }
.morecards > summary { font-size: 13px; margin-bottom: 8px; }
.kpi.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.rcard { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: grid; grid-template-columns: minmax(0, 1fr) 110px; gap: 12px; }
.rcard:hover, .rcard.on { border-color: var(--accent); }
.rcard p { margin: 4px 0 0; color: var(--muted); }
.rcard .todo { font-size: 13px; margin-top: 6px; }
.rcard .num { font: 500 22px var(--f-mono); text-align: right; }
.rcard .side { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.rcard .spark { width: 100%; }
.splits { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--soft); color: var(--muted); border: 0; }
button.tag:hover { background: var(--accent-soft); color: var(--accent); }
.pill { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--soft); color: var(--muted); margin-left: 6px; vertical-align: 1px; }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.focus { border-color: var(--accent); }
.focus .big { font: 800 18px var(--f-display); margin: 0 0 6px; }
.why { background: var(--soft); border-radius: 8px; padding: 10px 12px; margin: 10px 0; }
.why p { margin: 0 0 6px; }
.why p:last-child { margin: 0; }

/* job view (drawer) */
.scrim { position: fixed; inset: 0; background: rgb(0 0 0 / .3); z-index: 19; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(600px, 100%); background: var(--panel); border-left: 1px solid var(--line); z-index: 20; overflow-y: auto; box-shadow: -8px 0 24px rgb(0 0 0 / .12); padding: 16px max(18px, env(safe-area-inset-right, 0px)) 32px 18px; }
.drawer h2 { font: 800 19px var(--f-display); margin: 6px 0 4px; }
.drawer h3 { font: 700 14px var(--f-display); margin: 16px 0 6px; }
.steps { list-style: none; padding: 0; margin: 8px 0; border-left: 2px solid var(--line); }
.steps li { padding: 4px 0 8px 14px; position: relative; }
.steps li::before { content: ""; position: absolute; left: -6px; top: 9px; width: 10px; height: 10px; border-radius: 50%; background: var(--ok); }
.steps li.stop::before { background: var(--bad); }
.steps li.warn::before { background: var(--warn); }
.steps li span { color: var(--muted); font: 400 12px var(--f-mono); margin-left: 6px; }
.facts { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 14px; font-size: 13px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
details { margin-top: 14px; }
summary { cursor: pointer; color: var(--accent); }
.shot { margin-top: 10px; border: 1px dashed var(--line); border-radius: 8px; padding: 10px; color: var(--muted); font-size: 13px; }
.shot img { display: block; max-width: 100%; margin-top: 8px; border: 1px solid var(--line); border-radius: 6px; }
.items { margin: 4px 0 0 18px; padding: 0; }
.empty { color: var(--muted); padding: 12px 4px; }
.notice { background: var(--warn-soft); color: var(--ink); border-radius: 8px; padding: 8px 12px; font-size: 13px; }
.error { background: var(--bad-soft); color: var(--ink); border-radius: 8px; padding: 8px 12px; font-size: 13px; }
.loading { color: var(--muted); padding: 12px 4px; }
.search { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 10px; }
.search label { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--muted); }
.search input { max-width: 260px; }

/* ── phone ──────────────────────────────────────────────────────────────── */
@media (max-width: 700px) {
  header { position: static; }
  .right { margin-left: 0; width: 100%; justify-content: space-between; }
  nav { width: 100%; }
  nav button { padding: 7px 9px; }
  .ftoggle { display: inline-flex; }
  .fgrid { display: none; margin-top: 8px; }
  .filters.open .fgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fgrid label select, .fgrid label input { max-width: none; width: 100%; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bar { grid-template-columns: minmax(0, 7rem) minmax(0, 1fr) 2.8rem; }
  .rcard { grid-template-columns: minmax(0, 1fr) 80px; }
  .reason { grid-template-columns: minmax(0, 1fr) auto; }
  .reason .spark { display: none; }
  /* tables become cards: time · vendor · job type, then client, result, then worker number and time taken */
  table.cards thead { display: none; }
  table.cards, table.cards tbody, table.cards td { display: block; width: 100%; }
  table.cards tr { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; margin-bottom: 6px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 10px; }
  table.cards td { border: 0; padding: 1px 0; }
  table.cards td.wide { grid-column: 1 / -1; }
  table.cards td.lab::before { content: attr(data-label) ": "; color: var(--muted); font-family: var(--f-body); font-size: 11px; }
  table.cards td.lab { grid-column: span 1; font-size: 12px; }
  table.cards tr { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) minmax(0, 1fr); }
  table.cards td.c-time { white-space: normal; }
  table.cards td.c-result { order: 5; }
  table.cards td.c-staff { grid-column: 1 / span 2; order: 6; }
  table.cards td.c-took { order: 7; white-space: normal; }
  table.cards:not(.jobs) td::before { content: attr(data-label); display: block; font-size: 11px; color: var(--muted); }
  table.cards:not(.jobs) tr { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  [data-view="live"] tr.x6 { display: none; }
  .kv { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
  .kv > div { padding: 5px 6px; }
  .kv b { font-size: 15px; }
  .kv span { font-size: 10px; line-height: 1.25; display: block; }
  .tile .foot .hint, .chips .note, .who-am-i { display: none; }
  .tablewrap { overflow-x: visible; }
  .chart { height: 230px; }
  .chart.tall { height: 300px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
