/* seelive monitor — layout modelled on New Relic One: dark left nav, light work area, cards. */
:root {
  color-scheme: light;
  --page: #f3f4f4;
  --surface-1: #fcfcfb;
  --surface-2: #f1f1ef;
  --border: rgba(11, 11, 11, 0.10);
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --hover: rgba(11, 11, 11, 0.04);
  --nav-bg: #1d252c;
  --nav-text: #c3c9cd;
  --nav-muted: #85919a;
  --nav-hover: rgba(255, 255, 255, 0.06);
  --nav-active: rgba(255, 255, 255, 0.10);
  --accent: #00ac69;
  --accent-ink: #00804e;
  --delta-good: #006300;
  --delta-bad: #d03b3b;

  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;

  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-serious: #ec835a;
  --status-critical: #d03b3b;
  --status-unknown: #898781;

  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface-1: #1a1a19;
    --surface-2: #232321;
    --border: rgba(255, 255, 255, 0.10);
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --hover: rgba(255, 255, 255, 0.05);
    --nav-bg: #111413;
    --accent: #1ce783;
    --accent-ink: #1ce783;
    --delta-good: #0ca30c;
    --delta-bad: #e66767;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface-1: #1a1a19;
  --surface-2: #232321;
  --border: rgba(255, 255, 255, 0.10);
  --text-primary: #f0efec;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --hover: rgba(255, 255, 255, 0.05);
  --nav-bg: #111413;
  --accent: #1ce783;
  --accent-ink: #1ce783;
  --delta-good: #0ca30c;
  --delta-bad: #e66767;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text-primary);
  background: var(--page);
}
a { color: inherit; }
button { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.nav {
  background: var(--nav-bg);
  color: var(--nav-text);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 22px; color: #fff; text-decoration: none; }
.brand-mark { width: 26px; height: 26px; }
.brand-name { font-weight: 650; font-size: 15px; letter-spacing: 0.2px; }
.brand-sub { display: block; font-size: 11px; font-weight: 500; color: var(--nav-muted); letter-spacing: 0.6px; text-transform: uppercase; }
.nav-section { padding: 6px 10px 12px; }
.nav-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.7px; color: var(--nav-muted); padding: 6px 10px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 4px;
  color: var(--nav-text); text-decoration: none;
  position: relative;
}
.nav-item:hover { background: var(--nav-hover); }
.nav-item.active { background: var(--nav-active); color: #fff; }
.nav-item.active::before {
  content: ""; position: absolute; left: -10px; top: 6px; bottom: 6px; width: 3px;
  border-radius: 0 3px 3px 0; background: #1ce783;
}
.nav-item svg { width: 16px; height: 16px; flex: none; opacity: 0.85; }
.nav-item .count { margin-left: auto; font-size: 12px; background: var(--status-critical); color: #fff; border-radius: 9px; padding: 0 7px; }
.nav-foot { margin-top: auto; padding: 12px; border-top: 1px solid rgba(255, 255, 255, 0.08); display: flex; align-items: center; gap: 6px; }
.nav-user { font-size: 12px; color: var(--nav-muted); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn {
  background: transparent; border: 0; border-radius: 4px; padding: 6px; cursor: pointer; color: var(--nav-text);
  display: inline-flex;
}
.icon-btn:hover { background: var(--nav-hover); }
.icon-btn svg { width: 16px; height: 16px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 24px; min-height: 52px;
  background: var(--surface-1); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.crumbs { display: flex; align-items: center; gap: 8px; color: var(--text-secondary); font-size: 13px; }
.crumbs a { text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.crumbs .sep { color: var(--text-muted); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.updated { font-size: 12px; color: var(--text-muted); }

/* ---------- time picker ---------- */
.picker { position: relative; }
.picker-btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); background: var(--surface-1); border-radius: 4px;
  padding: 6px 10px; cursor: pointer; font-size: 13px;
}
.picker-btn:hover { background: var(--hover); }
.picker-btn svg { width: 14px; height: 14px; color: var(--text-secondary); }
.picker-menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16); padding: 6px; z-index: 30;
}
.picker-menu button {
  display: flex; width: 100%; align-items: center; gap: 10px;
  background: transparent; border: 0; border-radius: 4px; padding: 7px 10px; cursor: pointer; text-align: left;
}
.picker-menu button:hover { background: var(--hover); }
.picker-menu .check { width: 16px; font-weight: 800; color: var(--text-primary); }

/* ---------- page ---------- */
.page { padding: 20px 24px 40px; max-width: 1480px; width: 100%; }
.page.loading { opacity: 0.55; transition: opacity 0.2s; }
.page-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; font-weight: 650; margin: 0; line-height: 1.25; }
.page-sub { color: var(--text-secondary); font-size: 13px; margin-top: 4px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.page-sub .dot-sep { color: var(--text-muted); }
.page-sub a { color: var(--text-secondary); }

.health {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; padding: 3px 9px 3px 7px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface-1); white-space: nowrap;
}
.health .hicon { width: 14px; height: 14px; flex: none; }
.health-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; display: inline-block; }
.st-good { color: var(--status-good); }
.st-warning { color: var(--status-warning); }
.st-serious { color: var(--status-serious); }
.st-critical { color: var(--status-critical); }
.st-unknown { color: var(--status-unknown); }
.bg-good { background: var(--status-good); }
.bg-warning { background: var(--status-warning); }
.bg-serious { background: var(--status-serious); }
.bg-critical { background: var(--status-critical); }
.bg-unknown { background: var(--status-unknown); }
.health .label { color: var(--text-primary); }

.grid { display: grid; gap: 16px; }
.grid-tiles { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 1280px) { .grid-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 980px) {
  .grid-2, .grid-main { grid-template-columns: 1fr; }
  .app { grid-template-columns: 1fr; }
  .nav { position: static; height: auto; }
}
@media (max-width: 640px) { .grid-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } .page { padding: 14px; } }
.stack { display: flex; flex-direction: column; gap: 16px; }

.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 6px; min-width: 0; }
.card-head { display: flex; align-items: flex-start; gap: 10px; padding: 14px 16px 6px; }
.card-title { font-weight: 650; font-size: 14px; margin: 0; }
.card-sub { color: var(--text-secondary); font-size: 12px; margin-top: 2px; }
.card-actions { margin-left: auto; display: flex; gap: 4px; }
.card-body { padding: 6px 16px 14px; }
.card-body.flush { padding: 0; }
.ghost-btn {
  background: transparent; border: 1px solid transparent; border-radius: 4px; padding: 3px 8px;
  font-size: 12px; color: var(--text-secondary); cursor: pointer;
}
.ghost-btn:hover { background: var(--hover); border-color: var(--border); }
.ghost-btn[aria-pressed="true"] { border-color: var(--border); color: var(--text-primary); background: var(--surface-2); }

/* stat tiles */
.tile { padding: 14px 16px; }
.tile-label { font-size: 12px; color: var(--text-secondary); }
.tile-value { font-size: 26px; font-weight: 600; margin-top: 4px; line-height: 1.15; white-space: nowrap; }
.tile-value small { font-size: 14px; font-weight: 500; color: var(--text-secondary); margin-left: 2px; }
.tile-foot { font-size: 12px; color: var(--text-muted); margin-top: 6px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.delta { font-weight: 600; }
.delta.good { color: var(--delta-good); }
.delta.bad { color: var(--delta-bad); }
.delta.flat { color: var(--text-secondary); }

/* tables */
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; font-weight: 600; font-size: 12px; color: var(--text-secondary);
  padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface-1);
}
table.data td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data tbody tr.link { cursor: pointer; }
table.data tbody tr.link:hover td { background: var(--hover); }
.entity-name { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.entity-name a { text-decoration: none; }
.entity-name a:hover { text-decoration: underline; }
.entity-meta { font-size: 12px; color: var(--text-muted); font-weight: 400; }
.table-scroll { overflow-x: auto; max-height: 360px; overflow-y: auto; }
.table-scroll table.data th { position: sticky; top: 0; }
.empty { color: var(--text-secondary); padding: 18px 16px; display: flex; align-items: center; gap: 8px; }
.empty svg { width: 16px; height: 16px; color: var(--status-good); }

.summary-row { display: flex; gap: 24px; flex-wrap: wrap; margin-bottom: 16px; }
.summary-pill { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-secondary); }
.summary-pill strong { color: var(--text-primary); font-size: 18px; font-weight: 600; }

dl.details { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; font-size: 13px; }
dl.details dt { color: var(--text-secondary); }
dl.details dd { margin: 0; overflow-wrap: anywhere; }

.alert-row { display: flex; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--border); }
.alert-row:first-child { border-top: 0; }
.alert-row .hicon { width: 16px; height: 16px; flex: none; margin-top: 2px; }
.alert-title { font-weight: 600; }
.alert-desc { color: var(--text-secondary); font-size: 12px; }

.banner { border: 1px solid var(--border); border-left: 3px solid var(--status-critical); background: var(--surface-1); padding: 10px 14px; border-radius: 4px; margin-bottom: 16px; }

/* ---------- charts ---------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart .tick { fill: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { stroke: none; }
.chart .crosshair { stroke: var(--text-muted); stroke-width: 1; shape-rendering: crispEdges; }
.chart .hover-dot { stroke: var(--surface-1); stroke-width: 2; }
.chart .overlay { fill: transparent; cursor: crosshair; outline: none; }
.chart .overlay:focus-visible { stroke: var(--accent); stroke-width: 1; }
.chart .seg { cursor: pointer; }
.chart .seg:hover, .chart .seg.on { opacity: 0.75; }
.chart-empty { color: var(--text-muted); font-size: 13px; padding: 40px 0; text-align: center; }

.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 12px; color: var(--text-secondary); padding: 0 0 8px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.key-line { width: 14px; height: 2px; border-radius: 1px; display: inline-block; }
.key-rect { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.legend .hicon { width: 12px; height: 12px; }

.tooltip {
  position: absolute; pointer-events: none; z-index: 10;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18); padding: 8px 10px; font-size: 12px; min-width: 160px;
}
.tooltip .tt-head { color: var(--text-secondary); margin-bottom: 6px; white-space: nowrap; }
.tooltip .tt-row { display: flex; align-items: center; gap: 8px; white-space: nowrap; line-height: 1.7; }
.tooltip .tt-row strong { font-weight: 650; color: var(--text-primary); font-variant-numeric: tabular-nums; min-width: 56px; }
.tooltip .tt-row span.name { color: var(--text-secondary); }
.tooltip .tt-total { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 4px; }

.spark { display: block; width: 120px; height: 28px; }
.spark path { fill: none; stroke: var(--series-1); stroke-width: 1.5; stroke-linejoin: round; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: var(--nav-bg); padding: 20px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface-1); border-radius: 8px; padding: 28px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35); }
.login-card .brand { padding: 0 0 20px; color: var(--text-primary); }
.login-card .brand-sub { color: var(--text-muted); }
.login-card h1 { font-size: 18px; margin: 0 0 16px; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 12px; color: var(--text-secondary); margin-bottom: 5px; }
.field input {
  width: 100%; padding: 9px 10px; border-radius: 4px; border: 1px solid var(--axis);
  background: var(--surface-1); color: var(--text-primary); font: inherit;
}
.field input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.primary-btn {
  width: 100%; padding: 10px; border: 0; border-radius: 4px; background: #00ac69; color: #fff;
  font-weight: 600; cursor: pointer;
}
.primary-btn:hover { background: #008c55; }
.login-error { color: var(--status-critical); font-size: 13px; margin-bottom: 12px; }
.nowrap { white-space: nowrap; }
