/* Machine Pulse — UI styles (light theme). Colors are roles from a validated
   palette, stepped for the light surface. */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f3f2ee;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --accent-wash: rgba(42, 120, 214, 0.10);
  --good: #0ca30c;
  --good-ink: #006300;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --critical-ink: #b42f2f;
  --st-run: #0ca30c;
  --st-stop: #b7b5ac;
  --st-none: #ecebe6;
  --st-pending-run: #9ed79e;
  --st-pending-stop: #d9d8d1;
  --planned: rgba(42, 120, 214, 0.07);
  --hatch: repeating-linear-gradient(135deg, var(--axis) 0 1.5px, var(--surface) 1.5px 6px);      /* no data */
  --hatch-sm: repeating-linear-gradient(135deg, var(--axis) 0 1.5px, var(--surface) 1.5px 4.5px);
  --seq-0: #cde2fb; --seq-1: #9ec5f4; --seq-2: #6da7ec; --seq-3: #3987e5;
  --seq-4: #256abf; --seq-5: #184f95; --seq-6: #0d366b;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 2px 8px rgba(11, 11, 11, 0.04);
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}


* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font: 14px/1.45 var(--font);
  color: var(--ink);
  background: var(--page);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; font-weight: 650; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 15px; font-weight: 650; margin: 0; }
h3 { font-size: 13px; font-weight: 650; margin: 0 0 8px; color: var(--ink-2); }
p { margin: 0 0 8px; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.ink2 { color: var(--ink-2); }
.small { font-size: 12px; }
.hidden { display: none !important; }

/* --- top bar ------------------------------------------------------------ */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 24px;
  padding: 0 24px; height: 56px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none !important; }
.brand-bg { fill: var(--ink); }

.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.brand-site { color: var(--muted); font-size: 13px; border-left: 1px solid var(--grid); padding-left: 10px; }
#nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
#nav a {
  color: var(--ink-2); padding: 7px 12px; border-radius: 8px; font-weight: 550; white-space: nowrap;
  text-decoration: none;
}
#nav a:hover { background: var(--surface-2); }
#nav a.active { color: var(--ink); background: var(--surface-2); }
.topbar-right { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
.updated { color: var(--muted); font-size: 12px; }
.demo-badge {
  font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--accent-ink); background: var(--accent-wash); padding: 3px 8px; border-radius: 999px;
}

main { max-width: 1440px; margin: 0 auto; padding: 20px 24px 64px; }
main.loading { opacity: 0.55; transition: opacity 0.15s; }

/* --- page header & filter row -------------------------------------------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head .sub { color: var(--ink-2); margin-top: 4px; }
.filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filters .grow { flex: 1; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 8px; padding: 2px; }
.seg button { border: 0; background: transparent; color: var(--ink-2); font: inherit; font-weight: 550; padding: 5px 10px; border-radius: 6px; cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* --- controls ------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 600;
  border: 1px solid var(--border); background: var(--surface); color: var(--ink);
  padding: 7px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap; text-decoration: none !important;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--critical-ink); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { padding: 4px 8px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: default; }
input[type=text], input[type=search], input[type=number], input[type=date], input[type=password], input[type=time], select, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 9px; min-width: 0;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
input[type=number] { width: 100px; }
label.field { display: grid; gap: 4px; font-weight: 550; color: var(--ink-2); font-size: 12.5px; }
label.check { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px 18px; }
.form-grid .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
.unit { display: flex; align-items: center; gap: 6px; }
.unit span { color: var(--muted); font-weight: 400; }
.err { color: var(--critical-ink); font-size: 12px; }

/* --- cards & layout ------------------------------------------------------------ */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head .sub { color: var(--muted); font-size: 12.5px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.stack { display: grid; gap: 16px; align-content: start; }
@media (max-width: 960px) { .grid2 { grid-template-columns: 1fr; } }

/* --- stat tiles ------------------------------------------------------------------ */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; box-shadow: var(--shadow); }
.kpi .label { color: var(--ink-2); font-size: 12.5px; font-weight: 550; display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 28px; font-weight: 650; letter-spacing: -0.02em; margin-top: 2px; }
.kpi .value small { font-size: 15px; font-weight: 550; color: var(--muted); margin-left: 3px; }
.kpi .foot { color: var(--muted); font-size: 12px; }

/* --- state pills (icon + label, never color alone) --------------------------------- */
.pill { display: inline-flex; align-items: center; gap: 6px; font-weight: 650; font-size: 12.5px; padding: 2px 9px 2px 7px; border-radius: 999px; white-space: nowrap; }
.pill .ico { width: 9px; height: 9px; flex: none; }
.pill.running { color: var(--good-ink); background: rgba(12, 163, 12, 0.10); }
.pill.running .ico { background: var(--st-run); border-radius: 50%; }
.pill.stopped { color: var(--ink-2); background: var(--surface-2); }
.pill.stopped .ico { background: var(--muted); border-radius: 2px; }
.pill.offline { color: var(--critical-ink); background: rgba(208, 59, 59, 0.10); }
.pill.offline .ico { width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 9px solid var(--critical); }
.pill.unknown { color: var(--muted); background: var(--surface-2); }
.pill.unknown .ico { border: 2px solid var(--muted); border-radius: 50%; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; }

/* --- machine cards ------------------------------------------------------------------- */
.mgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.mcard {
  display: grid; gap: 8px; color: var(--ink); text-decoration: none !important;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 16px 12px; transition: border-color 0.12s;
}
.mcard:hover { border-color: var(--axis); }
.mcard-top { display: flex; align-items: center; gap: 8px; }
.mcard-top .since { color: var(--ink-2); font-size: 12.5px; }
.mcard-top .icons { margin-left: auto; display: flex; gap: 10px; color: var(--muted); font-size: 12px; align-items: center; }
.mcard-name { font-weight: 650; font-size: 15.5px; line-height: 1.25; overflow-wrap: anywhere; }
.mcard-sub { color: var(--muted); font-size: 12.5px; margin-top: -6px; min-height: 18px; }
.mcard-util { display: flex; align-items: baseline; gap: 8px; }
.mcard-util .big { font-size: 22px; font-weight: 650; letter-spacing: -0.02em; }
.mcard-util .lbl { color: var(--muted); font-size: 12.5px; }
.meter { height: 6px; border-radius: 999px; background: var(--seq-0); overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.strip { display: block; width: 100%; border-radius: 4px; background: var(--hatch); }
.strip-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; margin-top: -4px; }
.flag { color: var(--serious); font-size: 12px; font-weight: 600; }
.flag.warn { color: #b77a00; }


/* --- legend ----------------------------------------------------------------------------- */
.legend { display: flex; gap: 14px; flex-wrap: wrap; color: var(--ink-2); font-size: 12.5px; align-items: center; }
.legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -2px; }
.legend .ln { display: inline-block; width: 16px; height: 0; border-top: 2px solid; margin-right: 6px; vertical-align: 3px; }

/* --- gantt ---------------------------------------------------------------------------------- */
.gantt { display: grid; grid-template-columns: minmax(150px, 220px) 1fr 64px; align-items: center; row-gap: 6px; column-gap: 12px; }
.gantt .gname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.gantt .gname small { display: block; color: var(--muted); font-weight: 400; font-size: 11.5px; }
.gantt .gutil { text-align: right; font-weight: 650; }
.gantt .gaxis { position: relative; height: 18px; color: var(--muted); font-size: 11px; }
.gantt .gaxis span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.gantt .ghead { color: var(--muted); font-size: 12px; font-weight: 550; }

/* --- tables ------------------------------------------------------------------------------------ */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th { text-align: left; color: var(--ink-2); font-weight: 600; font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
td { padding: 8px 10px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
tr.total td { font-weight: 650; border-bottom: 0; border-top: 1px solid var(--axis); }
tbody tr:hover { background: var(--surface-2); }
th.sort { cursor: pointer; }
th.sort:hover { color: var(--ink); }

/* --- charts --------------------------------------------------------------------------------------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; overflow: visible; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .tick line, .chart .gridline { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart .crosshair { stroke: var(--ink-2); stroke-width: 1; shape-rendering: crispEdges; pointer-events: none; }
.chart .thr { stroke: var(--ink-2); stroke-width: 1; shape-rendering: crispEdges; }
.chart .thr-label { fill: var(--ink-2); font-weight: 600; }
.chart .sugg { stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 4 3; }
.chart .sugg-label { fill: var(--accent-ink); font-weight: 650; }
.chart-empty { color: var(--muted); padding: 32px 0; text-align: center; }

/* --- what the puck feels: mounting check + small multiples --------------------------------------- */
.mcheck { background: var(--surface-2); border-radius: 8px; padding: 10px 14px 12px; display: grid; gap: 7px; }
.mcheck-head { font-weight: 650; font-size: 13px; color: var(--ink-2); }
.mitem { display: grid; grid-template-columns: 20px 1fr; gap: 8px; align-items: start; font-size: 13px; line-height: 1.45; }
.mitem b { color: var(--ink); font-weight: 650; }
.mitem span:last-child { color: var(--ink-2); }
.micon { width: 18px; height: 18px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; color: #fff; margin-top: 1px; }
.mitem.good .micon { background: var(--good); }
.mitem.warn .micon { background: var(--warning); color: var(--ink); }
.mitem.info .micon { background: var(--accent); }
.sig { display: grid; }
.sig-row { display: grid; grid-template-columns: 176px minmax(0, 1fr) 196px; gap: 14px; align-items: center;
  padding: 5px 0; border-top: 1px solid var(--grid); }
.sig-row.sig-axis { border-top: 0; padding: 0; }
.sig-label b { display: block; font-size: 13px; }
.sig-label span { display: block; font-size: 11.5px; color: var(--muted); line-height: 1.35; }
.sig-sum { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--muted); }
.sig-verdict { color: var(--ink); font-weight: 600; font-size: 12.5px; }
.sig-chart { position: relative; width: 100%; }
.sig-chart svg { display: block; overflow: visible; }
.sig-chart text { fill: var(--muted); font-size: 10.5px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.sig-chart .gridline { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.sig-chart .crosshair { stroke: var(--ink-2); stroke-width: 1; shape-rendering: crispEdges; pointer-events: none; }
.sig-chart .thr { stroke: var(--ink-2); stroke-width: 1; shape-rendering: crispEdges; }
.sig-chart .thr-label { fill: var(--ink-2); font-weight: 600; }
.sig-run { fill: var(--st-run); opacity: 0.12; }
.sig-band { fill: var(--accent); opacity: 0.12; }
.sig-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.sig-dot { fill: var(--accent); }
.sig-hdot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; pointer-events: none; }
.sig-off { fill: var(--surface-2); }
.sig-chart .sig-off-text { fill: var(--muted); font-size: 11.5px; }
@media (max-width: 760px) {
  .sig-row { grid-template-columns: 1fr; gap: 4px; }
  .sig-row.sig-axis > div:first-child, .sig-row.sig-axis > div:last-child { display: none; }
}
.tableview { margin-top: 8px; max-height: 320px; overflow: auto; }

/* --- tooltip --------------------------------------------------------------------------------------- */
#tooltip {
  position: fixed; z-index: 50; pointer-events: none; min-width: 120px; max-width: 280px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font-size: 12.5px;
  box-shadow: 0 4px 16px rgba(11, 11, 11, 0.12);
}
#tooltip .tt-title { color: var(--ink-2); font-size: 11.5px; margin-bottom: 4px; }
#tooltip .tt-row { display: flex; align-items: center; gap: 8px; }
#tooltip .tt-row b { font-weight: 650; font-variant-numeric: tabular-nums; }
#tooltip .tt-row span { color: var(--ink-2); }
#tooltip .key { width: 12px; height: 0; border-top: 2px solid; flex: none; }
#tooltip .keybox { width: 10px; height: 10px; border-radius: 2px; flex: none; }

#toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 60;
  background: var(--ink); color: var(--page); padding: 9px 16px; border-radius: 8px; font-weight: 550;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
}

/* --- detail page ------------------------------------------------------------------------------- */
.detail-head { display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; margin-bottom: 16px; }
.detail-head .title { display: grid; gap: 6px; }
.detail-head .meta { display: flex; gap: 4px 10px; align-items: center; flex-wrap: wrap; color: var(--ink-2); }
.detail-head .name-row { display: flex; gap: 12px; align-items: center; }
.head-dev { text-align: right; }
.only-sm { display: none; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 550; overflow-wrap: anywhere; }
.events { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.events li { display: grid; grid-template-columns: 120px 1fr; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--grid); font-size: 13px; }
.events li:last-child { border-bottom: 0; }
.events time { color: var(--muted); font-variant-numeric: tabular-nums; }
.banner { border-radius: 8px; padding: 9px 12px; font-size: 13px; display: flex; gap: 8px; align-items: flex-start; }
.banner.info { background: var(--accent-wash); color: var(--ink); }
.banner.warn { background: rgba(250, 178, 25, 0.14); color: var(--ink); }
.banner.ok { background: rgba(12, 163, 12, 0.09); color: var(--ink); }
.callout { background: var(--surface-2); border-radius: 8px; padding: 12px 14px; }
.calib-suggest { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.danger-zone { border-color: rgba(208, 59, 59, 0.35); }
pre.snippet { background: var(--surface-2); border-radius: 8px; padding: 12px 14px; overflow-x: auto; margin: 6px 0 10px; }
.copyrow { display: flex; gap: 8px; align-items: center; }
.sched { display: grid; grid-template-columns: 110px auto auto 1fr; gap: 8px 12px; align-items: center; }
.login { max-width: 360px; margin: 12vh auto; }

/* --- sensitivity ------------------------------------------------------------------------------- */
.sens-row { display: grid; grid-template-columns: auto 1fr auto auto; gap: 6px 14px; align-items: start; }
.sens-end { font-weight: 650; font-size: 13px; display: grid; line-height: 1.25; padding-top: 2px; }
.sens-end small { font-weight: 400; color: var(--muted); font-size: 11.5px; }
.sens-end.r { text-align: right; }
.sens-track { position: relative; padding-bottom: 18px; }
.sens-slider { width: 100%; margin: 4px 0 0; accent-color: var(--accent); height: 22px; cursor: pointer; }
.sens-auto { position: absolute; top: 28px; transform: translateX(-50%); font-size: 10.5px; font-weight: 650;
  color: var(--accent-ink); text-transform: uppercase; letter-spacing: 0.04em; pointer-events: none; }
.sens-auto::before { content: ""; position: absolute; left: 50%; top: -6px; width: 1px; height: 5px; background: var(--accent-ink); }
.sens-val { display: grid; justify-items: end; min-width: 150px; }
.sens-val b { font-size: 24px; font-weight: 650; line-height: 1.1; }
.sens-mode { color: var(--muted); font-size: 12px; text-align: right; }
.sens-stats { display: flex; gap: 6px 18px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); align-items: baseline; }
.sens-stats b { color: var(--ink); font-size: 15px; }
.delta { font-weight: 650; }
.delta.up { color: var(--good-ink); }
.delta.down { color: var(--critical-ink); }
.sens-levels { display: flex; gap: 6px 8px; flex-wrap: wrap; align-items: center; }
.lvl { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 2px 8px;
  border-radius: 999px; background: var(--surface-2); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.lvl .dot { width: 8px; height: 8px; }
.lvl.on .dot { background: var(--st-run); }
.lvl.off .dot { background: var(--st-stop); }

@media (max-width: 720px) {
  .sens-row { grid-template-columns: 1fr 1fr; }
  .sens-track { grid-column: 1 / -1; grid-row: 2; }
  .sens-end.r { grid-column: 2; grid-row: 1; }
  .sens-val { grid-column: 1 / -1; justify-items: start; }
  .topbar { padding: 8px 12px 6px; gap: 6px 12px; height: auto; flex-wrap: wrap; }
  #nav { order: 3; flex-basis: 100%; }
  #nav a { padding: 6px 7px; font-size: 13.5px; }
  .topbar-right { margin-left: auto; }
  .brand-site, .updated { display: none; }
  main { padding: 14px 12px 48px; }
  .gantt { grid-template-columns: 110px 1fr 48px; column-gap: 8px; }
  .events li { grid-template-columns: 1fr; gap: 2px; }
}
tbody tr.sel { background: var(--accent-wash); }

/* --- phones --------------------------------------------------------------------------------------- */
/* Grid children may shrink below their content, so a wide table scrolls inside its card
   instead of widening the page (which makes a phone zoom everything out). */
.stack > *, .grid2 > *, .kpis > *, .mgrid > * { min-width: 0; }
.table-wrap { -webkit-overflow-scrolling: touch; }
.seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg button { white-space: nowrap; }
.chart .halo { paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round; }

@media (max-width: 600px) {
  h1 { font-size: 20px; }
  .page-head { margin-bottom: 10px; }
  .page-head .sub { font-size: 13px; }
  .filters { gap: 6px; margin-bottom: 12px; }
  .stack { gap: 12px; }
  .grid2 { gap: 12px; }
  .card { padding: 12px 12px 14px; }
  .card-head { margin-bottom: 8px; gap: 6px 8px; }
  .card-head h2 { font-size: 15px; }
  /* tiles: two per row, an odd last one across the whole row */
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
  .kpis > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  .kpi { padding: 9px 12px; }
  .kpi .value { font-size: 22px; }
  .kpi .foot { font-size: 11.5px; }
  /* machine cards: one per row, compact; the 24 h strip says what the meter and axis said */
  .mgrid { grid-template-columns: 1fr; gap: 8px; }
  .mcard { padding: 10px 12px; gap: 5px; }
  .mcard-name { font-size: 15px; }
  .mcard-sub { margin-top: -4px; min-height: 0; }
  .mcard-util .big { font-size: 17px; }
  .mcard .meter, .mcard .strip-axis { display: none; }
  /* timeline: the name and utilization on one line, the day's bar full width below */
  .gantt { grid-template-columns: minmax(0, 1fr) auto; grid-auto-flow: row dense; row-gap: 3px; column-gap: 8px; }
  .gantt > .strip, .gantt > .gaxis { grid-column: 1 / -1; }
  .gantt > .strip { margin-bottom: 6px; }
  .gantt .gname { white-space: normal; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
  .gantt .gname small { display: inline; }
  /* tables: fewer columns, tighter cells */
  .hide-sm { display: none; }
  table { font-size: 12.5px; }
  th, td { padding: 7px 8px; }
  .kv { gap: 4px 12px; font-size: 12.5px; }
  .banner { font-size: 12.5px; }
  .legend { gap: 6px 12px; font-size: 12px; }
}
/* first and last labels of a time axis stay inside the card */
.gantt .gaxis span:first-child { transform: none; }
.gantt .gaxis span:last-child { transform: translateX(-100%); }
@media (max-width: 600px) {
  /* tables with class rows-sm: each row a two-line entry (name, then the facts) */
  table.rows-sm thead { display: none; }
  table.rows-sm tr { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 9px 2px; border-bottom: 1px solid var(--grid); }
  table.rows-sm td { display: inline-flex; align-items: center; gap: 4px; padding: 0; border: 0; }
  table.rows-sm td:first-child { flex-basis: 100%; font-weight: 600; font-size: 14px; }
  table.rows-sm td[data-label]::before { content: attr(data-label); color: var(--muted); }
  table.rows-sm .dash { display: none; }
  table.rows-sm tbody tr:hover { background: none; }
}
@media (max-width: 600px) {
  table.rows-sm td.hide-sm { display: none; }
  .sched { grid-template-columns: 92px minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
  .sched > span:empty { display: none; }
  .sched input[type=time] { width: 100%; min-width: 0; }
}
@media (max-width: 600px) {
  table.rows-sm tr { gap: 3px 9px; }
  table.rows-sm td:not(:first-child) { font-size: 12.5px; }
}

/* --- phones: no boxes. Sections are a heading and a hairline on one white surface. --- */
@media (max-width: 600px) {
  body { background: var(--surface); }
  .card { background: none; border: 0; border-radius: 0; box-shadow: none; padding: 14px 0 2px; border-top: 1px solid var(--grid); }
  .card-head h2 { font-size: 16px; }
  .stack { gap: 6px; }
  .grid2 { gap: 6px; }
  /* key figures: a plain two-column grid divided by hairlines */
  .kpis { gap: 0; margin-bottom: 4px; border-top: 1px solid var(--grid); }
  .kpi { background: none; border: 0; border-radius: 0; box-shadow: none; padding: 10px 0; }
  .kpis > .kpi:nth-child(odd) { padding-right: 12px; }
  .kpis > .kpi:nth-child(even) { padding-left: 12px; border-left: 1px solid var(--grid); }
  .kpis > .kpi:nth-child(n+3) { border-top: 1px solid var(--grid); }
  .kpis > .kpi:last-child:nth-child(odd) { padding-right: 0; }
  /* machines: list rows instead of cards */
  .mgrid { gap: 0; }
  .mcard { background: none; border: 0; border-radius: 0; box-shadow: none; padding: 12px 0; border-top: 1px solid var(--grid); }
  .mcheck { background: none; padding: 4px 0; }
}

/* --- phones: each device / machine of a list in its own light gray box --- */
@media (max-width: 600px) {
  table.rows-sm, table.rows-sm tbody { display: block; }
  table.rows-sm tr { background: var(--surface-2); border-radius: 10px; border-bottom: 0; padding: 10px 12px; margin-bottom: 8px; }
  .mgrid { gap: 8px; }
  .mcard { background: var(--surface-2); border-radius: 10px; border-top: 0; padding: 10px 12px; }
}
@media (max-width: 600px) {
  .mcard .pill.stopped, .mcard .pill.unknown, table.rows-sm .pill.stopped, table.rows-sm .pill.unknown { background: var(--surface); }
}

/* --- machine page: running and stopped, day by day --- */
.days { display: grid; grid-template-columns: 84px minmax(0, 1fr) 48px; align-items: center; gap: 8px 12px; padding-top: 14px; }
.days-label { font-size: 13px; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.days-pct { text-align: right; font-weight: 650; }
.days .strip-axis { margin-top: -2px; }
.strip-axis.abs { display: block; position: relative; height: 1.4em; }
.strip-axis.abs span { position: absolute; top: 0; transform: translateX(-50%); white-space: nowrap; }
.strip-axis.abs span:first-child { transform: none; }
.strip-axis.abs span:last-child { transform: translateX(-100%); }
.days-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; }
.daybar { position: relative; }
.daybar-now { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; background: var(--ink); border-radius: 1px; }
.daybar-now span { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); font-size: 10.5px; font-weight: 650; color: var(--ink); line-height: 1.3; }
.legend .sw.hatch { background: var(--hatch-sm); box-shadow: inset 0 0 0 1px var(--grid); }
@media (max-width: 600px) {
  .days { grid-template-columns: 64px minmax(0, 1fr) 38px; gap: 8px; }
  .days-label { font-size: 12px; }
}

/* --- machine page: key figures inside the Utilization section --- */
.util-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--grid); margin-top: 4px; }
.util-stats > div { padding: 12px 16px 0; min-width: 0; }
.util-stats > div:first-child { padding-left: 0; }
.util-stats > div + div { border-left: 1px solid var(--grid); }
.util-stats .label { color: var(--ink-2); font-size: 12.5px; font-weight: 550; }
.util-stats .value { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.util-stats .foot { color: var(--muted); font-size: 12px; }

/* --- phones: a compact machine header, wider day bars, a nav that always fits --- */
@media (max-width: 600px) {
  .only-sm { display: inline; }
  .detail-head { display: block; margin-bottom: 8px; }
  .detail-head .title { gap: 3px; }
  .detail-head .name-row { justify-content: space-between; gap: 10px; }
  /* one flowing line; a separator stays at the end of a line, never starts one */
  .detail-head .meta { display: block; font-size: 12.5px; line-height: 1.45; color: var(--muted); }
  .detail-head .meta > span:not(:last-child)::after { content: '\00A0\00B7\20'; }
  .head-dev { display: none; }
  .days { grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; }
  .days-label { font-size: 12px; }
  .days-pct { font-size: 12.5px; }
  .util-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .util-stats > div { padding: 10px 0 8px; }
  .util-stats > div:nth-child(odd) { padding-right: 12px; border-left: 0; }
  .util-stats > div:nth-child(even) { padding-left: 12px; }
  .util-stats > div:nth-child(n+3) { border-top: 1px solid var(--grid); }
  .util-stats .value { font-size: 22px; }
  .util-stats .foot { font-size: 11.5px; }
}
@media (max-width: 720px) {
  .topbar { padding: 6px 12px 5px; row-gap: 4px; }
  #nav { gap: 2px; overflow: visible; }
  #nav a { flex: 1 1 0; min-width: 0; padding: 6px 2px; text-align: center; font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
}
@media (max-width: 350px) {
  #nav a { font-size: 12px; }
}

/* --- the activity graph moves through time: a pad over it takes touches and drags (it is
       never redrawn, so a gesture keeps going while the chart under it is) --- */
.trace-wrap { position: relative; }
.trace-pad { position: absolute; inset: 0; touch-action: pan-y; cursor: grab; user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.trace-pad.grabbing { cursor: grabbing; }
