/* VirtuProbe Dashboard. Single dark theme, brand palette lifted from the landing
   (virtuprobe-landing/assets/base.css) so it reads as one product. Vanilla CSS,
   no bundler, no framework. */

:root {
  color-scheme: dark;

  --bg: #0a0d0c;
  --bg-1: #0f1413;
  --bg-2: #141a18;
  --bg-3: #1b231f;
  --line: #1f2a25;
  --line-2: #2a3830;

  --fg: #e6f2ec;
  --fg-dim: #a3b3ac;
  --fg-mute: #7d8c85;
  /* Landing uses #5c6a64 for sparse decorative text; a data dashboard leans on this
     for hints and empty states, so it is lifted to pass WCAG AA (~4.8:1 on the dark
     surfaces) while staying a step below --fg-mute. */
  --fg-faint: #76847b;

  --neon: #6ff39b;
  --neon-mint: #5ef0c2;
  --neon-lime: #8df860;
  --neon-glow: #6ff39b33;
  --on-neon: #06140d;

  --info: #5ec3f0;
  --warn: #f5c453;
  --danger: #ff6b6b;
  --violet: #c79df5;

  --tier-free: #7d8c85;
  --tier-eng: #38d9c9;
  --tier-sec: #c79df5;
  --tier-aca: #f5c453;
  --tier-ent: #5ec3f0;

  --shadow-md: 0 8px 24px -8px rgba(0, 0, 0, 0.5);
  --radius: 12px;

  --font-body: "Satoshi", "Geist", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-display: "Clash Display", "Geist", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; }
a { color: var(--neon-mint); }
code, .mono { font-family: var(--font-mono); font-size: 0.86em; }

/* ── topbar ───────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 12px 24px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand-mark {
  width: 14px; height: 14px; border-radius: 4px; align-self: center;
  background: linear-gradient(135deg, var(--neon-lime), var(--neon-mint));
  box-shadow: 0 0 12px var(--neon-glow);
}
.brand-name { font-family: var(--font-display); font-weight: 600; font-size: 18px; }
.brand-sub { color: var(--fg-mute); font-size: 13px; letter-spacing: 0.04em; text-transform: uppercase; }

.tabs { display: flex; gap: 4px; }
.tab {
  background: transparent; border: 0; color: var(--fg-dim);
  padding: 8px 16px; border-radius: 8px; cursor: pointer; font: inherit; font-size: 14px;
}
.tab:hover { background: var(--bg-2); color: var(--fg); }
.tab.is-active { background: var(--bg-3); color: var(--fg); }

.topbar-right { margin-left: auto; }
.banner {
  font-size: 12.5px; padding: 7px 14px; border-radius: 999px;
  border: 1px solid var(--line-2); font-family: var(--font-mono);
}
.banner-muted { color: var(--fg-mute); }
.banner-local { color: var(--neon); border-color: color-mix(in srgb, var(--neon) 40%, transparent); background: var(--neon-glow); }
.banner-prod  { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 50%, transparent); background: color-mix(in srgb, var(--danger) 12%, transparent); font-weight: 600; }
.banner-warn  { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); background: color-mix(in srgb, var(--warn) 10%, transparent); display: block; border-radius: 8px; margin: 0 0 12px; padding: 10px 14px; }

/* ── layout ───────────────────────────────────────────── */
main { max-width: 1240px; margin: 0 auto; padding: 24px 24px 80px; }
.view { display: none; }
.view.is-active { display: block; }
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.view-head h1 { font-size: 24px; margin: 0; }
.controls { display: flex; align-items: center; gap: 10px; }
.days { color: var(--fg-dim); font-size: 13px; display: flex; align-items: center; gap: 8px; }

.section-title { font-size: 15px; color: var(--fg-dim); text-transform: uppercase; letter-spacing: 0.06em; margin: 28px 0 14px; font-family: var(--font-body); font-weight: 600; }
.section-title .hint { text-transform: none; letter-spacing: 0; color: var(--fg-faint); font-weight: 400; margin-left: 8px; }
.hint { color: var(--fg-faint); font-size: 13px; }

.status { color: var(--fg-mute); font-size: 13px; min-height: 18px; margin: 4px 0; }
.status.err { color: var(--danger); }

/* ── inputs / buttons ─────────────────────────────────── */
.input, select {
  background: var(--bg-2); color: var(--fg); border: 1px solid var(--line-2);
  border-radius: 8px; padding: 8px 12px; font: inherit; font-size: 14px;
}
.input:focus, select:focus { outline: 2px solid var(--neon-glow); border-color: var(--neon); }
.input { min-width: 240px; }
.btn {
  background: var(--bg-2); color: var(--fg); border: 1px solid var(--line-2);
  border-radius: 8px; padding: 8px 16px; cursor: pointer; font: inherit; font-size: 14px;
}
.btn:hover { background: var(--bg-3); border-color: var(--line-2); }
.btn-primary { background: var(--neon); color: var(--on-neon); border-color: transparent; font-weight: 600; }
.btn-primary:hover { background: var(--neon-lime); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 14%, transparent); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 5px 10px; font-size: 13px; }

/* ── cards / grid ─────────────────────────────────────── */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.card { background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card h3 { margin: 0 0 14px; font-size: 14px; color: var(--fg-dim); font-weight: 600; }
.card-wide { grid-column: 1 / -1; }

/* KPI strip: auto-fit so the row always fills, whatever the tile count (no empty tiles). */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(176px, 1fr)); gap: 14px; margin-bottom: 4px; }
.kpi { background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.kpi-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.kpi .v { font-family: var(--font-display); font-size: 29px; font-weight: 600; color: var(--neon); line-height: 1.1; }
.kpi .l { color: var(--fg-mute); font-size: 12.5px; margin-top: 5px; }
.kpi.alt .v { color: var(--neon-mint); }
.delta { font-size: 12px; font-family: var(--font-mono); font-weight: 600; padding: 2px 7px; border-radius: 999px; white-space: nowrap; }
.delta.up { color: var(--neon); background: color-mix(in srgb, var(--neon) 14%, transparent); }
.delta.down { color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, transparent); }
.delta.flat { color: var(--fg-mute); background: var(--bg-3); }

/* ── bar lists ────────────────────────────────────────── */
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 116px 1fr 50px 42px; align-items: center; gap: 10px; font-size: 13px; cursor: default; }
.bar-row .k { color: var(--fg-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .track { background: var(--bg-3); border-radius: 6px; height: 14px; overflow: hidden; }
.bar-row .fill { height: 100%; background: linear-gradient(90deg, var(--neon-mint), var(--neon)); border-radius: 6px; transition: filter .1s; }
.bar-row:hover .fill { filter: brightness(1.12); }
.bar-row .n { text-align: right; color: var(--fg); font-family: var(--font-mono); font-size: 12.5px; }
.bar-row .pct { text-align: right; color: var(--fg-mute); font-family: var(--font-mono); font-size: 11.5px; }
.bar-row.t-FREE .fill { background: var(--tier-free); }
.bar-row.t-ENGINEERING .fill { background: var(--tier-eng); }
.bar-row.t-SECURITY .fill { background: var(--tier-sec); }
.bar-row.t-ACADEMIC .fill { background: var(--tier-aca); }
.bar-row.t-ENTERPRISE .fill { background: var(--tier-ent); }

/* ── svg charts (axes, gridlines, hover) ──────────────── */
.chart svg.cx { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis-label { fill: var(--fg-faint); font-size: 11px; font-family: var(--font-mono); }
.chart .series-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { opacity: 0.14; }
.chart .vbar { opacity: 0.9; transition: opacity .1s, filter .1s; }
.chart .vbar.hot { opacity: 1; filter: brightness(1.18); }
.chart .crosshair { stroke: var(--line-2); stroke-width: 1; stroke-dasharray: 3 3; pointer-events: none; }
.chart .hot-dot { pointer-events: none; }
.chart-empty, .empty { color: var(--fg-faint); font-size: 13px; padding: 24px 0; text-align: center; }

/* legend */
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 0 0 8px 44px; }
.leg { color: var(--fg-dim); font-size: 12px; display: inline-flex; align-items: center; }
.tip-dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }

/* shared tooltip */
.tip { position: fixed; z-index: 100; pointer-events: none; display: none; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 10px; font-size: 12.5px; color: var(--fg); box-shadow: var(--shadow-md); max-width: 260px; }
.tip-h { color: var(--fg-dim); font-size: 11.5px; margin-bottom: 4px; font-family: var(--font-mono); }
.tip b { color: var(--fg); }

/* ── funnel ───────────────────────────────────────────── */
.funnel { display: flex; flex-direction: column; gap: 18px; }
.funnel-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.funnel-label { color: var(--fg-dim); font-size: 13px; }
.funnel-val { font-family: var(--font-display); font-size: 21px; font-weight: 600; color: var(--fg); }
.funnel-track { background: var(--bg-3); border-radius: 7px; height: 18px; overflow: hidden; }
.funnel-fill { height: 100%; border-radius: 7px; }
.funnel-meta { display: flex; gap: 12px; align-items: baseline; margin-top: 6px; flex-wrap: wrap; }
.funnel-conv { color: var(--neon); font-size: 12px; font-family: var(--font-mono); }
.panel-note { color: var(--fg-faint); font-size: 12px; margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }

/* ── retention heatmap ────────────────────────────────── */
.heat { display: flex; flex-direction: column; gap: 3px; overflow-x: auto; }
.heat-row { display: flex; gap: 3px; }
.heat-cell { flex: 1 1 0; min-width: 36px; height: 30px; display: flex; align-items: center; justify-content: center; font-size: 11px; font-family: var(--font-mono); border-radius: 4px; background: var(--bg-2); color: var(--fg-dim); }
.heat-label { flex: 0 0 66px; justify-content: flex-start; padding-left: 6px; color: var(--fg-dim); background: transparent; }
.heat-size { flex: 0 0 42px; color: var(--fg-mute); background: transparent; }
.heat-head .heat-cell { background: transparent; color: var(--fg-faint); height: 20px; }
.heat-empty { background: var(--bg-1); color: var(--fg-faint); }
.heat-val { cursor: default; }

/* ── R2 ───────────────────────────────────────────────── */
.r2-stat { display: flex; gap: 28px; margin-bottom: 14px; }
.r2-fig .v { font-family: var(--font-display); font-size: 22px; font-weight: 600; color: var(--neon-mint); }
.r2-fig .l { color: var(--fg-mute); font-size: 12px; margin-left: 6px; }

/* ── licences ─────────────────────────────────────────── */
.lic-layout { display: grid; grid-template-columns: 1fr 1.1fr; gap: 16px; align-items: start; }
.lic-list { padding: 0; overflow: hidden; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; color: var(--fg-mute); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; padding: 12px 14px; border-bottom: 1px solid var(--line); }
td { padding: 11px 14px; border-bottom: 1px solid var(--line); }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--bg-2); }
tbody tr.is-selected { background: var(--bg-3); }
tbody tr:last-child td { border-bottom: 0; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; font-family: var(--font-mono); border: 1px solid var(--line-2); }
.badge.tier-FREE { color: var(--tier-free); }
.badge.tier-ENGINEERING { color: var(--tier-eng); }
.badge.tier-SECURITY { color: var(--tier-sec); }
.badge.tier-ACADEMIC { color: var(--tier-aca); }
.badge.tier-ENTERPRISE { color: var(--tier-ent); }
.badge.on { color: var(--neon); border-color: color-mix(in srgb, var(--neon) 35%, transparent); }
.badge.off { color: var(--fg-mute); }
.badge.demo { color: var(--warn); }

.lic-detail dl { display: grid; grid-template-columns: 150px 1fr; gap: 6px 14px; margin: 0 0 16px; font-size: 13.5px; }
.lic-detail dt { color: var(--fg-mute); }
.lic-detail dd { margin: 0; word-break: break-all; }
.lic-detail h2 { font-size: 18px; margin: 0 0 4px; }
.lic-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 18px; }
.detail-section-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--fg-mute); margin: 12px 0 8px; }

/* ── modal ────────────────────────────────────────────── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: flex-start; justify-content: center; padding: 60px 16px; z-index: 50; }
.modal { background: var(--bg-1); border: 1px solid var(--line-2); border-radius: var(--radius); box-shadow: var(--shadow-md); width: 100%; max-width: 480px; padding: 22px; }
.modal h2 { margin: 0 0 16px; font-size: 18px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 12.5px; color: var(--fg-dim); }
.field-row { display: flex; gap: 16px; flex-wrap: wrap; }
.field-check { flex-direction: row; align-items: center; gap: 8px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.form-err { color: var(--danger); font-size: 13px; min-height: 18px; }

@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr; }
  .lic-layout { grid-template-columns: 1fr; }
  .tabs { order: 3; }
}
