/* Bot Tracker — panel y TV. Sobrio: neutros, una sola tinta de acento y color solo para el estado. */

:root {
  color-scheme: light;
  --fondo: #f6f6f4;
  --superficie: #ffffff;
  --superficie-2: #f3f3f0;
  --superficie-hover: #f0f0ec;
  --texto: #111110;
  --texto-2: #52514e;
  --texto-3: #8a8983;
  --linea: #ebeae5;
  --rejilla: #ebeae5;
  --borde: #e4e3dd;
  --borde-fuerte: #cfcec7;
  --sombra-alta: 0 16px 48px rgba(16, 16, 12, 0.16);
  --acento: #2a78d6;
  --barra-ok: #8195b0;
  --tooltip-fondo: #1a1a19;
  --tooltip-texto: #f0efec;

  --ok: #0ca30c;
  --aviso: #e0a00f;
  --serio: #ec835a;
  --critico: #d03b3b;
  --neutro: #a3a29b;
  --texto-critico: #b02a2a;

  --radio: 12px;
  --fuente: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --fondo: #111110; --superficie: #1a1a19; --superficie-2: #212120; --superficie-hover: #252524;
    --texto: #f0efec; --texto-2: #b9b8b0; --texto-3: #807f79;
    --linea: #2a2a28; --rejilla: #2a2a28; --borde: #2c2c2a; --borde-fuerte: #3d3d3a;
    --sombra-alta: 0 16px 48px rgba(0, 0, 0, 0.6);
    --acento: #4b91e8; --barra-ok: #5f7594;
    --tooltip-fondo: #f0efec; --tooltip-texto: #111110;
    --aviso: #fab219; --texto-critico: #f07070; --neutro: #6b6a65;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --fondo: #111110; --superficie: #1a1a19; --superficie-2: #212120; --superficie-hover: #252524;
  --texto: #f0efec; --texto-2: #b9b8b0; --texto-3: #807f79;
  --linea: #2a2a28; --rejilla: #2a2a28; --borde: #2c2c2a; --borde-fuerte: #3d3d3a;
  --sombra-alta: 0 16px 48px rgba(0, 0, 0, 0.6);
  --acento: #4b91e8; --barra-ok: #5f7594;
  --tooltip-fondo: #f0efec; --tooltip-texto: #111110;
  --aviso: #fab219; --texto-critico: #f07070; --neutro: #6b6a65;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--fondo);
  color: var(--texto);
  font: 15px/1.45 var(--fuente);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--acento); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--acento); outline-offset: 2px; border-radius: 6px; }
.oculto { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.ico { width: 16px; height: 16px; flex: none; display: inline-block; vertical-align: -3px; }
a.enlace { display: inline-flex; vertical-align: -2px; color: var(--texto-3); }
a.enlace:hover { color: var(--acento); }
a.enlace .ico { width: 14px; height: 14px; }

/* ---------- Barra superior ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px max(16px, calc((100vw - 1320px) / 2));
  background: color-mix(in srgb, var(--fondo) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--borde);
}
.marca { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; letter-spacing: -0.01em; min-width: 0; }
.marca span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logo {
  width: 28px; height: 28px; flex: none; border-radius: 8px; display: grid; place-items: center;
  background: var(--texto); color: var(--fondo);
}
.logo svg { width: 16px; height: 16px; stroke-width: 2.2; }
.acciones { display: flex; align-items: center; gap: 4px; }
.refresco { color: var(--texto-3); font-size: 13px; margin-right: 8px; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.refresco::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
.refresco.error::before { background: var(--critico); }

.boton {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--borde); background: var(--superficie); color: var(--texto);
  font-size: 14px; font-weight: 500; cursor: pointer; text-decoration: none !important; white-space: nowrap;
}
.boton:hover { border-color: var(--borde-fuerte); }
.boton.fantasma { background: transparent; border-color: transparent; color: var(--texto-2); }
.boton.fantasma:hover { background: var(--superficie-hover); color: var(--texto); }
.boton.primario { background: var(--texto); border-color: var(--texto); color: var(--fondo); }
.boton.primario:hover { opacity: 0.88; }
.boton.icono { width: 34px; padding: 0; justify-content: center; }
.boton svg { width: 17px; height: 17px; flex: none; }
.boton[disabled] { opacity: 0.4; cursor: default; }

/* ---------- Estructura ---------- */
.contenedor { max-width: 1320px; margin: 0 auto; padding: 28px 16px 64px; display: grid; gap: 32px; }
.bloque { min-width: 0; }
.bloque-cab { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 16px; margin-bottom: 12px; min-height: 34px; }
.bloque-cab h2 { font-size: 13px; font-weight: 600; color: var(--texto-2); }
.tarjeta { background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--radio); padding: 20px; }
.columnas { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 32px; align-items: start; }
@media (max-width: 1020px) { .columnas { grid-template-columns: minmax(0, 1fr); } }

.segmentado { display: inline-flex; padding: 2px; border-radius: 9px; background: var(--superficie-2); border: 1px solid var(--borde); }
.segmentado button {
  border: 0; background: transparent; padding: 4px 11px; border-radius: 7px;
  font-size: 13px; font-weight: 500; color: var(--texto-3); cursor: pointer;
}
.segmentado button:hover { color: var(--texto); }
.segmentado button[aria-pressed="true"] { background: var(--superficie); color: var(--texto); box-shadow: 0 0 0 1px var(--borde); }
.filtros { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filtros select, .filtros input {
  height: 32px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--borde);
  background: var(--superficie); font-size: 13.5px; max-width: 100%;
}
.filtros label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--texto-3); }

/* ---------- Alertas activas ---------- */
.alertas { display: grid; gap: 6px; }
.alerta {
  all: unset; box-sizing: border-box; cursor: pointer;
  display: grid; grid-template-columns: auto auto auto minmax(0, 1fr) auto; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 10px; font-size: 14px;
  background: var(--superficie); border: 1px solid var(--borde); border-left: 3px solid var(--c);
}
.alerta:hover { border-color: var(--borde-fuerte); border-left-color: var(--c); }
.alerta .ico { color: var(--c); }
.alerta.nivel-critico { --c: var(--critico); }
.alerta.nivel-aviso { --c: var(--aviso); }
.alerta.nivel-info { --c: var(--neutro); }
.alerta-nivel { font-size: 12px; color: var(--texto-3); }
.alerta-msg { color: var(--texto-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alerta time { font-size: 12.5px; color: var(--texto-3); white-space: nowrap; }
@media (max-width: 560px) {
  .alerta { grid-template-columns: auto minmax(0, 1fr) auto; }
  .alerta-nivel { display: none; }
  .alerta-msg { grid-column: 2 / -1; white-space: normal; }
}

/* ---------- Indicadores (KPI) ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.kpi {
  background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--radio);
  padding: 16px 16px 12px; display: grid; gap: 2px; min-height: 148px; align-content: start;
}
.kpi-cab { display: flex; align-items: center; gap: 8px; color: var(--texto-2); font-size: 13px; }
.kpi-icono { display: inline-flex; color: var(--texto-3); }
.kpi-titulo { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi-valor { font-size: 32px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; margin-top: 8px; }
.kpi-delta { font-size: 12.5px; color: var(--texto-3); display: flex; gap: 4px; align-items: center; white-space: nowrap; overflow: hidden; }
.kpi-delta b { color: var(--texto-2); font-weight: 600; }
.kpi-delta span { overflow: hidden; text-overflow: ellipsis; }
.ico-delta { width: 12px; height: 12px; flex: none; color: var(--texto-2); stroke-width: 2.4; }
.kpi-spark { position: relative; height: 30px; margin-top: 12px; }
.kpi-spark svg { width: 100%; height: 100%; display: block; overflow: visible; }
.spark-linea { fill: none; stroke: var(--texto-3); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.spark-area { fill: var(--texto-3); opacity: 0.07; }
.kpi-spark .punto {
  position: absolute; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%;
  background: var(--acento); box-shadow: 0 0 0 2px var(--superficie);
}

/* ---------- Estados ---------- */
.pastilla {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px 0 7px;
  border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap;
  border: 1px solid var(--borde); color: var(--texto-2);
}
.pastilla i { width: 7px; height: 7px; border-radius: 50%; background: var(--c); flex: none; }
.e-ok { --c: var(--ok); }
.e-aviso { --c: var(--aviso); }
.e-serio { --c: var(--serio); }
.e-critico { --c: var(--critico); }
.e-neutro { --c: var(--neutro); }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.resumen-estados { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- Tarjetas de bots ---------- */
.bots { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.bot {
  all: unset; box-sizing: border-box; cursor: pointer;
  display: grid; gap: 10px; align-content: start; padding: 16px;
  background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--radio);
  transition: border-color 0.15s ease;
}
.bot:hover { border-color: var(--borde-fuerte); }
.bot:focus-visible { outline: 2px solid var(--acento); outline-offset: 2px; }
.bot-cab { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.bot-tipo { font-size: 12px; color: var(--texto-3); display: inline-flex; align-items: center; gap: 5px; }
.bot-tipo .ico { width: 13px; height: 13px; }
.bot h3 { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bot-desc { font-size: 13px; color: var(--texto-3); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.9em; margin-top: 2px; }
.bot-num { display: grid; grid-template-columns: auto auto minmax(0, 1fr); gap: 8px 20px; padding: 10px 0; border-block: 1px solid var(--linea); }
.bot-num b { display: block; font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bot-num b.pequeno { font-size: 13.5px; font-weight: 500; line-height: 25px; }
.bot-num b.hay-errores { color: var(--texto-critico); }
.bot-num span { font-size: 11.5px; color: var(--texto-3); white-space: nowrap; }
.bot-pie { font-size: 12.5px; color: var(--texto-2); display: flex; align-items: center; gap: 6px; min-width: 0; }
.bot-pie span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bot-pie .ico { width: 12px; height: 12px; color: var(--texto-3); }

/* ---------- Feed de actividad ---------- */
.feed { list-style: none; margin: 0; padding: 4px 14px; display: grid; background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--radio); }
.feed-item { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 10px; padding: 11px 0; }
.feed-item + .feed-item { border-top: 1px solid var(--linea); }
.feed-item.nuevo { animation: entrar 0.5s ease-out; }
@keyframes entrar { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.feed-icono {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  background: var(--superficie-2); color: var(--texto-2);
}
.feed-icono .ico { width: 15px; height: 15px; }
.feed-icono.critico { color: var(--critico); background: color-mix(in srgb, var(--critico) 10%, var(--superficie)); }
.feed-icono.aviso { color: var(--aviso); background: color-mix(in srgb, var(--aviso) 12%, var(--superficie)); }
.feed-texto { font-size: 14px; line-height: 1.35; overflow-wrap: anywhere; }
.feed-meta { font-size: 12px; color: var(--texto-3); margin-top: 2px; display: flex; gap: 5px; flex-wrap: wrap; }
.feed-meta b { color: var(--texto-2); font-weight: 500; }
.vacio { padding: 28px; text-align: center; color: var(--texto-3); font-size: 14px; }

/* ---------- Gráfica ---------- */
.grafica { position: relative; height: 280px; }
.leyenda { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; font-size: 13px; color: var(--texto-2); }
.leyenda button, .leyenda span { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.leyenda span { cursor: default; }
.leyenda button[aria-pressed="false"] { opacity: 0.4; }
.leyenda i { width: 9px; height: 9px; border-radius: 2px; background: var(--c); }

/* ---------- Tabla ---------- */
.tabla-envoltorio { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
.tabla { width: 100%; border-collapse: collapse; font-size: 14px; }
.tabla th {
  text-align: left; font-size: 12px; font-weight: 500; color: var(--texto-3);
  padding: 8px 10px; border-bottom: 1px solid var(--linea); white-space: nowrap;
}
.tabla td { padding: 10px; border-bottom: 1px solid var(--linea); vertical-align: top; }
.tabla tbody tr.fila { cursor: pointer; }
.tabla tbody tr.fila:hover td { background: var(--superficie-hover); }
.tabla .col-fecha { white-space: nowrap; color: var(--texto-2); font-variant-numeric: tabular-nums; }
.tabla .col-valor { text-align: right; font-variant-numeric: tabular-nums; }
.tabla .col-texto { min-width: 220px; color: var(--texto-2); }
.tabla code { font-family: var(--mono); font-size: 12.5px; color: var(--texto-2); white-space: nowrap; }
.tabla tr.detalle td { background: var(--superficie-2); }
.json { margin: 0; font: 12.5px/1.55 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; color: var(--texto-2); }
.json .k { color: var(--texto); }
.json .s { color: #3f7d5a; }
.json .n { color: #a55a2a; }
.json .b { color: #6a55c0; }
:root[data-theme="dark"] .json .s { color: #7cc59a; }
:root[data-theme="dark"] .json .n { color: #e3a26f; }
:root[data-theme="dark"] .json .b { color: #a99cf0; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .json .s { color: #7cc59a; }
  :root:not([data-theme="light"]) .json .n { color: #e3a26f; }
  :root:not([data-theme="light"]) .json .b { color: #a99cf0; }
}
.paginacion { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; font-size: 13px; color: var(--texto-3); flex-wrap: wrap; }
.paginacion div { display: flex; gap: 6px; }
@media (max-width: 720px) {
  .tabla .col-valor, .tabla th.col-valor { display: none; }
  .tabla .col-texto { min-width: 160px; }
}

/* ---------- Usuarios ---------- */
.usuario-actual { color: var(--texto-3); font-size: 13px; margin-right: 4px; white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.formulario { display: grid; gap: 12px; }
.formulario .campos { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.formulario label { display: grid; gap: 6px; font-size: 13px; font-weight: 500; color: var(--texto-2); }
.formulario input, .formulario select, .lista-usuarios select, .lista-usuarios input[type="password"] {
  height: 36px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--borde); background: var(--superficie); min-width: 0;
}
.formulario input:focus, .formulario select:focus { border-color: var(--borde-fuerte); outline: none; }
.formulario .boton { justify-self: start; }
.msg-error { color: var(--texto-critico); font-size: 13.5px; }
.msg-ok { color: var(--texto-2); font-size: 13.5px; }
.lista-usuarios { list-style: none; padding: 0; margin: 0; background: var(--superficie); border: 1px solid var(--borde); border-radius: 10px; }
.lista-usuarios li { display: grid; gap: 10px; padding: 12px; }
.lista-usuarios li + li { border-top: 1px solid var(--linea); }
.lista-usuarios .u-cab { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.lista-usuarios .u-cab b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lista-usuarios .u-sub { color: var(--texto-3); font-size: 12.5px; }
.lista-usuarios .u-acciones { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.lista-usuarios .inactivo b { color: var(--texto-3); text-decoration: line-through; }

/* ---------- Catálogo ---------- */
.cat-acciones { display: flex; align-items: center; gap: 4px; }
.cat-tipos { max-width: 100%; overflow-x: auto; justify-self: start; }
.cat-tipos button { white-space: nowrap; }
.cat-barra { display: flex; gap: 8px; }
.cat-barra input { flex: 1; min-width: 0; height: 36px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--borde); background: var(--superficie); }
.cat-barra input:focus { border-color: var(--borde-fuerte); outline: none; }
.lista-catalogo li { padding: 0; }
.lista-catalogo .cat-item {
  display: grid; gap: 4px; width: 100%; padding: 12px; text-align: left; background: none; border: 0; border-radius: 10px; cursor: pointer;
}
.lista-catalogo .cat-item:hover { background: var(--superficie-hover); }
.lista-catalogo .u-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.formulario .campo-ancho { grid-column: 1 / -1; }
.formulario textarea {
  padding: 8px 10px; border-radius: 8px; border: 1px solid var(--borde); background: var(--superficie); font: inherit; color: inherit; resize: vertical; min-width: 0;
}
.formulario textarea:focus { border-color: var(--borde-fuerte); outline: none; }
.formulario .cat-titulo { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }

/* ---------- Panel lateral (detalle de bot) ---------- */
dialog.lateral {
  margin: 0 0 0 auto; height: 100dvh; max-height: 100dvh; width: min(560px, 100vw); max-width: 100vw;
  border: 0; border-left: 1px solid var(--borde); padding: 0; background: var(--fondo); color: var(--texto); box-shadow: var(--sombra-alta);
}
dialog.lateral::backdrop { background: rgba(10, 10, 8, 0.35); }
dialog.lateral[open] { animation: deslizar 0.2s ease-out; }
@keyframes deslizar { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.lateral-cab { position: sticky; top: 0; background: var(--fondo); padding: 18px 20px 16px; border-bottom: 1px solid var(--borde); display: grid; gap: 6px; z-index: 1; }
.lateral-cab .fila-cab { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.lateral-cab h2 { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.lateral-cab p { color: var(--texto-2); font-size: 14px; }
.lateral-cab .linea-ejec { color: var(--texto-3); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.lateral-cab .linea-ejec .ico { width: 12px; height: 12px; }
.lateral-cuerpo { padding: 20px; display: grid; gap: 24px; }
.metricas { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.metrica { background: var(--superficie); border: 1px solid var(--borde); border-radius: 10px; padding: 12px; }
.metrica b { display: block; font-size: 18px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metrica.ancha { grid-column: 1 / -1; }
.metrica.ancha b { font-size: 14.5px; font-weight: 500; }
.metrica span { font-size: 12px; color: var(--texto-3); }
.subtitulo { font-size: 13px; font-weight: 600; color: var(--texto-2); margin-bottom: 10px; }
.linea-tiempo svg { width: 100%; height: 40px; display: block; }
.linea-tiempo .ejes { display: flex; justify-content: space-between; font-size: 11px; color: var(--texto-3); margin-top: 4px; }
.leyenda-mini { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--texto-2); margin-top: 8px; }
.leyenda-mini span { display: inline-flex; align-items: center; gap: 5px; }
.leyenda-mini i { width: 8px; height: 8px; border-radius: 2px; background: var(--c); }
.lista-ejec { list-style: none; padding: 0; margin: 0; background: var(--superficie); border: 1px solid var(--borde); border-radius: 10px; }
.lista-ejec li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 12px; font-size: 13.5px; }
.lista-ejec li + li { border-top: 1px solid var(--linea); }
.lista-ejec .cuando { color: var(--texto-2); font-variant-numeric: tabular-nums; }
.lista-ejec .dur { color: var(--texto-3); font-variant-numeric: tabular-nums; }
.lista-ejec .motivo { display: block; color: var(--texto-3); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; background: var(--fondo); }
.login form {
  width: min(360px, 100%); display: grid; gap: 14px; padding: 28px;
  background: var(--superficie); border: 1px solid var(--borde); border-radius: 14px;
}
.login h1 { font-size: 19px; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.login p { color: var(--texto-3); font-size: 14px; margin-top: -6px; }
.login label { display: grid; gap: 6px; font-size: 13px; font-weight: 500; color: var(--texto-2); }
.login input { height: 40px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--borde); background: var(--superficie); }
.login input:focus { border-color: var(--borde-fuerte); outline: none; }
.login .boton { height: 40px; justify-content: center; margin-top: 4px; }
.login .error { color: var(--texto-critico); font-size: 13.5px; border: 1px solid color-mix(in srgb, var(--critico) 30%, transparent); padding: 8px 12px; border-radius: 8px; }

/* ---------- Esqueleto de carga ---------- */
.esqueleto { background: linear-gradient(90deg, var(--superficie-2), var(--superficie-hover), var(--superficie-2)); background-size: 200% 100%; animation: brillo 1.4s linear infinite; border-radius: var(--radio); min-height: 148px; }
@keyframes brillo { to { background-position: -200% 0; } }

@media (max-width: 560px) {
  .contenedor { padding-top: 16px; gap: 24px; }
  .refresco span, .ocultar-movil { display: none; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi { min-height: 128px; padding: 12px; }
  .kpi-valor { font-size: 26px; }
  .kpi-delta span { display: none; }
  .tarjeta { padding: 16px; }
  .tabla-envoltorio { margin: 0 -16px; padding: 0 16px; }
  .grafica { height: 230px; }
}

/* =================== Modo TV =================== */
body.tv {
  height: 100vh; overflow: hidden;
  font-size: clamp(12px, 1.05vw, 26px);
  display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr); gap: 1.6vh;
  padding: 2.6vh 2.2vw;
}
body.tv.sin-cursor, body.tv.sin-cursor * { cursor: none; }
.tv .ico { width: 1em; height: 1em; vertical-align: -0.15em; }
/* Filas fijas: el banner de alertas oculto no debe descolocar el resto. */
.tv-cab { grid-row: 1; display: flex; align-items: center; justify-content: space-between; gap: 2vw; }
.tv-alerta { grid-row: 2; }
.tv-cuerpo { grid-row: 3; }
.tv-bots { grid-row: 4; }
.tv-cab .marca { font-size: 1.6em; gap: 0.55em; }
.tv-cab .logo { width: 1.5em; height: 1.5em; border-radius: 0.35em; }
.tv-cab .logo svg { width: 0.9em; height: 0.9em; }
.tv-periodo { display: flex; gap: 0.3em; padding: 0.2em; border-radius: 0.6em; border: 1px solid var(--borde); }
.tv-periodo span { padding: 0.3em 0.9em; border-radius: 0.45em; font-size: 0.95em; font-weight: 500; color: var(--texto-3); transition: all 0.4s ease; }
.tv-periodo span.activo { background: var(--superficie-2); color: var(--texto); }
.tv-reloj { text-align: right; line-height: 1.1; }
.tv-reloj b { font-size: 2.1em; font-weight: 500; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.tv-reloj span { display: block; color: var(--texto-3); font-size: 0.95em; }

.tv-alerta {
  display: flex; align-items: center; gap: 0.8em; padding: 0.75em 1.1em; border-radius: 0.6em; font-size: 1.05em;
  background: var(--superficie); border: 1px solid var(--borde); border-left: 0.25em solid var(--critico);
}
.tv-alerta .icono-alerta { color: var(--critico); display: inline-flex; font-size: 1.15em; }
.tv-alerta.solo-avisos { border-left-color: var(--aviso); }
.tv-alerta.solo-avisos .icono-alerta { color: var(--aviso); }
.tv-alerta > span:nth-child(2) { font-weight: 600; white-space: nowrap; }
.tv-alerta .detalle { flex: 1; min-width: 0; color: var(--texto-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tv-cuerpo { display: grid; grid-template-columns: minmax(0, 2.15fr) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); gap: 1.6vh 1.2vw; min-height: 0; }
.tv-kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.6vh 1vw; }
.tv-kpis .kpi { min-height: 0; padding: 1em 1.2em 0.8em; border-radius: 0.8em; gap: 0.1em; transition: opacity 0.4s ease; }
.tv-kpis .kpi.cambiando { opacity: 0.3; }
.tv-kpis .kpi-cab { font-size: 1em; gap: 0.55em; }
.tv-kpis .kpi-icono .ico { width: 1.1em; height: 1.1em; }
.tv-kpis .kpi-valor { font-size: 3em; margin-top: 0.2em; }
.tv-kpis .kpi-delta { font-size: 0.85em; }
.tv-kpis .ico-delta { width: 0.9em; height: 0.9em; }
.tv-kpis .kpi-spark { height: 2.2em; margin-top: 0.6em; }
.tv-kpis .kpi-spark .punto { width: 0.55em; height: 0.55em; margin: -0.275em 0 0 -0.275em; }

.tv-grafica { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-height: 0; padding: 1em 1.2em; border-radius: 0.8em; }
.tv-grafica h2, .tv-feed h2 { font-size: 0.9em; font-weight: 600; color: var(--texto-2); margin-bottom: 0.8em; }
.tv-grafica .grafica { position: relative; height: 100%; min-height: 0; }
.tv-grafica .leyenda { font-size: 0.85em; margin-top: 0.6em; }
.tv-grafica .leyenda i { width: 0.65em; height: 0.65em; }

.tv-feed { grid-column: 2; grid-row: 1 / span 2; display: grid; grid-template-rows: auto minmax(0, 1fr); min-height: 0; padding: 1em 1.2em 0.4em; border-radius: 0.8em; }
.tv-feed .feed { background: none; border: 0; padding: 0; overflow: hidden; align-content: start;
  mask-image: linear-gradient(to bottom, #000 82%, transparent); -webkit-mask-image: linear-gradient(to bottom, #000 82%, transparent); }
.tv-feed .feed-item { grid-template-columns: 2em minmax(0, 1fr); gap: 0.75em; padding: 0.75em 0; }
.tv-feed .feed-icono { width: 2em; height: 2em; border-radius: 0.5em; }
.tv-feed .feed-icono .ico { width: 1em; height: 1em; }
.tv-feed .feed-texto { font-size: 1em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tv-feed .feed-meta { font-size: 0.8em; }

.tv-bots { display: flex; gap: 0.8vw; overflow: hidden; }
.tv-bot {
  flex: 1 1 0; min-width: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 0.6em; align-items: center;
  padding: 0.7em 0.9em; border-radius: 0.6em; background: var(--superficie); border: 1px solid var(--borde);
}
.tv-bot i { grid-row: span 2; width: 0.6em; height: 0.6em; border-radius: 50%; background: var(--c); }
.tv-bot b { font-size: 0.95em; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tv-bot span { font-size: 0.78em; color: var(--texto-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
