/* jarvis dashboard theme: dense, muted, analyst-style. Light and dark via CSS variables. */
:root {
  --bg: #f3f4f6; --surface: #ffffff; --surface-2: #f8f9fb; --border: #d9dde3;
  --text: #1f2937; --text-muted: #6b7280; --accent: #2563eb; --accent-soft: #dbeafe;
  --ok: #16a34a; --warn: #d97706; --crit: #dc2626; --muted: #9ca3af; --stale: #7c3aed;
  --s1: #2563eb; --s2: #d97706; --s3: #16a34a; --s4: #dc2626; --s5: #7c3aed; --s6: #0891b2;
  --grid-line: #e5e7eb; --shadow: 0 1px 2px rgba(0,0,0,.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
html[data-theme="dark"] {
  --bg: #0f1216; --surface: #171b21; --surface-2: #1e232b; --border: #2a3039;
  --text: #e5e7eb; --text-muted: #9aa3ad; --accent: #60a5fa; --accent-soft: #1e3a5f;
  --ok: #22c55e; --warn: #f59e0b; --crit: #ef4444; --muted: #6b7280; --stale: #a78bfa;
  --s1: #60a5fa; --s2: #fbbf24; --s3: #4ade80; --s4: #f87171; --s5: #c084fc; --s6: #22d3ee;
  --grid-line: #262c35; --shadow: none;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --bg: #0f1216; --surface: #171b21; --surface-2: #1e232b; --border: #2a3039;
    --text: #e5e7eb; --text-muted: #9aa3ad; --accent: #60a5fa; --accent-soft: #1e3a5f;
    --ok: #22c55e; --warn: #f59e0b; --crit: #ef4444; --muted: #6b7280; --stale: #a78bfa;
    --s1: #60a5fa; --s2: #fbbf24; --s3: #4ade80; --s4: #f87171; --s5: #c084fc; --s6: #22d3ee;
    --grid-line: #262c35; --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 13px/1.4 var(--font); }
button, input, select { font: inherit; color: inherit; }
main { padding: 8px 10px 40px; }

/* ---- top bar --------------------------------------------------------------------------- */
#topbar {
  display: flex; align-items: center; gap: 14px; min-height: 44px; padding: 0 12px; flex-wrap: wrap;
  background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; letter-spacing: .2px; white-space: nowrap; }
.logo { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.spacer { flex: 1; }
.tabs { display: flex; gap: 2px; height: 100%; }
.tabs button {
  background: none; border: 0; border-bottom: 2px solid transparent; padding: 0 12px; height: 44px;
  color: var(--text-muted); cursor: pointer; font-weight: 500;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.controls { display: flex; align-items: center; gap: 8px; }
.clock { font-family: var(--mono); font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.btn {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 4px 10px;
  cursor: pointer; color: var(--text); white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.icon { padding: 3px 7px; }
.btn.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.edit-tools { display: flex; gap: 6px; }
.edit-tools[hidden], [hidden] { display: none !important; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2); font-size: 12px; color: var(--text-muted); white-space: nowrap;
}
.pill .dot, .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; }
.pill.ok .dot { background: var(--ok); } .pill.warn .dot { background: var(--warn); }
.pill.crit .dot { background: var(--crit); } .pill.stale .dot { background: var(--stale); }
.alert-pill { cursor: pointer; }
.alert-pill.has-alerts { color: var(--crit); border-color: var(--crit); font-weight: 600; }
.badge { font-size: 10px; padding: 1px 6px; border-radius: 3px; font-weight: 700; letter-spacing: .5px; }
.badge.sim { background: var(--warn); color: #fff; }

/* ---- drawer ---------------------------------------------------------------------------- */
.drawer {
  position: fixed; right: 10px; top: 50px; width: 420px; max-height: 70vh; overflow: auto; z-index: 60;
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.18);
}
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--border); }

/* ---- grid & panels --------------------------------------------------------------------- */
.tab-page { display: none; }
.tab-page.active { display: block; }
.grid-stack { min-height: 200px; }
.grid-stack-item-content {
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden;
}
.editing .grid-stack-item-content { border-style: dashed; border-color: var(--accent); }
/* section heading panel: no box, just the title and a rule */
.grid-stack-item-content.section-heading { background: transparent; border: 0; box-shadow: none; justify-content: flex-end; }
.section-heading .panel-head { border-bottom: 0; padding: 0 4px; font-size: 14px; letter-spacing: .8px; color: var(--text); flex-wrap: nowrap; }
.section-heading .panel-head .title { flex: 0 0 auto; }
.section-heading .panel-head .rule { flex: 1 1 auto; border-top: 1px solid var(--border); }
.editing .grid-stack-item-content.section-heading { border: 1px dashed var(--accent); }
.panel-head {
  display: flex; align-items: center; gap: 6px 8px; flex-wrap: wrap; padding: 4px 10px; border-bottom: 1px solid var(--border);
  font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .4px;
  min-height: 28px; flex: 0 0 auto;
}
.panel-head .title { flex: 1 1 60px; min-width: 40px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel-head .extra { font-weight: 400; text-transform: none; letter-spacing: 0; font-family: var(--mono); font-size: 11px; }
.panel-head .extra.warn { color: var(--warn); font-weight: 600; }
.panel-head .tools { display: none; gap: 4px; }
.editing .panel-head .tools { display: flex; }
.panel-head .tools button { background: none; border: 0; cursor: pointer; color: var(--text-muted); padding: 0 4px; }
.panel-head .tools button:hover { color: var(--accent); }
.panel-head .seg { display: inline-flex; border: 1px solid var(--border); border-radius: 4px; overflow: hidden; }
.panel-head .seg button { background: none; border: 0; padding: 1px 6px; cursor: pointer; color: var(--text-muted); font-size: 11px; }
.panel-head .seg button.active { background: var(--accent-soft); color: var(--accent); }
.panel-head label.chk { font-weight: 400; text-transform: none; letter-spacing: 0; display: inline-flex; gap: 3px; align-items: center; cursor: pointer; }
.panel-head .live-btn { background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent); border-radius: 4px; padding: 1px 6px; font-size: 11px; cursor: pointer; text-transform: none; letter-spacing: 0; }
.panel-head .max { background: none; border: 0; cursor: pointer; color: var(--text-muted); padding: 0 2px; font-size: 14px; line-height: 1; }
.panel-head .max:hover { color: var(--accent); }

/* maximized panel: covers the viewport until the button is clicked again or Escape is pressed */
.grid-stack-item.maximized {
  position: fixed !important; inset: 0 !important; width: auto !important; height: auto !important;
  transform: none !important; z-index: 55; padding: 8px; background: var(--bg);
}
.grid-stack-item.maximized > .grid-stack-item-content { inset: 8px; }
body.has-maximized { overflow: hidden; }
.editing .grid-stack-item.maximized .grid-stack-item-content { cursor: default; }
.panel-body { flex: 1 1 auto; min-height: 0; position: relative; overflow: hidden; }
.panel-body.pad { padding: 8px 10px; }
.panel-empty { color: var(--text-muted); padding: 10px; font-style: italic; }
.editing .panel-body { pointer-events: none; }
.editing .grid-stack-item-content { cursor: move; user-select: none; }

/* stat panel */
.stat { height: 100%; display: flex; flex-direction: column; padding: 8px 12px 4px; }
.stat .value { font-size: 28px; font-weight: 600; font-family: var(--mono); line-height: 1.1; display: flex; align-items: baseline; gap: 6px; }
.stat .value .unit { font-size: 13px; color: var(--text-muted); font-family: var(--font); font-weight: 500; }
.stat .sub { display: flex; justify-content: space-between; color: var(--text-muted); font-size: 11px; margin-top: 2px; }
.stat .spark { flex: 1; min-height: 18px; width: 100%; }
.stat.q-warn .value { color: var(--warn); } .stat.q-crit .value { color: var(--crit); }
.stat.q-stale .value { color: var(--stale); } .stat.q-muted .value { color: var(--muted); }
.stat .qtag { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; font-weight: 700; }
.q-ok .qtag { color: var(--ok); } .q-warn .qtag { color: var(--warn); } .q-crit .qtag { color: var(--crit); }
.q-stale .qtag { color: var(--stale); } .q-muted .qtag { color: var(--muted); }

/* status panel */
.status-list { display: flex; flex-direction: column; gap: 4px; padding: 6px 10px; overflow: auto; height: 100%; }
.status-row { display: grid; grid-template-columns: 14px 1fr auto; align-items: center; gap: 8px; padding: 3px 0; border-bottom: 1px dashed var(--grid-line); }
.status-row:last-child { border-bottom: 0; }
.status-list.compact .status-row { padding: 1px 0; gap: 6px; }
.status-list.compact .status-row .name, .status-list.compact .status-row .state { font-size: 11px; }
.status-row .lamp { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.lamp.ok { background: var(--ok); box-shadow: 0 0 0 2px color-mix(in srgb, var(--ok) 25%, transparent); }
.lamp.warn { background: var(--warn); } .lamp.crit { background: var(--crit); animation: blink 1s infinite; }
.lamp.stale { background: var(--stale); } .lamp.muted { background: var(--muted); }
.status-row .state { font-family: var(--mono); font-size: 12px; }
.status-row .state.crit { color: var(--crit); font-weight: 700; } .status-row .state.warn { color: var(--warn); }
@keyframes blink { 50% { opacity: .35; } }

/* spectrum panel: range row (when used) + plot + footer with calibration / counts / state */
.spec, .chart-body { height: 100%; display: flex; flex-direction: column; }
.spec .chart-wrap, .chart-body .chart-wrap { flex: 1 1 auto; min-height: 0; }
.spec .rate-range, .chart-body .rate-range { padding: 4px 10px 0; }
.spec-foot { flex: 0 0 auto; padding: 2px 10px 4px; font-family: var(--mono); font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spec-foot .extra { font-family: var(--mono); }

/* chart panel */
.chart-wrap { width: 100%; height: 100%; }
.uplot { font-family: var(--font); }
.u-legend { font-size: 11px; color: var(--text-muted); }
.u-legend .u-marker { border-radius: 2px; }
.u-select { background: color-mix(in srgb, var(--accent) 20%, transparent); }

/* image panel */
.image-wrap { height: 100%; display: flex; flex-direction: column; }
.image-wrap img { flex: 1; min-height: 0; object-fit: contain; width: 100%; background: #000; cursor: zoom-in; image-rendering: auto; }
.image-wrap .caption { display: flex; gap: 14px; padding: 4px 10px; font-family: var(--mono); font-size: 11px; color: var(--text-muted); flex-wrap: wrap; }

/* alerts panel */
table.alerts { width: 100%; border-collapse: collapse; font-size: 12px; }
table.alerts th { text-align: left; font-weight: 600; color: var(--text-muted); padding: 4px 8px; border-bottom: 1px solid var(--border); font-size: 11px; text-transform: uppercase; }
table.alerts td { padding: 4px 8px; border-bottom: 1px solid var(--grid-line); vertical-align: top; }
table.alerts tr.crit td:first-child { border-left: 3px solid var(--crit); }
table.alerts tr.warn td:first-child { border-left: 3px solid var(--warn); }
table.alerts tr.stale td:first-child { border-left: 3px solid var(--stale); }
table.alerts .lvl { font-weight: 700; text-transform: uppercase; font-size: 11px; }
tr.crit .lvl { color: var(--crit); } tr.warn .lvl { color: var(--warn); } tr.stale .lvl { color: var(--stale); }
table.alerts .acked { opacity: .55; }
.alerts-ok { padding: 12px; color: var(--ok); font-weight: 600; }

/* log panel */
.log { font-family: var(--mono); font-size: 11px; padding: 4px 8px; overflow: auto; height: 100%; }
.log div { white-space: pre-wrap; border-bottom: 1px dashed var(--grid-line); padding: 1px 0; }
.log .t { color: var(--text-muted); } .log .alert { color: var(--crit); } .log .driver { color: var(--accent); }

/* integrated-rate panel (spectrum counts in an energy window / time) */
.rate { height: 100%; display: flex; flex-direction: column; padding: 8px 12px 6px; gap: 2px; }
.rate-value { font-size: 28px; font-weight: 600; font-family: var(--mono); line-height: 1.1; display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.rate-value .unit { font-size: 13px; color: var(--text-muted); font-family: var(--font); font-weight: 500; }
.rate-value .err { font-size: 12px; color: var(--text-muted); font-weight: 400; }
.rate.q-ok .rate-value .num { color: var(--text); } .rate.q-warn .rate-value .num { color: var(--warn); } .rate.q-muted .rate-value .num { color: var(--muted); }
.rate-sub { display: flex; gap: 6px; flex-wrap: wrap; color: var(--text-muted); font-size: 11px; }
.rate-sub .cov.warn { color: var(--warn); font-weight: 600; }
.rate-chart { flex: 1; min-height: 70px; width: 100%; margin-top: 4px; }
.rate-chart .u-legend { font-size: 10px; }
.rate-win { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--text-muted); margin-top: 4px; flex-wrap: wrap; }
.rate-win .k { text-transform: uppercase; letter-spacing: .4px; font-size: 10px; margin-right: 2px; }
.rate-win .u { margin-left: 2px; }
.rate-win .ts { margin-left: auto; font-family: var(--mono); }
.rate-in { width: 58px; padding: 1px 4px; border: 1px solid var(--border); border-radius: 3px; background: var(--surface-2); font-family: var(--mono); font-size: 11px; }
.rate-in:focus { border-color: var(--accent); outline: none; }
.rate-range { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--text-muted); flex-wrap: wrap; margin-top: 2px; }
.rate-range .k { text-transform: uppercase; letter-spacing: .4px; font-size: 10px; }
.rate-in.wide { width: auto; }
.rate-range select.rate-in { width: auto; padding: 1px 2px; }
.rate-range .rate-in[type=number] { width: 56px; }
.btn.tiny.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.tiny { padding: 0 6px; font-size: 11px; line-height: 18px; }
.range-in { display: flex; align-items: center; gap: 6px; margin-top: 3px; }
.range-in input { width: 90px; padding: 5px 7px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface-2); }

/* turbopump panel (HiCube / TC 110) */
.pump { height: 100%; display: flex; flex-direction: column; gap: 6px; padding: 6px 10px 8px; overflow: auto; }
.pump-hero { display: flex; align-items: stretch; justify-content: space-between; gap: 10px; }
.pump-hero-l { display: flex; flex-direction: column; min-width: 0; }
.pump-set { font-size: 10px; color: var(--text-muted); font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pump-spark { flex: 1 1 auto; min-width: 60px; max-width: 220px; height: 34px; align-self: center; }
.pump-speed { display: flex; align-items: baseline; gap: 5px; font-family: var(--mono); }
.pump-speed .num { font-size: 24px; font-weight: 600; line-height: 1.1; }
.pump-speed .unit { font-size: 12px; color: var(--text-muted); font-family: var(--font); }
.pump-pct { font-family: var(--mono); font-size: 13px; color: var(--text-muted); }
.pump-bar { height: 4px; border-radius: 2px; background: var(--grid-line); overflow: hidden; margin-top: -2px; }
.pump-bar .fill { height: 100%; width: 0; background: var(--muted); transition: width .6s ease; }
.pump-bar .fill.ok { background: var(--ok); } .pump-bar .fill.warn { background: var(--warn); }
.pump-bar .fill.crit { background: var(--crit); } .pump-bar .fill.stale { background: var(--stale); }
.pump-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--grid-line);
  border: 1px solid var(--grid-line); border-radius: 4px; overflow: hidden; }
.pump-cell { background: var(--surface); padding: 3px 6px; display: flex; flex-direction: column; min-width: 0; }
.pump-cell .k { font-size: 10px; text-transform: uppercase; letter-spacing: .4px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pump-cell .v { font-family: var(--mono); font-size: 13px; font-weight: 600; white-space: nowrap; }
.pump-grid.temps .pump-cell .v { font-size: 12px; font-weight: 500; }
.pump-cell .v.on { color: var(--ok); } .pump-cell .v.off { color: var(--text-muted); } .pump-cell .v.stale { color: var(--stale); }
.pump-cell .v.warn { color: var(--warn); } .pump-cell .v.crit { color: var(--crit); }
.pump-grid.info .pump-cell .v { font-size: 11px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 5px; }
.pump-grid.info .lamp { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.pump-badge.sim { background: var(--warn); margin-left: 0; }
/* acquisition run control on the spectrum panel */
.run-badge { font-weight: 400; text-transform: none; letter-spacing: 0; font-family: var(--mono); font-size: 11px; color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46%; }
.run-badge.ok { color: var(--ok); font-weight: 600; } .run-badge.warn { color: var(--warn); } .run-badge.crit { color: var(--crit); font-weight: 600; }
.run-btn { font-size: 11px; font-weight: 600; padding: 1px 8px; text-transform: none; letter-spacing: 0; }
/* target ladder panel */
.ladder { height: 100%; display: flex; flex-direction: column; gap: 8px; padding: 8px 10px; overflow: auto; }
.ladder-groups { display: flex; gap: 10px; flex-wrap: wrap; }
.ladder-group { flex: 1 1 180px; border: 1px solid var(--grid-line); border-radius: 6px; padding: 6px 8px; background: var(--surface-2); }
.ladder-group-title { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); font-weight: 700; margin-bottom: 5px; }
.ladder-aps { display: flex; gap: 6px; flex-wrap: wrap; }
.ladder-ap { display: flex; flex-direction: column; align-items: center; padding: 5px 10px; min-width: 96px; flex: 1 1 auto; }
.ladder-ap .n { font-weight: 700; font-size: 15px; } .ladder-ap .c { font-size: 10px; color: var(--text-muted); font-family: var(--mono); white-space: nowrap; }
.ladder-ap.active { border-color: var(--ok); border-width: 2px; background: color-mix(in srgb, var(--ok) 14%, transparent); }
.ladder-ap.active .c { color: var(--ok); }
.ladder-adjust { border: 1px dashed var(--border); border-radius: 6px; padding: 6px 8px; display: flex; flex-direction: column; gap: 6px; }
.ladder-adj-title { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); font-weight: 700; }
.ladder-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 11px; color: var(--text-muted); }
.ladder-row .k { font-size: 10px; }
.ladder-row .rate-in { width: 64px; }
.ladder-posfoot { font-family: var(--mono); font-size: 11px; color: var(--text-muted); white-space: nowrap; }
/* bigger ladder panel (own tab): scale the controls with the panel */
.grid-stack-item[gs-h="7"] .ladder, .grid-stack-item[gs-h="8"] .ladder { gap: 12px; padding: 12px 14px; }
.grid-stack-item[gs-h="7"] .ladder-ap .n, .grid-stack-item[gs-h="8"] .ladder-ap .n { font-size: 20px; }
.grid-stack-item[gs-h="7"] .ladder-ap, .grid-stack-item[gs-h="8"] .ladder-ap { padding: 10px 16px; min-width: 120px; }
.grid-stack-item[gs-h="7"] .ladder-row .btn, .grid-stack-item[gs-h="8"] .ladder-row .btn { padding: 6px 12px; font-size: 13px; }
.ladder-cal { height: 100%; overflow: auto; padding: 4px 0 6px; display: flex; flex-direction: column; gap: 6px; }
.ladder-cal-title { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); font-weight: 700; padding: 4px 8px 0; }
.ladder-hist { font-family: var(--mono); font-size: 11px; padding: 0 8px; display: flex; flex-direction: column; gap: 2px; }
.ladder-hist-row { display: flex; gap: 10px; border-bottom: 1px dashed var(--grid-line); padding: 2px 0; }
.ladder-hist-row .t { color: var(--text-muted); }
table.runs tr.over td:nth-child(4), table.runs tr.over td:nth-child(5) { color: var(--warn); font-weight: 600; }
/* turbo pump (Arduino remote) panel */
.turbo { height: 100%; display: flex; flex-direction: column; gap: 8px; padding: 8px 10px; }
.turbo-lamps { display: flex; flex-direction: column; gap: 4px; }
.turbo-row { display: grid; grid-template-columns: 14px 1fr auto; align-items: center; gap: 8px; font-size: 12px; }
.turbo-row .lamp { width: 10px; height: 10px; border-radius: 50%; }
.turbo-row .v { font-family: var(--mono); font-size: 12px; }
.turbo-outs { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 11px; color: var(--text-muted); }
.turbo-outs .k { text-transform: uppercase; letter-spacing: .4px; font-size: 10px; }
.turbo-out { font-family: var(--mono); padding: 1px 6px; border: 1px solid var(--grid-line); border-radius: 3px; }
.turbo-out.on { border-color: var(--ok); color: var(--ok); font-weight: 600; }
.turbo-il { display: flex; align-items: center; gap: 6px; }
.turbo-il .lamp { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.turbo-btns { display: flex; gap: 6px; }
/* runs panel */
.runs-wrap { height: 100%; overflow: auto; }
table.runs { width: 100%; border-collapse: collapse; font-size: 12px; }
table.runs th { text-align: left; font-weight: 600; color: var(--text-muted); padding: 4px 8px; border-bottom: 1px solid var(--border); font-size: 11px; text-transform: uppercase; position: sticky; top: 0; background: var(--surface); }
table.runs td { padding: 3px 8px; border-bottom: 1px solid var(--grid-line); white-space: nowrap; }
table.runs td.mono { font-family: var(--mono); }
table.runs td.edit { cursor: text; } table.runs td.edit:hover { color: var(--accent); }
table.runs td.notes { white-space: normal; min-width: 120px; color: var(--text-muted); }
table.runs tr.running td { background: color-mix(in srgb, var(--ok) 10%, transparent); font-weight: 600; }
table.runs tr.running td:first-child { border-left: 3px solid var(--ok); }
.log .run { color: var(--ok); font-weight: 600; }
.pump-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; }
.pump-err { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 12px; }
.pump-err > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pump-err .lamp { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.pump-badge { margin-left: auto; font-size: 10px; font-weight: 700; letter-spacing: .5px; padding: 1px 7px; border-radius: 3px;
  color: #fff; background: var(--muted); text-transform: uppercase; }
.pump-badge.ok { background: var(--ok); } .pump-badge.warn { background: var(--warn); }
.pump-badge.crit { background: var(--crit); } .pump-badge.stale { background: var(--stale); }
.btn.danger { background: var(--crit); border-color: var(--crit); color: #fff; }
.btn.go { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger:hover, .btn.go:hover { filter: brightness(1.1); border-color: transparent; }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.pump-btn { font-size: 12px; font-weight: 600; padding: 3px 10px; flex: 0 0 auto; }
.pump-dialog { width: 380px; }
.pump-dialog input[type=password] { width: 100%; padding: 5px 7px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface-2); margin-top: 3px; }
.pump-dialog p { margin: 0 0 8px; line-height: 1.45; }
.pump-dlg-err { color: var(--crit); font-size: 12px; min-height: 16px; }
.log .control { color: var(--warn); }

/* dialog */
dialog { border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); padding: 16px 18px; width: 460px; max-width: 95vw; }
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog h3 { margin: 0 0 10px; }
dialog label { display: block; margin: 8px 0; font-size: 12px; color: var(--text-muted); }
dialog label.inline { display: flex; align-items: center; gap: 6px; }
dialog input[type=text], dialog input:not([type]), dialog select { width: 100%; padding: 5px 7px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface-2); margin-top: 3px; }
.channel-list { max-height: 180px; overflow: auto; border: 1px solid var(--border); border-radius: 4px; margin-top: 4px; padding: 4px; background: var(--surface-2); }
.channel-list label { display: flex; gap: 6px; align-items: center; margin: 2px 0; font-size: 12px; color: var(--text); cursor: pointer; }
.channel-list code { color: var(--text-muted); font-size: 11px; }
dialog menu { display: flex; justify-content: flex-end; gap: 8px; margin: 12px 0 0; padding: 0; }
dialog .opt:not(.show) { display: none !important; }
.hint { color: var(--text-muted); font-size: 11px; }

/* ---- tablets: 6-column grid (gridstack.min.css only ships 12- and 1-column widths) --------- */
.gs-6 > .grid-stack-item { width: 16.667%; }
.gs-6 > .grid-stack-item[gs-w="2"] { width: 33.333%; }
.gs-6 > .grid-stack-item[gs-w="3"] { width: 50%; }
.gs-6 > .grid-stack-item[gs-w="4"] { width: 66.667%; }
.gs-6 > .grid-stack-item[gs-w="5"] { width: 83.333%; }
.gs-6 > .grid-stack-item[gs-w="6"] { width: 100%; }
.gs-6 > .grid-stack-item[gs-x="1"] { left: 16.667%; }
.gs-6 > .grid-stack-item[gs-x="2"] { left: 33.333%; }
.gs-6 > .grid-stack-item[gs-x="3"] { left: 50%; }
.gs-6 > .grid-stack-item[gs-x="4"] { left: 66.667%; }
.gs-6 > .grid-stack-item[gs-x="5"] { left: 83.333%; }

/* Layout editing needs the full 12-column grid; scaled-down views are read-only. */
@media (max-width: 1100px) { #edit-btn, #edit-tools { display: none !important; } }

/* ---- phones (the grid collapses to one column, see layout.js) ------------------------------ */
@media (max-width: 700px) {
  main { padding: 6px 6px 40px; }
  #topbar { gap: 8px; padding: 0 8px; min-height: 40px; }
  .brand { font-size: 13px; }
  .tabs { order: 10; flex: 1 0 100%; height: 38px; overflow-x: auto; scrollbar-width: none; margin: 0 -8px; padding: 0 4px; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button { height: 38px; padding: 0 10px; flex: 0 0 auto; }
  .controls { gap: 6px; }
  #clock, #health { display: none !important; }
  .drawer { left: 8px; right: 8px; width: auto; top: 86px; max-height: 75vh; }
  .stat .value { font-size: 24px; }
  .panel-head { padding: 5px 8px; }
  .panel-head .seg button { padding: 2px 5px; }
  table.alerts th, table.alerts td { padding: 4px 6px; }
}
@media (pointer: coarse) {
  .btn { padding: 6px 12px; }
  .tabs button { padding: 0 14px; }
  .image-wrap img { cursor: default; }
}
