/* Shared console styles for every system UI. Light and dark themes come from the same tokens. */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f3f2ee;
  --surface-3: #ebeae4;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --border-strong: rgba(11, 11, 11, 0.18);
  --good: #0ca30c;
  --good-text: #006300;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.06), 0 4px 16px rgba(11, 11, 11, 0.04);
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --surface-2: #222220; --surface-3: #2c2c2a;
    --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781; --grid: #2c2c2a; --axis: #383835;
    --border: rgba(255, 255, 255, 0.10); --border-strong: rgba(255, 255, 255, 0.18); --good-text: #0ca30c;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #222220; --surface-3: #2c2c2a;
  --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781; --grid: #2c2c2a; --axis: #383835;
  --border: rgba(255, 255, 255, 0.10); --border-strong: rgba(255, 255, 255, 0.18); --good-text: #0ca30c;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--page); color: var(--ink); font: 14px/1.45 var(--font); }
a { color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 15px; } h4 { font-size: 13px; color: var(--ink-2); }
p { margin: 0; }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); } .ink2 { color: var(--ink-2); } .small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.nowrap { white-space: nowrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.tight { gap: 6px; } .spacer { flex: 1; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.cols-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.cols-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

/* App shell */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--border); padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 14px; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); flex: none; box-shadow: inset 0 0 0 1px rgba(255,255,255,.2); }
.brand-name { font-weight: 650; font-size: 14px; line-height: 1.2; }
.brand-sub { font-size: 11px; color: var(--muted); }
.sim-badge { display: inline-block; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); border: 1px solid var(--border-strong); border-radius: 99px; padding: 1px 7px; margin-top: 3px; }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); padding: 12px 10px 4px; }
.nav a { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 7px; text-decoration: none; color: var(--ink-2); }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.active { background: var(--surface-3); color: var(--ink); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
.side-foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.side-foot a { color: var(--ink-2); }
.main { min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 12px; padding: 14px 28px; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 5; }
.top h1 { font-size: 18px; }
.clock { font-variant-numeric: tabular-nums; font-size: 12.5px; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--border); border-radius: 99px; padding: 3px 10px; }
.content { padding: 22px 28px 48px; display: flex; flex-direction: column; gap: 18px; max-width: 1600px; width: 100%; }
.btn.menu-btn { display: none; }

/* Cards & tiles */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; min-width: 0; }
.card > h2, .card > h3 { margin-bottom: 10px; }
.card-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head .spacer { flex: 1; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.tile .label { font-size: 12.5px; color: var(--ink-2); }
.tile .value { font-size: 28px; font-weight: 600; margin-top: 2px; letter-spacing: -0.02em; }
.tile .delta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.hero { font-size: 56px; font-weight: 600; letter-spacing: -0.03em; line-height: 1; }
.explain { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; color: var(--ink-2); font-size: 13px; }
.explain b { color: var(--ink); }

/* Tables */
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 8px; max-width: 100%; }
table.t { border-collapse: collapse; width: 100%; font-size: 13px; }
table.t th { position: sticky; top: 0; background: var(--surface-2); text-align: left; font-weight: 600; color: var(--ink-2); font-size: 12px; padding: 7px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; z-index: 1; }
table.t th.sortable { cursor: pointer; } table.t th.sortable:hover { color: var(--ink); }
table.t td { padding: 6px 10px; border-bottom: 1px solid var(--border); vertical-align: top; max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.t tr:last-child td { border-bottom: none; }
table.t tbody tr:hover td { background: var(--surface-2); }
table.t tr.clickable { cursor: pointer; }
table.t td.wrap { white-space: normal; }
table.t td .cell-json { font-family: var(--mono); font-size: 11.5px; color: var(--ink-2); white-space: nowrap; }
.pager { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-2); padding-top: 8px; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 1px 8px; border-radius: 99px; background: var(--surface-3); color: var(--ink-2); white-space: nowrap; line-height: 1.6; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.badge.plain::before { display: none; }
.badge.good::before { background: var(--good); } .badge.warning::before { background: var(--warning); }
.badge.serious::before { background: var(--serious); } .badge.critical::before { background: var(--critical); }
.badge.info::before { background: var(--s1); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.dot.good { background: var(--good); } .dot.critical { background: var(--critical); } .dot.warning { background: var(--warning); }

/* Forms */
.btn { font: inherit; font-size: 13px; font-weight: 550; border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink); padding: 6px 12px; border-radius: 7px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.btn.primary:hover { opacity: .9; }
.btn.small { padding: 3px 9px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; font-size: 13px; color: var(--ink); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 7px; padding: 6px 9px; min-width: 0; }
textarea { font-family: var(--mono); font-size: 12.5px; width: 100%; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--ink-2); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filters label { min-width: 140px; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
.seg button { font: inherit; font-size: 12.5px; border: 0; background: var(--surface); color: var(--ink-2); padding: 5px 11px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--border-strong); }
.seg button.on { background: var(--ink); color: var(--surface); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tabs button { font: inherit; font-size: 13px; border: 0; background: none; color: var(--ink-2); padding: 8px 12px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.alert { background: color-mix(in srgb, var(--critical) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--critical) 35%, transparent); color: var(--ink); border-radius: 8px; padding: 9px 12px; font-size: 13px; }
.note { background: color-mix(in srgb, var(--s1) 8%, var(--surface)); border: 1px solid color-mix(in srgb, var(--s1) 30%, transparent); border-radius: 8px; padding: 9px 12px; font-size: 13px; }

/* Code / payload viewer */
pre.code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px; overflow: auto; max-height: 520px; margin: 0; line-height: 1.5; white-space: pre; }
pre.code .k { color: var(--s1); } pre.code .s { color: var(--good-text); } pre.code .n { color: var(--s2); } pre.code .b { color: var(--s7); }

/* Timeline */
.timeline { display: flex; flex-direction: column; gap: 0; position: relative; }
.tl-item { display: grid; grid-template-columns: 150px 18px 1fr; gap: 10px; align-items: start; padding: 5px 0; }
.tl-time { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--ink-2); text-align: right; padding-top: 1px; }
.tl-mark { position: relative; height: 100%; display: flex; justify-content: center; }
.tl-mark::before { content: ""; position: absolute; top: 0; bottom: -10px; width: 2px; background: var(--grid); }
.tl-item:last-child .tl-mark::before { display: none; }
.tl-dot { position: relative; width: 12px; height: 12px; border-radius: 50%; background: var(--muted); border: 2px solid var(--surface); margin-top: 3px; }
.tl-item.future { opacity: .45; }

/* Drawer */
.drawer-back { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 100vw); background: var(--page); z-index: 41; box-shadow: -8px 0 30px rgba(0,0,0,.2); display: flex; flex-direction: column; }
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); background: var(--surface); }
.drawer-body { padding: 18px; overflow: auto; display: flex; flex-direction: column; gap: 16px; }

/* Login */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); padding: 26px; display: flex; flex-direction: column; gap: 16px; }
.login-brand { display: flex; gap: 12px; align-items: center; }
.login-name { font-weight: 650; font-size: 17px; }
.login-card input { padding: 9px 11px; font-size: 14px; }
.login-card .btn { justify-content: center; padding: 9px 12px; font-size: 14px; }

/* Charts (shared marks) */
.chart { width: 100%; display: block; overflow: visible; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .grid line { stroke: var(--grid); stroke-width: 1; }
.chart .axis line, .chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .lbl { fill: var(--ink-2); font-size: 11.5px; }
.chart .val { fill: var(--ink); font-size: 11.5px; font-weight: 600; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; }
.legend i.sw { width: 10px; height: 10px; border-radius: 3px; }
.tooltip { position: fixed; pointer-events: none; background: var(--surface); color: var(--ink); border: 1px solid var(--border-strong); box-shadow: var(--shadow); border-radius: 8px; padding: 8px 10px; font-size: 12px; z-index: 100; max-width: 320px; }
.tooltip .tt-title { font-weight: 600; margin-bottom: 3px; }
.tooltip .tt-row { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.tooltip .tt-row span:first-child { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); }
.meter { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 99px; background: var(--s1); }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 30; left: 0; top: 0; width: 260px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .side.open { transform: none; }
  .btn.menu-btn { display: inline-flex; }
  .top, .content { padding-left: 16px; padding-right: 16px; }
  .tl-item { grid-template-columns: 100px 18px 1fr; }
}
