/* ---------------------------------------------------------------------------
   DAQ console — one stylesheet, no framework, no webfont.

   Design constraints that came from the shop floor, not from a mood board:
   - readable from a couple of metres away, so type is large and contrast high;
   - numbers must line up in columns -> tabular figures everywhere;
   - colour carries meaning (OK/NG), so it is never used for decoration only;
   - the same page is used in a dark office and on a bright shop-floor panel,
     so every colour is a variable and the two themes are one attribute apart.

   Theme switch: <html data-theme="light"> or "dark".  Nothing else changes;
   no colour is hard-coded below this block.
--------------------------------------------------------------------------- */

:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #070b14;
  --bg-soft: #0c1322;
  --panel: #111a2b;
  --panel-2: #16223a;
  --line: #22304a;
  --line-soft: #1a2740;
  --text: #e8eefc;
  --dim: #93a4c4;
  --faint: #64748b;
  --ok: #34d399;
  --ok-text: #6ee7b7;
  --ok-dim: #0f3d31;
  --ok-line: #14532d;
  --ok-fill: rgba(52, 211, 153, .13);
  --ng: #fb7185;
  --ng-text: #fda4af;
  --ng-dim: #431a26;
  --ng-line: #7f1d3a;
  --over: #fbbf24;
  --over-text: #fcd34d;
  --over-dim: #43320f;
  --over-line: #7c2d12;
  --info-text: #93c5fd;
  --info-dim: #0f2a44;
  --info-line: #1e3a8a;
  --accent: #38bdf8;
  --accent-dim: #0b3347;
  --accent-line: #17506b;
  --accent-text: #bae6fd;
  --warn: #f59e0b;
  --warn-text: #fde9c8;
  --warn-dim: rgba(245, 158, 11, .08);
  --alarm: #f43f5e;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);

  /* surfaces that are not simply bg/panel */
  --topbar-top: rgba(22, 34, 58, .92);
  --topbar-bottom: rgba(17, 26, 43, .82);
  --glow-a: rgba(56, 189, 248, .10);
  --glow-b: rgba(52, 211, 153, .07);
  --hover-row: rgba(56, 189, 248, .05);
  --selected-row: rgba(56, 189, 248, .10);
  --log-bg: #060a12;
  --log-text: #b6c4dc;
  --log-ts: #55657f;
  --tip-bg: #0b1424;
  --sw-off: #1b2a44;
  --sw-knob: #cbd5e1;
  --sw-on: #0e7490;
  --sw-on-line: #0891b2;
  --sw-on-knob: #e0f2fe;
  --btn-hover: #1d2c48;
  --btn-hover-line: #2d4166;
  --primary-a: #0ea5e9;
  --primary-b: #0284c7;
  --primary-line: #0369a1;
  --primary-a-hover: #38bdf8;
  --primary-b-hover: #0ea5e9;
  --primary-text: #f0f9ff;
  --danger-bg: #2a1220;
  --danger-bg-hover: #3b1526;
  --danger-line: #7f1d3a;
  --danger-text: #fecdd3;
  --note-bg: rgba(56, 189, 248, .07);
  --note-text: #cfe3f8;
  --invalid-line: #9f1239;
  --overlay-bg: rgba(3, 7, 14, .72);
  --toast-bg: #0d1728;
  --toast-ok-bg: #0a211b;
  --toast-ok-line: #14532d;
  --toast-err-bg: #26101a;
  --toast-err-line: #7f1d3a;
  --hero-a: #1d4ed8;
  --hero-b: #0ea5e9;

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", "Noto Sans CJK SC", "Source Han Sans SC", "Microsoft YaHei", sans-serif;
}

/* Light theme: a bright shop floor, or a projector.  Not just "inverted" --
   the OK/NG colours are darkened so they still pass contrast on white. */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f6fb;
  --bg-soft: #eef2f9;
  --panel: #ffffff;
  --panel-2: #f1f5fb;
  --line: #d8e0ee;
  --line-soft: #e8eef7;
  --text: #16233a;
  --dim: #4d5f7d;
  --faint: #7688a5;
  --ok: #0f9d6b;
  --ok-text: #0a7a53;
  --ok-dim: #e3f7ee;
  --ok-line: #9fdec6;
  --ok-fill: rgba(15, 157, 107, .11);
  --ng: #d92d4b;
  --ng-text: #b91c3c;
  --ng-dim: #fdecef;
  --ng-line: #f5b8c4;
  --over: #b8730a;
  --over-text: #92600a;
  --over-dim: #fdf3e0;
  --over-line: #f0d49a;
  --info-text: #1d4ed8;
  --info-dim: #e8eefc;
  --info-line: #b9c9f5;
  --accent: #0b7fc4;
  --accent-dim: #e2f2fc;
  --accent-line: #a8d8f2;
  --accent-text: #075f93;
  --warn: #b45309;
  --warn-text: #92400e;
  --warn-dim: rgba(180, 83, 9, .08);
  --alarm: #be123c;
  --shadow: 0 10px 26px rgba(24, 42, 78, .10);

  --topbar-top: rgba(255, 255, 255, .95);
  --topbar-bottom: rgba(244, 247, 252, .92);
  --glow-a: rgba(11, 127, 196, .07);
  --glow-b: rgba(15, 157, 107, .05);
  --hover-row: rgba(11, 127, 196, .05);
  --selected-row: rgba(11, 127, 196, .10);
  --log-bg: #f7f9fd;
  --log-text: #2c3b55;
  --log-ts: #8b9bb4;
  --tip-bg: #ffffff;
  --sw-off: #d7dfec;
  --sw-knob: #ffffff;
  --sw-on: #0b7fc4;
  --sw-on-line: #0969a3;
  --sw-on-knob: #ffffff;
  --btn-hover: #e6eef9;
  --btn-hover-line: #c3d3e8;
  --primary-a: #1287c9;
  --primary-b: #0b6ea8;
  --primary-line: #095a8a;
  --primary-a-hover: #1b96dc;
  --primary-b-hover: #0b7fc4;
  --primary-text: #ffffff;
  --danger-bg: #fdeef1;
  --danger-bg-hover: #fbdfe5;
  --danger-line: #eba4b3;
  --danger-text: #b91c3c;
  --note-bg: rgba(11, 127, 196, .06);
  --note-text: #21456b;
  --invalid-line: #d92d4b;
  --overlay-bg: rgba(22, 35, 58, .42);
  --toast-bg: #ffffff;
  --toast-ok-bg: #eafaf3;
  --toast-ok-line: #9fdec6;
  --toast-err-bg: #fdeef1;
  --toast-err-line: #f5b8c4;
  --hero-a: #2563eb;
  --hero-b: #0ea5e9;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(1200px 600px at 85% -10%, var(--glow-a), transparent 60%),
    radial-gradient(900px 500px at 5% 0%, var(--glow-b), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100%;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Theme toggle: one switch, remembered in localStorage and applied before the
   first paint (see the inline script in the pages) so the page never flashes
   the wrong background. */
.theme-toggle {
  display: inline-flex; align-items: center; gap: 0;
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 9px; padding: 2px; gap: 2px;
}
.theme-toggle button {
  border: 0; background: transparent; color: var(--dim);
  padding: 4px 9px; font-size: 12.5px; border-radius: 7px; line-height: 1.2;
}
.theme-toggle button:hover { background: var(--panel-2); color: var(--text); }
.theme-toggle button[aria-pressed="true"] {
  background: var(--accent-dim); color: var(--accent-text); font-weight: 600;
}
.theme-toggle svg { display: block; }

/* ------------------------------------------------------------------ layout */

.wrap { max-width: 1560px; margin: 0 auto; padding: 18px 22px 64px; }

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  margin-bottom: 18px;
  background: linear-gradient(180deg, var(--topbar-top), var(--topbar-bottom));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  position: sticky;
  top: 12px;
  z-index: 20;
  backdrop-filter: blur(10px);
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand .logo {
  width: 38px; height: 38px; flex: none;
  display: grid; place-items: center;
  border-radius: 11px;
  background: linear-gradient(145deg, var(--hero-a), var(--hero-b));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.16);
}
.brand h1 { font-size: 17px; margin: 0; letter-spacing: .3px; white-space: nowrap; }
.brand .sub { font-size: 12px; color: var(--dim); white-space: nowrap; }

.nav { display: flex; gap: 6px; margin-left: 8px; }
.nav a {
  padding: 7px 13px; border-radius: 9px; color: var(--dim);
  font-size: 13.5px; border: 1px solid transparent;
}
.nav a:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-dim); border-color: var(--accent-line); color: var(--accent-text); }

.topbar .spacer { flex: 1 1 auto; }

.controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

select, input[type="text"], input[type="number"], input[type="password"], input[type="search"] {
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 7px 10px;
  font: inherit;
  font-size: 13.5px;
  min-width: 0;
}
select:focus, input:focus { outline: 2px solid var(--accent-line); outline-offset: 1px; }

button, .btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 7px 13px;
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background .15s, border-color .15s, transform .05s;
  white-space: nowrap;
}
button:hover, .btn:hover { background: var(--btn-hover); border-color: var(--btn-hover-line); text-decoration: none; }
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: linear-gradient(180deg, var(--primary-a), var(--primary-b)); border-color: var(--primary-line); color: var(--primary-text); }
button.primary:hover { background: linear-gradient(180deg, var(--primary-a-hover), var(--primary-b-hover)); }
button.danger { border-color: var(--danger-line); color: var(--danger-text); background: var(--danger-bg); }
button.danger:hover { background: var(--danger-bg-hover); }
button.ghost { background: transparent; }
button.small { padding: 4px 9px; font-size: 12.5px; }

/* --------------------------------------------------------------- sections */

.section { margin-top: 22px; }
.section > header {
  display: flex; align-items: baseline; gap: 12px; margin-bottom: 10px;
}
.section > header h2 {
  font-size: 13px; letter-spacing: 1.4px; text-transform: uppercase;
  color: var(--dim); margin: 0; font-weight: 600;
}
.section > header .hint { font-size: 12.5px; color: var(--faint); }
.section > header .spacer { flex: 1; }

.grid { display: grid; gap: 14px; }
/* Seven KPI cards: fixed 7 columns on a wide screen so they never wrap a
   lone card onto a second row, and auto-fit below that. */
.grid.kpi { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
@media (min-width: 1400px) { .grid.kpi { grid-template-columns: repeat(7, minmax(0, 1fr)); } }
@media (min-width: 1180px) and (max-width: 1399px) { .grid.kpi { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 760px) and (max-width: 1179px) { .grid.kpi { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 759px) { .grid.kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.split { grid-template-columns: minmax(0, 2.1fr) minmax(320px, 1fr); }
@media (max-width: 1100px) { .grid.split { grid-template-columns: 1fr; } }

.card {
  background: linear-gradient(180deg, var(--panel), var(--bg-soft));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  min-width: 0;
}
.card.tight { padding: 0; overflow: hidden; }
/* A padded title bar above a zero-padding card: the table then starts flush
   with the card edge (like the 分品种 table) while the title keeps its
   spacing instead of being glued to the corner. */
.card-head { padding: 14px 18px 10px; border-bottom: 1px solid var(--line-soft); }
.card-head h3 {
  margin: 0; font-size: 13px; color: var(--dim); font-weight: 600;
  letter-spacing: .4px; display: flex; align-items: center; gap: 8px;
}
.card-head h3 .sub { color: var(--faint); font-weight: 400; font-size: 12px; }
.card-head h3 .spacer { flex: 1; }
.card > h3 {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--dim);
  font-weight: 600;
  letter-spacing: .4px;
  display: flex; align-items: center; gap: 8px;
}
.card > h3 .spacer { flex: 1; }
.card > h3 .sub { color: var(--faint); font-weight: 400; font-size: 12px; }

/* --------------------------------------------------------------------- KPI */

.kpi {
  position: relative;
  overflow: hidden;
}
.kpi .label { font-size: 12.5px; color: var(--dim); display: flex; align-items: center; gap: 7px; }
.kpi .value {
  font-size: clamp(24px, 2.1vw, 34px); font-weight: 650; letter-spacing: -.5px; margin: 6px 0 2px;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.kpi .value small { font-size: 15px; font-weight: 500; color: var(--dim); margin-left: 4px; }
.kpi .foot { font-size: 12.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.kpi .delta { font-size: 12.5px; font-variant-numeric: tabular-nums; }
.kpi .delta.up { color: var(--ok); }
.kpi .delta.down { color: var(--ng); }
.kpi::after {
  content: ""; position: absolute; inset: auto 0 0 0; height: 3px;
  background: var(--accent); opacity: .55;
}
.kpi.ok::after { background: var(--ok); }
.kpi.ng::after { background: var(--ng); }
.kpi.warn::after { background: var(--warn); }
.kpi .spark { position: absolute; right: 12px; bottom: 10px; opacity: .5; }

/* ------------------------------------------------------------------ status */

.statusline {
  display: flex; flex-wrap: wrap; gap: 10px 26px; align-items: center;
  padding: 13px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
}
.statusline .item { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.statusline .item .k { color: var(--faint); }
.statusline .item .v { font-variant-numeric: tabular-nums; }
.statusline .spacer { flex: 1; }

.pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 11px 4px 9px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid transparent;
  letter-spacing: .2px;
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.ok { color: var(--ok-text); background: var(--ok-dim); border-color: var(--ok-line); }
.pill.idle { color: var(--info-text); background: var(--info-dim); border-color: var(--info-line); }
.pill.alarm, .pill.error { color: var(--ng-text); background: var(--ng-dim); border-color: var(--ng-line); }
.pill.stale, .pill.disconnected, .pill.crashed, .pill.dead, .pill.unresponsive {
  color: var(--over-text); background: var(--over-dim); border-color: var(--over-line);
}
.pill.ok .dot { box-shadow: 0 0 0 0 var(--ok); animation: pulse 2.4s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 var(--ok); opacity: .55; }
  70% { box-shadow: 0 0 0 7px transparent; opacity: 1; }
  100% { box-shadow: 0 0 0 0 transparent; opacity: 1; }
}

.tag {
  display: inline-block; padding: 1px 7px; border-radius: 6px;
  font-size: 11.5px; font-weight: 600; letter-spacing: .3px;
}
.tag.ok { background: var(--ok-dim); color: var(--ok-text); }
.tag.ng { background: var(--ng-dim); color: var(--ng-text); }
.tag.over { background: var(--over-dim); color: var(--over-text); }
.tag.muted { background: var(--sw-off); color: var(--dim); }
/* A metal rejection that came from a test piece, not from a product: the same
   event, deliberately not the same colour as a real detection. */
.tag.test { background: var(--info-dim); color: var(--info-text); }

/* ------------------------------------------------------------------ charts */

.chart { width: 100%; position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis text { fill: var(--faint); font-size: 11px; }
.chart .grid-line { stroke: var(--line-soft); stroke-width: 1; }
.chart .series-line { fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.chart .hover-band { fill: transparent; }
.chart .bar { transition: opacity .15s; }
.chart .bar:hover { opacity: .82; }
.chart-tip {
  position: fixed; pointer-events: none; z-index: 60;
  background: var(--tip-bg); border: 1px solid var(--line); border-radius: 9px;
  padding: 7px 10px; font-size: 12.5px; color: var(--text);
  box-shadow: var(--shadow); opacity: 0; transform: translate(-50%, -110%);
  transition: opacity .12s; white-space: nowrap;
}
.chart-tip.show { opacity: 1; }
.chart-tip .row { display: flex; gap: 10px; justify-content: space-between; }
.chart-tip .sw { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-right: 6px; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--dim); margin-top: 8px; }
.legend .item { display: flex; align-items: center; gap: 6px; }
/* A legend swatch is a colour chip by default, but a line series should show a
   line: inline width/height overrides let the rhythm legend draw a thin bar for
   the raw series and a thick one for the smoothed mean. */
.legend .sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend .sw.line { width: 16px; height: 2px; border-radius: 1px; }
.legend .sw.line.thick { height: 4px; border-radius: 2px; }

/* ------------------------------------------------------------------ tables */

.table-wrap { overflow: auto; max-height: 420px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  position: sticky; top: 0; z-index: 2;
  text-align: left; font-weight: 600; font-size: 12px; letter-spacing: .5px;
  text-transform: uppercase; color: var(--faint);
  background: var(--panel);
  padding: 9px 12px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody td { padding: 8px 12px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
tbody tr:hover td { background: var(--hover-row); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.mono { font-family: var(--mono); font-size: 12.5px; }
.empty { padding: 26px 16px; text-align: center; color: var(--faint); font-size: 13px; }
/* Only the block-level placeholders get the tall, centred treatment; a
   td.empty inside a table must stay a table cell. */
.card .empty:not(td) { display: flex; align-items: center; justify-content: center; min-height: 170px; }
tr.selected td { background: var(--selected-row); box-shadow: inset 3px 0 0 var(--accent); }

/* A row that opens something (currently the recipe table).  Hover is the only
   affordance it needs; the browser's pointer is the rest. */
tbody tr.clickable { cursor: pointer; }
/* A caret says "this opens" without a sentence explaining it: drawn from
   borders rather than typed, so it is the same shape in every font, and it
   points down while the row is open.  It sits inside the first column's
   padding -- the table is already wide enough that a caret column of its own
   would push the timestamp's last digits out of the panel. */
#recipe-table th:first-child,
#recipe-table td:first-child { padding-left: 5px; }
.caret {
  display: inline-block; width: 0; height: 0; margin: 0 6px 0 2px;
  vertical-align: 1px;
  border-left: 5px solid var(--faint);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform .12s ease;
}
tbody tr.open .caret { transform: rotate(90deg); transform-origin: 2px 4px; }
tbody tr.recipe-detail td { cursor: pointer; }
/* The opened row keeps the accent bar so it stays identifiable while the
   detail sits underneath it, but drops the fill: the detail's own background
   already belongs to this row. */
tbody tr.open td { box-shadow: inset 3px 0 0 var(--accent); }

/* The recipe detail: the rest of the 7.12 frame, laid out as label/value
   pairs that wrap instead of forcing the panel wider. */
tbody tr.recipe-detail td {
  background: var(--bg-soft);
  padding: 10px 12px 14px;
  white-space: normal;
  box-shadow: inset 3px 0 0 var(--accent);
}
tbody tr.recipe-detail:hover td { background: var(--bg-soft); }

/* The history of the selected product, as one quiet line under its row.
   It used to scatter the figures into the columns they repeat (合格率, 节拍,
   均重), but each cell then held a stacked label+number in a column narrow
   enough to wrap, and the result read as three vertical stripes.  One row of
   "label value" pairs is what people actually scan. */
tbody tr.product-history td {
  background: var(--bg-soft);
  padding: 5px 12px 7px;
  border-bottom: 1px solid var(--line-soft);
  box-shadow: none;
  cursor: default;
  text-align: left;
}
tbody tr.product-history:hover td { background: var(--bg-soft); }
tbody tr.product-history td:nth-child(n+3) { text-align: right; }
.hist-k { color: var(--faint); font-size: 11.5px; letter-spacing: .2px; }
.hist-v { color: var(--dim); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.detail-grid { display: flex; flex-wrap: wrap; gap: 8px 26px; }
.detail-grid > div {
  display: flex; flex-direction: column; gap: 2px;
  flex: 1 1 120px; min-width: 0; max-width: 260px;
}
.detail-grid .k { font-size: 11px; letter-spacing: .4px; color: var(--faint); }
/* Wraps instead of truncating: this row exists to show the values in full, so
   a long product name must not end in an ellipsis. */
.detail-grid .v {
  font-size: 13px; font-family: var(--mono);
  white-space: normal; word-break: break-word;
}

/* The totals row sits under the product list and doubles as the "show
   everything" button, so it is visually distinct from a data row. */
tbody tr.total td {
  border-top: 2px solid var(--line);
  background: var(--bg-soft);
  font-variant-numeric: tabular-nums;
}
tbody tr.total:hover td { background: var(--hover-row); }
/* The totals row is a button ("clear the filter"), not a selection.  It must
   not borrow the selected row's blue bar: with a product filtered, both rows
   looked selected and it was impossible to tell which one was the filter.
   Hover is the only affordance it needs. */
tbody tr.total td { cursor: pointer; }
tbody tr.total:hover td { background: var(--hover-row); box-shadow: none; }
tbody tr.total.active td { background: var(--bg-soft); box-shadow: none; }
tbody tr.total.active:hover td { background: var(--hover-row); }

/* -------------------------------------------------------------------- logs */

.log {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.62;
  background: var(--log-bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  max-height: 300px;
  overflow: auto;
  white-space: pre;
  color: var(--log-text);
}
.log .l-warn { color: var(--over-text); }
.log .l-error { color: var(--ng-text); }
.log .l-info { color: var(--log-text); }
.log .ts { color: var(--log-ts); }

/* -------------------------------------------------------------- form (config) */

.form { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12.5px; color: var(--dim); }
.field .hint { font-size: 11.5px; color: var(--faint); }
.field input, .field select { width: 100%; }
.field.invalid input, .field.invalid select { border-color: var(--invalid-line); }
.field .err { font-size: 11.5px; color: var(--ng-text); min-height: 0; }
.field .err:empty { display: none; }

.switch { display: flex; align-items: center; gap: 10px; }
.switch input { width: 38px; height: 21px; appearance: none; background: var(--sw-off); border-radius: 999px; position: relative; cursor: pointer; border: 1px solid var(--line); transition: background .15s; flex: none; }
.switch input:checked { background: var(--sw-on); border-color: var(--sw-on-line); }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 15px; height: 15px; border-radius: 50%; background: var(--sw-knob); transition: transform .15s; }
.switch input:checked::after { transform: translateX(17px); background: var(--sw-on-knob); }

.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.form-actions .spacer { flex: 1; }

.note {
  border-left: 3px solid var(--accent);
  background: var(--note-bg);
  padding: 10px 14px; border-radius: 0 10px 10px 0;
  font-size: 13px; color: var(--note-text);
}
.note.warn { border-color: var(--warn); background: var(--warn-dim); color: var(--warn-text); }
.note.danger { border-color: var(--alarm); background: var(--ng-dim); color: var(--ng-text); }
.note code, .mono { font-family: var(--mono); }

/* --------------------------------------------------------------- banners */

.toast {
  position: fixed; right: 22px; bottom: 22px; z-index: 100;
  display: flex; flex-direction: column; gap: 10px; align-items: flex-end;
}
.toast .item {
  background: var(--toast-bg); border: 1px solid var(--line);
  border-radius: 11px; padding: 11px 15px; font-size: 13.5px;
  box-shadow: var(--shadow); max-width: 460px;
  animation: slide-in .18s ease-out;
}
.toast .item.ok { border-color: var(--toast-ok-line); background: var(--toast-ok-bg); }
.toast .item.err { border-color: var(--toast-err-line); background: var(--toast-err-bg); }
@keyframes slide-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.overlay {
  position: fixed; inset: 0; background: var(--overlay-bg);
  display: grid; place-items: center; z-index: 90; backdrop-filter: blur(3px);
}
.overlay .box {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 24px; width: min(420px, 90vw);
  box-shadow: var(--shadow);
}
.overlay .box h2 { margin: 0 0 6px; font-size: 17px; }
.overlay .box p { margin: 0 0 16px; color: var(--dim); font-size: 13px; }
.overlay .box input { width: 100%; margin-bottom: 12px; }
.overlay .box .row { display: flex; gap: 10px; }
.hidden { display: none !important; }

.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--accent);
  animation: spin .8s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.muted { color: var(--dim); }
.faint { color: var(--faint); }
.mono { font-family: var(--mono); }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

.dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.dl dt { color: var(--faint); }
.dl dd { margin: 0; font-variant-numeric: tabular-nums; }

.bar-track { height: 7px; border-radius: 99px; background: var(--panel-2); overflow: hidden; display: flex; }
.bar-track span { display: block; height: 100%; }

@media (max-width: 720px) {
  .wrap { padding: 12px 12px 48px; }
  .topbar { position: static; flex-wrap: wrap; }
  .brand h1 { font-size: 15px; }
  .kpi .value { font-size: 28px; }
}
