/* Hoptech Monitor — light/dark tokens per the validated reference palette. */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series-1: #2a78d6;
  --band: rgba(42, 120, 214, 0.10);
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --good-text: #006300;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5;
    --band: rgba(57, 135, 229, 0.14);
    --good-text: #0ca30c;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --series-1: #3987e5;
  --band: rgba(57, 135, 229, 0.14);
  --good-text: #0ca30c;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--ink);
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--series-1); text-decoration: none; }
button {
  font: inherit; cursor: pointer; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink);
  border-radius: 8px; padding: 7px 14px;
}
button.primary { background: var(--series-1); border-color: var(--series-1); color: #fff; }
button.small { padding: 3px 10px; font-size: 13px; }
button.ghost { border: none; background: none; color: var(--series-1); padding: 4px 6px; }
input, select {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--baseline); border-radius: 8px; padding: 8px 10px;
  width: 100%;
}
label { font-size: 13px; color: var(--ink-2); display: block; margin: 10px 0 4px; }

header.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.topbar .logo { font-weight: 700; letter-spacing: -0.02em; font-size: 17px; }
.topbar .logo .dot { color: var(--series-1); }
.topbar nav { display: flex; gap: 4px; margin-left: auto; }
.topbar nav a {
  padding: 6px 12px; border-radius: 8px; color: var(--ink-2); font-size: 14px;
}
.topbar nav a.active { background: var(--band); color: var(--series-1); font-weight: 600; }

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

h1 { font-size: 20px; margin: 10px 0 2px; }
h2 { font-size: 15px; color: var(--ink-2); font-weight: 600; margin: 22px 0 10px; }
.sub { color: var(--muted); font-size: 13px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px;
}
/* Device tiles: technical corner ticks + a faint dot-grid field behind the
   sparkline area — the "instrument" look. */
.card.device {
  cursor: pointer; transition: border-color 0.15s; position: relative;
  background-image: radial-gradient(var(--grid) 1px, transparent 1.1px);
  background-size: 14px 14px;
  background-position: 7px 9px;
}
.card.device::before, .card.device::after {
  content: ""; position: absolute; width: 9px; height: 9px;
  border: 1.5px solid var(--baseline); pointer-events: none;
  transition: border-color 0.15s;
}
.card.device::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; border-top-left-radius: 12px; }
.card.device::after { bottom: -1px; right: -1px; border-left: 0; border-top: 0; border-bottom-right-radius: 12px; }
.card.device:hover { border-color: var(--series-1); }
.card.device:hover::before, .card.device:hover::after { border-color: var(--series-1); }

.ic { width: 17px; height: 17px; vertical-align: -3.5px; }
.st-good { color: var(--good-text); }
.st-critical { color: var(--critical); }
.st-muted { color: var(--muted); }
.st-accent { color: var(--series-1); }
.devicon { display: inline-flex; margin-right: 7px; color: var(--series-1); vertical-align: -4px; }
.devicon .ic { width: 19px; height: 19px; }

.tile-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.tile-name {
  font-family: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, monospace;
  font-weight: 600; font-size: 11.5px; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--ink-2);
}
.tile-main { display: flex; align-items: center; gap: 12px; margin-top: 6px; }
.tile-glyph svg { display: block; }
.glyph-strip { display: flex; gap: 26px; flex-wrap: wrap; margin: 14px 0 6px; padding: 18px 20px 14px; }
.glyph-cell svg { display: block; }

.tile-value {
  font-family: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, monospace;
  font-size: 29px; font-weight: 700; letter-spacing: -0.01em; margin: 4px 0 0;
  font-variant-numeric: tabular-nums;
}
.tile-value .unit { font-size: 14px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.tile-sub { display: flex; gap: 12px; margin-top: 4px; font-size: 12.5px; color: var(--muted); align-items: center; }
.tile-sub .ic { width: 15px; height: 15px; vertical-align: -3px; }

.status {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase;
}
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status.ok::before { animation: pulse 2.4s ease-in-out infinite; }
.status.alert::before { animation: pulse 0.9s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: 0.35 } }
@media (prefers-reduced-motion: reduce) { .status::before { animation: none !important; } }
.status.ok { color: var(--good-text); }
.status.alert { color: var(--critical); }
.status.warn { color: var(--serious); }
.status.off { color: var(--muted); }

.alert-row {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 4px; border-bottom: 1px solid var(--grid); font-size: 14px;
}
.alert-row .icon { line-height: 1.3; }
.alert-row .icon .ic { width: 18px; height: 18px; }
.alert-row .when { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.alert-row.resolved { color: var(--ink-2); }

.chart-wrap { position: relative; }
.chart-tip {
  position: absolute; pointer-events: none; display: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 9px; font-size: 12.5px; box-shadow: 0 2px 10px rgba(0,0,0,0.18);
  white-space: nowrap; z-index: 5;
}
.chart-tip b { font-variant-numeric: tabular-nums; }
.range-row { display: flex; gap: 6px; margin: 10px 0; flex-wrap: wrap; }
.range-row button.active { background: var(--band); border-color: var(--series-1); color: var(--series-1); font-weight: 600; }

.tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.gridline { stroke: var(--grid); stroke-width: 1; }
.baseline { stroke: var(--baseline); stroke-width: 1; }

table.plain { border-collapse: collapse; width: 100%; font-size: 14px; }
table.plain th, table.plain td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--grid); }
table.plain th { color: var(--muted); font-weight: 600; font-size: 12.5px; }
table.plain td.num { font-variant-numeric: tabular-nums; }

.login-box { max-width: 360px; margin: 12vh auto 0; }
.login-box .card { padding: 22px; }
.err { color: var(--critical); font-size: 13.5px; margin-top: 8px; min-height: 18px; }

.modal-back {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 20;
  display: flex; align-items: flex-start; justify-content: center; padding: 4vh 12px;
  overflow-y: auto;
}
.modal { background: var(--page); border-radius: 14px; max-width: 760px; width: 100%; padding: 18px; }
.modal .close { float: right; }

.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.pill {
  font-size: 11.5px; padding: 2px 8px; border-radius: 999px;
  background: var(--band); color: var(--series-1); font-weight: 600;
}
.muted { color: var(--muted); }
.mt { margin-top: 14px; }
.right { text-align: right; }
footer { text-align: center; color: var(--muted); font-size: 12px; padding: 30px 0 20px; }
