/* ==========================================================================
   Pulso — tablero en vivo
   Tokens primero: todo color pasa por una variable. Oscuro es el predeterminado.
   ========================================================================== */

:root {
  --font-ui: "Onest", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;

  /* Curvas: ease-out fuerte para entradas, nunca ease-in en UI */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --dur-fast: 140ms;
  --dur: 220ms;

  --radius: 14px;
  --radius-sm: 8px;
  --gap: 12px;

  /* Superficies — oscuro cálido, no azul pizarra */
  --page: #0b0b0a;
  --page-glow: rgba(57, 135, 229, 0.07);
  --panel: #151514;
  --panel-2: #1d1d1b;
  --panel-hi: rgba(255, 255, 255, 0.035);
  --hover: rgba(255, 255, 255, 0.045);
  --press: rgba(255, 255, 255, 0.07);
  --line: rgba(255, 255, 255, 0.075);
  --line-strong: rgba(255, 255, 255, 0.14);
  --topbar: rgba(11, 11, 10, 0.78);

  /* Tinta */
  --ink: #f4f3ef;
  --ink-2: #c3c2b7;
  --ink-3: #8f8d86;

  /* Gráficos */
  --grid: #242422;
  --axis: #383835;
  --s1: #3987e5;
  --s2: #d95926;
  --s3: #199e70;
  --s-muted: #5c5b56;
  --accent: #3987e5;
  --focus: #6da7ec;

  /* Estado — reservados, siempre con ícono + texto */
  --good: #0ca30c;
  --warn: #fab219;
  --serious: #ec835a;
  --crit: #d03b3b;
  --delta-up: #3fbf5a;
  --delta-down: #ef6b6b;

  /* Rampa secuencial (mapa de calor), del fondo hacia lo intenso */
  --q0: #1b1d21;
  --q1: #16304f;
  --q2: #184f95;
  --q3: #256abf;
  --q4: #3987e5;
  --q5: #6da7ec;
  --q6: #b7d3f6;

  --shadow-pop: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 18px 50px -12px rgba(0, 0, 0, 0.7);
  color-scheme: dark;
}

:root[data-theme="light"] {
  --page: #f3f2ee;
  --page-glow: rgba(42, 120, 214, 0.06);
  --panel: #ffffff;
  --panel-2: #f7f6f3;
  --panel-hi: rgba(255, 255, 255, 1);
  --hover: rgba(11, 11, 11, 0.04);
  --press: rgba(11, 11, 11, 0.07);
  --line: rgba(11, 11, 11, 0.08);
  --line-strong: rgba(11, 11, 11, 0.16);
  --topbar: rgba(243, 242, 238, 0.82);

  --ink: #0b0b0b;
  --ink-2: #4a4945;
  --ink-3: #6b6a64;

  --grid: #ecebe6;
  --axis: #c3c2b7;
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  --s-muted: #b4b2aa;
  --accent: #2a78d6;
  --focus: #2a78d6;

  --delta-up: #006300;
  --delta-down: #b42323;

  --q0: #f1f0ec;
  --q1: #cde2fb;
  --q2: #9ec5f4;
  --q3: #6da7ec;
  --q4: #3987e5;
  --q5: #256abf;
  --q6: #184f95;

  --shadow-pop: 0 18px 50px -14px rgba(20, 20, 10, 0.22), 0 0 0 1px rgba(11, 11, 11, 0.06);
  color-scheme: light;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 15% -10%, var(--page-glow), transparent 60%),
    var(--page);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  transition: background-color var(--dur) var(--ease-out), color var(--dur) var(--ease-out);
}
/* Grano sutil: textura, no decoración */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
:root[data-theme="light"] body::before { opacity: 0.025; }

button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { display: block; }
kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 5px;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  color: var(--ink-2);
}
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: 12px; top: -40px; z-index: 100;
  background: var(--accent); color: #fff; padding: 8px 12px; border-radius: 8px;
  text-decoration: none; transition: top var(--dur) var(--ease-out);
}
.skip:focus { top: 12px; }

/* ---------- Barra superior ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  padding: 14px 20px 12px;
  background: var(--topbar);
  backdrop-filter: saturate(160%) blur(16px);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  border-bottom: 1px solid var(--line);
}
.topbar__row { display: flex; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand__text { min-width: 0; }
.brand__mark {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  border-radius: 10px;
  background: linear-gradient(160deg, var(--accent), color-mix(in oklab, var(--accent) 55%, #000));
  box-shadow: 0 0 0 1px rgba(255,255,255,.08) inset, 0 6px 18px -6px color-mix(in oklab, var(--accent) 70%, transparent);
}
.brand__mark svg { width: 20px; height: 20px; fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.brand__title { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand__sub { margin: 0; font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.clock { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.status {
  display: inline-flex; align-items: center; gap: 8px;
  margin-left: auto;
  padding: 5px 11px 5px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  font-size: 12px; color: var(--ink-2);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.status__dot { position: relative; width: 8px; height: 8px; border-radius: 50%; background: var(--good); }
.status__dot::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%;
  border: 2px solid var(--good); opacity: 0;
}
.status[data-state="live"] .status__dot::after { animation: ping 2s var(--ease-out) infinite; }
.status[data-state="paused"] .status__dot { background: var(--warn); }
.status[data-state="manual"] .status__dot { background: var(--ink-3); }
.status[data-state="flash"] .status__dot::after { animation: ping 900ms var(--ease-out) 1; }
@keyframes ping { 0% { transform: scale(.6); opacity: .7; } 100% { transform: scale(1.8); opacity: 0; } }

.topbar__actions { display: flex; gap: 4px; }
.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center;
  border: 0; border-radius: 10px; background: transparent; color: var(--ink-2);
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
@media (hover: hover) { .icon-btn:hover { background: var(--hover); color: var(--ink); } }
.icon-btn:active { transform: scale(0.94); background: var(--press); }
#btn-pause .i-play, #btn-pause[aria-pressed="true"] .i-pause { display: none; }
#btn-pause[aria-pressed="true"] .i-play { display: block; }
#btn-pause[aria-pressed="true"] { color: var(--warn); }
.i-sun { display: none; }
:root[data-theme="light"] .i-sun { display: block; }
:root[data-theme="light"] .i-moon { display: none; }

.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; margin-top: 12px; }
.field { display: inline-flex; align-items: center; gap: 0; position: relative; }
.field__label {
  height: 34px; display: inline-flex; align-items: center;
  padding: 0 10px; font-size: 12px; color: var(--ink-3);
  border: 1px solid var(--line); border-right: 0; border-radius: 9px 0 0 9px;
  background: var(--panel-2);
}
.field select {
  height: 34px; padding: 0 30px 0 10px;
  border: 1px solid var(--line); border-radius: 0 9px 9px 0;
  background: var(--panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none' stroke='%238f8d86' stroke-width='1.6' stroke-linecap='round'%3E%3Cpath d='M1 1l4 4 4-4'/%3E%3C/svg%3E") no-repeat right 11px center;
  appearance: none; -webkit-appearance: none;
  font-weight: 500; font-size: 13px;
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out);
}
.field--inline select { border-radius: 9px; }
@media (hover: hover) { .field select:hover { border-color: var(--line-strong); } }
.field select option { background: var(--panel); color: var(--ink); }

.seg {
  display: inline-flex; padding: 3px; gap: 2px;
  border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line);
  position: relative;
}
.seg button {
  position: relative; z-index: 1;
  height: 28px; padding: 0 12px; border: 0; border-radius: 7px;
  background: transparent; color: var(--ink-3); font-size: 13px; font-weight: 500;
  transition: color var(--dur-fast) var(--ease-out);
}
@media (hover: hover) { .seg button:hover { color: var(--ink); } }
.seg button[aria-checked="true"] { color: var(--ink); }
.seg__thumb {
  position: absolute; z-index: 0; top: 3px; bottom: 3px; left: 0;
  border-radius: 7px; background: var(--panel);
  box-shadow: 0 1px 2px rgba(0,0,0,.25), 0 0 0 1px var(--line-strong);
  transition: transform 260ms var(--ease-out), width 260ms var(--ease-out);
}

.refresh { display: inline-flex; gap: 6px; margin-left: auto; }
.btn {
  height: 34px; display: inline-flex; align-items: center; gap: 7px;
  padding: 0 12px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--panel);
  font-size: 13px; font-weight: 500; color: var(--ink);
  transition: background-color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
@media (hover: hover) { .btn:hover { background: var(--panel-2); border-color: var(--line-strong); } }
.btn:active { transform: scale(0.97); }
.btn.is-spinning svg { animation: spin 600ms var(--ease-out); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Grilla ---------- */
.grid {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--gap);
  padding: 16px 20px 8px;
  max-width: 1720px;
  margin: 0 auto;
  outline: none;
}
.span-2 { grid-column: span 2; }
.span-4 { grid-column: span 4; }
.span-8 { grid-column: span 8; }

/* ---------- Panel ---------- */
.panel {
  position: relative;
  display: flex; flex-direction: column;
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 0 var(--panel-hi) inset;
  transition: border-color var(--dur) var(--ease-out), background-color var(--dur) var(--ease-out);
}
.panel.is-entering { animation: enter 520ms var(--ease-out) both; animation-delay: calc(var(--i, 0) * 45ms); }
@keyframes enter { from { opacity: 0; transform: translateY(8px) scale(0.985); } }

.panel__head {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 10px 0 14px;
  min-height: 38px;
}
.panel__title {
  margin: 0; font-size: 13px; font-weight: 600; color: var(--ink);
  letter-spacing: -0.005em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.panel__hint { color: var(--ink-3); font-weight: 400; }
.panel__tools { margin-left: auto; display: flex; align-items: center; gap: 2px; flex: none; }
.panel__menu { width: 28px; height: 28px; border-radius: 8px; opacity: .7; }
.panel:hover .panel__menu, .panel:focus-within .panel__menu, .panel__menu[aria-expanded="true"] { opacity: 1; }
.panel__menu svg { width: 16px; height: 16px; }
.panel__body { position: relative; flex: 1; min-height: 0; padding: 8px 14px 12px; }
.panel__body > [data-heat] { height: 100%; }
.panel__foot {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 0 14px 12px;
  font-size: 11px; color: var(--ink-3);
}

/* Origen de los datos: el corazón de "unificar" */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 20px; padding: 0 7px;
  border-radius: 6px; border: 1px solid var(--line);
  background: var(--panel-2);
  font-size: 11px; color: var(--ink-3);
  white-space: nowrap;
}
.chip svg { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chip--stale { color: var(--ink); border-color: color-mix(in oklab, var(--warn) 45%, transparent); background: color-mix(in oklab, var(--warn) 10%, var(--panel)); }
.chip--stale svg { stroke: var(--warn); }

.menu {
  position: absolute; right: 8px; top: 40px; z-index: 15;
  min-width: 170px; padding: 5px;
  border-radius: 11px; background: var(--panel-2);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-pop);
  transform-origin: top right;
  animation: pop 160ms var(--ease-out);
}
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(-2px); } }
.menu button {
  display: flex; align-items: center; gap: 9px; width: 100%;
  height: 32px; padding: 0 10px; border: 0; border-radius: 7px;
  background: transparent; font-size: 13px; text-align: left; color: var(--ink);
}
.menu button svg { width: 15px; height: 15px; fill: none; stroke: var(--ink-3); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.menu button:hover, .menu button:focus-visible { background: var(--hover); outline: none; }
.menu kbd { margin-left: auto; }

/* Panel ampliado (Grafana "ver panel") */
.panel.is-expanded {
  position: fixed; inset: 24px; z-index: 40;
  box-shadow: var(--shadow-pop);
  animation: expand 260ms var(--ease-out);
}
@keyframes expand { from { opacity: .4; transform: scale(.97); } }
.scrim {
  position: fixed; inset: 0; z-index: 39;
  background: color-mix(in oklab, var(--page) 70%, transparent);
  backdrop-filter: blur(6px);
  animation: fade 200ms var(--ease-out);
}
@keyframes fade { from { opacity: 0; } }

/* ---------- Indicadores ---------- */
.stat { display: flex; flex-direction: column; height: 100%; }
.stat__value {
  font-size: 26px; font-weight: 600; letter-spacing: -0.025em;
  line-height: 1.1; margin-top: 2px;
  white-space: nowrap;
}
.stat__meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; font-size: 12px; color: var(--ink-3); }
.stat__spark { margin-top: auto; padding-top: 10px; height: 44px; }
.panel--hero .stat__value { font-size: clamp(40px, 4.2vw, 58px); letter-spacing: -0.035em; margin-top: 4px; }
.panel--hero .stat__spark { height: 64px; }
.panel--hero .panel__body { display: flex; flex-direction: column; }
.hero__row { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.hero__goal { margin-top: 12px; }
.goal__track { position: relative; height: 6px; border-radius: 99px; background: color-mix(in oklab, var(--s1) 18%, var(--panel-2)); overflow: hidden; }
.goal__fill { position: absolute; inset: 0 auto 0 0; border-radius: 99px; background: var(--s1); transition: width 600ms var(--ease-out); }
.goal__mark { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink-2); border-radius: 2px; }
.goal__labels { display: flex; justify-content: space-between; margin-top: 6px; font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

.delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; font-variant-numeric: tabular-nums; }
.delta svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.delta--good { color: var(--delta-up); }
.delta--bad { color: var(--delta-down); }
.delta--flat { color: var(--ink-3); }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 500; color: var(--ink-2);
  white-space: nowrap;
}
.badge svg { width: 13px; height: 13px; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.badge--good svg { stroke: var(--good); }
.badge--warn svg { stroke: var(--warn); }
.badge--crit svg { stroke: var(--crit); }

.value-flash { animation: vflash 900ms var(--ease-out); }
@keyframes vflash { 0% { text-shadow: 0 0 0 transparent; } 25% { text-shadow: 0 0 18px color-mix(in oklab, var(--s1) 55%, transparent); } 100% { text-shadow: 0 0 0 transparent; } }

/* ---------- Gráficos ---------- */
.chart { position: relative; width: 100%; height: 100%; min-height: 160px; outline: none; touch-action: pan-y; }
.chart:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; border-radius: 8px; }
.chart svg { width: 100%; height: 100%; overflow: visible; }
.chart text { font-family: var(--font-mono); font-size: 10.5px; fill: var(--ink-3); font-variant-numeric: tabular-nums; }
.chart .t-end { font-family: var(--font-ui); font-size: 12px; font-weight: 600; fill: var(--ink); }
.chart .t-end-sub { font-family: var(--font-ui); font-size: 11px; fill: var(--ink-3); }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .base-line { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart .series { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .series--muted { stroke-width: 1.5; }
.chart .series--partial { stroke-dasharray: 2 5; opacity: .7; }
.chart .bar--partial { opacity: .5; }
.chart.has-hover .bar--partial.on { opacity: .75; }
.chart .threshold { stroke-width: 1; shape-rendering: crispEdges; }
.chart .threshold-label { font-family: var(--font-ui); font-size: 10.5px; }
.chart .now-line { stroke: var(--line-strong); stroke-width: 1; shape-rendering: crispEdges; }
.chart .annot-line { stroke: var(--ink-3); stroke-width: 1; opacity: .45; shape-rendering: crispEdges; }
.chart .annot-mark { fill: var(--ink-2); }
.chart .annot-mark.is-active { fill: var(--ink); }
.chart .cross { stroke: var(--ink-3); stroke-width: 1; shape-rendering: crispEdges; opacity: 0; transition: opacity var(--dur-fast) var(--ease-out); }
.chart .cross.on { opacity: .8; }
.chart .hdot { opacity: 0; transition: opacity var(--dur-fast) var(--ease-out); stroke: var(--panel); stroke-width: 2; }
.chart .hdot.on { opacity: 1; }
.chart .bar { transition: opacity var(--dur-fast) var(--ease-out); }
.chart.has-hover .bar { opacity: .45; }
.chart.has-hover .bar.on { opacity: 1; }
.chart .end-dot { stroke: var(--panel); stroke-width: 2; }
.chart .pulse { fill: none; stroke-width: 2; transform-box: fill-box; transform-origin: center; animation: pulse 1.6s var(--ease-out) 1; opacity: 0; }
@keyframes pulse { 0% { transform: scale(.5); opacity: .8; } 100% { transform: scale(3); opacity: 0; } }

.spark svg { width: 100%; height: 100%; overflow: visible; }
.spark .series { fill: none; stroke-linejoin: round; stroke-linecap: round; }
.spark .end-dot, .spark .hdot { stroke: var(--panel); stroke-width: 2; }
.spark .hdot { opacity: 0; transition: opacity var(--dur-fast) var(--ease-out); }
.spark .hdot.on { opacity: 1; }

.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--ink-2); margin-left: 4px; }
.legend__item { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.legend__key { width: 14px; height: 2px; border-radius: 2px; }
.legend__key--bar { width: 9px; height: 9px; border-radius: 3px; }

/* Barras por canal */
.bars { display: flex; flex-direction: column; justify-content: space-evenly; gap: 12px; height: 100%; padding-top: 4px; }
.bars__row { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: baseline; }
.bars__label { font-size: 12.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bars__value { font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.bars__value small { font-weight: 400; color: var(--ink-3); margin-left: 6px; }
.bars__track { grid-column: 1 / -1; height: 8px; border-radius: 4px; background: color-mix(in oklab, var(--s1) 12%, var(--panel-2)); overflow: hidden; }
.bars__fill { height: 100%; border-radius: 0 4px 4px 0; background: var(--s1); transition: width 600ms var(--ease-out); }

/* Fuentes */
.sources { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.source {
  display: grid; grid-template-columns: 32px 1fr auto; gap: 2px 10px; align-items: center;
  padding: 9px 0; border-top: 1px solid var(--line);
}
.source:first-child { border-top: 0; padding-top: 2px; }
.source__icon {
  grid-row: span 2; width: 32px; height: 32px; border-radius: 9px;
  display: grid; place-items: center;
  background: var(--panel-2); border: 1px solid var(--line);
}
.source__icon svg { width: 16px; height: 16px; fill: none; stroke: var(--ink-2); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.source__name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.source__desc { font-size: 11.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.source__state { grid-row: span 2; text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.source__ago { font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.source.is-syncing .source__icon { border-color: color-mix(in oklab, var(--s1) 60%, transparent); }
.source.is-syncing .source__icon svg { stroke: var(--s1); }
.sources__summary { display: flex; justify-content: space-between; gap: 8px; padding-top: 10px; margin-top: 4px; border-top: 1px solid var(--line); font-size: 12px; color: var(--ink-3); }
.sources__summary strong { color: var(--ink); font-weight: 600; }

/* Alertas */
.alerts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.alert {
  display: grid; grid-template-columns: 18px 1fr; gap: 2px 10px;
  padding: 9px 10px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--line);
}
.alert svg { width: 16px; height: 16px; margin-top: 1px; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.alert--crit svg { stroke: var(--crit); }
.alert--warn svg { stroke: var(--warn); }
.alert--info svg { stroke: var(--s1); }
.alert--good svg { stroke: var(--good); }
.alert__text { font-size: 12.5px; line-height: 1.4; }
.alert__meta { grid-column: 2; font-size: 11px; color: var(--ink-3); }
.alert.is-new { animation: slide-in 360ms var(--ease-out); }
@keyframes slide-in { from { opacity: 0; transform: translateY(-6px); } }
.count-pill {
  display: inline-grid; place-items: center; min-width: 20px; height: 18px; padding: 0 6px;
  border-radius: 99px; font-size: 11px; font-weight: 600;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

/* Tabla */
.table-wrap { overflow-x: auto; margin: 0 -14px; padding: 0 14px; }
.table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.table th {
  text-align: left; font-weight: 500; font-size: 11.5px; color: var(--ink-3);
  padding: 4px 10px 8px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table th.num { text-align: right; }
.table th:first-child, .table td:first-child { padding-left: 0; }
.table th:last-child, .table td:last-child { padding-right: 0; }
.table tbody tr { transition: background-color var(--dur-fast) var(--ease-out); }
@media (hover: hover) { .table tbody tr:hover { background: var(--hover); } }
.table .rank { color: var(--ink-3); font-family: var(--font-mono); font-size: 11px; width: 22px; }
.table .spark-cell { width: 110px; }
.table .spark-cell svg { width: 100px; height: 24px; }
.dialog .table td, .dialog .table th { padding-left: 10px; }

/* Mapa de calor */
.heat { display: grid; gap: 3px; height: 100%; grid-template-rows: repeat(7, minmax(26px, 1fr)) auto; }
.heat__row { display: grid; height: 100%; grid-template-columns: 34px repeat(var(--cols), minmax(0, 1fr)); gap: 3px; align-items: center; }
.heat__day { font-size: 11px; color: var(--ink-3); }
.heat__cell {
  height: 100%; min-height: 26px; border-radius: 4px; border: 0; padding: 0;
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.heat__cell:hover, .heat__cell:focus-visible { transform: scale(1.08); box-shadow: 0 0 0 2px var(--panel), 0 0 0 3px var(--ink-2); outline: none; position: relative; z-index: 1; }
.heat__hours { display: grid; grid-template-columns: 34px repeat(var(--cols), minmax(0, 1fr)); gap: 3px; margin-top: 4px; }
.heat__hours span { font-family: var(--font-mono); font-size: 10px; color: var(--ink-3); text-align: center; }
.heat__legend { display: flex; align-items: center; gap: 8px; margin-left: auto; font-size: 11px; color: var(--ink-3); }
.heat__ramp { display: flex; gap: 2px; }
.heat__ramp span { width: 14px; height: 8px; border-radius: 2px; }
.q0 { background: var(--q0); } .q1 { background: var(--q1); } .q2 { background: var(--q2); }
.q3 { background: var(--q3); } .q4 { background: var(--q4); } .q5 { background: var(--q5); } .q6 { background: var(--q6); }

/* Actividad en vivo */
.feed { list-style: none; margin: 0; padding: 0; position: relative; }
.feed__item {
  display: grid; grid-template-columns: 28px 1fr auto; gap: 1px 10px; align-items: center;
  padding: 8px 0; border-top: 1px solid var(--line);
}
.feed__item:first-child { border-top: 0; }
.feed__item.is-new { animation: feed-in 420ms var(--ease-out); }
@keyframes feed-in { from { opacity: 0; transform: translateY(-10px); } }
.feed__icon { grid-row: span 2; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--panel-2); border: 1px solid var(--line); }
.feed__icon svg { width: 14px; height: 14px; fill: none; stroke: var(--ink-2); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.feed__title { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed__sub { font-size: 11px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed__amount { grid-row: span 2; text-align: right; font-weight: 600; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.feed__amount small { display: block; font-weight: 400; font-size: 11px; color: var(--ink-3); font-family: var(--font-mono); }
.panel__body--scroll { overflow: hidden; mask-image: linear-gradient(to bottom, #000 80%, transparent); }

/* Tooltip compartido */
.tooltip {
  position: fixed; z-index: 60; pointer-events: none;
  min-width: 150px; max-width: 280px;
  padding: 9px 11px;
  border-radius: 10px;
  background: color-mix(in oklab, var(--panel-2) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-pop);
  font-size: 12px;
  transition: opacity 120ms var(--ease-out);
}
.tooltip__title { font-size: 11px; color: var(--ink-3); margin-bottom: 6px; font-family: var(--font-mono); }
.tooltip__row { display: flex; align-items: center; gap: 8px; padding: 1px 0; }
.tooltip__row .legend__key { flex: none; }
.tooltip__name { color: var(--ink-2); }
.tooltip__val { margin-left: auto; padding-left: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tooltip__note { margin-top: 7px; padding-top: 7px; border-top: 1px solid var(--line); color: var(--ink-2); display: flex; gap: 6px; }
.tooltip__note svg { width: 13px; height: 13px; flex: none; margin-top: 2px; fill: none; stroke: var(--ink-2); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Diálogos ---------- */
.dialog {
  width: min(760px, calc(100vw - 32px));
  max-height: min(80vh, 720px);
  padding: 0; border: 1px solid var(--line-strong); border-radius: 16px;
  background: var(--panel); color: var(--ink);
  box-shadow: var(--shadow-pop);
}
.dialog--narrow { width: min(520px, calc(100vw - 32px)); }
.dialog[open] { animation: dlg-in 240ms var(--ease-out); }
@keyframes dlg-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.dialog::backdrop { background: rgba(0, 0, 0, .45); backdrop-filter: blur(4px); }
.dialog__head { display: flex; align-items: center; gap: 8px; padding: 14px 12px 4px 20px; }
.dialog__head h2 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.dialog__head .icon-btn { margin-left: auto; }
.dialog__sub { margin: 0; padding: 0 20px; font-size: 12px; color: var(--ink-3); }
.dialog__body { padding: 12px 20px 20px; overflow: auto; max-height: calc(min(80vh, 720px) - 80px); }
.prose p { margin: 0 0 12px; color: var(--ink-2); line-height: 1.55; }
.prose h3 { font-size: 13px; margin: 18px 0 8px; }
.checks { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.checks li { padding-left: 18px; position: relative; color: var(--ink-2); line-height: 1.5; }
.checks li::before { content: ""; position: absolute; left: 2px; top: 8px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.checks strong { color: var(--ink); font-weight: 600; }
.keys { display: grid; gap: 6px; margin: 0; }
.keys div { display: flex; gap: 12px; align-items: center; }
.keys dt { min-width: 70px; }
.keys dd { margin: 0; color: var(--ink-2); }

/* ---------- Pie ---------- */
.foot {
  position: relative; z-index: 1;
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px;
  max-width: 1720px; margin: 0 auto; padding: 8px 20px 28px;
  font-size: 12px; color: var(--ink-3);
}
.foot p { margin: 0; }
.foot strong { color: var(--ink-2); font-weight: 600; }

/* ---------- Modo pantalla (kiosco) ---------- */
.tv-exit { display: none; }
body.tv .toolbar, body.tv .topbar__actions, body.tv .foot, body.tv .panel__menu { display: none; }
body.tv .topbar { padding: 16px 28px; }
body.tv .grid { padding: 18px 28px 28px; max-width: none; }
body.tv .brand__title { font-size: 20px; }
body.tv .brand__sub { font-size: 14px; }
body.tv .clock { font-size: 15px; color: var(--ink); }
body.tv .tv-exit {
  display: block; position: fixed; left: 50%; bottom: 20px; z-index: 30;
  transform: translate(-50%, 12px); opacity: 0;
  transition: opacity var(--dur) var(--ease-out), transform var(--dur) var(--ease-out);
}
body.tv.tv-show .tv-exit { opacity: 1; transform: translate(-50%, 0); }
body.tv.tv-idle { cursor: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .span-2 { grid-column: span 3; }
  .panel--hero.span-4 { grid-column: span 12; }
}
@media (max-width: 1024px) {
  .grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .span-2 { grid-column: span 3; }
  .span-4 { grid-column: span 3; }
  .span-8 { grid-column: span 6; }
  .panel--hero.span-4, #p-sources, #p-alerts, #p-feed { grid-column: span 6; }
  #p-count, #p-second { grid-column: span 3; }
  .refresh { margin-left: 0; }
}
@media (max-width: 680px) {
  /* En el celular la barra no queda fija: la pantalla es para los datos */
  .topbar { position: relative; padding: 12px 16px 10px; }
  .topbar__row { flex-wrap: wrap; gap: 8px 10px; }
  .brand { flex: 1 1 0; }
  .brand__mark { width: 30px; height: 30px; }
  .brand__title { font-size: 15px; }
  .status { order: 3; margin-left: 0; }
  .topbar__actions { flex: none; gap: 0; }
  .icon-btn { width: 34px; height: 40px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 12px 16px 8px; gap: 10px; }
  .span-2 { grid-column: span 1; }
  .span-4, .span-8, .panel--hero.span-4, #p-sources, #p-alerts, #p-feed, #p-count, #p-second { grid-column: span 2; }
  .stat__value { font-size: 21px; }
  .panel__head { flex-wrap: wrap; row-gap: 4px; }
  .panel__head .legend { order: 3; flex-basis: 100%; margin-left: 0; }
  .field { flex: 1 1 calc(50% - 5px); }
  .field select { flex: 1; min-width: 0; }
  .seg { width: 100%; }
  .seg button { flex: 1; padding: 0 6px; }
  .refresh { width: 100%; }
  .refresh .field { flex: 1; }
  .foot { padding: 8px 16px 24px; }
  .panel.is-expanded { inset: 8px; }
}

/* ---------- Movimiento reducido: estado final, sin coreografía ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
  .chart .pulse, .status__dot::after { display: none; }
}

@media (forced-colors: active) {
  .panel, .chip, .seg, .btn { border: 1px solid CanvasText; }
  .bars__fill, .goal__fill { background: Highlight; }
}
