:root {
  /* superficies */
  --bg: #0b0e14;
  --surface-1: #121823;
  --surface-2: #171f2b;
  --border: #212b3a;
  --border-soft: #1a2230;
  /* texto */
  --ink: #e8edf4;
  --muted: #8d98a9;
  --faint: #5c6675;
  /* marca / paleta (dark, validada CVD) */
  --accent: #3987e5;
  --accent-soft: rgba(57, 135, 229, .14);
  --c-blue: #3987e5;
  --c-orange: #d95926;
  --c-aqua: #199e70;
  --c-yellow: #c98500;
  --c-red: #e66767;
  --good: #199e70;
  --warn: #c98500;
  --bad: #d95926;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -12px rgba(0,0,0,.5);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: radial-gradient(1200px 600px at 80% -10%, #141c2b 0%, var(--bg) 60%) fixed;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv05", "ss01";
}
h1, h2, h3 { font-weight: 650; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.grow { flex: 1; }

/* ─── topbar ─── */
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 22px;
  background: rgba(14, 19, 28, .78);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar .brand { font-weight: 700; letter-spacing: -.02em; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.topbar .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 3px rgba(25,158,112,.18); }
.clock { font-variant-numeric: tabular-nums; color: var(--faint); font-size: 13px; }

main {
  max-width: 1180px; margin: 0 auto;
  padding: 24px 20px 64px;
  display: flex; flex-direction: column; gap: 20px;
}

/* ─── cards ─── */
.card {
  background: linear-gradient(180deg, var(--surface-2), var(--surface-1));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 14px; font-size: 15px; display: flex; align-items: baseline; gap: 8px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 12px; }
.card-head h2 { margin: 0; }

/* ─── KPIs ─── */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.kpi { position: relative; display: flex; flex-direction: column; gap: 8px; padding: 16px 18px; overflow: hidden; }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); opacity: .9; }
.kpi .label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.kpi .val { font-size: 30px; font-weight: 700; line-height: 1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi.k-users::before { background: var(--c-aqua); }
.kpi.k-new::before { background: var(--c-blue); }
.kpi.k-bots::before { background: var(--c-orange); }
.kpi.k-caja::before { background: var(--c-yellow); }

.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ─── listas ─── */
.list { display: flex; flex-direction: column; max-height: 430px; overflow: auto; margin: 0 -8px; padding: 0 2px; }
.list::-webkit-scrollbar { width: 8px; }
.list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 8px; border-radius: 8px; border-bottom: 1px solid var(--border-soft);
  transition: background .12s ease;
}
.row:hover { background: rgba(255,255,255,.025); }
.row:last-child { border-bottom: none; }
.row-title { font-weight: 600; font-size: 14px; }
.rank { color: var(--accent); font-weight: 700; margin-right: 6px; font-variant-numeric: tabular-nums; }

.pill {
  background: var(--accent-soft); color: var(--accent);
  border-radius: 999px; padding: 3px 11px; font-size: 12px; font-weight: 600;
  white-space: nowrap; font-variant-numeric: tabular-nums;
}
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 6px; }

.status .row { font-size: 13px; border-bottom-color: var(--border-soft); }

/* ─── charts ─── */
canvas { max-width: 100%; }
.chart-box { position: relative; height: 200px; }
.chart-box.tall { height: 280px; }
.chart-box[hidden] { display: none; }
.cols[hidden] { display: none; } /* el display:grid de .cols tapa el [hidden] por defecto */

/* ─── heatmap hora×día (conectados) ─── */
.heatmap-wrap { overflow-x: auto; padding-bottom: 4px; } /* scroll horizontal en móvil */
.heatmap-wrap[hidden] { display: none; }
.heatmap {
  display: grid;
  grid-template-columns: 38px repeat(24, minmax(22px, 1fr));
  gap: 3px;
  min-width: 600px; /* fuerza scroll en pantallas chicas, no rompe el layout */
}
.hm-h { font-size: 10px; color: var(--muted); text-align: center; align-self: end; padding-bottom: 3px; font-variant-numeric: tabular-nums; }
.hm-d { font-size: 11px; font-weight: 600; color: var(--muted); display: flex; align-items: center; }
.hm-cell {
  height: 22px; border-radius: 4px;
  background: var(--surface-1);
  transition: outline .1s ease;
}
.hm-cell:hover { outline: 2px solid var(--ink); outline-offset: -1px; cursor: default; }
.hm-cell.empty { /* sin dato: superficie tenue con trama, distinta de "cero" */
  background-color: var(--surface-1);
  background-image: repeating-linear-gradient(45deg, transparent 0 3px, rgba(255,255,255,.05) 3px 4px);
}
.heatmap-legend { display: flex; align-items: center; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.heatmap-legend[hidden] { display: none; }
.hm-scale { width: 150px; height: 10px; border-radius: 999px; border: 1px solid var(--border); }
.hm-empty-key { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-left: 8px; }
.hm-empty-key .hm-cell { width: 16px; height: 16px; }

/* ─── whale watch ─── */
.whale-right { display: flex; align-items: center; gap: 10px; }
.spark { display: block; opacity: .9; flex: none; }
.spark-empty { display: inline-block; width: 62px; height: 20px; flex: none; }

/* ─── controles ─── */
button {
  background: var(--accent); color: #06101d; border: none; border-radius: 9px;
  padding: 9px 15px; font-weight: 650; font-size: 13px; cursor: pointer;
  font-family: inherit; transition: filter .12s ease, background .12s ease;
}
button:hover { filter: brightness(1.08); }
button.ghost { background: rgba(255,255,255,.04); color: var(--ink); border: 1px solid var(--border); }
button.ghost:hover { background: rgba(255,255,255,.08); filter: none; }
select {
  background: var(--surface-1); color: var(--ink); border: 1px solid var(--border);
  border-radius: 9px; padding: 8px 12px; font-family: inherit; font-size: 13px; cursor: pointer;
}
select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ─── modal ─── */
.modal { position: fixed; inset: 0; background: rgba(3,6,11,.66); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal[hidden] { display: none; }
.modal-card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; width: 360px; max-width: 92vw; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow); }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { margin: 0; }
.modal-card label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.modal-card code { background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: 12px; }

/* ─── login ─── */
.login-body { display: flex; min-height: 100vh; align-items: center; justify-content: center; }
.login-card { display: flex; flex-direction: column; gap: 12px; width: 320px; }
.login-card h1 { margin: 0; letter-spacing: -.02em; }
.login-card input { background: var(--bg); color: var(--ink); border: 1px solid var(--border); border-radius: 10px; padding: 11px 13px; font-family: inherit; font-size: 14px; }
.login-card input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.err { color: var(--c-red); margin: 0; font-size: 13px; }

@media (max-width: 760px) {
  .cols { grid-template-columns: 1fr; }
  main { padding: 16px 14px 48px; gap: 16px; }
  .topbar { padding: 10px 14px; gap: 10px; }
}
