/* ObservaIQ · el local como mercado.
   Neutros fríos, azul de marca (el del logo) para la interfaz y para "intensidad",
   ciruela / naranja / verde agua para las áreas (paleta validada para daltonismo),
   estados reservados (verde, ámbar, rojo) siempre con ícono y texto. */

@font-face {
  font-family: "Mona Sans";
  src: url("fonts/mona-sans-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 900;
  font-display: swap;
}
@font-face {
  font-family: "Martian Mono";
  src: url("fonts/martian-mono-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 800;
  font-display: swap;
}

:root {
  color-scheme: light;
  --page: #f3f4f7;
  --surface: #ffffff;
  --raised: #f8f9fb;
  --ink: #0d1017;
  --ink-2: #4b5463;
  --muted: #687180;
  --line: #e5e8ed;
  --line-strong: #d2d7df;
  --brand: #0a4cf5;
  --brand-ink: #0036c2;
  --brand-soft: rgba(10, 76, 245, 0.09);
  --area-1: #b03aa8;
  --area-2: #eb6834;
  --area-3: #1baf7a;
  --demand: #aab2c0;
  --compare: #8d95a3;
  --good: #0ca30c;
  --good-ink: #0a7a0a;
  --good-soft: rgba(12, 163, 12, 0.08);
  --warn: #fab219;
  --warn-ink: #8a5800;
  --warn-soft: rgba(250, 178, 25, 0.14);
  --crit: #d03b3b;
  --crit-ink: #b42525;
  --crit-soft: rgba(208, 59, 59, 0.07);
  --heat-base: 10, 76, 245;
  --shadow: 0 1px 2px rgba(13, 16, 23, 0.04), 0 8px 24px -12px rgba(13, 16, 23, 0.10);
  --shadow-pop: 0 12px 40px -8px rgba(13, 16, 23, 0.22);
  --r: 14px;
  --r-sm: 9px;
  --font: "Mona Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Martian Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #090b0f;
    --surface: #11141b;
    --raised: #171b24;
    --ink: #eef1f6;
    --ink-2: #a9b1be;
    --muted: #858e9d;
    --line: #20252f;
    --line-strong: #2d3340;
    --brand: #4a90ff;
    --brand-ink: #7fb0ff;
    --brand-soft: rgba(74, 144, 255, 0.14);
    --area-1: #d65fb4;
    --area-2: #d95926;
    --area-3: #199e70;
    --demand: #4b5566;
    --compare: #7c8594;
    --good-ink: #3ecf5a;
    --good-soft: rgba(12, 163, 12, 0.14);
    --warn-ink: #fab219;
    --warn-soft: rgba(250, 178, 25, 0.12);
    --crit-ink: #ff7a7a;
    --crit-soft: rgba(208, 59, 59, 0.14);
    --heat-base: 74, 144, 255;
    --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 10px 30px -14px rgba(0, 0, 0, 0.7);
    --shadow-pop: 0 16px 48px -8px rgba(0, 0, 0, 0.7);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #090b0f;
  --surface: #11141b;
  --raised: #171b24;
  --ink: #eef1f6;
  --ink-2: #a9b1be;
  --muted: #858e9d;
  --line: #20252f;
  --line-strong: #2d3340;
  --brand: #4a90ff;
  --brand-ink: #7fb0ff;
  --brand-soft: rgba(74, 144, 255, 0.14);
  --area-1: #d65fb4;
  --area-2: #d95926;
  --area-3: #199e70;
  --demand: #4b5566;
  --compare: #7c8594;
  --good-ink: #3ecf5a;
  --good-soft: rgba(12, 163, 12, 0.14);
  --warn-ink: #fab219;
  --warn-soft: rgba(250, 178, 25, 0.12);
  --crit-ink: #ff7a7a;
  --crit-soft: rgba(208, 59, 59, 0.14);
  --heat-base: 74, 144, 255;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 10px 30px -14px rgba(0, 0, 0, 0.7);
  --shadow-pop: 0 16px 48px -8px rgba(0, 0, 0, 0.7);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--page); color: var(--ink);
  font: 400 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--brand); color: #fff; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
button, select, input { font: inherit; color: inherit; }
h2 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon-xs { width: 13px !important; height: 13px !important; stroke-width: 2.4; }
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }

/* ---- barra superior ---- */
.bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 28px;
  padding: 0 28px; height: 60px;
  background: color-mix(in oklab, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 650; font-size: 17px; letter-spacing: -0.02em; }
/* Logo: una versión por tema (el texto del logo es azul marino y en oscuro pasa a blanco). */
.brand-logo { height: 28px; width: auto; display: block; }
.logo-on-dark { display: none; }
:root[data-theme="dark"] .logo-on-light { display: none; }
:root[data-theme="dark"] .logo-on-dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-on-light { display: none; }
  :root:not([data-theme="light"]) .logo-on-dark { display: block; }
}
.tabs { display: flex; gap: 4px; height: 100%; }
.tabs button {
  position: relative; border: 0; background: none; padding: 0 14px; cursor: pointer;
  color: var(--ink-2); font-weight: 500; height: 100%;
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); font-weight: 600; }
.tabs button[aria-selected="true"]::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--brand);
}
.bar-end { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.site-picker select {
  text-overflow: ellipsis; white-space: nowrap; overflow: hidden;
  height: 36px; padding: 0 34px 0 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237a8391' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E") no-repeat right 10px center / 16px;
  appearance: none; font-weight: 500; max-width: 260px; cursor: pointer;
}
.site-picker select:hover { border-color: var(--line-strong); }
.clock { font-size: 13px; font-variant-numeric: tabular-nums; color: var(--ink-2); display: inline-flex; align-items: center; gap: 8px; }
.clock::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
.clock.stale::before { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { color: var(--ink); border-color: var(--line-strong); }

main { max-width: 1440px; margin: 0 auto; padding: 24px 28px 64px; }
.view { display: flex; flex-direction: column; gap: 18px; }

/* ---- paneles ---- */
.panel {
  background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow);
  padding: 18px 20px 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0;
}
:root[data-theme="dark"] .panel, :root[data-theme="dark"] .kpi, :root[data-theme="dark"] .ticker { outline: 1px solid var(--line); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .panel, :root:not([data-theme="light"]) .kpi, :root:not([data-theme="light"]) .ticker { outline: 1px solid var(--line); }
}
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.panel-sub { margin: 3px 0 0; color: var(--ink-2); font-size: 12.5px; }
.panel-note { color: var(--muted); font-size: 12.5px; }

/* ---- vista en vivo: franja de resumen ---- */
/* Las celdas se separan con 1px del color de línea: la grilla se reacomoda sola en tablet y celular. */
.tape {
  display: flex; flex-wrap: wrap; gap: 1px;
  border-radius: var(--r); background: var(--line); box-shadow: var(--shadow); overflow: hidden;
}
.tape-item { flex: 1 1 110px; padding: 14px 22px; display: flex; flex-direction: column; gap: 2px; background: var(--surface); min-width: 0; }
.tape-label { color: var(--muted); font-size: 12px; }
.tape-value { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.tape-value small { font-size: 13px; color: var(--ink-2); margin-left: 4px; font-family: var(--font); }

/* franja de acción: lo primero que hay que hacer */
.actions { display: flex; flex-direction: column; gap: 10px; }
.action {
  display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 16px;
  padding: 16px 20px; border-radius: var(--r); background: var(--crit-soft);
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--crit) 35%, transparent);
}
.action > .icon { width: 26px; height: 26px; color: var(--crit-ink); }
.action.enter { animation: action-in 0.6s var(--ease) both; }
@keyframes action-in { from { opacity: 0; transform: translateY(-8px) scale(0.985); box-shadow: 0 0 0 6px var(--crit-soft); } }
@media (prefers-reduced-motion: reduce) { .action.enter { animation: none; } }
.action-title { font-size: 17px; font-weight: 650; letter-spacing: -0.015em; }
.action-detail { color: var(--ink-2); margin-top: 2px; }
.dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.calm {
  display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-radius: var(--r);
  background: var(--good-soft); color: var(--ink);
}
.calm .icon { color: var(--good-ink); width: 22px; height: 22px; }

/* tablero de áreas: cada área como una cotización */
.board { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.ticker {
  position: relative; background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow);
  padding: 18px 20px 14px; display: flex; flex-direction: column; gap: 10px; min-width: 0;
  transition: box-shadow 0.25s var(--ease), background 0.25s var(--ease);
}
.ticker[data-level="act"] { background: linear-gradient(180deg, var(--crit-soft), transparent 60%), var(--surface); box-shadow: var(--shadow), inset 0 0 0 1px color-mix(in oklab, var(--crit) 40%, transparent); }
.ticker[data-level="watch"] { background: linear-gradient(180deg, var(--warn-soft), transparent 55%), var(--surface); }
.ticker-head { display: flex; justify-content: space-between; align-items: center; gap: 8px 10px; flex-wrap: wrap; }
.ticker-name { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 16px; letter-spacing: -0.01em; }
.status {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600;
  padding: 4px 10px 4px 8px; border-radius: 999px; white-space: nowrap;
}
.status .icon { width: 15px; height: 15px; }
.status[data-level="ok"] { color: var(--good-ink); background: var(--good-soft); }
.status[data-level="watch"] { color: var(--warn-ink); background: var(--warn-soft); }
.status[data-level="act"] { color: #fff; background: var(--crit); }
.status[data-level="unknown"] { color: var(--ink-2); background: var(--raised); }
.ticker-quote { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.ticker-big { font-size: 52px; line-height: 1; font-weight: 600; letter-spacing: -0.035em; font-variant-numeric: tabular-nums; }
.ticker-unit { color: var(--ink-2); font-size: 14px; }
.chg { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; padding: 2px 7px; border-radius: 6px; }
.chg.up { color: var(--crit-ink); background: var(--crit-soft); }
.chg.down { color: var(--good-ink); background: var(--good-soft); }
.chg.flat { color: var(--ink-2); background: var(--raised); }
.ticker-wait { color: var(--ink-2); font-size: 13px; }
.ticker-wait strong { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.ticker-since { color: var(--muted); font-size: 12px; }
.ticker .chart { height: 96px; margin: 0 -4px; }
.ticker-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.stat-label { color: var(--muted); font-size: 11.5px; }
.stat-value { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }

.live-foot { display: grid; grid-template-columns: 1fr; gap: 16px; }

/* ---- análisis ---- */
.filters { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; }
.export { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; }
.export .btn { height: 34px; padding: 0 12px; font-size: 13px; }
.export-msg { font-size: 12.5px; color: var(--muted); }
.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 11px; background: var(--surface); box-shadow: var(--shadow); }
.seg button, .date-field input {
  height: 32px; padding: 0 14px; border: 0; border-radius: 8px; background: none; cursor: pointer; color: var(--ink-2); font-weight: 500;
}
.seg button:hover { color: var(--ink); background: var(--raised); }
.seg button[aria-pressed="true"] { background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; }
.date-field input { font-variant-numeric: tabular-nums; }
.date-field input[data-active="true"] { background: var(--brand-soft); color: var(--brand-ink); }
.seg-sm button { height: 28px; padding: 0 10px; font-size: 12.5px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 500; color: var(--ink-2);
}
.chip:hover { border-color: var(--line-strong); color: var(--ink); }
.chip[aria-checked="true"] { border-color: var(--brand); color: var(--ink); box-shadow: 0 0 0 3px var(--brand-soft); }

.kpis { display: grid; grid-template-columns: 1.35fr repeat(4, 1fr); gap: 14px; }
.kpi { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.kpi-label { color: var(--ink-2); font-size: 13px; }
.kpi-value { font-size: 32px; font-weight: 600; letter-spacing: -0.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-value small { font-family: var(--font); font-size: 14px; color: var(--ink-2); letter-spacing: 0; margin-left: 3px; }
.kpi-foot { font-size: 12.5px; color: var(--ink-2); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.kpi-lead .kpi-value { font-size: 44px; }
.bullet { position: relative; height: 8px; border-radius: 4px; background: var(--raised); margin: 4px 0 2px; overflow: visible; }
.bullet i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; background: var(--brand); }
.bullet b { position: absolute; top: -4px; bottom: -4px; width: 2px; border-radius: 1px; background: var(--ink); }
.delta-wrap { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.vs { color: var(--ink-2); font-size: 12.5px; }
.kpi-sub { color: var(--ink-2); flex-basis: 100%; }
.delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; font-size: 12.5px; font-variant-numeric: tabular-nums; padding: 1px 6px; border-radius: 5px; }
.delta.good { color: var(--good-ink); background: var(--good-soft); }
.delta.bad { color: var(--crit-ink); background: var(--crit-soft); }
.delta.flat { color: var(--ink-2); background: var(--raised); }

.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; } .span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; } .span-12 { grid-column: span 12; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.key-rect { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.key-line { width: 14px; height: 2px; border-radius: 1px; display: inline-block; }
.key-dash { width: 14px; height: 0; border-top: 2px dashed; display: inline-block; }

.chart { position: relative; height: 250px; }
.chart-sm { height: 190px; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart .tick { fill: var(--muted); font: 10px var(--mono); }
.chart .gridline { stroke: var(--line); stroke-width: 1; }
.chart .baseline { stroke: var(--line-strong); stroke-width: 1; }
.chart .crosshair { stroke: var(--muted); stroke-width: 1; }
.chart .ref-label { fill: var(--ink-2); font: 500 11px var(--font); }
.chart .peak-label { fill: var(--ink); font: 600 11.5px var(--mono); }
.chart .end-label { fill: var(--ink); font: 600 12px var(--mono); }
.chart .hit { fill: transparent; }
.chart .hit.clickable { cursor: pointer; }
.chart .band-hover { fill: var(--brand-soft); }
.chart .draw { stroke-dasharray: var(--len); stroke-dashoffset: var(--len); animation: draw 0.9s var(--ease) forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) { .chart .draw { animation: none; stroke-dasharray: none; stroke-dashoffset: 0; } }

details.data summary { cursor: pointer; color: var(--muted); font-size: 12.5px; width: max-content; list-style: none; }
details.data summary::-webkit-details-marker { display: none; }
details.data summary::before {
  content: ""; display: inline-block; width: 5px; height: 5px; margin: 0 8px 2px 2px;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg);
  transition: transform 0.2s var(--ease);
}
details.data[open] summary::before { transform: rotate(45deg); }
details.data summary:hover { color: var(--ink); }
details.data > div { overflow: auto; max-height: 280px; margin-top: 8px; }
table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
th, td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--muted); font-weight: 500; position: sticky; top: 0; background: var(--surface); }
td { font-family: var(--mono); }
td:first-child { font-family: var(--font); }

/* por área: ranking con barra de participación */
.area-rank { display: flex; flex-direction: column; gap: 4px; }
.rank-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.rank-row:last-child { border-bottom: 0; }
.rank-name { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.rank-share { font-weight: 600; font-variant-numeric: tabular-nums; }
.rank-bar { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--raised); overflow: hidden; }
.rank-bar i { display: block; height: 100%; border-radius: 3px; }
.rank-meta { grid-column: 1 / -1; display: flex; gap: 14px; flex-wrap: wrap; color: var(--ink-2); font-size: 12.5px; }
.rank-meta b { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }

/* mapa de calor del salón */
.heat { position: relative; border-radius: var(--r-sm); overflow: hidden; aspect-ratio: 16 / 9; background: var(--raised); max-width: 100%; }
.heat img, .heat canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.heat-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--ink-2); text-align: center; padding: 20px; }
.heat-zones { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.heat-labels { position: absolute; inset: 0; pointer-events: none; }
.heat-tag {
  position: absolute; transform: translateY(6px); display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 600; color: var(--ink); white-space: nowrap;
  background: color-mix(in oklab, var(--surface) 88%, transparent); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
}
.heat-tag i { width: 8px; height: 8px; border-radius: 2px; }
.heat-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px 16px; flex-wrap: wrap; }
.heat-note { margin: 0; color: var(--muted); font-size: 12px; }
.heat-scale { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.heat-scale i { flex: 0 0 140px; height: 8px; border-radius: 4px; background: linear-gradient(90deg, rgba(var(--heat-base), 0.04), rgba(var(--heat-base), 0.85)); outline: 1px solid var(--line); }

/* acumulados: cabecera tipo cartera vs índice */
.cum-head, .month-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.big-figure { font-size: 36px; font-weight: 600; letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.big-note { color: var(--ink-2); font-size: 13px; }

/* patrón semanal */
.matrix { overflow-x: auto; }
.matrix table { border-collapse: separate; border-spacing: 3px; width: 100%; min-width: 560px; }
.matrix th { position: static; background: none; border: 0; padding: 2px 4px; font: 500 11px var(--mono); color: var(--muted); text-align: center; }
.matrix th.row { text-align: left; font: 500 12px var(--font); color: var(--ink-2); padding-right: 8px; }
.matrix td { border: 0; padding: 0; height: 30px; border-radius: 5px; text-align: center; font: 500 11px var(--mono); color: var(--ink); cursor: default; }
.matrix td.hi { color: #fff; }
.matrix td.today-row { box-shadow: inset 0 0 0 1.5px var(--ink); }
.matrix td:hover { outline: 2px solid var(--ink); outline-offset: -1px; }

.weekdays { display: flex; flex-direction: column; gap: 6px; }
.wd { display: grid; grid-template-columns: 34px 1fr 64px 58px; align-items: center; gap: 10px; font-size: 13px; padding: 4px 0; }
.wd-name { color: var(--ink-2); font-weight: 500; }
.wd.today .wd-name { color: var(--ink); font-weight: 700; }
.wd-bar { height: 10px; border-radius: 4px; background: var(--raised); overflow: hidden; }
.wd-bar i { display: block; height: 100%; border-radius: 4px; background: color-mix(in oklab, var(--brand) 55%, var(--surface)); }
.wd.today .wd-bar i { background: var(--brand); }
.wd-num { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.wd-flow { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: 12px; padding: 1px 6px; border-radius: 5px; }

/* avisos */
.alerts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.alerts-cols { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 0 24px; }
.alert { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); align-items: start; }
.alert-icon { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; }
.alert-icon .icon { width: 16px; height: 16px; }
.alert[data-level="critical"] .alert-icon { background: var(--crit-soft); color: var(--crit-ink); }
.alert[data-level="warning"] .alert-icon { background: var(--warn-soft); color: var(--warn-ink); }
.alert-title { font-weight: 600; }
.alert-detail { color: var(--ink-2); font-size: 12.5px; margin-top: 1px; }
.alert-time { font-family: var(--mono); color: var(--muted); font-size: 12px; }
.alerts-empty { display: flex; gap: 10px; align-items: center; color: var(--ink-2); padding: 10px 0; }
.alerts-empty .icon { color: var(--good-ink); }

/* cámaras */
.cameras { display: grid; grid-template-columns: repeat(var(--cam-cols, 3), minmax(0, 1fr)); gap: 12px; }
.camera { display: flex; flex-direction: column; gap: 8px; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: zoom-in; border-radius: var(--r-sm); min-width: 0; }
.camera:hover .camera-view { box-shadow: 0 0 0 2px var(--brand); }
.camera:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }
.camera-view { aspect-ratio: 16 / 9; width: 100%; border-radius: var(--r-sm); background: var(--raised); object-fit: cover; display: grid; place-items: center; color: var(--muted); font-size: 12px; text-align: center; padding: 8px; max-width: 100%; }
.camera-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; }
.cam-state { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; color: var(--ink-2); }
.cam-state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.cam-state.on::before { background: var(--good); }
.cam-state.off { color: var(--crit-ink); }
.cam-state.off::before { background: var(--crit); }

.tooltip {
  position: fixed; z-index: 30; pointer-events: none; min-width: 150px;
  background: var(--surface); border-radius: 10px; box-shadow: var(--shadow-pop); outline: 1px solid var(--line);
  padding: 9px 11px; font-size: 12.5px;
}
.tt-title { color: var(--muted); margin-bottom: 5px; font-size: 12px; }
.tt-row { display: grid; grid-template-columns: 14px auto 1fr; align-items: center; gap: 7px; }
.tt-row + .tt-row { margin-top: 3px; }
.tt-value { font-family: var(--mono); font-weight: 600; }
.tt-name { color: var(--ink-2); }

.empty { text-align: center; color: var(--ink-2); padding: 48px 16px; }
main.loading .grid, main.loading .kpis { opacity: 0.55; transition: opacity 0.15s; }

@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .kpi-lead { grid-column: span 3; }
  .span-4, .span-5, .span-6, .span-7, .span-8 { grid-column: span 12; }
  .live-foot { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .bar { padding: 0 16px; gap: 14px; height: auto; min-height: 56px; flex-wrap: wrap; padding-block: 8px; }
  .tabs { order: 3; width: 100%; height: 40px; }
  .clock { display: none; }
  .site-picker select { max-width: 150px; }
  main { padding: 16px 16px 48px; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi-lead { grid-column: span 2; }
  .tape-item { flex-basis: 40%; padding: 12px 16px; }
  .brand-logo { height: 22px; }
  .bar-end { gap: 8px; }
  .heat-tag { font-size: 10px; padding: 2px 6px; gap: 4px; }
  .ticker-big { font-size: 40px; }
}

/* ---- sectores (zonas de permanencia) ---- */
.sectors { display: flex; flex-direction: column; }
.sector {
  display: grid; grid-template-columns: minmax(130px, 1.1fr) minmax(160px, 1.6fr) repeat(3, minmax(90px, 0.8fr)) auto;
  gap: 16px; align-items: center; padding: 11px 2px; border-bottom: 1px solid var(--line);
}
.sector:last-child { border-bottom: 0; }
.sector-name { font-weight: 600; }
.sector-now { display: flex; flex-direction: column; gap: 5px; }
.sector-now-text { font-size: 12.5px; color: var(--ink-2); }
.sector-now-text b { color: var(--ink); font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cap-bar { height: 6px; border-radius: 3px; background: var(--raised); overflow: hidden; }
.cap-bar i { display: block; height: 100%; border-radius: 3px; background: color-mix(in oklab, var(--brand) 55%, var(--surface)); }
.sector[data-level="full"] .cap-bar i { background: var(--warn); }
.sector .stat-value { font-size: 15px; }
.status[data-level="full"] { color: var(--warn-ink); background: var(--warn-soft); }
@media (max-width: 900px) {
  .sector { grid-template-columns: 1fr 1fr; gap: 8px 16px; }
  .sector-now { grid-column: 1 / -1; }
}

.zones-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 1180px) { .zones-grid { grid-template-columns: 1fr; } }
.mini-title { margin: 0 0 8px; font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
.rank-table table td, .rank-table table th { white-space: nowrap; }
.rank-table td.bar-cell { width: 34%; }
.inline-bar { display: flex; align-items: center; gap: 8px; }
.inline-bar i { display: block; height: 6px; border-radius: 3px; background: var(--brand); }
.inline-bar span { font-variant-numeric: tabular-nums; }

/* ---- configuración ---- */
.config { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, 1fr); gap: 16px; align-items: start; }
.config-main, .config-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.config-side { position: sticky; top: 76px; }
@media (max-width: 1100px) { .config { grid-template-columns: 1fr; } .config-side { position: static; } }
.form-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.fld { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--ink-2); min-width: 0; }
.fld-grow { flex: 1 1 220px; }
.fld-sm { flex: 0 0 150px; }
.fld input, .fld select {
  height: 36px; padding: 0 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); font-size: 14px; min-width: 0; width: 100%;
}
.fld select { appearance: none; padding-right: 30px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237a8391' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E") no-repeat right 9px center / 15px; }
.fld input:hover, .fld select:hover { border-color: var(--line-strong); }
.fld input:focus-visible, .fld select:focus-visible { outline: 2px solid var(--brand); outline-offset: 0; border-color: transparent; }
.fld input[aria-invalid="true"] { border-color: var(--crit); }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink); cursor: pointer; height: 36px; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); }
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 600; font-size: 13.5px;
}
.btn:hover { border-color: var(--line-strong); background: var(--raised); }
.btn .icon { width: 16px; height: 16px; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-quiet { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-quiet:hover { background: var(--raised); border-color: var(--line); color: var(--ink); }
.btn-primary:hover { background: var(--brand-ink); border-color: var(--brand-ink); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--crit-ink); }
.btn:disabled { opacity: 0.5; cursor: default; }
.template-confirm { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 10px; background: var(--warn-soft); }
.template-confirm p { margin: 0; flex: 1 1 260px; font-size: 13.5px; }

.area-list { display: flex; flex-direction: column; gap: 10px; }
.area-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 12px; background: var(--surface); }
.area-card.drawing { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.area-top { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.area-top .fld-grow { flex: 1 1 180px; }
.area-top .fld-kind { flex: 0 1 210px; }
.area-top .fld-cam { flex: 0 1 170px; }
.area-params { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.area-params .fld { flex: 0 1 150px; }
.area-foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.zone-state { font-size: 12.5px; color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; }
.zone-state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }
.zone-state.ok::before { background: var(--good); }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.empty-areas { padding: 18px; text-align: center; color: var(--ink-2); border: 1px dashed var(--line-strong); border-radius: 12px; }

.draw { position: relative; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: var(--raised); max-width: 100%; }
.draw img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.draw svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.draw svg.editing { cursor: crosshair; }
.draw-empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 16px; color: var(--ink-2); font-size: 13px; }
.draw-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.history { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.history li { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--line); color: var(--ink-2); }
.history li:last-child { border-bottom: 0; }
.history b { color: var(--ink); font-weight: 600; }

.savebar {
  position: sticky; bottom: 12px; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 12px 14px; border-radius: var(--r); background: color-mix(in oklab, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px); box-shadow: var(--shadow-pop);
}
.save-status { margin-right: auto; font-size: 13px; color: var(--ink-2); }
.save-status.dirty { color: var(--warn-ink); font-weight: 600; }
.save-status.error { color: var(--crit-ink); font-weight: 600; }
.save-status.ok { color: var(--good-ink); font-weight: 600; }

/* ---- pie ---- */
.site-foot { max-width: 1440px; margin: 0 auto; padding: 0 28px 28px; color: var(--muted); font-size: 12.5px; text-align: center; }
.site-foot strong { color: var(--ink-2); font-weight: 600; }

/* ---- alarma de la tablet y respuesta del encargado ---- */
.alarm-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 10px 16px;
  border-radius: var(--r); background: var(--surface); box-shadow: var(--shadow); font-size: 13.5px;
}
.alarm-note { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-2); flex: 1 1 260px; }
.alarm-note .icon { width: 16px; height: 16px; color: var(--warn-ink); }
.alarm-on { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; color: var(--good-ink); }
.alarm-on::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
.action-buttons { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.action-buttons .btn { height: 40px; padding: 0 18px; font-size: 14px; }
.action-ack { display: inline-flex; align-items: center; gap: 6px; color: var(--good-ink); font-weight: 600; font-size: 13.5px; }
.action-ack .icon { width: 16px; height: 16px; color: var(--good-ink); }
.action-note { color: var(--ink-2); font-size: 13.5px; }
.action.acked { background: var(--warn-soft); box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--warn) 45%, transparent); }
.action.acked > .icon { color: var(--warn-ink); }
.action.paused { background: var(--raised); box-shadow: inset 0 0 0 1px var(--line-strong); }
.action.paused > .icon { color: var(--ink-2); }
@media (prefers-reduced-motion: no-preference) {
  .action.ringing { animation: ringing 1.6s ease-in-out infinite; }
  @keyframes ringing { 50% { box-shadow: inset 0 0 0 2px var(--crit), 0 0 0 6px var(--crit-soft); } }
}

/* ---- encargados ---- */
.staff-list { display: flex; flex-direction: column; gap: 10px; }
.device-card .fld-kind { flex: 0 1 320px; }
.device-card .area-params .fld-grow { flex: 1 1 240px; }
.fld-xs { flex: 0 0 90px; }
.cam-list { display: flex; flex-direction: column; gap: 10px; }
.cam-row { border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 10px; background: var(--page); }
.cam-preview { display: flex; flex-direction: column; gap: 6px; }
.cam-preview img { width: 100%; max-width: 480px; border-radius: 8px; border: 1px solid var(--line); }
.device-save { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; }
.device-save .save-status { margin-right: auto; }
.staff-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.staff-card.paused { opacity: 0.7; }
.area-top .fld-phone { flex: 0 1 220px; }
.staff-sites { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; font-size: 13px; }
.fld-label { color: var(--ink-2); font-size: 12.5px; }
.site-check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.site-check input { width: 16px; height: 16px; accent-color: var(--brand); }
.site-check.current { font-weight: 600; }
.muted-tag { font-size: 11.5px; font-weight: 500; color: var(--muted); }
.tg-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.tg-link { flex: 1 1 260px; height: 36px; padding: 0 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--raised); color: var(--ink); font-family: var(--mono); font-size: 12.5px; min-width: 0; }
.admin-login .form-row { max-width: 520px; align-items: flex-end; }

/* sesión en la nube */
.user-chip { font-size: 12.5px; color: var(--ink-2); white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.login-screen { position: fixed; inset: 0; background: var(--page); display: grid; place-items: center; padding: 16px; z-index: 50; }
.login-card { width: min(420px, 100%); display: flex; flex-direction: column; gap: 14px; }
.login-card h2 { margin: 0; }
/* administración */
.adm-list { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.adm-item { text-align: left; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--surface); color: var(--ink); cursor: pointer; display: flex; flex-direction: column; gap: 2px; font: inherit; }
.adm-item span { font-size: 12.5px; color: var(--ink-2); }
.adm-item.selected { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.adm-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.adm-row > div:first-child { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.adm-key { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; flex: 1 1 100%; }
.adm-key .tg-link { flex: 1 1 260px; font-family: var(--mono, monospace); font-size: 12px; }
.adm-key .edge-key { flex-basis: 100%; resize: none; word-break: break-all; white-space: pre-wrap; }
#view-admin .config { grid-template-columns: minmax(0, 880px); }

/* cámara en grande */
.cam-zoom { position: fixed; inset: 0; z-index: 40; background: color-mix(in srgb, var(--page) 94%, transparent); backdrop-filter: blur(6px);
  display: flex; flex-direction: column; padding: calc(12px + env(safe-area-inset-top, 0px)) 16px calc(16px + env(safe-area-inset-bottom, 0px)); gap: 12px; }
.cam-zoom-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.cam-zoom-name { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-size: 17px; }
.cam-zoom-count { color: var(--ink-2); font-size: 13px; font-variant-numeric: tabular-nums; }
.cam-zoom-body { flex: 1; min-height: 0; display: grid; place-items: center; }
.cam-zoom-body img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: var(--r-sm); box-shadow: var(--shadow); background: var(--raised); }
.cam-zoom-empty { color: var(--muted); padding: 40px; text-align: center; }
body.zoom-open { overflow: hidden; }
