/* ==========================================================================
   Lingsaa Monitor — dashboard styles
   All colours are tokens on :root; dark mode is selected (not inverted).
   ========================================================================== */

:root {
  color-scheme: light;

  /* Surfaces & ink */
  --bg: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f2f1ed;        /* hover / subtle fill */
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --border-strong: rgba(11, 11, 11, 0.18);
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 8px 24px rgba(11, 11, 11, 0.08);

  /* Series (fixed mapping, colorblind-validated) */
  --series: #2a78d6;
  --s-2xx: #2a78d6;
  --s-3xx: #1baf7a;
  --s-4xx: #eda100;
  --s-5xx: #e87ba4;
  --s-rx: #2a78d6;
  --s-tx: #eb6834;

  /* Status (reserved for state; always with icon + label) */
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  /* Text-safe inks of the status hues (WCAG AA on surface) */
  --good-ink: #087a08;
  --warning-ink: #8a5a00;
  --critical-ink: #b52d2d;
  --neutral-ink: var(--text-2);

  /* Tints */
  --good-tint: color-mix(in srgb, var(--good) 13%, var(--surface));
  --warning-tint: color-mix(in srgb, var(--warning) 20%, var(--surface));
  --critical-tint: color-mix(in srgb, var(--critical) 12%, var(--surface));
  --muted-tint: color-mix(in srgb, var(--muted) 14%, var(--surface));
  --accent-tint: color-mix(in srgb, var(--series) 10%, var(--surface));

  /* Meter tracks: lighter step of the fill hue */
  --track-accent: color-mix(in srgb, var(--series) 16%, var(--surface));
  --track-warning: color-mix(in srgb, var(--warning) 24%, var(--surface));
  --track-critical: color-mix(in srgb, var(--critical) 18%, var(--surface));

  --focus: #2a78d6;
  --radius: 12px;
  --radius-sm: 8px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Consolas", monospace;
  --sidebar-w: 248px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232321;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --border-strong: rgba(255, 255, 255, 0.18);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.45);
    --series: #3987e5;
    --s-2xx: #3987e5;
    --s-3xx: #199e70;
    --s-4xx: #c98500;
    --s-5xx: #d55181;
    --s-rx: #3987e5;
    --s-tx: #d95926;
    --good-ink: #4cc44c;
    --warning-ink: #f5bf45;
    --critical-ink: #f07a7a;
    --focus: #3987e5;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #232321;
  --text: #f0efec;
  --text-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.18);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.45);
  --series: #3987e5;
  --s-2xx: #3987e5;
  --s-3xx: #199e70;
  --s-4xx: #c98500;
  --s-5xx: #d55181;
  --s-rx: #3987e5;
  --s-tx: #d95926;
  --good-ink: #4cc44c;
  --warning-ink: #f5bf45;
  --critical-ink: #f07a7a;
  --focus: #3987e5;
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: inherit; }
code, pre, kbd { font-family: var(--mono); font-size: 0.92em; font-variant-ligatures: none; }
code.inline {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 5px;
  overflow-wrap: anywhere;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link:focus {
  position: fixed; left: 8px; top: 8px; z-index: 100; width: auto; height: auto; margin: 0;
  clip: auto; padding: 8px 12px; background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.icon { width: 16px; height: 16px; flex: none; vertical-align: -3px; }
.icon-sm { width: 14px; height: 14px; }
.icon-xs { width: 12px; height: 12px; vertical-align: -2px; }

.muted { color: var(--muted); }
.secondary { color: var(--text-2); }
.num, .tnum { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.break { overflow-wrap: anywhere; }

/* ---------- App shell ---------- */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  min-width: 0;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 18px 16px 12px 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 650;
  font-size: 15px;
  letter-spacing: -0.01em;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--series);
  color: #fff;
}
.brand-mark .icon { width: 17px; height: 17px; }

.sidebar .menu-btn { display: none; }

.sidebar-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 4px 10px 12px;
}

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  text-decoration: none;
  font-weight: 500;
  min-width: 0;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link[aria-current="page"] { background: var(--accent-tint); color: var(--text); }
.nav-link[aria-current="page"] > .icon { color: var(--series); }
.nav-link .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav-count {
  font-size: 11.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 0 7px;
  line-height: 18px;
  border-radius: 9px;
  background: var(--critical-tint);
  color: var(--critical-ink);
}

.nav-section { margin-top: 18px; }
.nav-section-title {
  padding: 0 10px 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.nav-sub .nav-link { padding: 5px 10px; font-weight: 450; font-size: 13.5px; }
.nav-empty { padding: 2px 10px; color: var(--muted); font-size: 13px; }

.state-icon { display: inline-grid; place-items: center; flex: none; }
.state-icon.good { color: var(--good); }
.state-icon.critical { color: var(--critical); }
.state-icon.warning { color: var(--warning); }
.state-icon.unknown { color: var(--muted); }

.sidebar-foot {
  border-top: 1px solid var(--border);
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.user-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.user-email {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-2);
  font-size: 13px;
}

/* Main column */
.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px 16px;
  flex-wrap: wrap;
  padding: 14px 28px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.page-title {
  flex: 1 1 200px;
  min-width: 0;
  font-size: 18px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.top-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.updated { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.updated.failed { color: var(--critical-ink); }

.content {
  padding: 24px 28px 48px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 1480px;
  width: 100%;
}

.view { display: flex; flex-direction: column; gap: 20px; min-width: 0; }

/* ---------- Controls ---------- */

.seg {
  display: inline-flex;
  padding: 2px;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
}
.seg button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 7px;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"],
.seg button[aria-selected="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--border), 0 1px 2px rgba(0, 0, 0, 0.06);
}
.seg.seg-icons button { padding: 4px 8px; }

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn-primary { background: var(--series); border-color: transparent; color: #fff; }
.btn-primary:hover { background: color-mix(in srgb, var(--series) 88%, #000); }
.btn-danger { background: var(--critical); border-color: transparent; color: #fff; }
.btn-danger:hover { background: color-mix(in srgb, var(--critical) 88%, #000); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 13px; }

.icon-btn {
  appearance: none;
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  flex: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.bordered { border-color: var(--border-strong); background: var(--surface); }
.icon-btn.danger:hover { color: var(--critical-ink); }
.icon-btn:disabled { opacity: 0.5; cursor: default; }

.spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 0;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px 20px 0;
}
.card-head h2 { font-size: 14.5px; }
.card-head .sub { color: var(--muted); font-size: 12.5px; font-weight: 400; }
.card-body { padding: 14px 20px 18px; }
.card-flush { padding: 10px 0 4px; }
.card-foot { padding: 0 20px 16px; color: var(--text-2); font-size: 13px; }

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.section-title h2 { font-size: 15px; }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}
@media (max-width: 1100px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Stat tiles ---------- */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
}
.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-decoration: none;
}
a.tile:hover { border-color: var(--border-strong); }
.tile-label { color: var(--text-2); font-size: 12.5px; }
.tile-value {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tile-value .of { color: var(--muted); font-weight: 500; font-size: 0.75em; }
.tile-sub {
  font-size: 12.5px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  font-variant-numeric: tabular-nums;
}
.delta { font-weight: 600; display: inline-flex; align-items: center; gap: 3px; }
.delta.good { color: var(--good-ink); }
.delta.bad { color: var(--critical-ink); }
.delta.neutral { color: var(--text-2); }
.ink-good { color: var(--good-ink); }
.ink-warning { color: var(--warning-ink); }
.ink-critical { color: var(--critical-ink); }

/* ---------- Pills & badges ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 9px 0 7px;
  border-radius: 11px;
  font-size: 12.5px;
  font-weight: 550;
  white-space: nowrap;
  color: var(--text);
  background: var(--muted-tint);
}
.pill .icon { width: 13px; height: 13px; }
.pill.good { background: var(--good-tint); }
.pill.good .icon { color: var(--good); }
.pill.critical { background: var(--critical-tint); }
.pill.critical .icon { color: var(--critical); }
.pill.warning { background: var(--warning-tint); }
.pill.warning .icon { color: var(--warning-ink); }
.pill.unknown .icon { color: var(--muted); }
.pill.lg { height: 26px; font-size: 13px; padding: 0 11px 0 9px; border-radius: 13px; }

.sev {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 550;
  white-space: nowrap;
}
.sev.warning .icon { color: var(--warning); }
.sev.critical .icon { color: var(--critical); }
.sev.good .icon { color: var(--good); }

.tag {
  display: inline-block;
  padding: 0 7px;
  line-height: 20px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-2);
  white-space: nowrap;
}

/* ---------- Tables ---------- */

.table-wrap { position: relative; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.table th {
  text-align: left;
  font-weight: 500;
  font-size: 12.5px;
  color: var(--muted);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  white-space: nowrap;           /* tables scroll sideways rather than wrapping data */
}
.table td.break, .table td.wrap { white-space: normal; min-width: 180px; }
.table .clip { display: block; max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
.table tr:last-child td { border-bottom: 0; }
.table th:first-child, .table td:first-child { padding-left: 20px; }
.table th:last-child, .table td:last-child { padding-right: 20px; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table th.num { text-align: right; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover td { background: var(--surface-2); }
.table .actions { text-align: right; white-space: nowrap; width: 1%; }
.table .actions .icon-btn { width: 30px; height: 30px; }
.table .cell-title { font-weight: 550; text-decoration: none; }
.table a.cell-title:hover { text-decoration: underline; }
.table .cell-sub { display: block; color: var(--muted); font-size: 12.5px; }
.table .truncate { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table tr.detail-row td { white-space: normal; background: var(--surface-2); padding-top: 12px; padding-bottom: 14px; }
.table tr.expanded td { border-bottom-color: transparent; }

.detail-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text-2);
  margin: 6px 0 0;
}
.detail-meta { display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--text-2); font-size: 12.5px; }

.ssl-warn { color: var(--warning-ink); font-weight: 550; display: inline-flex; align-items: center; gap: 4px; }
.ssl-warn .icon { color: var(--warning); }
.ssl-bad { color: var(--critical-ink); font-weight: 550; display: inline-flex; align-items: center; gap: 4px; }
.ssl-bad .icon { color: var(--critical); }

/* Sparkline */
.spark { display: block; width: 96px; height: 28px; margin-left: auto; overflow: visible; }
.spark .line { fill: none; stroke: var(--series); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.spark .area { fill: var(--series); fill-opacity: 0.1; stroke: none; }
.spark .base { stroke: var(--grid); stroke-width: 1; vector-effect: non-scaling-stroke; }

/* ---------- Meters ---------- */

.meter { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.meter-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: 12.5px; }
.meter-label { color: var(--text-2); display: inline-flex; align-items: center; gap: 4px; }
.meter-value { font-weight: 600; font-variant-numeric: tabular-nums; }
.meter-track { height: 6px; border-radius: 3px; background: var(--track-accent); overflow: hidden; }
.meter-fill { height: 100%; border-radius: 3px; background: var(--series); }
.meter.warning .meter-track { background: var(--track-warning); }
.meter.warning .meter-fill { background: var(--warning); }
.meter.critical .meter-track { background: var(--track-critical); }
.meter.critical .meter-fill { background: var(--critical); }
.meter.warning .meter-label .icon { color: var(--warning-ink); }
.meter.critical .meter-label .icon { color: var(--critical); }
.meter.none .meter-track { background: var(--surface-2); }
.meter.inline { flex-direction: row; align-items: center; gap: 10px; min-width: 140px; }
.meter.inline .meter-track { flex: 1; min-width: 60px; }
.meter.inline .meter-value { min-width: 58px; text-align: right; font-size: 12.5px; display: inline-flex; align-items: center; justify-content: flex-end; gap: 4px; }
.meter.inline.warning .meter-value .icon { color: var(--warning-ink); }
.meter.inline.critical .meter-value .icon { color: var(--critical); }

/* ---------- Server cards ---------- */

.server-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.server-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  min-width: 0;
}
.server-card:hover { border-color: var(--border-strong); }
.server-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.server-card-name { font-weight: 600; font-size: 14.5px; overflow-wrap: anywhere; }
.server-card-meta { color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.server-meters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.server-card-foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}
.server-card-foot span { display: inline-flex; gap: 4px; align-items: center; }

/* ---------- Charts ---------- */

.chart-card .card-body { padding-top: 10px; }
.chart-box { position: relative; height: 220px; }
.chart-box.tall { height: 260px; }
.chart-box canvas { display: block; }
.chart-fallback { display: grid; place-items: center; height: 100%; color: var(--muted); font-size: 13px; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  margin: 2px 0 8px -6px;
}
.legend-item {
  appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 12.5px;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 6px;
  border-radius: 6px;
  cursor: pointer;
}
.legend-item:hover { background: var(--surface-2); }
.legend-item[aria-pressed="false"] { color: var(--muted); }
.legend-item[aria-pressed="false"] .swatch { opacity: 0.3; }
.legend.static .legend-item { cursor: default; }
.legend.static .legend-item:hover { background: transparent; }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; display: inline-block; }

.chart-tip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  min-width: 140px;
  max-width: 260px;
  padding: 8px 10px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: 12.5px;
  opacity: 0;
  transition: opacity 0.12s;
  white-space: nowrap;
}
.tip-title { font-weight: 600; margin-bottom: 4px; }
.tip-row { display: flex; align-items: center; gap: 7px; line-height: 1.6; }
.tip-label { color: var(--text-2); flex: 1; }
.tip-value { font-weight: 600; font-variant-numeric: tabular-nums; }
.tip-foot { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 4px; display: flex; justify-content: space-between; gap: 10px; }

/* Uptime strip */
.strip-wrap { position: relative; }
.strip {
  display: flex;
  gap: 2px;
  height: 32px;
  align-items: stretch;
}
.strip .cell {
  flex: 1 1 0;
  min-width: 0;
  border-radius: 2px;
  background: var(--surface-2);
}
.strip .cell.good { background: var(--good); }
.strip .cell.warning { background: var(--warning); }
.strip .cell.critical { background: var(--critical); }
.strip .cell.none { background: var(--grid); }
.strip .cell.hover { outline: 2px solid var(--text); outline-offset: 1px; }
.strip-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; margin-top: 6px; font-variant-numeric: tabular-nums; }
.strip-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 12px; font-size: 12.5px; color: var(--text); }
.strip-legend span { display: inline-flex; align-items: center; gap: 6px; }
.strip-legend .swatch.good { background: var(--good); }
.strip-legend .swatch.warning { background: var(--warning); }
.strip-legend .swatch.critical { background: var(--critical); }
.strip-legend .swatch.none { background: var(--grid); }

/* ---------- Page header (app / server) ---------- */

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.page-head-main { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.page-head-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-head-title h2 { font-size: 20px; overflow-wrap: anywhere; }
.page-head-sub { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--text-2); font-size: 13px; align-items: center; }
.page-head-sub a { color: var(--text-2); text-decoration: none; overflow-wrap: anywhere; display: inline-flex; gap: 4px; align-items: center; }
.page-head-sub a:hover { color: var(--text); text-decoration: underline; }
.page-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { font-size: 12.5px; color: var(--muted); }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--text); text-decoration: underline; }

.kv {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px 20px;
  margin: 0;
}
.kv div { min-width: 0; }
.kv dt { color: var(--muted); font-size: 12px; }
.kv dd { margin: 2px 0 0; font-weight: 500; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }

.error-line {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--critical-tint);
  font-size: 13px;
  overflow-wrap: anywhere;
}
.error-line .icon { color: var(--critical); margin-top: 1px; }

/* ---------- Lists ---------- */

.incident-list { list-style: none; margin: 0; padding: 0; }
.incident-list li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 4px 14px;
  align-items: center;
  padding: 11px 20px;
  border-top: 1px solid var(--border);
}
.incident-list li:first-child { border-top: 0; }
.incident-title { font-weight: 550; overflow-wrap: anywhere; }
.incident-target { color: var(--text-2); font-size: 12.5px; }
.incident-target a { color: var(--text-2); text-decoration: none; }
.incident-target a:hover { color: var(--text); text-decoration: underline; }
.incident-list .sev { min-width: 82px; }
.incident-when { color: var(--muted); font-size: 12.5px; white-space: nowrap; text-align: right; }

.simple-list { list-style: none; margin: 0; padding: 0; }
.simple-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 20px; border-top: 1px solid var(--border); }
.simple-list li:first-child { border-top: 0; }
.simple-list a { text-decoration: none; font-weight: 500; }
.simple-list a:hover { text-decoration: underline; }

/* ---------- Empty / loading / notes ---------- */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding: 32px 20px;
  color: var(--text-2);
}
.empty .icon { width: 22px; height: 22px; color: var(--muted); }
.empty strong { color: var(--text); font-weight: 600; }
.empty p { max-width: 460px; }
.empty.compact { padding: 18px 20px; }

.note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--accent-tint);
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
}
.note > .icon { color: var(--series); margin-top: 1px; }
.note.warning { background: var(--warning-tint); }
.note.warning > .icon { color: var(--warning-ink); }
.note.critical { background: var(--critical-tint); }
.note.critical > .icon { color: var(--critical); }
.note p + p { margin-top: 6px; }

.loading { display: flex; flex-direction: column; gap: 16px; }
.skeleton {
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface) 50%, var(--surface-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border: 1px solid var(--border);
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) {
  .skeleton, .spin { animation: none; }
}

/* ---------- Tabs ---------- */

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ---------- Forms ---------- */

.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label, .field .label { font-weight: 550; font-size: 13px; }
.field .opt { color: var(--muted); font-weight: 400; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field-row.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 560px) {
  .field-row, .field-row.three { grid-template-columns: minmax(0, 1fr); }
}
.help { color: var(--text-2); font-size: 12.5px; line-height: 1.45; }

input[type="text"], input[type="email"], input[type="password"], input[type="url"],
input[type="number"], select, textarea {
  width: 100%;
  min-width: 0;
  height: 36px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
textarea { height: auto; padding: 8px 10px; }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 0;
  border-color: transparent;
}
input[aria-invalid="true"] { border-color: var(--critical); }
input::placeholder { color: var(--muted); }

.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--series); margin: 0; }

.form-error {
  display: none;
  gap: 8px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--critical-tint);
  font-size: 13px;
}
.form-error.show { display: flex; }
.form-error .icon { color: var(--critical); margin-top: 1px; }

/* Code box */
.code-box {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.code-box pre {
  margin: 0;
  padding: 12px 48px 12px 12px;
  white-space: pre-wrap;
  word-break: break-all;
  font-size: 12.5px;
  line-height: 1.55;
  max-height: 220px;
  overflow: auto;
}
.code-box .copy-btn { position: absolute; top: 6px; right: 6px; }

/* ---------- Settings ---------- */

.channel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
}
.channel {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.channel-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text-2);
  flex: none;
}
.channel-name { font-weight: 550; }
.channel-state { font-size: 12.5px; display: inline-flex; align-items: center; gap: 4px; color: var(--text-2); }
.channel-state.on .icon { color: var(--good); }
.channel-state.off .icon { color: var(--muted); }
.test-result { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.test-result:empty { display: none; }
.test-result div { display: flex; gap: 6px; align-items: flex-start; overflow-wrap: anywhere; }
.test-result .ok .icon { color: var(--good); }
.test-result .fail .icon { color: var(--critical); }

/* ---------- Modal ---------- */

dialog.modal {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  overflow: hidden;
}
dialog.modal.wide { width: min(720px, calc(100vw - 32px)); }
dialog.modal::backdrop { background: rgba(10, 10, 10, 0.45); }
.modal-card { display: flex; flex-direction: column; max-height: calc(100vh - 48px); }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 12px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { font-size: 16px; }
.modal-body { padding: 18px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.modal-body ol, .modal-body ul { margin: 0; padding-left: 20px; }
.modal-body li + li { margin-top: 4px; }

/* ---------- Toasts ---------- */

.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: calc(100vw - 32px);
  width: 380px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: var(--shadow);
  font-size: 13.5px;
  overflow-wrap: anywhere;
  animation: toast-in 0.18s ease-out;
}
.toast .icon { margin-top: 1px; color: var(--series); }
.toast.good .icon { color: var(--good); }
.toast.critical .icon { color: var(--critical); }
.toast.warning .icon { color: var(--warning-ink); }
.toast .toast-msg { flex: 1; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

/* ---------- Login ---------- */

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.login-card {
  width: min(380px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.login-card .brand { font-size: 16px; }
.login-card h1 { font-size: 20px; }
.login-card .lead { color: var(--text-2); margin-top: 4px; }
.login-card .btn { height: 38px; width: 100%; }

/* ---------- Responsive: phones ---------- */

@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 40;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .sidebar-head { padding: 10px 16px; min-height: 56px; }
  .sidebar .menu-btn { display: inline-grid; }
  .sidebar-panel {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    max-height: calc(100vh - 56px);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
  }
  .sidebar.open .sidebar-panel { display: flex; }
  .sidebar-scroll { padding: 4px 8px 12px; }

  .topbar {
    position: static;
    padding: 12px 16px;
    background: var(--bg);
    backdrop-filter: none;
  }
  .page-title { flex-basis: 100%; font-size: 17px; }
  .top-controls { width: 100%; justify-content: space-between; }
  .content { padding: 16px 16px 40px; }
  .view { gap: 16px; }

  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tile { padding: 12px 14px; }
  .tile-value { font-size: 19px; }
  .card-head { padding: 14px 16px 0; }
  .card-body { padding: 12px 16px 16px; }
  .table th:first-child, .table td:first-child { padding-left: 16px; }
  .table th:last-child, .table td:last-child { padding-right: 16px; }
  .incident-list li { padding: 11px 16px; grid-template-columns: auto minmax(0, 1fr); }
  .incident-when { grid-column: 2; text-align: left; }
  .simple-list li { padding: 9px 16px; }
  .chart-box { height: 200px; }
  .server-grid { grid-template-columns: minmax(0, 1fr); }
}
