:root {
  color-scheme: light;
  --bg: #f4f3f0;
  --surface: #fcfcfb;
  --border: #e2e1dc;
  --grid: #ecebe7;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #7a7974;
  --accent: #2a78d6;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --good: #0ca30c;
  --warning: #fab219;
  --critical: #d03b3b;
  --meter-track: #ecebe7;
  --error-bg: #fbebeb;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111110;
    --surface: #1a1a19;
    --border: #2e2e2c;
    --grid: #2a2a28;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #8f8e88;
    --accent: #3987e5;
    --series-1: #3987e5;
    --series-2: #d95926;
    --meter-track: #2a2a28;
    --error-bg: #3a1f1f;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111110;
  --surface: #1a1a19;
  --border: #2e2e2c;
  --grid: #2a2a28;
  --text: #f0efec;
  --text-2: #c3c2b7;
  --muted: #8f8e88;
  --accent: #3987e5;
  --series-1: #3987e5;
  --series-2: #d95926;
  --meter-track: #2a2a28;
  --error-bg: #3a1f1f;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
pre { background: var(--bg); padding: 12px; border-radius: 8px; overflow-x: auto; }
.muted { color: var(--muted); }
.error { background: var(--error-bg); color: var(--critical); padding: 8px 12px; border-radius: 8px; }

.top {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 650; color: var(--text); text-decoration: none; }
.top nav { display: flex; align-items: center; gap: 16px; }
.top nav a { text-decoration: none; }
.top nav form { margin: 0; }

main { max-width: 1280px; margin: 0 auto; padding: 16px; }

button, .button {
  font: inherit; cursor: pointer; border: 0; border-radius: 8px;
  background: var(--accent); color: #fff; padding: 8px 14px; text-decoration: none; display: inline-block;
}
button.small { padding: 4px 10px; font-size: 13px; background: var(--meter-track); color: var(--text); }
button.link { background: none; color: var(--accent); padding: 0; }
input {
  font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); width: 100%;
}

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px; }
.panel.narrow { max-width: 420px; margin: 40px auto; }
.panel h1 { margin-top: 0; font-size: 22px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack label { display: flex; flex-direction: column; gap: 4px; color: var(--text-2); }
.inline { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.inline input { flex: 1; min-width: 200px; width: auto; }
.callout { border: 1px solid var(--accent); border-radius: 10px; padding: 12px 16px; margin-bottom: 16px; }
.callout h2 { margin: 0 0 4px; font-size: 16px; }
.qr { display: flex; justify-content: center; padding: 12px; background: #fff; border-radius: 8px; width: max-content; margin: 0 auto; }

table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); }
table.list th { color: var(--text-2); font-weight: 550; font-size: 13px; }
td.actions { display: flex; gap: 6px; flex-wrap: wrap; }
td.actions form { margin: 0; }
tr.muted td { color: var(--muted); }
@media (max-width: 640px) {
  table.list th:nth-child(4), table.list td:nth-child(4) { display: none; }
}

.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); margin: 28px 0 10px; }

.summary { display: flex; flex-wrap: wrap; gap: 12px; }
.summary .tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; min-width: 150px;
}
.tile .label { font-size: 13px; color: var(--text-2); }
.tile .value { font-size: 26px; font-weight: 650; font-variant-numeric: tabular-nums; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 400px), 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; min-width: 0; }
.card h3 { margin: 0; font-size: 17px; }
.card.placeholder { border-style: dashed; }
/* last known readings stay visible but faded while a machine is offline */
.card.offline .meters, .card.offline .chart, .card.offline .kv, .card.offline details { opacity: .55; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.sub { font-size: 13px; color: var(--muted); margin: 2px 0 12px; }

.status { font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.status::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.status.good { color: var(--good); }
.status.critical { color: var(--critical); }
.status.warning { color: var(--text-2); }
.status.warning::before { background: var(--warning); }

.meters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 12px; }
.meter .label { font-size: 12px; color: var(--text-2); }
.meter .value { font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; }
.meter .bar { height: 6px; border-radius: 3px; background: var(--meter-track); overflow: hidden; margin-top: 4px; }
.meter .bar span { display: block; height: 100%; border-radius: 3px; background: var(--series-1); }
.meter .bar span.hot { background: var(--critical); }

.chart { position: relative; margin: 4px 0 12px; }
.chart svg { display: block; width: 100%; height: 120px; overflow: visible; }
.chart .legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); margin-bottom: 4px; }
.chart .legend i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
.chart .tip {
  position: absolute; top: 0; pointer-events: none; background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; padding: 4px 8px; font-size: 12px; white-space: nowrap; display: none;
  box-shadow: 0 2px 8px rgba(0,0,0,.12); font-variant-numeric: tabular-nums;
}
.axis { fill: var(--muted); font-size: 10px; }
.gridline { stroke: var(--grid); stroke-width: 1; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; font-size: 13px; margin: 0 0 12px; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

details { border-top: 1px solid var(--border); padding-top: 8px; margin-top: 8px; }
summary { cursor: pointer; font-size: 13px; color: var(--text-2); }
table.procs { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 6px; }
table.procs td, table.procs th { padding: 3px 4px; text-align: left; }
table.procs th { color: var(--text-2); font-weight: 550; }
table.procs td.num, table.procs th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.procs td.name { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
ul.services { list-style: none; padding: 0; margin: 6px 0 0; font-size: 13px; }
ul.services li { display: flex; justify-content: space-between; padding: 2px 0; }
