:root {
  color-scheme: light;
  --bg: #f4f4f1;
  --surface-1: #fcfcfb;
  --surface-2: #f1f1ed;
  --surface-3: #e6e6e0;
  --border: #dcdcd5;
  --text-primary: #1b1b19;
  --text-secondary: #4a4a45;
  --text-muted: #77776f;
  --accent: #2a76d2;
  --robot-1: #3987e5;
  --robot-2: #d95926;
  --good: #168a62;
  --warn: #b07400;
  --crit: #c94545;
  --seq-0: #e3eefb; --seq-1: #b9d4f5; --seq-2: #86b6ef; --seq-3: #5598e7; --seq-4: #2f78d0; --seq-5: #1d5aa6; --seq-6: #104281;
  --radius: 8px;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { color-scheme: dark;
    --bg: #111110; --surface-1: #1a1a19; --surface-2: #222220; --surface-3: #2c2c2a; --border: #353532;
    --text-primary: #f0efec; --text-secondary: #c3c2b7; --text-muted: #8d8c84; --accent: #4b93ea;
    --good: #2bb586; --warn: #d99a1c; --crit: #e66767;
    --seq-0: #15253a; --seq-1: #173c66; --seq-2: #1d5aa6; --seq-3: #2f78d0; --seq-4: #5598e7; --seq-5: #86b6ef; --seq-6: #c3dbf8; }
}
:root[data-theme="dark"] { color-scheme: dark;
  --bg: #111110; --surface-1: #1a1a19; --surface-2: #222220; --surface-3: #2c2c2a; --border: #353532;
  --text-primary: #f0efec; --text-secondary: #c3c2b7; --text-muted: #8d8c84; --accent: #4b93ea;
  --good: #2bb586; --warn: #d99a1c; --crit: #e66767;
  --seq-0: #15253a; --seq-1: #173c66; --seq-2: #1d5aa6; --seq-3: #2f78d0; --seq-4: #5598e7; --seq-5: #86b6ef; --seq-6: #c3dbf8; }

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text-primary); }
body { min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; font-weight: 600; }
h2 { font-size: 15px; }
h3 { font-size: 13px; color: var(--text-secondary); }
.muted { color: var(--text-muted); }
.num { font-variant-numeric: tabular-nums; }
button, input, select { font: inherit; color: inherit; }
button { background: var(--surface-3); border: 1px solid var(--border); border-radius: 6px; padding: 6px 12px; cursor: pointer; }
button:hover { border-color: var(--text-muted); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--crit); }
button:disabled { opacity: .5; cursor: default; }
input, select { background: var(--surface-1); border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; min-width: 0; }
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: var(--surface-1);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.brand img { width: 26px; height: 26px; }
.brand b { color: var(--accent); }
.brand .site { font-weight: 400; color: var(--text-muted); }
nav.tabs { display: flex; gap: 2px; flex-wrap: wrap; }
nav.tabs a { padding: 6px 12px; border-radius: 6px; text-decoration: none; color: var(--text-secondary); }
nav.tabs a.active { background: var(--surface-3); color: var(--text-primary); }
nav.tabs a.admin::after { content: "admin"; font-size: 9px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-muted); margin-left: 5px; vertical-align: 2px; }
.spacer { flex: 1; }
.userbox { display: flex; align-items: center; gap: 8px; color: var(--text-secondary); }
.icon-btn { padding: 5px 9px; }

main { padding: 18px 24px 40px; max-width: 2200px; width: 100%; margin: 0 auto; }
.page { display: none; }
.page.active { display: block; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.page-head h1 { font-size: 20px; }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.g2 { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.card h2 { margin-bottom: 10px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card h2 .muted { font-weight: 400; font-size: 12px; }
.chart { width: 100%; height: 280px; }
.chart.tall { height: 360px; }
.chart.short { height: 200px; }

/* stat tiles */
.tile .label { color: var(--text-muted); font-size: 12px; }
.tile .value { font-size: 30px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile .sub { color: var(--text-secondary); font-size: 12px; margin-top: 4px; }

/* state pill: colour + label, never colour alone */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  background: var(--surface-3); font-weight: 600; font-size: 12px; letter-spacing: .3px; }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); }
.pill.good::before { background: var(--good); }
.pill.warn::before { background: var(--warn); }
.pill.crit::before { background: var(--crit); }

/* robots on the live page */
.robot-card { border-left: 4px solid var(--robot-color, var(--border)); }
.robot-card .row { display: flex; justify-content: space-between; padding: 3px 0; color: var(--text-secondary); }
.robot-card .row b { color: var(--text-primary); font-weight: 600; font-variant-numeric: tabular-nums; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

table { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
th { text-align: left; color: var(--text-muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 5px 8px; border-bottom: 1px solid var(--border); }
tr:hover td { background: var(--surface-2); }
.scroll { max-height: 520px; overflow: auto; }
.tag { font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--surface-3); color: var(--text-secondary); }
.tag.timeout, .tag.error, .tag.ERROR { color: var(--crit); }
.tag.WARNING { color: var(--warn); }

.notice { padding: 10px 14px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); margin-bottom: 14px; }
.notice.warn { border-color: var(--warn); }
.empty { color: var(--text-muted); padding: 30px; text-align: center; }

/* dialogs */
dialog { border: 1px solid var(--border); border-radius: 10px; background: var(--surface-1); color: var(--text-primary); padding: 20px; max-width: 420px; width: 92vw; }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog form { display: grid; gap: 10px; }
dialog label { display: grid; gap: 4px; font-size: 12px; color: var(--text-secondary); }
dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.secret { font-family: ui-monospace, monospace; background: var(--surface-3); padding: 8px; border-radius: 6px; user-select: all; word-break: break-all; }
.err { color: var(--crit); min-height: 1em; font-size: 12px; }

/* login */
.login-wrap { flex: 1; display: grid; place-items: center; padding: 20px; }
.login-card { width: 360px; max-width: 100%; }
.login-card form { display: grid; gap: 12px; margin-top: 14px; }
.login-card label { display: grid; gap: 4px; font-size: 12px; color: var(--text-secondary); }

@media (max-width: 700px) {
  .g2 { grid-template-columns: 1fr; }
  main { padding: 14px 12px 30px; }
  .topbar { padding: 8px 12px; }
}

.chart.timeline { height: 56px; }
.legend-row { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--text-secondary); margin: 2px 0 0 52px; }
.legend-row .swatch { vertical-align: -1px; }
.swatch.nodata { background: repeating-linear-gradient(45deg, var(--border), var(--border) 2px, transparent 2px, transparent 5px); border: 1px solid var(--border); }
.section-title { margin: 26px 0 10px; display: flex; gap: 8px; align-items: center; font-size: 16px; }
.card h2 .filters { font-weight: 400; font-size: 12px; }
.card table { table-layout: auto; }
.card .wrap td, .card .wrap th { white-space: normal; word-break: break-word; }
.card { overflow-x: auto; }
table.compact th, table.compact td { padding: 4px 5px; font-size: 12px; }

/* wide screens: more columns, tables keep their cells on one line */
@media (min-width: 1500px) { .g2 { grid-template-columns: repeat(auto-fit, minmax(620px, 1fr)); } }
.card td { white-space: nowrap; }
