/* HostView dashboard. Dark-first; light is opt-in via the toggle (app-feature-standards.md). */
:root,
[data-theme="dark"] {
  --bg: #0b0b0d;
  --panel: #141417;
  --card: #18181b;
  --card-hi: #1f1f23;
  --edge: #2a2a30;
  --text: #f2f2f4;
  --muted: #a1a1aa;
  --faint: #8b8b94;
  --accent: #ffc93c;
  --accent-ink: #ffd666;
  --sky: #4b93f2;
  --ok: #34d399;
  --warn: #fbbf24;
  --hot: #f87171;
  --off: #52525b;
  --track: #26262b;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --primary: #ffc93c;
  --primary-edge: #ffc93c;
  --primary-ink: #1a1405;
  --field: #0e0e11;
  --field-edge: #64646e;
  --seg-track: #0e0e11;
  --seg-on: #34343c;
  --seg-ring: #6a6a75;
  --code: #0e0e11;
  --scrim: rgba(0, 0, 0, 0.5);
  /* Work view: one colour per machine in history charts, and "other machines".
     The dataviz reference hues without yellow (amber means "waiting" here), in an
     order that passes its colour-vision checks on this card (worst adjacent
     CVD dE 8.6 dark, 7.2 light, with the 1.5px gap between bands as the second cue). */
  --c1: #3987e5; --c2: #d95926; --c3: #199e70; --c4: #9085e9;
  --c5: #d55181; --c6: #008300; --c7: #e66767; --c0: #71717a;
  --rank1: #ffd666;
}
[data-theme="light"] {
  --bg: #f4f4f6;
  --panel: #ffffff;
  --card: #ffffff;
  --card-hi: #f7f7f9;
  --edge: #e2e2e8;
  --text: #18181b;
  --muted: #52525b;
  --faint: #6b6b75;
  --accent: #b7791f;
  --accent-ink: #8a5a0f;
  --sky: #1d64c8;
  --ok: #15803d;
  --warn: #b45309;
  --hot: #c62828;
  --off: #a1a1aa;
  --track: #e9e9ee;
  --shadow: 0 10px 30px rgba(20, 20, 30, 0.08);
  --primary: #ffc93c;
  --primary-edge: #e0a91f;
  --primary-ink: #1a1405;
  --field: #ffffff;
  --field-edge: #8a8a94;
  --seg-track: #ececf0;
  --seg-on: #ffffff;
  --seg-ring: #80808a;
  --code: #f4f4f7;
  --scrim: rgba(20, 20, 30, 0.3);
  --c1: #2a78d6; --c2: #eb6834; --c3: #1baf7a; --c4: #4a3aa7;
  --c5: #e87ba4; --c6: #008300; --c7: #e34948; --c0: #a1a1aa;
  --rank1: #8a5a0f;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable", "Segoe UI", Roboto, Inter, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.tnum { font-variant-numeric: tabular-nums; }
.mono, .num { font-family: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-variant-numeric: tabular-nums; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; border: 1px solid var(--edge); background: var(--card-hi); color: var(--text); padding: 9px 16px; border-radius: 10px; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover { border-color: var(--faint); }
.btn.primary { background: var(--primary); border-color: var(--primary-edge); color: var(--primary-ink); }
.btn.primary:hover { border-color: var(--primary-edge); filter: brightness(1.05); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.busy { color: transparent; position: relative; pointer-events: none; }
.btn.busy::after { content: ""; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--primary-ink); border-right-color: transparent; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn.danger { background: transparent; border-color: color-mix(in srgb, var(--hot) 55%, var(--edge)); color: var(--hot); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.icon-btn { width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--edge); background: transparent; cursor: pointer; display: inline-grid; place-items: center; }
.icon-btn svg { width: 17px; height: 17px; fill: none; stroke: var(--muted); stroke-width: 1.8; }
.icon-btn:hover { border-color: var(--faint); }
:where(button, a, input, [tabindex]):focus-visible { outline: 2px solid var(--sky); outline-offset: 2px; }
[tabindex="-1"]:focus { outline: none; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* gate (signed out) */
.gate-body { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.gate { max-width: 440px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.gate-icon { border-radius: 22.5%; box-shadow: var(--shadow); }
.gate h1 { font-size: 34px; letter-spacing: -0.02em; margin: 6px 0 0; }
.gate h1.sentence { font-size: 28px; line-height: 1.2; text-wrap: balance; }
.gate .lede { color: var(--muted); margin: 0 0 6px; font-size: 15px; text-wrap: balance; overflow-wrap: anywhere; }
.inline { display: inline; }

/* header */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; padding: 12px 20px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--edge); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; letter-spacing: -0.01em; }
.brand img { border-radius: 22.5%; }
.status { display: flex; align-items: center; gap: 14px; margin-right: auto; min-width: 0; }
/* Fleet | Work (shown once a machine reports work). */
.views { display: inline-flex; gap: 2px; padding: 3px; border-radius: 11px; background: var(--seg-track); border: 1px solid var(--edge); }
.view-tab { border: 0; background: transparent; padding: 5px 14px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.view-tab:hover { color: var(--text); }
.view-tab[aria-selected="true"] { background: var(--seg-on); color: var(--text); box-shadow: inset 0 0 0 1px var(--seg-ring), 0 1px 2px rgba(0, 0, 0, 0.12); }
.view-tab:focus-visible { outline-offset: 1px; }
.summary { color: var(--muted); font-size: 13px; white-space: nowrap; }
.summary:empty { display: none; }
.actions { display: flex; align-items: center; gap: 10px; }
.add-top svg { width: 14px; height: 14px; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; }
.account { display: flex; align-items: center; gap: 8px; }
.who { color: var(--muted); font-size: 13px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conn { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.conn i { width: 8px; height: 8px; border-radius: 50%; background: var(--off); }
.conn.ok i { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
.conn.bad i { background: var(--warn); }

/* fleet grid */
.fleet-main { padding: 20px; max-width: 1480px; margin: 0 auto; }
.fleet { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.card { background: var(--card); border: 1px solid var(--edge); border-radius: 16px; padding: 14px 16px 14px; display: flex; flex-direction: column; gap: 10px; cursor: pointer; text-align: left; transition: border-color .12s, transform .12s; min-width: 0; }
.card:hover { border-color: var(--faint); }
.card:focus-visible { outline: 2px solid var(--sky); outline-offset: 2px; }
.card-head { display: flex; align-items: flex-start; gap: 10px; min-width: 0; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--off); flex: 0 0 9px; }
/* The dot and the chip sit on the name's first line (15px x 1.45 = 21.75px). */
.card-head .dot { margin-top: 6.4px; }
.card-head .chip { margin-top: 0.5px; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }
.dot.live { animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--ok) 8%, transparent); } }
.name { font-weight: 700; font-size: 15px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip { margin-left: auto; font-size: 11.5px; color: var(--muted); border: 1px solid var(--edge); border-radius: 999px; padding: 1px 8px; white-space: nowrap; }
.sub { color: var(--faint); font-size: 12px; margin-top: -6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
.meter { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.meter .lbl { display: flex; justify-content: space-between; gap: 6px; font-size: 12px; color: var(--muted); }
.meter .lbl b { color: var(--text); font-weight: 650; }
.bar { height: 6px; border-radius: 99px; background: var(--track); overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--sky); transition: width .5s ease; }
.bar > i.warm { background: var(--warn); }
.bar > i.hot { background: var(--hot); }
.foot { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: 12px; }
.foot span { white-space: nowrap; }
.card .foot .top-proc { flex-basis: 100%; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.spark { width: 100%; height: 34px; display: block; }
.spark path.line { fill: none; stroke: var(--sky); stroke-width: 1.6; }
.spark path.area { fill: color-mix(in srgb, var(--sky) 16%, transparent); stroke: none; }
/* An offline machine's last readings: the bars and the sparkline turn grey so they
   read as old, while every word and number keeps full contrast. The card itself is
   never faded (polish-spec section 4; the kit's staleReadings). */
.card.offline .bar > i { background: var(--off); }
.card.offline .spark path.line { stroke: var(--off); }
.card.offline .spark path.area { fill: color-mix(in srgb, var(--off) 16%, transparent); }

.empty { text-align: center; color: var(--muted); padding: 80px 16px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty img { border-radius: 22.5%; opacity: .9; }
.empty h2 { color: var(--text); margin: 8px 0 0; }
.empty p { max-width: 420px; margin: 0; text-wrap: balance; }
.empty .btn { margin-top: 12px; }

/* detail drawer */
.detail { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%); background: var(--panel); border-left: 1px solid var(--edge); box-shadow: var(--shadow); z-index: 10; overflow-y: auto; padding: 18px 20px 40px; }
.detail-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 4px; }
/* The whole name, wrapping if it must; its first line centres on the close button. */
.detail-head h2 { margin: 0; padding-top: 4px; font-size: 20px; line-height: 26px; min-width: 0; overflow-wrap: anywhere; }
.detail-head .dot { margin-top: 12.5px; }
.detail-head .close { margin-left: auto; flex: none; }
.detail .row-actions { display: flex; gap: 8px; margin: 10px 0 16px; }
.detail h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); margin: 22px 0 8px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: 13px; }
.facts dt { color: var(--faint); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.cores { display: grid; grid-template-columns: repeat(auto-fill, minmax(18px, 1fr)); gap: 3px; }
.cores i { height: 36px; border-radius: 4px; background: var(--track); position: relative; overflow: hidden; }
.cores i b { position: absolute; left: 0; right: 0; bottom: 0; background: var(--sky); }
.list { display: flex; flex-direction: column; gap: 10px; }
.list .item { display: flex; flex-direction: column; gap: 4px; }
.list .item .lbl { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.list .item .lbl span:last-child { color: var(--muted); }
table.procs { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.procs th { text-align: left; color: var(--faint); font-weight: 600; padding: 4px 0; border-bottom: 1px solid var(--edge); }
table.procs td { padding: 5px 0; border-bottom: 1px solid color-mix(in srgb, var(--edge) 60%, transparent); }
table.procs td.num, table.procs th.num { text-align: right; }
.tabs { display: inline-flex; border: 1px solid var(--edge); border-radius: 9px; overflow: hidden; }
.tabs button { background: transparent; border: 0; padding: 5px 11px; font-size: 12.5px; cursor: pointer; color: var(--muted); }
.tabs button[aria-pressed="true"] { background: var(--card-hi); color: var(--text); font-weight: 650; }
.chart { width: 100%; height: 150px; display: block; margin-top: 8px; }
.chart .grid { stroke: var(--edge); stroke-width: 1; }
.chart .l-cpu { stroke: var(--sky); fill: none; stroke-width: 1.8; }
.chart .l-mem { stroke: #a78bfa; fill: none; stroke-width: 1.8; }
.chart .l-gpu { stroke: var(--ok); fill: none; stroke-width: 1.8; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
.note { color: var(--faint); font-size: 12.5px; }
.detail .foot { margin-top: 14px; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); display: grid; place-items: center; z-index: 20; padding: 16px; }
.modal-box { background: var(--panel); border: 1px solid var(--edge); border-radius: 16px; padding: 20px; width: min(420px, 100%); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; }
.modal-box h2 { margin: 0; font-size: 18px; overflow-wrap: anywhere; }
.modal-box p { margin: 0; color: var(--muted); }
.modal-box input { font: inherit; color: var(--text); background: var(--card-hi); border: 1px solid var(--edge); border-radius: 10px; padding: 9px 12px; }
.modal-box .row { display: flex; justify-content: flex-end; gap: 8px; }

/* add machines (install tokens): a modal drawer over a scrim */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 14; animation: fade-in 0.18s ease-out; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%); background: var(--panel); border-left: 1px solid var(--edge); box-shadow: var(--shadow); z-index: 15; overflow-y: auto; overscroll-behavior: contain; animation: drawer-in 0.22s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes fade-in { from { opacity: 0; } }
@keyframes drawer-in { from { transform: translateX(28px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .scrim, .drawer { animation: none; } }
.drawer-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 10px; padding: 16px 20px 14px; background: var(--panel); border-bottom: 1px solid var(--edge); }
.drawer-head h2 { margin: 0; font-size: 20px; letter-spacing: -0.01em; }
.drawer-head .close { margin-left: auto; }
.drawer-body { padding: 18px 20px 40px; }
.drawer .lede { margin: 0 0 18px; color: var(--muted); text-wrap: balance; }

.token-form { display: flex; flex-direction: column; gap: 16px; padding: 16px; border: 1px solid var(--edge); border-radius: 14px; background: var(--card); }
.field { display: flex; flex-direction: column; align-items: flex-start; gap: 7px; min-width: 0; }
.field-label { font-size: 13px; font-weight: 600; }
.field-label .opt { color: var(--muted); font-weight: 400; }
.input { font: inherit; color: var(--text); background: var(--field); border: 1px solid var(--field-edge); border-radius: 10px; padding: 8px 12px; width: 100%; min-width: 0; }
.input:focus-visible { outline-offset: 1px; }
.input.count { width: 84px; font-variant-numeric: tabular-nums; }
.uses-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-height: 38px; }
.seg { position: relative; display: inline-flex; gap: 2px; padding: 3px; border-radius: 11px; background: var(--seg-track); border: 1px solid var(--edge); }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.seg label { padding: 6px 14px; border-radius: 8px; font-size: 13px; font-weight: 550; color: var(--muted); cursor: pointer; white-space: nowrap; user-select: none; }
.seg label:hover { color: var(--text); }
.seg input:checked + label { background: var(--seg-on); color: var(--text); box-shadow: inset 0 0 0 1px var(--seg-ring), 0 1px 2px rgba(0, 0, 0, 0.12); }
.seg input:focus-visible + label { outline: 2px solid var(--sky); outline-offset: 1px; }
.form-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 10px 12px; }
.form-error { flex: 1 1 220px; margin: 0; color: var(--hot); font-size: 13px; }
.form-error:empty { display: none; }

.tokens { margin-top: 28px; }
.tokens h3 { font-size: 15px; margin: 0 0 10px; }
.token-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--edge); border-radius: 14px; overflow: hidden; }
.token-list li { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--card); border-top: 1px solid var(--edge); }
.token-list li:first-child { border-top: 0; }
.token-list li:focus-visible { outline-offset: -2px; }
.ti-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.ti-head { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; min-width: 0; }
.ti-name { font-weight: 600; overflow-wrap: anywhere; }
.token-list li.past .ti-name { color: var(--muted); font-weight: 550; }
.ti-meta { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.ti-meta span { white-space: nowrap; }
.badge { font-size: 11.5px; line-height: 18px; padding: 0 8px; border-radius: 999px; border: 1px solid var(--edge); color: var(--muted); white-space: nowrap; }
.badge.active { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, var(--edge)); }
.list-msg { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px; border: 1px dashed var(--edge); border-radius: 14px; color: var(--muted); }
.list-msg p { margin: 0; }

/* The token, shown once: one command, picked by platform (polish-spec section 3). */
.reveal-title { font-size: 17px; margin: 0; }
.reveal-meta { margin: 3px 0 0; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.reveal-meta:empty { display: none; }
.callout { display: flex; align-items: flex-start; gap: 10px; margin: 16px 0 0; padding: 10px 12px; border-radius: 12px; font-size: 13px; background: color-mix(in srgb, var(--warn) 11%, var(--panel)); border: 1px solid color-mix(in srgb, var(--warn) 45%, var(--edge)); }
.callout svg { flex: 0 0 18px; width: 18px; height: 18px; margin-top: 1px; fill: none; stroke: var(--warn); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.cmd-card { margin-top: 22px; border: 1px solid var(--edge); border-radius: 12px; background: var(--code); overflow: hidden; }
.cmd-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 8px; background: var(--card); border-bottom: 1px solid var(--edge); }
/* Both commands (and both explainers) share one cell; the unchosen one is invisible,
   so the taller one sets the height and switching moves nothing. */
.stack { display: grid; grid-template-columns: minmax(0, 1fr); }
.stack > * { grid-area: 1 / 1; }
.stack > .off { visibility: hidden; }
.cmd-code { padding: 12px 14px 14px; }
.cmd-code code { display: block; font: 12px/1.7 "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace; white-space: normal; color: var(--text); user-select: all; -webkit-user-select: all; }
.cmd-code code .w { white-space: nowrap; }
.cmd-code code .tok { word-break: break-all; }
.cmd-notes { margin: 8px 0 0; }
.cmd-notes p { margin: 0; color: var(--muted); font-size: 13px; text-wrap: pretty; }
.btn.copy { display: inline-grid; }
.btn.copy > span { grid-area: 1 / 1; display: inline-flex; align-items: center; justify-content: center; gap: 5px; }
.btn.copy svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.btn.copy .c-done { visibility: hidden; color: var(--ok); }
.btn.copy.done .c-idle { visibility: hidden; }
.btn.copy.done .c-done { visibility: visible; }
.btn.primary.copy { min-width: 96px; }
.btn.primary.copy .c-done { color: var(--primary-ink); }
/* A quiet text button; its label lines up with the content edge above it. */
.btn.text { background: transparent; border-color: transparent; color: var(--muted); font-size: 13px; font-weight: 600; padding: 7px 10px; margin-left: -10px; }
.btn.text:hover { background: var(--card-hi); border-color: transparent; color: var(--text); }
.btn.text.copy > span { justify-content: flex-start; }
.reveal-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 26px; }
#reveal-done { min-width: 88px; }


/* ---------------------------------------------------------------- work view */
.work { display: flex; flex-direction: column; gap: 16px; }
.w-card { position: relative; background: var(--card); border: 1px solid var(--edge); border-radius: 16px; padding: 16px; min-width: 0; }
.w-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-bottom: 12px; }
.w-head h2 { font-size: 15px; margin: 0; letter-spacing: -0.005em; }
.w-sub { flex: 1 1 100%; margin: 0; color: var(--muted); font-size: 12.5px; text-wrap: pretty; }
.w-count { color: var(--muted); font-size: 12.5px; }
.w-count:empty { display: none; }
.w-row { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; }
.w-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
/* One column: the cards fall into the spec's order (where next, then the lists). */
@media (max-width: 960px) {
  .w-row { display: flex; flex-direction: column; align-items: stretch; }
  .w-col { display: contents; }
  .next-card { order: 1; }
  .running-card { order: 2; }
  .queued-card { order: 3; }
  .untracked-card { order: 4; }
}
.w-msg { margin: 0; color: var(--muted); font-size: 13px; }
.w-msg.err { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.loading-hold { opacity: 0.55; transition: opacity .2s; }

/* the strip: one chip per lane */
.strip { display: flex; flex-wrap: wrap; gap: 8px; }
.lane-chip { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--edge); background: var(--card); color: var(--text); font-size: 13px; cursor: pointer; white-space: nowrap; }
.lane-chip:hover { border-color: var(--faint); }
.lane-chip[aria-pressed="true"] { background: var(--seg-on); border-color: var(--seg-ring); box-shadow: inset 0 0 0 1px var(--seg-ring); }
.lane-chip b { font-weight: 650; }
.lane-chip .num, .lane-chip .muted { color: var(--muted); font-size: 12px; }
.lane-chip .q { display: inline-flex; align-items: center; gap: 5px; color: var(--text); font-size: 12px; }
.qdot { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); flex: none; }
.lane-chip .off-txt { color: var(--muted); font-size: 12px; }

/* the grid: machines x lanes */
.grid-card { padding: 0; overflow: hidden; }
.grid-card .w-head { padding: 16px 16px 0; }
/* positioned, so screen-reader-only text inside scrolls and clips with the grid */
/* A soft shadow at an edge says there is more grid that way (it scrolls with the
   content: the covers move with it, the shadows stay with the box). */
.grid-wrap { position: relative; overflow-x: auto; overscroll-behavior-x: contain;
  background:
    linear-gradient(to left, var(--card) 40%, transparent) right center / 48px 100% no-repeat local,
    radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, 0.45), transparent) right center / 16px 100% no-repeat scroll;
  background-color: var(--card); }
[data-theme="light"] .grid-wrap { background:
    linear-gradient(to left, var(--card) 40%, transparent) right center / 48px 100% no-repeat local,
    radial-gradient(farthest-side at 100% 50%, rgba(20, 20, 30, 0.16), transparent) right center / 16px 100% no-repeat scroll;
  background-color: var(--card); }
table.wgrid { border-collapse: separate; border-spacing: 0; table-layout: fixed; width: 100%; }
table.wgrid th, table.wgrid td { text-align: left; vertical-align: top; border-top: 1px solid var(--edge); padding: 0; }
table.wgrid thead th { border-top: 0; padding: 8px 10px 8px; font-size: 12px; font-weight: 650; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
table.wgrid thead th.mcol { padding-left: 16px; }
table.wgrid th[scope="row"] { position: sticky; left: 0; z-index: 1; background: var(--card); padding: 10px 10px 10px 16px; font-weight: 400; border-right: 1px solid var(--edge); }
table.wgrid thead th.mcol { position: sticky; left: 0; z-index: 2; background: var(--card); border-right: 1px solid var(--edge); }
table.wgrid td { padding: 4px; }
table.wgrid td + td, table.wgrid th + td { border-left: 1px solid color-mix(in srgb, var(--edge) 55%, transparent); }
.mh { display: flex; align-items: flex-start; gap: 8px; min-width: 0; }
.mh .dot { margin-top: 5.5px; }
.mh-text { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.mh-name { font-weight: 650; font-size: 13.5px; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.mh-sub { color: var(--muted); font-size: 12px; }
.nowrap { white-space: nowrap; }
.stack-sub { display: flex; flex-direction: column; }
.lc { display: flex; flex-direction: column; gap: 6px; padding: 6px; border-radius: 10px; min-height: 100%; }
.lc:focus-visible { outline: 2px solid var(--sky); outline-offset: -2px; }
.lc-top { display: flex; align-items: center; gap: 6px; min-height: 18px; }
.lc-lane { display: none; font-weight: 650; font-size: 12.5px; }
.lc-count { margin-left: auto; font-size: 12px; color: var(--muted); white-space: nowrap; }
.lc-count b { color: var(--text); font-weight: 650; }
.rank { font-size: 10.5px; font-weight: 700; line-height: 16px; padding: 0 6px; border-radius: 999px; border: 1px solid var(--edge); color: var(--muted); white-space: nowrap; }
.rank.r1 { color: var(--rank1); border-color: color-mix(in srgb, var(--accent) 55%, var(--edge)); }
.ranks { display: flex; flex-wrap: wrap; gap: 3px; min-width: 0; }
.none-cell { display: block; padding: 10px 6px; color: var(--faint); font-size: 12px; }
/* a slot bar: one segment per slot, busy filled; waiting jobs as hollow pips after it */
.slots { display: flex; align-items: center; gap: 6px; }
.segs { flex: 1; display: flex; gap: 2px; height: 8px; min-width: 0; }
.segs i { flex: 1; border-radius: 2px; background: var(--track); min-width: 2px; }
.segs i.busy { background: var(--sky); }
.segs.cont { border-radius: 99px; background: var(--track); overflow: hidden; gap: 0; }
.segs.cont i { flex: none; height: 100%; border-radius: 0; background: var(--sky); }
.pips { display: flex; gap: 2px; flex: none; align-items: center; }
.pips i { width: 8px; height: 8px; border-radius: 2px; border: 1.5px solid var(--warn); }
.pips span { font-size: 11px; color: var(--muted); margin-left: 2px; }
.lc.stale .segs i.busy, .lc.stale .segs.cont i { background: var(--off); }
.lc.stale .pips i { border-color: var(--off); }
.stale-note { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; }
.stale-note span { white-space: nowrap; }
/* job chips */
.jobs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.job { min-width: 0; padding: 4px 6px; border-radius: 7px; background: var(--card-hi); border: 1px solid var(--edge); display: flex; flex-direction: column; gap: 1px; }
.job.wait { background: transparent; border-style: dashed; border-color: color-mix(in srgb, var(--warn) 60%, var(--edge)); }
/* A label wraps to two lines (most break at their " · "), then ends in "…". */
.j-label { font-size: 11.5px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.j-meta { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); min-width: 0; }
.j-by { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.j-time { flex: none; white-space: nowrap; color: var(--text); display: inline-flex; align-items: center; gap: 3px; }
.j-time svg { width: 11px; height: 11px; fill: none; stroke: var(--warn); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.more { font-size: 11.5px; color: var(--muted); padding: 0 2px; }

/* where next */
.next { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.next li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; align-items: center; padding: 8px 0; border-top: 1px solid color-mix(in srgb, var(--edge) 60%, transparent); }
.next li:first-child { border-top: 0; padding-top: 0; }
.nx-kind { font-weight: 650; font-size: 13px; }
.nx-what { grid-column: 1; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nx-to { grid-column: 2; grid-row: 1 / span 2; justify-self: end; text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.nx-host { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; }
.nx-free { font-size: 12px; color: var(--muted); }
.nx-full { font-size: 12.5px; color: var(--text); display: inline-flex; align-items: center; gap: 6px; }

/* lists */
.wtable { width: 100%; border-collapse: collapse; font-size: 12.5px; table-layout: fixed; }
.wtable th { text-align: left; color: var(--faint); font-weight: 600; padding: 0 10px 6px 0; border-bottom: 1px solid var(--edge); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wtable td { padding: 7px 10px 7px 0; border-bottom: 1px solid color-mix(in srgb, var(--edge) 60%, transparent); vertical-align: top; min-width: 0; }
.wtable tr:last-child td { border-bottom: 0; }
.wtable .num { text-align: right; white-space: nowrap; }
.wtable th.num { text-align: right; }
.wtable tr > :last-child { padding-right: 0; }
.wtable .t-label { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wtable .t-cut { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.sort { background: transparent; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.sort svg { width: 10px; height: 10px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.res-ok { color: var(--ok); font-weight: 700; }
.res-fail { color: var(--hot); font-weight: 650; }
.res-ab { color: var(--muted); }
.show-more { margin-top: 10px; }

/* history */
.history-card .w-head .seg { margin-left: auto; }
.history-card h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); margin: 18px 0 10px; display: flex; align-items: center; gap: 10px; }
.history-card h3:first-child { margin-top: 4px; }
.h-row { display: flex; align-items: center; gap: 10px; margin: 4px 0 10px; }
.h-row h3 { margin: 0 !important; }
.h-row .btn { margin-left: auto; }
.legend.machines { flex-wrap: wrap; gap: 6px 14px; margin: 0 0 12px; }
.legend.machines i { width: 10px; height: 10px; border-radius: 3px; }
.smalls { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.sm { border: 1px solid var(--edge); border-radius: 12px; padding: 10px 12px 8px; background: var(--card); min-width: 0; }
.sm-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.sm-head b { font-size: 13px; }
.sm-head span { color: var(--muted); font-size: 12px; margin-left: auto; white-space: nowrap; }
.plot { position: relative; height: 84px; outline: none; touch-action: pan-y; }
.plot:focus-visible { outline: 2px solid var(--sky); outline-offset: 3px; border-radius: 4px; }
.plot svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; overflow: visible; }
.plot .cap { fill: none; stroke: var(--faint); stroke-width: 1; }
.plot .gridl { stroke: var(--edge); stroke-width: 1; }
.plot .band { stroke: var(--card); stroke-width: 1.5; stroke-linejoin: round; }
.plot .qbar { fill: var(--warn); }
.cross { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--text); opacity: .55; pointer-events: none; }
.sm-axis { display: flex; justify-content: space-between; color: var(--faint); font-size: 11px; margin-top: 4px; }
.m1 { fill: var(--c1); background: var(--c1); } .m2 { fill: var(--c2); background: var(--c2); }
.m3 { fill: var(--c3); background: var(--c3); } .m4 { fill: var(--c4); background: var(--c4); }
.m5 { fill: var(--c5); background: var(--c5); } .m6 { fill: var(--c6); background: var(--c6); }
.m7 { fill: var(--c7); background: var(--c7); }
.m0 { fill: var(--c0); background: var(--c0); }
.tip { position: fixed; z-index: 30; pointer-events: none; background: var(--panel); border: 1px solid var(--edge); border-radius: 10px; box-shadow: var(--shadow); padding: 8px 10px; font-size: 12px; min-width: 150px; max-width: 280px; }
.tip-t { color: var(--muted); margin-bottom: 4px; }
.tip-row { display: flex; align-items: center; gap: 8px; }
.tip-row i { width: 10px; height: 3px; border-radius: 2px; flex: none; }
.tip-row span { flex: 1; min-width: 0; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tip-row b { font-weight: 650; font-variant-numeric: tabular-nums; }
/* by kind */
.kinds .kcols { display: flex; align-items: flex-end; gap: 1px; height: 22px; width: 100%; max-width: 160px; }
.kinds .kcols i { flex: 1; background: var(--sky); border-radius: 1.5px 1.5px 0 0; min-height: 1px; }
.kinds .kcols i.zero { background: var(--track); }
.kinds td { vertical-align: middle; }
.rng { position: relative; height: 10px; margin-top: 4px; max-width: 160px; }
.rng::before { content: ""; position: absolute; left: 0; right: 0; top: 4.5px; height: 1px; background: var(--edge); }
.rng .r-line { position: absolute; top: 3px; height: 4px; border-radius: 2px; background: color-mix(in srgb, var(--sky) 45%, transparent); }
.rng .r-dot { position: absolute; top: 1px; width: 8px; height: 8px; margin-left: -4px; border-radius: 50%; background: var(--sky); box-shadow: 0 0 0 2px var(--card); }
.fail-n { display: inline-flex; align-items: center; gap: 4px; }
.fail-n svg { width: 11px; height: 11px; fill: none; stroke: var(--hot); stroke-width: 2; stroke-linecap: round; }
.k-note { margin: 8px 0 0; color: var(--muted); font-size: 12px; }
/* took the most time */
.tops { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.tops li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 12px; align-items: baseline; }
.tops .tl { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tops .tv { font-size: 12px; color: var(--muted); white-space: nowrap; }
.tops .tb { grid-column: 1 / -1; height: 6px; border-radius: 99px; background: var(--track); overflow: hidden; }
.tops .tb i { display: block; height: 100%; border-radius: inherit; background: var(--sky); }
.h-cols { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 24px; }

@media (max-width: 1024px) {
  .who { display: none; }
}
@media (max-width: 720px) {
  .top { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "brand views actions" "status status add"; gap: 8px 12px; padding: 10px 16px; }
  .brand { grid-area: brand; }
  .views { grid-area: views; justify-self: start; }
  .actions { grid-area: actions; }
  .status { grid-area: status; min-height: 30px; margin-right: 0; flex-wrap: wrap; gap: 2px 12px; }
  .add-top { grid-area: add; justify-self: end; }
  .fleet-main { padding: 14px 16px; }
  .fleet { grid-template-columns: 1fr; }
  /* One column: a long name wraps (two lines at most) instead of being cut, as on iOS. */
  .card .name { white-space: normal; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; }
  .detail { padding: 16px 16px 40px; }
  .drawer-head { padding: 14px 16px 12px; }
  .drawer-body { padding: 16px 16px 40px; }
  .token-form { padding: 14px; }
  .cmd-code { padding: 10px 12px 12px; }
  /* Work: the grid becomes one card per machine, its lanes one under another. */
  .w-card { padding: 14px; }
  .grid-card { padding: 0; }
  .grid-card .w-head { padding: 14px 14px 0; }
  .strip { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 0 16px 2px; scrollbar-width: none; }
  .strip::-webkit-scrollbar { display: none; }
  table.wgrid, table.wgrid tbody, table.wgrid tr, table.wgrid th, table.wgrid td { display: block; width: auto !important; min-width: 0 !important; }
  .grid-wrap { background: none; }
  table.wgrid colgroup, table.wgrid thead { display: none; }
  table.wgrid tr { border-top: 1px solid var(--edge); padding: 4px 0 8px; }
  table.wgrid th[scope="row"] { position: static; border: 0; padding: 10px 14px 4px; background: transparent; }
  table.wgrid td { border: 0 !important; padding: 0 8px; }
  table.wgrid td.empty-cell { display: none; }
  .lc-lane { display: inline; }
  /* One line per lane: its name, place in line and count, then the bar; jobs below. */
  .lc { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 38%); align-items: center; gap: 6px 12px; padding: 6px; }
  .lc .jobs, .lc .stale-note { grid-column: 1 / -1; }
  .lc .stale-note { flex-direction: row; gap: 4px; }
  .lc .stale-note span + span::before { content: "· "; }
  .h-cols { grid-template-columns: minmax(0, 1fr); }
  .smalls { grid-template-columns: minmax(0, 1fr); }
  /* list tables become stacked rows */
  .wtable, .wtable tbody, .wtable tr, .wtable td { display: block; width: auto; }
  .wtable thead { display: none; }
  .wtable tr { padding: 8px 0; border-bottom: 1px solid color-mix(in srgb, var(--edge) 60%, transparent); display: flex; flex-wrap: wrap; gap: 2px 10px; }
  .wtable tr:last-child { border-bottom: 0; }
  .wtable td { border: 0; padding: 0; color: var(--muted); font-size: 12px; min-width: 0; max-width: 100%; }
  .wtable td.t-first { flex-basis: 100%; color: var(--text); font-size: 13px; }
  .wtable td.num { text-align: left; }
  .wtable td[data-h]::before { content: attr(data-h) " "; color: var(--faint); }
  /* By kind: one small block per kind, the per-hour shape across its width. */
  .wtable.kinds tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 14px; padding: 10px 0; }
  .wtable.kinds td { color: var(--text); }
  .wtable.kinds td.t-first { order: 0; grid-column: 1 / -1; font-weight: 650; }
  .wtable.kinds td.k-hour { order: 1; grid-column: 1 / -1; }
  .wtable.kinds td.k-wait { order: 2; }
  .wtable.kinds td.k-dur { order: 3; }
  .wtable.kinds td.k-jobs { order: 4; }
  .wtable.kinds td.k-fail { order: 5; }
  .wtable.kinds td[data-h]::before { display: block; font-size: 11.5px; margin-bottom: 2px; }
  .wtable.kinds .kcols, .wtable.kinds .rng { max-width: none; }
}
@media (max-width: 479px) {
  .top.has-views .wordmark { display: none; }
}
