/* ============================================================
   Crash Dashboard — Redesign
   Design tokens, themes (dark/light), components
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans:wght@400;450;500;600;700&display=swap');

:root {
  /* spacing scale (4-based) */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;

  /* radii */
  --r-sm: 6px; --r-md: 9px; --r-lg: 14px; --r-pill: 999px;

  /* type */
  --font: 'IBM Plex Sans', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', 'SFMono-Regular', Menlo, monospace;

  /* non-themed semantic hues (shared chroma family) */
  --critical: oklch(0.66 0.20 22);
  --critical-soft: oklch(0.66 0.20 22 / 0.13);
  --error: oklch(0.74 0.15 62);
  --error-soft: oklch(0.74 0.15 62 / 0.14);
  --warning: oklch(0.80 0.12 95);
  --warning-soft: oklch(0.80 0.12 95 / 0.15);
  --success: oklch(0.72 0.14 158);
  --success-soft: oklch(0.72 0.14 158 / 0.14);
  --accent: oklch(0.64 0.17 268);
  --accent-soft: oklch(0.64 0.17 268 / 0.16);

  --easing: cubic-bezier(.2,.7,.3,1);
}

/* ---------- DARK (default) ---------- */
:root, [data-theme="dark"] {
  --bg: oklch(0.17 0.012 265);
  --surface: oklch(0.21 0.014 265);
  --surface-2: oklch(0.25 0.016 265);
  --surface-3: oklch(0.29 0.018 265);
  --border: oklch(1 0 0 / 0.09);
  --border-strong: oklch(1 0 0 / 0.16);
  --text: oklch(0.95 0.005 265);
  --text-2: oklch(0.80 0.01 265);
  --muted: oklch(0.66 0.02 265);
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 30px rgba(0,0,0,.35);
  --grid-line: oklch(1 0 0 / 0.05);
  color-scheme: dark;
}

/* ---------- LIGHT ---------- */
[data-theme="light"] {
  --bg: oklch(0.97 0.004 265);
  --surface: oklch(1 0 0);
  --surface-2: oklch(0.975 0.003 265);
  --surface-3: oklch(0.95 0.005 265);
  --border: oklch(0 0 0 / 0.09);
  --border-strong: oklch(0 0 0 / 0.16);
  --text: oklch(0.25 0.012 265);
  --text-2: oklch(0.40 0.014 265);
  --muted: oklch(0.52 0.018 265);
  --shadow: 0 1px 2px rgba(15,20,40,.06), 0 10px 30px rgba(15,20,40,.08);
  --grid-line: oklch(0 0 0 / 0.05);
  /* nudge semantic colors a touch darker for contrast on white */
  --critical: oklch(0.58 0.20 22);
  --error: oklch(0.64 0.15 55);
  --warning: oklch(0.70 0.13 80);
  --success: oklch(0.60 0.14 158);
  --accent: oklch(0.55 0.18 268);
  color-scheme: light;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--accent-soft); }

/* scrollbars */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: padding-box; }

/* ============================================================
   Layout
   ============================================================ */
.layout { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: var(--s5) 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: var(--s3);
  padding: 0 var(--s5) var(--s5);
  border-bottom: 1px solid var(--border);
}
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  background: linear-gradient(145deg, var(--accent), oklch(0.6 0.18 300));
  display: grid; place-items: center;
  box-shadow: 0 2px 10px var(--accent-soft);
}
.brand-mark svg { width: 18px; height: 18px; color: #fff; }
.brand-text h1 { font-size: 14px; font-weight: 600; letter-spacing: -.01em; }
.brand-text p { font-size: 11px; color: var(--muted); font-family: var(--mono); margin-top: 1px; }

.nav { padding: var(--s4) var(--s3); flex: 1; display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 10px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding: var(--s3) var(--s3) var(--s2); }
.nav-item {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s2) var(--s3); border-radius: var(--r-sm);
  cursor: pointer; font-size: 13.5px; font-weight: 450; color: var(--text-2);
  transition: background .15s, color .15s; user-select: none; position: relative;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.nav-item.active::before {
  content: ''; position: absolute; left: -var(--s3); left: -12px;
  top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; border-radius: 0 3px 3px 0; background: var(--accent);
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; stroke-width: 1.6; }
.nav-badge {
  margin-left: auto; font-family: var(--mono); font-size: 11px; font-weight: 500;
  background: var(--surface-3); color: var(--text-2);
  padding: 1px 7px; border-radius: var(--r-pill);
}
.nav-badge.alert { background: var(--critical-soft); color: var(--critical); }

.sidebar-foot { padding: 0 var(--s3); display: flex; flex-direction: column; gap: 2px; }

/* theme toggle */
.theme-toggle {
  display: flex; gap: 2px; padding: 3px; margin: 0 var(--s3) var(--s3);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-pill);
}
.theme-toggle button {
  flex: 1; border: none; background: transparent; color: var(--muted);
  font-family: var(--font); font-size: 12px; font-weight: 500; cursor: pointer;
  padding: 5px; border-radius: var(--r-pill); display: flex; align-items: center; justify-content: center; gap: 5px;
}
.theme-toggle button svg { width: 13px; height: 13px; }
.theme-toggle button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ============================================================
   Main
   ============================================================ */
.main { overflow-y: auto; height: 100vh; }
.main-inner { padding: var(--s5) var(--s6); max-width: 1400px; margin: 0 auto; }
.page { display: none; }
.page.active { display: block; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.topbar { display: flex; align-items: center; gap: var(--s4); margin-bottom: var(--s5); }
.topbar h2 { font-size: 22px; font-weight: 600; letter-spacing: -.02em; }
.topbar .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.topbar .spacer { flex: 1; }

.conn-badge {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 500; font-family: var(--mono);
  padding: 5px 12px; border-radius: var(--r-pill); border: 1px solid var(--border);
}
.conn-badge .dot { width: 7px; height: 7px; border-radius: 50%; }
.conn-badge.live { background: var(--success-soft); color: var(--success); border-color: oklch(0.72 0.14 158 / 0.3); }
.conn-badge.live .dot { background: var(--success); box-shadow: 0 0 0 0 var(--success); animation: ping 2s infinite; }
.conn-badge.offline { background: var(--critical-soft); color: var(--critical); }
.conn-badge.offline .dot { background: var(--critical); }
@keyframes ping { 0% { box-shadow: 0 0 0 0 oklch(0.72 0.14 158 / .5); } 70%,100% { box-shadow: 0 0 0 6px transparent; } }

/* ============================================================
   Hero — 24h activity
   ============================================================ */
.hero {
  display: grid; grid-template-columns: 1.6fr 1fr; gap: var(--s4); margin-bottom: var(--s5);
}
.hero-chart {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: var(--s5); position: relative; overflow: hidden;
}
.hero-chart h3 { font-size: 13px; font-weight: 600; }
.hero-chart .chart-meta { display: flex; align-items: baseline; gap: var(--s3); margin-top: 2px; }
.hero-chart .big { font-family: var(--mono); font-size: 28px; font-weight: 600; letter-spacing: -.02em; }
.hero-chart .delta { font-size: 12px; font-weight: 500; font-family: var(--mono); }
.delta.up { color: var(--critical); }
.delta.down { color: var(--success); }
.chart-svg { width: 100%; height: 90px; margin-top: var(--s4); display: block; overflow: visible; }
.chart-legend { display: flex; gap: var(--s4); margin-top: var(--s3); }
.chart-legend span { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.chart-legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }

.kpis { display: grid; grid-template-rows: repeat(2, 1fr); gap: var(--s4); }
.kpi-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: var(--s4); display: flex; flex-direction: column; justify-content: center;
  transition: border-color .2s, transform .2s;
}
.kpi:hover { border-color: var(--border-strong); }
.kpi .k-label { font-size: 11px; color: var(--muted); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.kpi .k-value { font-family: var(--mono); font-size: 26px; font-weight: 600; letter-spacing: -.02em; margin-top: 4px; line-height: 1; }
.kpi .k-foot { font-size: 11px; color: var(--muted); font-family: var(--mono); margin-top: 6px; }
.kpi.accent-red .k-value { color: var(--critical); }
.kpi.accent-warn .k-value { color: var(--warning); }
.kpi.accent-blue .k-value { color: var(--accent); }

/* ============================================================
   Controls — tabs, direction switch, filters
   ============================================================ */
.controls { display: flex; align-items: center; gap: var(--s4); margin-bottom: var(--s4); flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: var(--r-md); border: 1px solid var(--border); }
.tab {
  display: flex; align-items: center; gap: var(--s2); padding: 7px 14px; border-radius: var(--r-sm);
  font-size: 13px; font-weight: 500; cursor: pointer; color: var(--muted); transition: background .15s, color .15s; user-select: none;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.tab-count { font-family: var(--mono); font-size: 11px; padding: 1px 7px; border-radius: var(--r-pill); background: var(--surface-3); color: var(--text-2); }
.tab.active .tab-count.warn { background: var(--warning-soft); color: var(--warning); }

.spacer { flex: 1; }

.segmented {
  display: flex; gap: 2px; background: var(--surface-2); padding: 3px; border-radius: var(--r-md); border: 1px solid var(--border);
}
.segmented button {
  border: none; background: transparent; color: var(--muted); cursor: pointer;
  font-family: var(--font); font-size: 12.5px; font-weight: 500; padding: 6px 12px; border-radius: var(--r-sm);
  display: flex; align-items: center; gap: 6px;
}
.segmented button svg { width: 14px; height: 14px; }
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.filters { display: flex; gap: var(--s2); margin-bottom: var(--s4); flex-wrap: wrap; align-items: center; }
.field { position: relative; display: flex; align-items: center; }
.field svg { position: absolute; left: 10px; width: 15px; height: 15px; color: var(--muted); pointer-events: none; }
.input, .select {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  font-family: var(--font); font-size: 13px; padding: 8px 12px; border-radius: var(--r-sm); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field .input { padding-left: 32px; min-width: 260px; }
.input:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder { color: var(--muted); }
.select { cursor: pointer; }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid transparent; padding: 8px 14px; border-radius: var(--r-sm); cursor: pointer; font-family: var(--font); font-size: 13px; font-weight: 500; transition: all .15s; white-space: nowrap; }
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: var(--surface); color: var(--text-2); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--critical-soft); color: var(--critical); border-color: oklch(0.66 0.20 22 / 0.3); }
.btn-danger:hover { background: oklch(0.66 0.20 22 / 0.2); }
.btn-success { background: var(--success-soft); color: var(--success); border-color: oklch(0.72 0.14 158 / 0.3); }
.btn-success:hover { background: oklch(0.72 0.14 158 / 0.22); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ============================================================
   Issue lists (shared)
   ============================================================ */
.panel-surface { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.empty { text-align: center; padding: var(--s8) var(--s5); color: var(--muted); }
.empty svg { width: 32px; height: 32px; margin-bottom: var(--s3); opacity: .5; }
.empty p { font-size: 13px; }

/* skeleton */
.skel-row { padding: var(--s4); border-bottom: 1px solid var(--border); display: flex; gap: var(--s4); align-items: center; }
.skel { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: 5px; height: 12px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* severity tokens */
.sev-bar { width: 3px; align-self: stretch; border-radius: 3px; flex-shrink: 0; }
.sev-critical { background: var(--critical); }
.sev-error { background: var(--error); }
.sev-warning { background: var(--warning); }
.sev-chip { font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: var(--r-pill); text-transform: capitalize; white-space: nowrap; }
.sev-chip.critical { background: var(--critical-soft); color: var(--critical); }
.sev-chip.error { background: var(--error-soft); color: var(--error); }
.sev-chip.warning { background: var(--warning-soft); color: var(--warning); }

/* issue status badges */
.issue-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 500; padding: 3px 9px; border-radius: var(--r-pill); white-space: nowrap; border: 1px solid transparent; }
.issue-badge svg { width: 12px; height: 12px; }
.issue-open { background: var(--success-soft); color: var(--success); border-color: oklch(0.72 0.14 158 / .25); }
.issue-closed { background: var(--accent-soft); color: var(--accent); border-color: oklch(0.64 0.17 268 / .25); }
.issue-none { background: var(--surface-2); color: var(--muted); border-color: var(--border); }

/* trend badge */
.trend { display: inline-flex; align-items: center; gap: 3px; font-family: var(--mono); font-size: 11px; font-weight: 500; }
.trend.up { color: var(--critical); }
.trend.down { color: var(--success); }
.trend.flat { color: var(--muted); }
.trend svg { width: 11px; height: 11px; }

/* count pill */
.count-pill { font-family: var(--mono); font-size: 12px; font-weight: 500; background: var(--surface-2); border: 1px solid var(--border); padding: 2px 8px; border-radius: var(--r-sm); }
.chip { font-family: var(--mono); font-size: 11px; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); padding: 2px 8px; border-radius: var(--r-sm); white-space: nowrap; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }

/* sparkline */
.spark { width: 84px; height: 26px; display: block; overflow: visible; }

/* ============================================================
   Direction A — Refined Table
   ============================================================ */
.tbl-head, .tbl-row { display: grid; align-items: center; gap: var(--s3); }
.tbl-head { padding: 10px var(--s4) 10px 0; font-size: 11px; font-weight: 600; letter-spacing: .04em; color: var(--muted); text-transform: uppercase; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.tbl-head > div { cursor: default; }
.tbl-head .sortable { cursor: pointer; user-select: none; display: inline-flex; align-items: center; gap: 4px; }
.tbl-head .sortable:hover { color: var(--text); }
.tbl-row { padding: 0 var(--s4) 0 0; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .12s; min-height: 56px; }
.tbl-row:last-child { border-bottom: none; }
.tbl-row:hover { background: var(--surface-2); }
.tbl-row.flash { animation: flashIn .9s var(--easing); }
@keyframes flashIn { 0% { background: var(--accent-soft); } 100% { background: transparent; } }
.cell-pad { padding: var(--s3) 0; }
.crash-cols { grid-template-columns: 3px minmax(0,1fr) 96px 110px 90px 84px 130px 96px; }
.cnf-cols { grid-template-columns: 3px minmax(0,1.4fr) minmax(0,1fr) 90px 130px 96px; }
.err-title { font-size: 13.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.err-sub { font-family: var(--mono); font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }

/* ============================================================
   Direction B — Triage Cards
   ============================================================ */
.triage-group { margin-bottom: var(--s5); }
.triage-group-head { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s3); }
.triage-group-head h4 { font-size: 13px; font-weight: 600; }
.triage-group-head .line { flex: 1; height: 1px; background: var(--border); }
.triage-cards { display: flex; flex-direction: column; gap: var(--s3); }
.tcard {
  display: grid; grid-template-columns: 4px 1fr auto; gap: var(--s4); align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: var(--s4); cursor: pointer; transition: border-color .15s, transform .15s, box-shadow .15s;
}
.tcard:hover { border-color: var(--border-strong); transform: translateY(-1px); box-shadow: var(--shadow); }
.tcard .bar { width: 4px; align-self: stretch; border-radius: 4px; }
.tcard-main { min-width: 0; }
.tcard-title { display: flex; align-items: center; gap: var(--s3); }
.tcard-title .t { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tcard-meta { display: flex; align-items: center; gap: var(--s2); margin-top: var(--s2); flex-wrap: wrap; }
.tcard-right { display: flex; align-items: center; gap: var(--s5); }
.tcard-stat { text-align: right; }
.tcard-stat .n { font-family: var(--mono); font-size: 18px; font-weight: 600; }
.tcard-stat .l { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

/* ============================================================
   Direction C — Terminal Stream
   ============================================================ */
.terminal {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-lg);
  font-family: var(--mono); font-size: 12.5px; line-height: 1.7; overflow: hidden;
}
[data-theme="light"] .terminal { background: oklch(0.22 0.014 265); color: oklch(0.9 0.005 265); }
.term-head { padding: 10px var(--s4); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: var(--s2); color: var(--muted); }
.term-dots { display: flex; gap: 6px; margin-right: var(--s2); }
.term-dots i { width: 11px; height: 11px; border-radius: 50%; }
.term-body { padding: var(--s3) 0; max-height: 60vh; overflow-y: auto; }
.term-line { display: grid; grid-template-columns: 64px 14px 1fr auto; gap: var(--s3); align-items: baseline; padding: 5px var(--s4); cursor: pointer; transition: background .1s; }
[data-theme="dark"] .term-line:hover { background: oklch(1 0 0 / .04); }
[data-theme="light"] .term-line:hover { background: oklch(1 0 0 / .06); }
.term-line.flash { animation: flashIn .9s var(--easing); }
.term-time { color: var(--muted); }
.term-glyph { font-weight: 600; }
.term-glyph.critical { color: var(--critical); }
.term-glyph.error { color: var(--error); }
.term-glyph.warning { color: var(--warning); }
.term-msg { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
[data-theme="light"] .term-msg { color: oklch(0.92 0.005 265); }
.term-msg .dim { color: var(--muted); }
.term-tags { display: flex; gap: var(--s3); color: var(--muted); white-space: nowrap; }
.term-tags .ok { color: var(--success); }
.term-tags .op { color: var(--accent); }
.term-cursor { display: inline-block; width: 8px; height: 15px; background: var(--success); margin-left: 4px; vertical-align: middle; animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.term-prompt { padding: 8px var(--s4); color: var(--success); display: flex; align-items: center; gap: var(--s2); border-top: 1px solid var(--border); }

/* ============================================================
   Detail overlay
   ============================================================ */
.overlay { display: none; position: fixed; inset: 0; background: oklch(0.1 0.01 265 / .6); backdrop-filter: blur(3px); z-index: 100; align-items: center; justify-content: center; padding: var(--s5); }
.overlay.open { display: flex; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); width: 780px; max-width: 100%; max-height: 88vh; overflow-y: auto; box-shadow: var(--shadow); animation: panelUp .28s var(--easing); }
@keyframes panelUp { from { transform: translateY(16px) scale(.98); } to { transform: none; } }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s4); padding: var(--s5) var(--s5) var(--s4); border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.panel-head .ph-left { min-width: 0; }
.panel-head .ph-kicker { display: flex; align-items: center; gap: var(--s2); margin-bottom: var(--s2); }
.panel-title { font-size: 18px; font-weight: 600; letter-spacing: -.01em; word-break: break-word; }
.close-btn { background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); width: 32px; height: 32px; border-radius: var(--r-sm); cursor: pointer; display: grid; place-items: center; flex-shrink: 0; transition: all .15s; }
.close-btn:hover { color: var(--text); background: var(--surface-3); }
.close-btn svg { width: 16px; height: 16px; }
.panel-body { padding: var(--s5); }
.meta-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s3); margin-bottom: var(--s5); }
.meta-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: var(--s3) var(--s4); }
.meta-lbl { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; margin-bottom: 4px; }
.meta-val { font-family: var(--mono); font-size: 13px; word-break: break-word; }
.sec-lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; margin-bottom: var(--s3); display: flex; align-items: center; gap: var(--s2); }
.stack-pre { background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-sm); padding: var(--s4); font-family: var(--mono); font-size: 12px; line-height: 1.85; color: var(--text-2); white-space: pre-wrap; word-break: break-word; max-height: 320px; overflow-y: auto; margin-bottom: var(--s5); }
.stack-pre .hl { color: var(--accent); }
.gh-link { color: var(--accent); font-size: 12px; word-break: break-all; text-decoration: none; }
.gh-link:hover { text-decoration: underline; }
.panel-actions { display: flex; gap: var(--s2); flex-wrap: wrap; padding-top: var(--s4); border-top: 1px solid var(--border); }

/* sparkline big (detail) */
.detail-spark { width: 100%; height: 70px; display: block; margin-bottom: var(--s5); }

/* ============================================================
   API Keys
   ============================================================ */
.key-toolbar { display: flex; gap: var(--s3); margin-bottom: var(--s5); }
.key-toolbar .input { flex: 1; }
.new-key-banner {
  background: var(--success-soft); border: 1px solid oklch(0.72 0.14 158 / .3); border-radius: var(--r-md);
  padding: var(--s4) var(--s5); margin-bottom: var(--s5); display: none;
}
.new-key-banner.show { display: block; animation: fadeUp .3s var(--easing); }
.new-key-banner .nk-head { display: flex; align-items: center; gap: var(--s2); color: var(--success); font-size: 13px; font-weight: 600; margin-bottom: var(--s3); }
.new-key-banner .nk-head svg { width: 16px; height: 16px; }
.nk-code { display: flex; align-items: center; gap: var(--s3); }
.nk-code code { flex: 1; font-family: var(--mono); font-size: 13px; background: var(--bg); border: 1px solid var(--border); padding: 10px 12px; border-radius: var(--r-sm); word-break: break-all; }
.new-key-banner small { font-size: 12px; color: var(--muted); display: block; margin-top: var(--s3); }
.new-key-banner small code { font-family: var(--mono); background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }

.keys-cols { grid-template-columns: minmax(0,1.4fr) 150px 100px 80px 130px 150px; }
.key-row { display: grid; align-items: center; gap: var(--s3); padding: var(--s4); border-bottom: 1px solid var(--border); transition: background .12s; }
.key-row:last-child { border-bottom: none; }
.key-row:hover { background: var(--surface-2); }
.key-row.revoked { opacity: .5; }
.key-label { font-size: 13.5px; font-weight: 500; display: flex; align-items: center; gap: var(--s2); }
.key-prefix { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.status-badge { font-size: 11px; font-weight: 500; padding: 3px 9px; border-radius: var(--r-pill); display: inline-flex; align-items: center; gap: 5px; }
.status-active { background: var(--success-soft); color: var(--success); }
.status-revoked { background: var(--critical-soft); color: var(--critical); }
.key-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* responsive */
@media (max-width: 1080px) {
  .layout { grid-template-columns: 64px 1fr; }
  .brand-text, .nav-label, .nav-item span, .nav-badge, .theme-toggle button span { display: none; }
  .brand { justify-content: center; padding: 0 0 var(--s4); }
  .nav-item { justify-content: center; }
  .hero { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .main-inner { padding: var(--s4); }
  .meta-grid { grid-template-columns: 1fr 1fr; }
  .crash-cols { grid-template-columns: 3px minmax(0,1fr) 84px 64px; }
  .crash-cols .hide-sm, .cnf-cols .hide-sm { display: none; }
}
