/* Muñiz Automations — Web Analytics
   Spotify-style layout, Muñiz brand palette. Matches the CRM + hub theme. */
:root {
  --bg: #0e141b;
  --surface: #151e28;
  --surface-2: #1d2935;
  --surface-3: #243344;
  --line: #314252;
  --ink: #edf5fb;
  --muted: #b2c2d1;
  --faint: #7d93a6;
  --brand: #69b6ef;
  --brand-deep: #3d9be9;
  --brand-soft: #15334a;
  --accent: #f1865d;
  --accent-soft: #3a2417;
  --radius: 12px;
  --shadow: 0 18px 50px rgba(0, 0, 0, .35);
  --font-body: "DM Sans", -apple-system, "Segoe UI", sans-serif;
  --font-head: "Manrope", "DM Sans", -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font-body); font-size: 15px; line-height: 1.5;
  min-width: 320px;
}
h1, h2 { font-family: var(--font-head); letter-spacing: -.03em; margin: 0; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.hidden { display: none !important; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .86em; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 28px; background: #0b1118; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20; flex-wrap: wrap;
}
.topbar-left { display: flex; align-items: center; gap: 18px; }
.back {
  color: var(--muted); text-decoration: none; font-weight: 600; font-size: .9rem;
  padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface);
}
.back:hover { color: var(--ink); border-color: var(--brand); }
.topbar h1 { font-size: 1.35rem; font-weight: 800; }
.topbar .sub { color: var(--faint); font-size: .8rem; margin: 2px 0 0; }
.range-pills { display: flex; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px; }
.pill {
  border: 0; background: transparent; color: var(--muted); font-weight: 700; font-size: .85rem;
  border-radius: 999px; padding: 7px 16px; cursor: pointer;
}
.pill:hover { color: var(--ink); }
.pill.active { background: var(--brand); color: #08131d; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.clear-btn {
  background: transparent; color: var(--faint); border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 14px; font-size: .78rem; font-weight: 600;
  cursor: pointer; transition: all .15s ease; white-space: nowrap;
}
.clear-btn:hover { color: #ff8f8f; border-color: #ff8f8f; }
.clear-btn.armed { background: #ff5d5d; border-color: #ff5d5d; color: #1a0d0d; }

/* ---------- main ---------- */
.main { max-width: 1080px; margin: 0 auto; padding: 28px 28px 60px; }
.banner {
  background: var(--accent-soft); border: 1px solid var(--accent); color: var(--ink);
  border-radius: var(--radius); padding: 12px 16px; margin-bottom: 18px; font-size: .9rem;
}

.kpi-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px; margin-bottom: 18px;
}
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px;
}
.kpi .v { font-family: var(--font-head); font-size: 1.9rem; font-weight: 800; letter-spacing: -.02em; }
.kpi .l { color: var(--faint); font-size: .82rem; margin-top: 2px; }
.kpi.hot .v { color: var(--brand); }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 22px; margin-bottom: 18px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { font-size: 1.05rem; font-weight: 800; }
.chip {
  font-size: .7rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--brand); background: var(--brand-soft); border: 1px solid var(--line);
  border-radius: 999px; padding: 3px 10px;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-2 .card { margin-bottom: 18px; }

.legend { display: flex; gap: 16px; font-size: .82rem; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.swatch-blue { background: var(--brand); }
.swatch-orange { background: var(--accent); }

.chart { min-height: 120px; }
.chart-svg { width: 100%; height: auto; display: block; }
.chart-svg .bar-blue { fill: var(--brand); opacity: .92; }
.chart-svg .bar-orange { fill: var(--accent); opacity: .75; }
.chart-svg .axis { fill: var(--faint); font-size: 11px; }
.chart-svg .axis-line { stroke: var(--line); stroke-width: 1; }

.tracks { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tracks th {
  text-align: left; color: var(--faint); font-size: .75rem; text-transform: uppercase;
  letter-spacing: .05em; padding: 8px 10px; border-bottom: 1px solid var(--line); font-weight: 700;
}
.tracks td { padding: 10px; border-bottom: 1px solid var(--line); }
.tracks tr:last-child td { border-bottom: 0; }
.tracks .num { text-align: right; font-variant-numeric: tabular-nums; }
.tracks th.num { text-align: right; }

.funnel-row { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.funnel-row:last-child { border-bottom: 0; }
.funnel-row .name { flex: 0 0 45%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: .9rem; }
.funnel-track { flex: 1; height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.funnel-bar { height: 100%; background: linear-gradient(90deg, var(--brand-deep), var(--brand)); border-radius: 999px; }
.funnel-row .n { flex: 0 0 44px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

.tag {
  display: inline-block; font-size: .78rem; font-weight: 700; color: var(--brand);
  background: var(--brand-soft); border-radius: 6px; padding: 3px 10px;
}

.empty {
  color: var(--faint); font-size: .9rem; padding: 22px 8px; text-align: center;
  border: 1px dashed var(--line); border-radius: 8px;
}

/* ---------- fatal ---------- */
.fatal {
  position: fixed; inset: 0; z-index: 100; background: var(--bg);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.fatal-inner { max-width: 560px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 32px; }
.fatal-inner h2 { margin-bottom: 10px; }
.fatal-inner .muted { color: var(--muted); }
.fatal-inner code {
  display: block; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 12px 14px; margin: 14px 0; font-size: .82rem; line-height: 1.6;
}
.btn-accent {
  background: var(--brand); color: #08131d; border: 0; border-radius: 8px;
  font-weight: 700; padding: 10px 18px; cursor: pointer; font-size: .92rem;
}
.btn-accent:hover { background: var(--brand-deep); }

@media (max-width: 760px) {
  .grid-2 { grid-template-columns: 1fr; }
  .topbar { padding: 12px 16px; }
  .main { padding: 20px 16px 44px; }
  .kpi .v { font-size: 1.5rem; }
}
