:root {
  --bg: #04070c;
  --panel: rgba(10, 16, 24, 0.78);
  --border: rgba(148, 163, 184, 0.16);
  --text: #e6edf3;
  --muted: #8b98a8;
  --green: #22c55e;
  --amber: #f59e0b;
  --fire: #ff6a1a;
  --alert: #ff3b5c;
  --accent: #34d399;
  --radius: 14px;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden; }
a { color: var(--accent); }
h1 { font-size: 20px; margin: 0; letter-spacing: 0.2px; }
h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); margin: 16px 0 8px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }

#globe { position: fixed; inset: 0; }

.panel {
  position: fixed;
  background: var(--panel);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  z-index: 10;
}

/* encabezado */
.brand { top: 16px; left: 16px; width: 320px; }
.brand-row { display: flex; gap: 12px; align-items: center; }
.logo { font-size: 30px; }
.subtitle { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.live-row { display: flex; gap: 10px; align-items: center; margin-top: 10px; }
.badge { font-size: 11px; font-weight: 700; letter-spacing: 1px; padding: 3px 8px; border-radius: 999px; }
.badge.data { color: #04110a; background: var(--accent); }

/* filtros */
.filters { top: 136px; left: 16px; width: 320px; }
.filters h2:first-child { margin-top: 0; }
.range-labels { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.range-labels strong { color: var(--text); font-size: 15px; }
.dual-range { position: relative; height: 30px; }
.dual-range input { position: absolute; left: 0; right: 0; width: 100%; top: 6px; pointer-events: none; appearance: none; background: transparent; }
.dual-range input::-webkit-slider-thumb { pointer-events: all; appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--accent); border: 2px solid #04110a; cursor: pointer; }
.dual-range input::-moz-range-thumb { pointer-events: all; width: 16px; height: 16px; border-radius: 50%; background: var(--accent); border: 2px solid #04110a; cursor: pointer; }
.dual-range::before { content: ""; position: absolute; left: 0; right: 0; top: 14px; height: 4px; border-radius: 4px; background: linear-gradient(90deg, #14532d, var(--amber), var(--alert)); opacity: 0.7; }
.row { display: flex; gap: 8px; align-items: center; justify-content: space-between; margin-top: 8px; }

.segmented { display: inline-flex; background: rgba(148, 163, 184, 0.12); border-radius: 10px; padding: 3px; gap: 2px; }
.segmented button, .tabs button {
  border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 12px;
  padding: 6px 10px; border-radius: 8px; cursor: pointer;
}
.segmented button.active, .tabs button.active { background: rgba(52, 211, 153, 0.18); color: var(--text); }
.segmented button:focus-visible, .btn:focus-visible, .tabs button:focus-visible, .ranking button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn { border: 1px solid var(--border); background: rgba(148, 163, 184, 0.12); color: var(--text); font: inherit; font-size: 13px; padding: 8px 12px; border-radius: 10px; cursor: pointer; }
.btn.primary { background: var(--accent); color: #03140c; border-color: transparent; font-weight: 700; }
.btn.primary:hover { filter: brightness(1.08); }
.btn:disabled { opacity: 0.6; cursor: progress; }
.btn.wide { width: 100%; margin-top: 12px; }

.toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; font-size: 13px; }
.toggles input { accent-color: var(--accent); }

/* lateral */
.side { top: 16px; right: 16px; width: 330px; max-height: calc(100vh - 64px); overflow-y: auto; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kpi { background: rgba(148, 163, 184, 0.08); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 2px; }
.kpi-label { font-size: 11px; color: var(--muted); }
.kpi-value { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--amber); transition: transform 0.3s; }
.kpi-value.fire { color: var(--fire); }
.kpi-value.alert { color: var(--alert); }
.kpi-value.bump { transform: scale(1.12); }
.kpi-foot { font-size: 10px; color: var(--muted); }

.tabs { display: flex; gap: 4px; margin-top: 14px; }
.ranking { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-direction: column; gap: 4px; }
.ranking li button {
  width: 100%; display: grid; grid-template-columns: 18px 1fr auto; gap: 8px; align-items: center;
  background: transparent; border: 0; color: var(--text); font: inherit; font-size: 13px; padding: 4px 2px; cursor: pointer; text-align: left;
}
.ranking .bar { grid-column: 2 / 4; height: 3px; border-radius: 3px; background: linear-gradient(90deg, var(--amber), var(--alert)); }
.ranking .num { color: var(--muted); font-size: 11px; }
.ranking .val { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; }

.feed { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.feed li { font-size: 12px; padding: 8px 10px; border-radius: 10px; background: rgba(148, 163, 184, 0.08); border-left: 3px solid var(--muted); animation: slideIn 0.5s ease-out; }
.feed li.alert { border-left-color: var(--alert); cursor: pointer; }
.feed li.alert.media { border-left-color: var(--amber); }
.feed li.data { border-left-color: var(--accent); }
.feed .t { color: var(--muted); font-size: 10px; display: block; margin-bottom: 2px; }
.feed strong { display: block; font-size: 13px; }
@keyframes slideIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }

/* detalle */
.detail { bottom: 48px; left: 352px; width: 360px; max-height: calc(100vh - 120px); overflow-y: auto; }
.detail h2 { font-size: 18px; text-transform: none; letter-spacing: 0; color: var(--text); margin: 0 24px 2px 0; }
.close { position: absolute; top: 10px; right: 10px; background: transparent; border: 0; color: var(--muted); font-size: 16px; cursor: pointer; }
.chart-title { font-size: 11px; color: var(--muted); margin: 12px 0 4px; }
svg { width: 100%; display: block; }
.agent-out { margin-top: 12px; font-size: 13px; line-height: 1.5; background: rgba(52, 211, 153, 0.08); border: 1px solid rgba(52, 211, 153, 0.25); border-radius: 10px; padding: 10px 12px; }
.agent-out .footprint { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border); font-size: 11px; color: var(--muted); }
.agent-out .footprint b { color: var(--accent); }
.agent-out.fallback { background: rgba(245, 158, 11, 0.08); border-color: rgba(245, 158, 11, 0.3); }

/* año grande */
#bigYear {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%); z-index: 5; pointer-events: none;
  font-size: 96px; font-weight: 900; letter-spacing: -2px; color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 0 40px rgba(255, 106, 26, 0.6); opacity: 0; transition: opacity 0.4s; font-variant-numeric: tabular-nums;
}
#bigYear.show { opacity: 1; }

.credits { position: fixed; bottom: 10px; left: 16px; right: 16px; z-index: 10; text-align: center; }

.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 30;
  background: rgba(10, 16, 24, 0.95); border: 1px solid var(--accent); color: var(--text);
  padding: 10px 16px; border-radius: 12px; font-size: 14px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.globe-tip { font-family: inherit; background: rgba(5, 8, 13, 0.92); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; font-size: 12px; line-height: 1.5; }
.globe-tip b { font-size: 14px; }

@media (max-width: 1100px) {
  .filters { top: auto; bottom: 40px; }
  .side { width: 280px; }
  .detail { left: 16px; right: 16px; width: auto; bottom: 40px; }
  .filters.collapsed { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .feed li { animation: none; }
}

/* ---------- móvil (para quien escanea el QR en la charla) ---------- */
@media (max-width: 700px) {
  .panel { padding: 10px 12px; border-radius: 12px; }
  .brand { top: 8px; left: 8px; right: 8px; width: auto; }
  .brand .subtitle, .logo { display: none; }
  h1 { font-size: 17px; }
  .live-row { margin-top: 6px; }
  .side { top: 92px; left: 8px; right: 8px; width: auto; max-height: none; overflow: visible; }
  .side .tabs, .side .ranking, .side h2, .side .feed { display: none; }
  .kpis { grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .kpi { padding: 6px; }
  .kpi-label { font-size: 9px; line-height: 1.2; }
  .kpi-value { font-size: 15px; }
  .kpi-foot { font-size: 8px; }
  .filters, .filters.collapsed { display: block; top: auto; bottom: 8px; left: 8px; right: 8px; width: auto; }
  .filters h2 { margin: 8px 0 4px; font-size: 10px; }
  .filters h2:nth-of-type(3), .toggles { display: none; }
  .row { margin-top: 4px; }
  .detail { left: 8px; right: 8px; bottom: 8px; width: auto; max-height: 58vh; z-index: 20; }
  .credits { display: none; }
  #bigYear { font-size: 56px; bottom: auto; top: 190px; }
}
