:root {
  color-scheme: dark;
  --bg: #090d18;
  --bg-soft: #0d1321;
  --panel: rgba(17, 24, 40, .88);
  --panel-solid: #111828;
  --panel-hover: #151e31;
  --border: #202b40;
  --border-strong: #2d3b55;
  --text: #eef4ff;
  --muted: #8b99b3;
  --muted-2: #64728d;
  --cyan: #56d5ff;
  --cyan-soft: rgba(86, 213, 255, .13);
  --violet: #a78bfa;
  --amber: #f9bd63;
  --green: #55dda3;
  --blue: #6da7ff;
  --red: #ff7185;
  --shadow: 0 20px 60px rgba(0, 0, 0, .26);
  --radius: 16px;
  --chart-grid: rgba(120, 140, 175, .14);
  --chart-label: #71809a;
}

:root.light {
  color-scheme: light;
  --bg: #f3f6fb;
  --bg-soft: #eaf0f8;
  --panel: rgba(255, 255, 255, .92);
  --panel-solid: #fff;
  --panel-hover: #f8faff;
  --border: #dce4ef;
  --border-strong: #cbd6e5;
  --text: #132037;
  --muted: #64728a;
  --muted-2: #8491a7;
  --cyan-soft: rgba(11, 158, 203, .10);
  --shadow: 0 18px 50px rgba(38, 57, 82, .10);
  --chart-grid: rgba(65, 82, 110, .12);
  --chart-label: #78869c;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 15% -5%, rgba(65, 167, 214, .10), transparent 34rem),
    radial-gradient(circle at 90% 0%, rgba(136, 94, 246, .08), transparent 30rem),
    var(--bg);
  font: 14px/1.5 Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
button, a { font: inherit; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
.app-shell { min-height: 100vh; }
.topbar {
  height: 68px;
  padding: 0 max(24px, calc((100vw - 1440px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: inline-flex; align-items: center; gap: 11px; }
.brand-mark {
  width: 34px; height: 34px; display: grid; place-items: center;
  color: #07111b; background: linear-gradient(145deg, #81e9ff, #54d2fc 55%, #8c9fff);
  border-radius: 10px; font-weight: 900; font-size: 18px; box-shadow: 0 8px 24px rgba(65, 194, 239, .2);
}
.brand strong { display: block; font-size: 15px; letter-spacing: -.01em; }
.brand small { display: block; color: var(--muted-2); font-size: 8px; font-weight: 700; letter-spacing: .16em; margin-top: -1px; }
.top-actions { display: flex; align-items: center; gap: 9px; }
.icon-button, .live-button {
  border: 1px solid var(--border); background: var(--panel); border-radius: 10px; height: 36px;
  cursor: pointer; transition: .18s ease;
}
.icon-button { width: 36px; font-size: 17px; }
.icon-button:hover, .live-button:hover { border-color: var(--border-strong); background: var(--panel-hover); }
.live-button { display: inline-flex; align-items: center; gap: 8px; padding: 0 13px; color: var(--muted); font-size: 12px; font-weight: 650; }
.pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 5px rgba(85, 221, 163, .10); }
.live-button.paused .pulse { background: var(--amber); box-shadow: none; }
main { max-width: 1440px; margin: 0 auto; padding: 34px 24px 64px; }
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; margin: 6px 0 26px; }
.eyebrow, .panel-kicker { color: var(--cyan); font-size: 10px; line-height: 1; font-weight: 800; letter-spacing: .16em; }
h1 { font-size: clamp(28px, 4vw, 42px); line-height: 1.05; letter-spacing: -.04em; margin: 10px 0 8px; }
.subtitle { margin: 0; color: var(--muted); }
.health-pill {
  min-width: 210px; display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border: 1px solid var(--border); background: var(--panel); border-radius: 13px; box-shadow: var(--shadow);
}
.health-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--muted); flex: 0 0 auto; }
.health-pill strong, .health-pill small { display: block; }
.health-pill strong { font-size: 13px; }
.health-pill small { color: var(--muted); font-size: 11px; margin-top: 2px; }
.health-pill.online .health-dot { background: var(--green); box-shadow: 0 0 0 6px rgba(85, 221, 163, .10); }
.health-pill.online strong { color: var(--green); }
.health-pill.error .health-dot { background: var(--red); box-shadow: 0 0 0 6px rgba(255, 113, 133, .10); }
.health-pill.error strong { color: var(--red); }
.metrics-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.metric-card, .chart-card, .samples-card, .insight {
  position: relative; overflow: hidden; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.metric-card { min-height: 154px; padding: 17px; transition: transform .18s ease, border-color .18s ease; }
.metric-card:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.metric-card::after { content: ""; position: absolute; height: 2px; inset: 0 42% auto 0; opacity: .9; }
.accent-cyan::after { background: var(--cyan); } .accent-violet::after { background: var(--violet); }
.accent-amber::after { background: var(--amber); } .accent-green::after { background: var(--green); }
.accent-blue::after { background: var(--blue); } .accent-slate::after { background: var(--muted-2); }
.metric-head, .metric-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.metric-head { color: var(--muted); font-size: 12px; font-weight: 650; }
.metric-badge { padding: 3px 7px; border-radius: 6px; background: var(--bg-soft); color: var(--muted-2); font-size: 9px; letter-spacing: .04em; }
.metric-value { display: flex; align-items: baseline; gap: 7px; margin: 18px 0 17px; }
.metric-value strong { font-size: 35px; line-height: .9; letter-spacing: -.05em; }
.metric-value.compact strong { font-size: 27px; letter-spacing: -.03em; }
.metric-value span { color: var(--muted); font-size: 11px; font-weight: 700; }
.metric-foot { min-height: 17px; color: var(--muted-2); font-size: 10px; }
.metric-foot .positive { color: var(--green); } .metric-foot .negative { color: var(--red); }
.control-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 28px 0 12px; }
.range-control { display: inline-flex; gap: 3px; padding: 4px; border: 1px solid var(--border); background: var(--panel); border-radius: 11px; }
.range-control button { border: 0; background: transparent; color: var(--muted); padding: 7px 12px; border-radius: 7px; cursor: pointer; font-size: 11px; font-weight: 650; }
.range-control button:hover { color: var(--text); background: var(--bg-soft); }
.range-control button.active { color: var(--text); background: var(--border-strong); box-shadow: 0 2px 6px rgba(0,0,0,.12); }
.control-actions { display: flex; align-items: center; gap: 16px; color: var(--muted); font-size: 11px; }
.control-actions a { color: var(--cyan); font-weight: 650; }
.chart-card { padding: 20px 20px 14px; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 14px; }
.panel-head h2 { font-size: 17px; line-height: 1.2; margin: 7px 0 3px; letter-spacing: -.02em; }
.panel-head p { margin: 0; color: var(--muted); font-size: 11px; }
.panel-head.compact { margin-bottom: 8px; }
.panel-stat { color: var(--muted); font-size: 11px; white-space: nowrap; font-weight: 650; }
.amber-text { color: var(--amber); }.blue-text { color: var(--blue); }.green-text { color: var(--green); }
.legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 13px; color: var(--muted); font-size: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 9px; height: 9px; border-radius: 3px; }
.legend .cyan { background: var(--cyan); }.legend .violet { background: var(--violet); }
.legend .threshold { height: 1px; border-radius: 0; background: var(--muted-2); }
.chart-wrap { position: relative; width: 100%; height: 250px; }
.chart-wrap.large { height: 380px; }
.chart-wrap.short { height: 200px; }
canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.chart-tooltip {
  position: absolute; z-index: 3; pointer-events: none; min-width: 134px; padding: 9px 10px;
  border: 1px solid var(--border-strong); background: color-mix(in srgb, var(--panel-solid) 94%, transparent);
  border-radius: 9px; box-shadow: 0 12px 30px rgba(0, 0, 0, .25); opacity: 0; transform: translate(-50%, -108%);
  color: var(--muted); font-size: 10px; backdrop-filter: blur(12px); transition: opacity .08s ease;
}
.chart-tooltip.visible { opacity: 1; }
.chart-tooltip strong { display: block; color: var(--text); font-size: 11px; margin-bottom: 5px; }
.tooltip-row { display: flex; justify-content: space-between; gap: 16px; margin-top: 3px; }
.tooltip-row b { color: var(--text); font-weight: 700; }
.insight-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin: 12px 0; }
.insight { padding: 14px 15px; }
.insight span, .insight small { color: var(--muted); font-size: 10px; }
.insight strong { display: block; font-size: 22px; line-height: 1.15; margin: 7px 0 1px; letter-spacing: -.03em; }
.small-chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.span-two { grid-column: 1 / -1; }
.samples-card { margin-top: 12px; padding: 20px; }
.table-note { color: var(--muted-2); font-size: 10px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th { padding: 9px 12px; color: var(--muted-2); font-size: 9px; letter-spacing: .06em; text-align: right; border-bottom: 1px solid var(--border); }
th:first-child, td:first-child { text-align: left; padding-left: 0; }
td { padding: 11px 12px; text-align: right; color: var(--muted); font-size: 11px; border-bottom: 1px solid color-mix(in srgb, var(--border) 65%, transparent); }
tbody tr:last-child td { border-bottom: 0; }
td strong { color: var(--text); }
.status-tag { display: inline-flex; align-items: center; gap: 5px; color: var(--green); font-size: 10px; }
.status-tag::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.status-tag.bad { color: var(--red); }
.empty { text-align: center !important; padding: 30px !important; color: var(--muted-2); }
footer { max-width: 1440px; margin: 0 auto; padding: 20px 24px 34px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; gap: 16px; color: var(--muted-2); font-size: 10px; }
footer span:first-child { color: var(--muted); font-weight: 800; }

@media (max-width: 1180px) {
  .metrics-grid { grid-template-columns: repeat(3, 1fr); }
  .insight-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 760px) {
  .topbar { padding: 0 16px; }
  main { padding: 24px 14px 48px; }
  .hero { align-items: flex-start; flex-direction: column; }
  .health-pill { width: 100%; }
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-card { min-height: 143px; }
  .metric-value strong { font-size: 31px; }
  .control-row { align-items: flex-start; flex-direction: column; }
  .range-control { width: 100%; overflow-x: auto; }
  .range-control button { flex: 1 0 auto; }
  .control-actions { width: 100%; justify-content: space-between; }
  .panel-head { flex-direction: column; gap: 8px; }
  .legend { justify-content: flex-start; }
  .chart-wrap.large { height: 310px; }
  .small-chart-grid { grid-template-columns: 1fr; }
  .span-two { grid-column: auto; }
  .insight-grid { grid-template-columns: repeat(2, 1fr); }
  footer { padding: 18px 14px 28px; flex-direction: column; }
}
@media (max-width: 420px) {
  .metrics-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 132px; }
  .metric-value { margin: 15px 0; }
  .live-button span:last-child { display: none; }
  .live-button { width: 36px; padding: 0; justify-content: center; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
