/* F1 console on top of Pico. Chart and status colours are tokens (light below, dark under both scopes). */
:root {
  --surface-1: #fcfcfb; --text-1: #0b0b0b; --text-2: #52514e; --grid: #e5e4e0; --axis: #b9b8b2;
  --series-1: #2a78d6; --series-2: #eb6834; --pos: #2a78d6; --neg: #e34948;
  --good: #0ca30c; --good-text: #006300; --warning: #fab219; --warning-text: #8a5a00; --serious: #ec835a; --critical: #d03b3b;
  --pico-font-size: 15px;
  --pico-font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    --surface-1: #1a1a19; --text-1: #f0efec; --text-2: #c3c2b7; --grid: #383835; --axis: #6b6a64;
    --series-1: #3987e5; --series-2: #d95926; --pos: #3987e5; --neg: #e66767;
    --good-text: #4cc94c; --warning-text: #fab219;
  }
}
:root[data-theme="dark"] {
  --surface-1: #1a1a19; --text-1: #f0efec; --text-2: #c3c2b7; --grid: #383835; --axis: #6b6a64;
  --series-1: #3987e5; --series-2: #d95926; --pos: #3987e5; --neg: #e66767;
  --good-text: #4cc94c; --warning-text: #fab219;
}
[v-cloak] { display: none; }
body { background: var(--pico-background-color); }
.muted { color: var(--pico-muted-color); }
.small { font-size: 0.82rem; }
.error { color: var(--critical); }
.banner { padding: 0.5rem 1rem; border: 1px solid var(--critical); border-radius: 6px; }

/* login */
.login { max-width: 420px; margin-top: 10vh; }

/* top bar and tabs */
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; padding: 0.6rem 1rem; border-bottom: 1px solid var(--pico-muted-border-color); }
.brand { font-weight: 700; }
.pills { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.topbar .right { margin-left: auto; display: flex; align-items: center; gap: 0.6rem; }
.eq { font-weight: 700; font-variant-numeric: tabular-nums; }
.small-btn { padding: 0.2rem 0.6rem; font-size: 0.85rem; margin: 0; width: auto; }
.tabs { display: flex; justify-content: flex-start; gap: 0.2rem; padding: 0 1rem; border-bottom: 1px solid var(--pico-muted-border-color); overflow-x: auto; }
.tabs a { padding: 0.55rem 0.8rem; text-decoration: none; color: var(--pico-muted-color); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--pico-color); border-bottom-color: var(--series-1); font-weight: 600; }
.page { padding-top: 1rem; padding-bottom: 3rem; }

/* status pills: colour + icon + label, never colour alone */
.pill { display: inline-block; padding: 0.1rem 0.55rem; border-radius: 999px; font-size: 0.82rem; border: 1px solid currentColor; white-space: nowrap; }
.s-good, .s-ok { color: var(--good-text); }
.s-warning, .s-warn { color: var(--warning-text); }
.s-serious { color: var(--serious); }
.s-critical, .s-bad { color: var(--critical); }
.s-muted { color: var(--pico-muted-color); }
.good-text { color: var(--good-text); }
.warn-text { color: var(--warning-text); }
.bad-text { color: var(--critical); }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0.8rem; }
.kpi { margin: 0; padding: 0.8rem 1rem; display: flex; flex-direction: column; gap: 0.15rem; }
.kpi small { color: var(--pico-muted-color); }
.kpi strong { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 1rem; margin-top: 1rem; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }
article { margin-bottom: 1rem; }
article > header { font-weight: 600; }
header.sub { margin-top: 1rem; font-weight: 600; }

/* health checks */
.checks { list-style: none; padding: 0; margin: 0; }
.checks li { display: grid; grid-template-columns: 1.4rem 8.5rem 1fr; gap: 0.3rem; padding: 0.25rem 0; border-bottom: 1px solid var(--pico-muted-border-color); list-style: none; }
.checks .icon { font-weight: 700; }
.checks .name { color: var(--pico-color); }
.checks .text { color: var(--pico-muted-color); font-size: 0.88rem; }

/* tables */
table.compact { font-size: 0.86rem; margin-bottom: 0.5rem; }
table.compact th, table.compact td { padding: 0.3rem 0.5rem; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.sortable th { cursor: pointer; user-select: none; }
table.clickable tbody tr { cursor: pointer; }
table.clickable tbody tr.selected td { background: var(--pico-primary-focus); }
.long { color: var(--pos); }
.short { color: var(--neg); }
.chan { display: inline-block; margin-right: 0.8rem; white-space: nowrap; }

/* charts */
.chart { height: 340px; width: 100%; }
.chart-sm { height: 220px; width: 100%; }

/* toolbars and forms */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.8rem; margin-bottom: 0.8rem; }
.toolbar [role="group"] { width: auto; margin: 0; }
.toolbar [role="group"] button { padding: 0.3rem 0.8rem; font-size: 0.88rem; }
label.inline { display: inline-flex; align-items: center; gap: 0.5rem; margin: 0; }
label.inline select { margin: 0; width: auto; }
.inline-select { display: inline-block; width: auto; margin: 0 0 0 0.5rem; padding: 0.15rem 2rem 0.15rem 0.5rem; font-size: 0.85rem; height: auto; }
.inline-form { display: flex; gap: 0.5rem; align-items: center; }
.inline-form input { width: 8rem; margin: 0; }
.inline-form button { width: auto; margin: 0; }
.buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.buttons button { width: auto; margin: 0; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.6rem; margin-bottom: 0.8rem; }
.facts div { display: flex; flex-direction: column; padding: 0.5rem 0.7rem; border: 1px solid var(--pico-muted-border-color); border-radius: 6px; }
.facts small { color: var(--pico-muted-color); }
.log { max-height: 520px; overflow: auto; font-size: 0.78rem; white-space: pre-wrap; word-break: break-all; }

/* control page */
.modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0.8rem; margin-bottom: 0.8rem; }
.mode-card { padding: 0.8rem; border: 1px solid var(--pico-muted-border-color); border-radius: 8px; display: flex; flex-direction: column; gap: 0.3rem; }
.mode-card.current { border-color: var(--series-1); border-width: 2px; }
.mode-card button { margin-top: auto; }
.danger-zone { border: 1px solid var(--critical); }
.stop-btn { background: var(--critical); border-color: var(--critical); color: #fff; font-weight: 700; font-size: 1.1rem; }

/* toast */
.toast { position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%); background: var(--pico-contrast-background); color: var(--pico-contrast-inverse);
         padding: 0.6rem 1rem; border-radius: 6px; z-index: 1000; max-width: 90vw; }
@media (max-width: 600px) {
  .topbar .right { margin-left: 0; width: 100%; justify-content: space-between; }
  .checks li { grid-template-columns: 1.4rem 6.5rem 1fr; }
}
