/* MinerQA - "Minimalism & Swiss" ops dashboard (ui-ux-pro-max design system:
   operational green / incident red / maintenance amber, Fira Sans + Fira Code, dense spacing). */
:root {
  --bg: #f4f6fb; --panel: #ffffff; --ink: #161a33; --muted: #4f5670; --line: #dde1ee; --line-strong: #c3c9de;
  --primary: #4338ca; --primary-ink: #ffffff; --primary-soft: #eceefe;
  --accent: #0e7490; --accent-ink: #ffffff; --ring: #6366f1;
  --heading: #312e81; --panel-top: #c7cdf5;
  --pass: #15803d; --pass-bg: #e6f8eb; --fail: #c81e1e; --fail-bg: #fde8e8;
  --warn: #92560a; --warn-bg: #fdf1d6; --info: #0369a1; --info-bg: #e0f2fe;
  --warming: #c2410c; --warming-bg: #ffedd5; --config: #a21caf; --config-bg: #fae8ff;
  --idle: #4f5670; --idle-bg: #e9ecf4;
  --header: #1e1b4b; --header-ink: #e0e7ff; --header-muted: #a5b4fc; --header-accent: #22d3ee;
  --shadow: 0 1px 2px rgba(22, 26, 51, .06), 0 1px 1px rgba(22, 26, 51, .04);
  --radius: 8px;
  --font: "Fira Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Fira Code", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px;
  color-scheme: light;
}
/* Theme: Auto (no data-theme) follows the system; a theme picked in the footer sets data-theme on <html>. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #0d1020; --panel: #151a2e; --ink: #e6e9f5; --muted: #a0a8c3; --line: #262c45; --line-strong: #3a4263;
    --primary: #818cf8; --primary-ink: #0b0d1f; --primary-soft: #1f2450;
    --accent: #22d3ee; --accent-ink: #04141a; --ring: #a5b4fc;
    --heading: #c7d2fe; --panel-top: #3b3f8f;
    --pass: #4ade80; --pass-bg: #123222; --fail: #f87171; --fail-bg: #3a1616;
    --warn: #fbbf24; --warn-bg: #33270c; --info: #38bdf8; --info-bg: #0c2a3d;
    --warming: #fb923c; --warming-bg: #3a1d0a; --config: #e879f9; --config-bg: #3a1340;
    --idle: #a0a8c3; --idle-bg: #1f2438;
    --header: #090b18; --header-ink: #e6e9f5; --header-muted: #a5b4fc; --header-accent: #22d3ee;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --bg: #0d1020; --panel: #151a2e; --ink: #e6e9f5; --muted: #a0a8c3; --line: #262c45; --line-strong: #3a4263;
    --primary: #818cf8; --primary-ink: #0b0d1f; --primary-soft: #1f2450;
    --accent: #22d3ee; --accent-ink: #04141a; --ring: #a5b4fc;
    --heading: #c7d2fe; --panel-top: #3b3f8f;
    --pass: #4ade80; --pass-bg: #123222; --fail: #f87171; --fail-bg: #3a1616;
    --warn: #fbbf24; --warn-bg: #33270c; --info: #38bdf8; --info-bg: #0c2a3d;
    --warming: #fb923c; --warming-bg: #3a1d0a; --config: #e879f9; --config-bg: #3a1340;
    --idle: #a0a8c3; --idle-bg: #1f2438;
    --header: #090b18; --header-ink: #e6e9f5; --header-muted: #a5b4fc; --header-accent: #22d3ee;
    --shadow: none;
    color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 14px/1.5 var(--font); font-feature-settings: "tnum" 1; }
a { color: var(--primary); text-decoration: none; transition: color .2s; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: 4px; }
h1 { font-size: 22px; font-weight: 600; letter-spacing: -.01em; margin: 0 0 var(--s3); color: var(--heading); }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 var(--s3); color: var(--heading); }
h3 { font-size: 11.5px; font-weight: 600; margin: 0 0 var(--s2); color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }
small, .muted { color: var(--muted); }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
code { background: var(--idle-bg); padding: 1px 5px; border-radius: 4px; }
pre { background: var(--bg); border: 1px solid var(--line); padding: var(--s3); overflow: auto; max-height: 480px; border-radius: var(--radius); }
pre code { background: none; padding: 0; }
.skip { position: absolute; left: -999px; top: 0; background: var(--primary); color: var(--primary-ink); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; top: 8px; }
.icon { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }

/* header */
header.top { display: flex; align-items: center; gap: var(--s5); padding: 0 var(--s5); min-height: 52px; background: var(--header); color: var(--header-ink); position: sticky; top: 0; z-index: 10; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: var(--s2); font-weight: 700; font-size: 16px; color: var(--header-ink); letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand .logo { width: 22px; height: 22px; border-radius: 6px; background: linear-gradient(135deg, var(--primary), var(--accent)); display: grid; place-items: center; color: #fff; }
.brand .logo .icon { width: 14px; height: 14px; }
header nav { display: flex; gap: 2px; flex-wrap: wrap; }
header nav a { display: flex; align-items: center; gap: 6px; padding: 7px 11px; border-radius: 6px; color: var(--header-muted); font-weight: 500; transition: background .2s, color .2s; }
header nav a:hover { color: var(--header-ink); background: rgba(255, 255, 255, .07); text-decoration: none; }
header nav a.on { color: var(--header-ink); background: rgba(255, 255, 255, .12); box-shadow: inset 0 -2px 0 var(--header-accent); }
.who { margin-left: auto; display: flex; gap: var(--s3); align-items: center; color: var(--header-muted); }
.who b { color: var(--header-ink); font-weight: 500; }
.who form { margin: 0; }
.who button.link { color: var(--header-muted); }
.who button.link:hover { color: var(--header-ink); }

/* layout */
main { padding: var(--s5); max-width: 1640px; margin: 0 auto; }
.panel { background: var(--panel); border: 1px solid var(--line); border-top: 2px solid var(--panel-top); border-radius: var(--radius); padding: var(--s4); margin-bottom: var(--s4); box-shadow: var(--shadow); }
.grid { display: grid; gap: var(--s4); }
.g2 { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.row { display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; }
.row > h1, .row > h2 { margin-bottom: 0; }
.row + * { margin-top: var(--s3); }
.spacer { flex: 1; }

/* stat tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--s3); margin-bottom: var(--s4); }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s3) var(--s4); box-shadow: var(--shadow); position: relative; overflow: hidden; }
.tile::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--primary); }
.tile:nth-child(3)::before { background: var(--pass); }
.tile:nth-child(4)::before { background: var(--fail); }
.tile:nth-child(5)::before { background: var(--info); }
.tile:nth-child(7)::before { background: var(--warn); }
.tile .k { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.tile .v { font-size: 26px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.25; margin-top: 2px; }
.tile .v small { font-size: 15px; font-weight: 500; }
.tile .s { font-size: 12px; color: var(--muted); }
.tile a { color: inherit; }
.tile a:hover { text-decoration: none; }
.tile a:hover .v { color: var(--primary); }

/* bars */
.bar { height: 10px; background: var(--idle-bg); border-radius: 999px; overflow: hidden; display: flex; }
.bar > span { display: block; height: 100%; transition: width .4s ease-out; }
.bar .pass { background: var(--pass); } .bar .fail { background: var(--fail); }
.bar .run { background: var(--info); } .bar .fill { background: var(--primary); }
/* adaptive test past its earliest decision: full, striped, still running */
.bar .run.extended { background: repeating-linear-gradient(-45deg, var(--info) 0 8px, color-mix(in srgb, var(--info) 60%, var(--panel)) 8px 16px);
  background-size: 22.6px 22.6px; animation: stripes 1s linear infinite; }
@keyframes stripes { to { background-position: 22.6px 0; } }
.legend { display: flex; gap: var(--s4); font-size: 12px; color: var(--muted); margin-top: var(--s2); flex-wrap: wrap; }
.legend a { color: var(--muted); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: 0; }

/* tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; background: var(--panel); position: sticky; top: 0; }
th a { color: inherit; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr { transition: background .15s; }
tbody tr:hover { background: var(--primary-soft); }
tbody tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }
.panel.table-wrap { padding: 0; }
.panel.table-wrap > table th:first-child, .panel.table-wrap > table td:first-child { padding-left: var(--s4); }
.panel.table-wrap .pager { padding: var(--s3) var(--s4); border-top: 1px solid var(--line); margin: 0; }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; letter-spacing: .02em; padding: 2px 8px; border-radius: 999px; white-space: nowrap; background: var(--idle-bg); color: var(--idle); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.b-PASS, .b-IN-SYNC { background: var(--pass-bg); color: var(--pass); }
.b-FAIL, .b-FAILED { background: var(--fail-bg); color: var(--fail); }
.b-TESTING, .b-APPLYING { background: var(--info-bg); color: var(--info); }
.b-WARMING_UP { background: var(--warming-bg); color: var(--warming); }
.b-CONFIGURING { background: var(--config-bg); color: var(--config); }
.b-PENDING { background: var(--warn-bg); color: var(--warn); }
.b-offline { background: var(--fail-bg); color: var(--fail); }
.b-blink { background: var(--primary); color: var(--primary-ink); }
.b-blink::before { animation: blink 1s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }
.flag { color: var(--fail); font-weight: 600; }
.reasons { margin: 0; padding-left: 16px; color: var(--fail); }
.reasons li { margin: 0; }

/* forms */
form.inline { display: inline; margin: 0; }
input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=password], input[type=number], input[type=search], select, textarea {
  background: var(--panel); border: 1px solid var(--line-strong); border-radius: 6px; padding: 6px 10px; min-height: 34px; min-width: 0; transition: border-color .2s, box-shadow .2s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ring); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 25%, transparent); }
input[type=checkbox], input[type=radio] { accent-color: var(--primary); width: 15px; height: 15px; vertical-align: -2px; cursor: pointer; }
textarea { width: 100%; font-family: var(--mono); font-size: 12.5px; }
button, .btn { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; background: var(--panel); border: 1px solid var(--line-strong); border-radius: 6px; padding: 5px 13px; cursor: pointer; color: var(--ink); font-weight: 500; transition: background .2s, border-color .2s, color .2s; }
button:hover, .btn:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
button.primary, .btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
button.primary:hover, .btn.primary:hover { filter: brightness(1.08); color: var(--primary-ink); }
button.danger { color: var(--fail); border-color: color-mix(in srgb, var(--fail) 50%, transparent); }
button.danger:hover { background: var(--fail); color: #fff; border-color: var(--fail); }
button.link { background: none; border: 0; padding: 0; min-height: 0; color: var(--primary); }
button:disabled, button:disabled:hover { opacity: .45; cursor: not-allowed; color: var(--ink); border-color: var(--line-strong); background: var(--panel); }
label { display: block; cursor: pointer; }
.field { margin-bottom: var(--s3); cursor: default; }
.field > span { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 3px; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--s1) var(--s4); }
.fields input, .fields select { width: 100%; }

.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: var(--s3); border: 1px solid transparent; font-weight: 500; }
.flash.ok { background: var(--pass-bg); color: var(--pass); border-color: color-mix(in srgb, var(--pass) 25%, transparent); }
.flash.err { background: var(--fail-bg); color: var(--fail); border-color: color-mix(in srgb, var(--fail) 25%, transparent); }
.flash.warn { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.toolbar { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; margin-bottom: var(--s3); }
.bulk { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s2) var(--s3); }
.pager { display: flex; gap: var(--s3); align-items: center; margin-top: var(--s3); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 5px var(--s4); margin: 0; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; }
.login { max-width: 360px; margin: 14vh auto; padding: var(--s5); }
.login .brand { color: var(--ink); font-size: 20px; margin-bottom: var(--s1); }
.login input { width: 100%; }
.login button { width: 100%; justify-content: center; margin-top: var(--s2); }
.chart-box { position: relative; height: 220px; }
.health-ok { color: var(--pass); font-weight: 600; } .health-bad { color: var(--fail); font-weight: 600; }
.lvl-WARNING { color: var(--warn); font-weight: 600; } .lvl-ERROR, .lvl-CRITICAL { color: var(--fail); font-weight: 600; }
details > summary { cursor: pointer; color: var(--primary); font-weight: 500; }

@media (prefers-reduced-motion: reduce) {
  *, *::before { transition: none !important; animation: none !important; }
}
@media (max-width: 640px) {
  .g2, .g3 { grid-template-columns: 1fr; }
  header.top { padding: var(--s2) var(--s4); gap: var(--s2); }
  main { padding: var(--s4); }
}

/* settings: advanced dropdown */
details.advanced > summary { list-style: none; display: flex; align-items: baseline; gap: var(--s3); color: var(--ink); }
details.advanced > summary::-webkit-details-marker { display: none; }
details.advanced > summary::before { content: "▸"; color: var(--muted); transition: transform .2s; display: inline-block; }
details.advanced[open] > summary::before { transform: rotate(90deg); }
details.advanced[open] > summary { margin-bottom: var(--s3); }
form.sub { border-top: 1px solid var(--line); padding-top: var(--s4); margin-top: var(--s4); }
form.sub h3 { margin-top: var(--s3); }
section.panel { scroll-margin-top: 64px; }

/* unit profile popup */
dialog#unit-modal { width: min(1180px, 96vw); max-height: 92vh; padding: 0; border: 1px solid var(--line); border-radius: 12px;
  background: var(--bg); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
dialog#unit-modal::backdrop { background: rgba(9, 11, 24, .55); }
dialog#unit-modal[open] { animation: pop .18s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.99); } }
#modal-body { padding: var(--s5); overflow: auto; max-height: 92vh; }
.profile-head { display: flex; gap: var(--s3); align-items: flex-start; flex-wrap: wrap; margin-bottom: var(--s3); }
.profile .tiles { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.profile .panel h3 { margin-bottom: var(--s2); }
tr.clickable { cursor: pointer; }
.chipmap { display: inline-flex; flex-wrap: wrap; gap: 1px; max-width: 240px; vertical-align: middle; }
.chipmap i { width: 5px; height: 9px; border-radius: 1px; background: var(--pass); opacity: .8; }
.chipmap i.c-bad { background: var(--fail); opacity: 1; }

/* dashboard unit strip: tiny chips with a status blob */
.units-panel { padding-bottom: var(--s5); }
.units-panel > form { margin-bottom: var(--s4); }
.strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: var(--s2); }
.strip .empty { grid-column: 1 / -1; margin: var(--s3) 0; }
.chip { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 7px 12px 7px 10px; border-radius: 999px;
  background: var(--bg); border: 1px solid var(--line); text-align: left; width: 100%; justify-content: flex-start; }
.chip:hover { border-color: var(--primary); color: inherit; background: var(--primary-soft); }
.chip:hover .blob { transform: scale(1.12); }
.chip-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.chip-model { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip-ip { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }

.blob { --c: var(--idle); --p: 0; position: relative; flex: none; display: inline-block; width: 22px; height: 22px; border-radius: 50%;
  background: var(--c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 22%, transparent); transition: transform .2s; }
.blob.s-DISCOVERED { --c: var(--idle); }
.blob.s-CONFIGURING { --c: var(--config); }
.blob.s-WARMING_UP { --c: var(--warming); animation: breathe 2.2s ease-in-out infinite; }
.blob.s-TESTING { --c: var(--info); background: conic-gradient(var(--c) calc(var(--p) * 1%), color-mix(in srgb, var(--c) 25%, var(--panel)) 0); }
.blob.s-TESTING::after { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: var(--panel); }
.blob.s-PASS { --c: var(--pass); }
.blob.s-FAIL { --c: var(--fail); }
.blob.off { --c: var(--idle); background: transparent; box-shadow: inset 0 0 0 2px var(--idle); }
.blob.ident { animation: ident 1s ease-in-out infinite; }
@keyframes breathe { 50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--c) 12%, transparent); } }
/* LOST: left the bench before its test finished. The whole chip blinks red until resolved. */
.chip.lost { background: var(--fail-bg); border-color: var(--fail); animation: lost-chip 1s steps(1, end) infinite; }
.chip.lost .chip-model, .chip.lost .chip-ip { color: var(--fail); font-weight: 700; }
.blob.lost { --c: var(--fail); background: var(--fail); box-shadow: none; }
.blob.lost::after { content: "!"; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px; background: none; }
.chip.lost .chip-model, .chip.lost .chip-ip { animation: lost-text 1s steps(1, end) infinite; }
@keyframes lost-chip { 50% { background: var(--fail); } }
@keyframes lost-text { 50% { color: #fff; } }
.chip.lost:hover { animation-play-state: paused; }
.lost-banner { border-width: 2px; border-color: var(--fail); }
.lost-banner form { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-weight: 400; }
.lost-banner input[type=text] { flex: 1 1 220px; }
@keyframes ident { 50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--c) 45%, transparent); } }
.legend.blobs { margin: 0; gap: var(--s3); }
.legend.blobs .blob { width: 11px; height: 11px; margin-right: 5px; vertical-align: -1px; box-shadow: none; animation: none; }
.legend.blobs .blob.s-TESTING::after { inset: 3px; }

.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 2px; }
.seg label { margin: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 4px 14px; border-radius: 999px; font-size: 13px; font-weight: 500; color: var(--muted); transition: background .2s, color .2s; }
.seg input:checked + span { background: var(--panel); color: var(--ink); box-shadow: var(--shadow), 0 0 0 1px var(--line); }
.seg input:focus-visible + span { outline: 2px solid var(--ring); }

.bar.slim { height: 6px; margin: calc(-1 * var(--s2)) 0 var(--s4); }
table.compact td { padding: 5px 6px; }
.exports { margin: var(--s2) 0 var(--s4); }
.brand img { display: block; }
.login .brand { display: flex; align-items: center; gap: 10px; }

/* logs tabs */
.tabs { display: inline-flex; gap: 2px; background: var(--idle-bg); padding: 3px; border-radius: 8px; margin-left: var(--s3); }
.tabs a { padding: 5px 12px; border-radius: 6px; color: var(--muted); font-weight: 500; }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.tabs a.on { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }

/* test report */
.report-head { display: flex; gap: var(--s4); align-items: center; }
.report-badge { font-size: 20px; font-weight: 700; letter-spacing: .04em; padding: 14px 18px; border-radius: 10px; }
.report-badge.b-PASS { background: var(--pass); color: #fff; }
.report-badge.b-FAIL { background: var(--fail); color: #fff; }

.board { border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s3); margin-bottom: var(--s3); }
.board-head { display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; }
.board-sn { font-size: 14px; font-weight: 600; background: var(--idle-bg); padding: 2px 8px; border-radius: 6px; }
.board-stats { display: flex; flex-wrap: wrap; gap: 6px var(--s4); margin: var(--s2) 0; font-size: 13px; }
.board-stats small { color: var(--muted); margin-right: 3px; }
.chipgrid { display: grid; grid-template-columns: repeat(auto-fill, 11px); gap: 3px; }
.chipgrid i { width: 11px; height: 11px; border-radius: 3px; background: var(--pass); opacity: .85; }
.chipgrid i.c-bad { background: var(--fail); opacity: 1; }

/* footer + theme switch */
footer.site { max-width: 1640px; margin: 0 auto; padding: var(--s3) var(--s5) var(--s5); display: flex; gap: var(--s3);
  align-items: center; justify-content: space-between; color: var(--muted); font-size: 12px; flex-wrap: wrap; }
.theme-switch .seg span { padding: 3px 12px; font-size: 12px; }

pre.logtail { max-height: 260px; margin: 0; font-size: 11.5px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
pre.logtail.issues { color: var(--fail); }
.chipmap i.c-warn, .chipgrid i.c-warn { background: #f59e0b; opacity: 1; }

/* report-an-issue button */
.report-fab { position: fixed; left: calc(16px + env(safe-area-inset-left, 0px)); bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 40; width: 44px; height: 44px; min-height: 44px; padding: 0; border-radius: 50%; justify-content: center;
  font: italic 700 18px/1 Georgia, "Times New Roman", serif; color: var(--muted);
  background: color-mix(in srgb, var(--panel) 45%, transparent); border: 1px solid color-mix(in srgb, var(--line-strong) 70%, transparent);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); opacity: .55; transition: opacity .2s, color .2s, border-color .2s; }
.report-fab:hover, .report-fab:focus-visible { opacity: 1; color: var(--primary); border-color: var(--primary); }
dialog#report-dialog { width: min(480px, 94vw); border: 1px solid var(--line); border-radius: 12px; padding: var(--s5);
  background: var(--panel); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
dialog#report-dialog::backdrop { background: rgba(9, 11, 24, .45); }
dialog#dead-dialog { width: min(640px, 94vw); border: 1px solid var(--line); border-radius: 12px; padding: var(--s5);
  background: var(--panel); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
dialog#dead-dialog::backdrop { background: rgba(9, 11, 24, .45); }

/* ---- iPad / touch -------------------------------------------------------------------- */
html { -webkit-tap-highlight-color: transparent; }
header.top { padding-top: env(safe-area-inset-top, 0px); padding-left: max(var(--s5), env(safe-area-inset-left, 0px));
  padding-right: max(var(--s5), env(safe-area-inset-right, 0px)); }
header nav { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
header nav::-webkit-scrollbar { display: none; }
header nav a { white-space: nowrap; }
.table-wrap, #modal-body, pre { -webkit-overflow-scrolling: touch; }
dialog#unit-modal { max-height: 92dvh; }
#modal-body { max-height: 92dvh; overscroll-behavior: contain; }

@media (pointer: coarse) {
  /* iOS zooms into inputs smaller than 16px */
  input[type=text], input[type=password], input[type=number], input[type=search], select, textarea { font-size: 16px; min-height: 44px; }
  button, .btn { min-height: 44px; padding: 8px 16px; }
  header nav a { padding: 11px 13px; }
  .seg span { padding: 9px 16px; }
  .chip { min-height: 52px; }
  .tabs a { padding: 10px 14px; }
  input[type=checkbox], input[type=radio] { width: 20px; height: 20px; }
  tbody tr:hover { background: transparent; }
  .chip:hover { background: var(--bg); border-color: var(--line); }
  .chip:active { background: var(--primary-soft); border-color: var(--primary); }
}

/* iPad portrait (768-1024px): tighten the header, two-column grids */
@media (max-width: 1100px) {
  header.top { gap: var(--s3); }
  .who small { display: none; }
  .g3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
  .g2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
  main { padding: var(--s4); }
  dialog#unit-modal { width: 98vw; }
  #modal-body { padding: var(--s4); }
}
@media (max-width: 820px) {
  header.top { flex-wrap: wrap; row-gap: 0; }
  header nav { order: 3; width: 100%; padding-bottom: 6px; }
  .who { margin-left: auto; }
  .strip { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .units-panel > form input[type=search] { width: 100% !important; }
}

/* PASS with warnings = yellow */
.b-PASS-WARN { background: var(--warn-bg); color: var(--warn); }
.report-badge.b-PASS-WARN { background: #e0a20b; color: #2b1d00; }
.blob.s-PASS.warn { --c: #e0a20b; }

/* where new units are filed (dashboard banner) */
.flash.filing { display: flex; flex-wrap: wrap; gap: 4px 24px; align-items: center; justify-content: space-between; padding: 10px 14px; }
.flash.filing a { text-decoration: underline; }

/* history page legend swatches */
.legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 4px; border: 1px solid transparent; }

/* History: failures by part */
table.parts .bar { display: inline-block; vertical-align: middle; width: 100%; height: 10px; border-radius: 5px; background: var(--line); overflow: hidden; }
table.parts .bar i { display: block; height: 100%; background: var(--fail); }
table.compact.parts .bar { width: 100%; }  /* dashboard panel: no % text beside the bar */
table.parts .bar i.part-fan { background: #0891b2; }
table.parts .bar i.part-overheat { background: #ea580c; }
table.parts .bar i.part-hashboard { background: #c81e1e; }
table.parts .bar i.part-psu { background: #7c3aed; }
table.parts .bar i.part-control_board { background: #db2777; }
table.parts .bar i.part-lost { background: var(--muted); }
table.parts .bar i.part-dead { background: #475569; }

/* Reports timeline: one slot per hour / day / week; bar = pass on top of fail */
.timeline .tl-head { gap: 8px; margin-bottom: 8px; }
.tl-strip { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(28px, 1fr); gap: 4px; overflow-x: auto; padding-bottom: 2px; }
.tl-slot { display: grid; grid-template-rows: 56px auto auto auto; justify-items: center; gap: 2px; padding: 4px 2px; border-radius: 6px;
  border: 1px solid transparent; color: var(--ink); text-decoration: none; min-width: 28px; }
.tl-slot:hover { background: var(--primary-soft); }
.tl-slot.on { background: var(--primary-soft); border-color: var(--primary); }
.tl-slot:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
.tl-bar { display: flex; flex-direction: column-reverse; justify-content: flex-start; width: 70%; max-width: 28px; height: 56px;
  background: var(--line); border-radius: 4px 4px 0 0; overflow: hidden; }
.tl-bar i { display: block; width: 100%; }
.tl-bar .tl-pass { background: var(--pass); }
.tl-bar .tl-fail { background: repeating-linear-gradient(135deg, var(--fail) 0 3px, color-mix(in srgb, var(--fail) 55%, transparent) 3px 6px); }
.tl-slot.empty .tl-bar { opacity: .45; }
.tl-n { font-size: 12px; font-weight: 600; min-height: 1em; }
.tl-l { font-size: 12px; }
.tl-s { font-size: 11px; color: var(--muted); min-height: 1em; white-space: nowrap; }

/* shown by app.js while the server cannot be reached (a restart); panels keep their last content */
body[data-offline]::after {
  content: "Reconnecting…"; position: fixed; top: 0; left: 50%; transform: translateX(-50%); z-index: 1000;
  padding: 4px 14px; border-radius: 0 0 var(--radius) var(--radius); font-size: 13px; font-weight: 600;
  background: var(--warn-bg); color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); border-top: 0;
}

/* ---- Colour themes (footer picker, saved per browser). Status colours stay green PASS / red FAIL in every
   theme; every text/background pair checked for WCAG AA. ---- */
:root[data-theme="lime"] {
  --bg: #f5f9ec; --panel: #ffffff; --ink: #1a2e05; --muted: #4b5a37; --line: #dde7c9; --line-strong: #bfcf9f;
  --primary: #3f6212; --primary-ink: #ffffff; --primary-soft: #ecf6d6;
  --accent: #0f766e; --accent-ink: #ffffff; --ring: #65a30d;
  --heading: #365314; --panel-top: #bef264;
  --pass: #15803d; --pass-bg: #e6f8eb; --fail: #c81e1e; --fail-bg: #fde8e8;
  --warn: #92560a; --warn-bg: #fdf1d6; --info: #0369a1; --info-bg: #e0f2fe;
  --warming: #c2410c; --warming-bg: #ffedd5; --config: #a21caf; --config-bg: #fae8ff;
  --idle: #4b5a37; --idle-bg: #eaf0dd;
  --header: #1a2e05; --header-ink: #f7fee7; --header-muted: #bef264; --header-accent: #a3e635;
  --shadow: 0 1px 2px rgba(26, 46, 5, .07), 0 1px 1px rgba(26, 46, 5, .04);
  color-scheme: light;
}
:root[data-theme="purple"] {
  --bg: #120b22; --panel: #1b1330; --ink: #f1ebff; --muted: #b9aedb; --line: #2c2148; --line-strong: #46377a;
  --primary: #c084fc; --primary-ink: #1a0b2e; --primary-soft: #2d1a4d;
  --accent: #f472b6; --accent-ink: #22061a; --ring: #d8b4fe;
  --heading: #e9d5ff; --panel-top: #7e22ce;
  --pass: #4ade80; --pass-bg: #123222; --fail: #f87171; --fail-bg: #3a1616;
  --warn: #fbbf24; --warn-bg: #33270c; --info: #38bdf8; --info-bg: #0c2a3d;
  --warming: #fb923c; --warming-bg: #3a1d0a; --config: #e879f9; --config-bg: #3a1340;
  --idle: #b9aedb; --idle-bg: #241a3d;
  --header: #0b0616; --header-ink: #f3e8ff; --header-muted: #c4b5fd; --header-accent: #f472b6;
  --shadow: none;
  color-scheme: dark;
}
:root[data-theme="ocean"] {
  --bg: #eff6f9; --panel: #ffffff; --ink: #0b2533; --muted: #46606e; --line: #d6e5ec; --line-strong: #b6cdd8;
  --primary: #0e7490; --primary-ink: #ffffff; --primary-soft: #e0f2f7;
  --accent: #1d4ed8; --accent-ink: #ffffff; --ring: #0891b2;
  --heading: #164e63; --panel-top: #a5e1ee;
  --pass: #15803d; --pass-bg: #e6f8eb; --fail: #c81e1e; --fail-bg: #fde8e8;
  --warn: #92560a; --warn-bg: #fdf1d6; --info: #0369a1; --info-bg: #e0f2fe;
  --warming: #c2410c; --warming-bg: #ffedd5; --config: #a21caf; --config-bg: #fae8ff;
  --idle: #46606e; --idle-bg: #e6eef2;
  --header: #083344; --header-ink: #ecfeff; --header-muted: #a5f3fc; --header-accent: #67e8f9;
  --shadow: 0 1px 2px rgba(8, 51, 68, .07), 0 1px 1px rgba(8, 51, 68, .04);
  color-scheme: light;
}

:root[data-theme="hacker"] {
  /* The original MinerQA dark look: near-black green, terminal-green primary, mono headings. */
  --bg: #0b1410; --panel: #111d17; --ink: #e4efe8; --muted: #9aaea2; --line: #22352b; --line-strong: #2f4a3b;
  --primary: #22c55e; --primary-ink: #04140b; --primary-soft: #133222;
  --accent: #4ade80; --accent-ink: #04140b; --ring: #4ade80;
  --heading: #86efac; --panel-top: #166534;
  --pass: #4ade80; --pass-bg: #123222; --fail: #f87171; --fail-bg: #3a1616;
  --warn: #fbbf24; --warn-bg: #33270c; --info: #7cb2ff; --info-bg: #13253f;
  --warming: #fb923c; --warming-bg: #3a1d0a; --config: #e879f9; --config-bg: #3a1340;
  --idle: #9aaea2; --idle-bg: #1b2b22;
  --header: #070d0a; --header-ink: #e4efe8; --header-muted: #8aa395; --header-accent: #22c55e;
  --shadow: none;
  color-scheme: dark;
}
:root[data-theme="hacker"] h1, :root[data-theme="hacker"] h2 { font-family: var(--mono); letter-spacing: 0; }

/* ---- UX touches ---- */
header.top { background: linear-gradient(100deg, var(--header) 0%, color-mix(in srgb, var(--header) 82%, var(--primary)) 100%);
  box-shadow: 0 1px 0 color-mix(in srgb, var(--header-accent) 35%, transparent); }
body, .panel, .tile, header.top, footer.site { transition: background-color .25s ease, color .25s ease, border-color .25s ease; }
.tile { transition: transform .15s ease, box-shadow .15s ease, background-color .25s ease; }
.tile:hover { transform: translateY(-2px); box-shadow: 0 6px 16px color-mix(in srgb, var(--ink) 10%, transparent); }
button:active, .btn:active { transform: translateY(1px); }
.panel { border-radius: calc(var(--radius) + 2px); }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

/* theme picker: a swatch per theme */
.theme-switch .seg label span { display: inline-flex; align-items: center; gap: 6px; }
.theme-switch .seg label span i { width: 12px; height: 12px; border-radius: 50%; flex: none;
  background: linear-gradient(135deg, var(--a) 50%, var(--b) 50%); box-shadow: 0 0 0 1px color-mix(in srgb, var(--ink) 25%, transparent); }

/* footer at the very bottom of the page, also on short pages */
body { min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1 0 auto; width: 100%; box-sizing: border-box; }
footer.site { flex-shrink: 0; width: 100%; box-sizing: border-box; align-items: center; }
footer.site #sound-toggle[aria-pressed="true"] { border-color: var(--primary); }
main { padding-bottom: 56px; }  /* room for the report button */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .tile:hover { transform: none; }
}

/* ---- Charts (static/charts.js): UniFi-style card header with a big number and series chips ---- */
.mq-head { display: flex; flex-direction: column; gap: 8px; margin-bottom: var(--s3); }
.mq-head h3, .mq-head h2 { margin: 0 0 2px; }
.mq-big { display: flex; align-items: baseline; gap: 6px; min-height: 1.2em; font-feature-settings: "tnum" 1; }
.mq-big b { font-size: 24px; font-weight: 600; letter-spacing: -.02em; color: var(--ink); line-height: 1.15; }
.mq-big .mq-unit { font-size: 13px; color: var(--muted); font-weight: 500; }
.mq-big .mq-sub { font-size: 12px; color: var(--muted); margin-left: 4px; }
.mq-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.mq-chips:empty { display: none; }
.grid .mq-chips:empty { display: block; min-height: 27px; }  /* cards side by side keep their charts level */
.mq-chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 7px; border-radius: 999px; font-size: 11.5px; line-height: 1.5;
  background: color-mix(in srgb, var(--ink) 5%, transparent); border: 1px solid transparent; color: var(--muted); cursor: pointer;
  transition: opacity .2s, background-color .2s, border-color .2s; }
.mq-chip:hover { border-color: var(--line-strong); }
.mq-chip i { width: 8px; height: 8px; border-radius: 50%; flex: none; box-shadow: 0 0 0 2px color-mix(in srgb, currentColor 0%, var(--panel)); }
.mq-chip b { color: var(--ink); font-weight: 600; font-feature-settings: "tnum" 1; }
.mq-chip.off { opacity: .45; }
.mq-chip.off i { background: transparent !important; outline: 1.5px solid var(--muted); outline-offset: -1.5px; }
.chart-box { height: 240px; }
.chart-empty { display: grid; place-items: center; text-align: center; gap: 4px; height: 160px; border-radius: var(--radius);
  background: repeating-linear-gradient(135deg, transparent 0 10px, color-mix(in srgb, var(--ink) 3%, transparent) 10px 20px); color: var(--muted); }
.chart-empty b { color: var(--ink); font-weight: 600; }
/* thin pill meters (Failures by part) */
table.parts .bar { height: 8px; border-radius: 999px; background: color-mix(in srgb, var(--ink) 7%, transparent); overflow: hidden; }
table.parts .bar i { display: block; height: 100%; border-radius: 999px; }
/* reports timeline: the chart is the picker; the slot links stay for keyboard / screen readers */
.tl-links { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.tl-links:focus-within { position: static; width: auto; height: auto; clip: auto; display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 8px; font-size: 12px; white-space: normal; }
.timeline .mq-head { margin-top: 4px; }
.timeline .mq-head { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 6px; }
.timeline .tl-head { margin-bottom: 2px; }
