/* ============================================================================
   NACIÓN DEVICE AI — Hoja de estilos
   Tokens del Anexo B §2 · modo oscuro por defecto + claro · responsive
   ==========================================================================*/
:root {
  --bg: #0B1020;
  --surface: #121B2D;
  --surface2: #19263C;
  --surface3: #21314E;
  --border: #223350;
  --border2: #2E4266;
  --text: #E9EFFB;
  --text2: #A9B8D2;
  --muted: #66779A;
  --accent: #5B8CFF;
  --accent-ink: #0A1226;
  --accent-soft: rgba(91, 140, 255, 0.14);
  --accent2: #27CDBA;
  --accent2-soft: rgba(39, 205, 186, 0.13);
  --ok: #34C78F;
  --ok-soft: rgba(52, 199, 143, 0.14);
  --warn: #F3B544;
  --warn-soft: rgba(243, 181, 68, 0.13);
  --danger: #E86975;
  --danger-soft: rgba(232, 105, 117, 0.13);
  --violet: #8465E8;
  --violet-soft: rgba(132, 101, 232, 0.15);
  --r: 12px;
  --r-sm: 8px;
  --shadow: 0 10px 30px rgba(3, 7, 18, 0.5);
  --font: 'Inter', 'Geist', 'Segoe UI', system-ui, -apple-system, sans-serif;
  /* Analog-first: targets táctiles + piso tipográfico + overlays por token */
  --tap: 44px;
  --tap-sm: 38px;
  --fs-body: 15px;
  --fs-label: 13px;
  --fs-micro: 12.5px;
  --muted: #8E9FBE;
  --focus: 0 0 0 3px var(--accent-soft);
  --frame-ink: #05070F;
  --overlay: rgba(4, 8, 20, 0.62);
  --shadow-ink: rgba(4, 8, 20, 0.18);
  --grad-brand: linear-gradient(135deg, var(--accent), var(--accent2));
  --r-lg: 16px;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px;
}
[data-theme="light"] {
  --bg: #F3F5FA;
  --surface: #FFFFFF;
  --surface2: #EDF1F8;
  --surface3: #E0E7F3;
  --border: #CBD6E8;
  --border2: #AEBDD6;
  --text: #141F36;
  --text2: #43536F;
  --muted: #5F6E8C;
  --accent-ink: #FFFFFF;
  --accent-soft: rgba(91, 140, 255, 0.12);
  --accent2-soft: rgba(39, 205, 186, 0.14);
  --ok-soft: rgba(52, 199, 143, 0.15);
  --warn-soft: rgba(243, 181, 68, 0.16);
  --danger-soft: rgba(232, 105, 117, 0.14);
  --violet-soft: rgba(132, 101, 232, 0.13);
  --shadow: 0 10px 26px rgba(24, 40, 78, 0.12);
  --frame-ink: #0E1526;
  --overlay: rgba(28, 40, 64, 0.45);
  --shadow-ink: rgba(24, 40, 78, 0.10);
}

* { box-sizing: border-box; }
/* Bug 5: el documento NUNCA scrollea/panorea — la app es un shell y el
   scroll vive en .main/.nav. Sin esto, cualquier overflow transitorio
   (teclado/IMÉ) dejaba la WebView "scrolleada" y TODA la UI (topbar
   incluida) saltaba de esquina. */
html, body { height: 100%; overflow: hidden; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.ic { display: inline-flex; align-items: center; justify-content: center; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum'; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- layout shell ---------- */
.app {
  display: grid;
  /* minmax(0,1fr): la columna NUNCA supera el viewport por el min-content
     de un hijo (una fila nowrap inflaba el documento a 468px y la WebView
     hacía zoom-out al 77% en el APK) */
  grid-template-columns: 252px minmax(0, 1fr);
  /* safe-area: con viewport-fit=cover la WebView entra bajo la status bar */
  grid-template-rows: calc(56px + env(safe-area-inset-top, 0px)) 1fr;
  grid-template-areas: "side top" "side main";
  height: 100vh;
  padding-top: env(safe-area-inset-top, 0px);
  /* sin anclas a nivel documento: un rebuild de contenido "corregía" el
     scroll y la app entera se desplazaba bajo el dedo (bug 5) */
  overflow-anchor: none;
  position: relative;
}
.app.side-collapsed { grid-template-columns: 64px minmax(0, 1fr); }
/* Hover-expand del sidebar colapsado (sin JS): el flyout cubre el main */
.app.side-collapsed .sidebar:hover,
.app.side-collapsed .sidebar:focus-within {
  position: absolute; top: 0; left: 0; bottom: 0; width: 252px; z-index: 75;
  box-shadow: var(--shadow); overflow-y: auto;
}
.app.side-collapsed .sidebar:hover .brand-text,
.app.side-collapsed .sidebar:hover .nav-label,
.app.side-collapsed .sidebar:hover .nav-group-label { display: flex; }
.app.side-collapsed .sidebar:hover .brand { justify-content: flex-start; padding: 14px 14px 12px; }
.app.side-collapsed .sidebar:hover .nav-item { justify-content: flex-start; }
.app.side-collapsed .sidebar:hover .nav-count { display: inline-flex; }

.sidebar {
  grid-area: side;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 14px 14px 12px; border-bottom: 1px solid var(--border); min-height: 56px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: grid; place-items: center; color: #071018; font-weight: 800; font-size: 13px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-name { font-weight: 800; font-size: 13.5px; letter-spacing: 0.01em; }
.brand-sub { font-size: 12.5px; color: var(--muted); }
.side-collapsed .brand-text, .side-collapsed .nav-label, .side-collapsed .nav-group-label { display: none; }
.side-collapsed .brand { justify-content: center; padding: 14px 6px; }
.side-collapsed .nav-item { justify-content: center; }

.nav { flex: 1; overflow-y: auto; padding: 10px 8px 16px; }
.nav-group-label {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--muted); padding: 18px 10px 8px; font-weight: 700;
  border-top: 1px solid var(--border); margin-top: 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 12px; margin: 1px 0; border: 0; background: none;
  color: var(--text2); font: inherit; font-size: 13.5px; font-weight: 500;
  border-radius: 9px; cursor: pointer; text-align: left; position: relative;
  min-height: var(--tap);
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item.active::before {
  content: ''; position: absolute; left: -8px; top: 6px; bottom: 6px;
  width: 3px; border-radius: 3px; background: var(--accent);
}
/* 3 pesos visuales: rutas principales (Dashboard / Live / Asistente) */
#nav-dashboard, #nav-live, #nav-asistente { font-size: 14px; font-weight: 700; color: var(--text); }
#nav-dashboard .ic, #nav-live .ic, #nav-asistente .ic { color: var(--accent); }
#nav-dashboard .ic svg, #nav-live .ic svg, #nav-asistente .ic svg { width: 18px; height: 18px; }
#nav-dashboard.nav-item.active, #nav-live.nav-item.active, #nav-asistente.nav-item.active { color: var(--accent); font-weight: 700; }
#nav-dashboard:not(.active)::before, #nav-live:not(.active)::before, #nav-asistente:not(.active)::before {
  content: ''; position: absolute; left: -8px; top: 6px; bottom: 6px; width: 3px;
  border-radius: 3px; background: var(--accent); opacity: .45;
}
.nav-count { margin-left: auto; font-size: 12.5px; background: var(--surface3); border-radius: 999px; padding: 3px 9px; color: var(--text2); }
.side-collapsed .nav-count { display: none; }

.side-foot { border-top: 1px solid var(--border); padding: 10px; display: flex; gap: 8px; align-items: center; }
.side-collapsed .side-foot { justify-content: center; }

.topbar {
  grid-area: top;
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: relative; z-index: 40;
  min-height: calc(56px + env(safe-area-inset-top, 0px));
}
/* specificity .icon-btn.hamburger: sin esto, la regla .icon-btn de más
   abajo (mismo specificity, después) dejaba el hamburger VISIBLE en desktop */
.icon-btn.hamburger { display: none; }
.search-box { position: relative; flex: 1; max-width: 440px; min-width: 0; }
.search-box .ic { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-input {
  width: 100%; padding: 10px 14px 10px 36px;
  background: var(--bg); border: 1px solid var(--border2); border-radius: 999px;
  color: var(--text); font: inherit; font-size: 14px;
  min-height: var(--tap);
}
.search-input::placeholder { color: var(--muted); }
.search-input:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
/* título de página en la topbar — solo móvil ≤560px (ver media query) */
.tb-title { display: none; }
.tb-right { margin-left: auto; display: flex; align-items: center; gap: 6px; padding-left: 10px; border-left: 1px solid var(--border); }
.tb-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 999px;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--muted); font-size: 11.5px; font-weight: 500; cursor: pointer; font-family: inherit;
  opacity: .9;
}
.tb-pill:hover { border-color: var(--border2); color: var(--text); }
.tb-pill select { background: transparent; border: 0; color: inherit; font: inherit; font-size: 11.5px; cursor: pointer; }
.tb-pill select option { color: var(--text); background: var(--surface); }
.tb-status { display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px; border-radius: 999px; background: var(--ok-soft); color: var(--ok); font-size: 11.5px; font-weight: 600; white-space: nowrap; flex: none; opacity: .9; }
.tb-status .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
/* jerga "API · control plane" solo en title (desktop) */
@media (min-width: 941px) { .tb-st-long { display: none; } }
.avatar {
  width: var(--tap); height: var(--tap); border-radius: 50%; flex: none;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-weight: 700; font-size: 14px; border: 0; cursor: pointer; font-family: inherit;
}
@media (max-width: 1280px) { .hide-md { display: none !important; } }
@media (max-width: 1080px) { .hide-sm { display: none !important; } .search-box { max-width: 240px; } }

/* dropdowns (buscador y notificaciones) */
.dd-panel {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 80;
  width: min(380px, calc(100vw - 24px));
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden;
}
.dd-panel .dd-head { padding: 10px 14px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 12.5px; display: flex; justify-content: space-between; align-items: center; }
.dd-item { display: flex; gap: 10px; padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--border); align-items: flex-start; min-height: var(--tap); }
.dd-item:hover { background: var(--surface2); }
.dd-item:last-child { border-bottom: 0; }
.dd-item .ic { margin-top: 2px; }
.dd-item b { display: block; font-size: 13px; font-weight: 600; }
.dd-item span { font-size: 12.5px; color: var(--muted); display: block; margin-top: 1px; }
.dd-kind { font-size: 12.5px; padding: 2px 8px; border-radius: 999px; background: var(--surface3); color: var(--text2); margin-left: auto; flex: none; }
.search-res-icon { color: var(--accent); background: var(--accent-soft); width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; flex: none; }

.main { grid-area: main; overflow-y: auto; padding: 24px 28px 70px; min-width: 0;
  /* el contenido se reconstruye por completo en cada render/tick: el
     scroll-anchoring de Chromium "corregía" el scrollTop y el viewport
     saltaba bajo el dedo (bug: "al tocar, todo se mueve") */
  overflow-anchor: none;
  /* bug 5: sin cadena de overscroll al documento + sin scroll horizontal
     (las tablas scrollean en su .table-wrap; un overflow en X hacía que la
     WebView "encogiera" la página como en el viejo zoom al 77%) */
  overscroll-behavior: none;
  overflow-x: hidden; }
.content { max-width: 1560px; margin: 0 auto; }

/* ---------- página ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; }
.page-sub { color: var(--text2); font-size: 13.5px; margin-top: 3px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.crumbs { display: flex; gap: 6px; align-items: center; font-size: 12.5px; color: var(--muted); margin-bottom: 12px; flex-wrap: wrap; }
.crumbs a { color: var(--text2); font-weight: 500; }
.crumbs .sep { opacity: .6; }

.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g21 { grid-template-columns: 2fr 1fr; }
.g12 { grid-template-columns: 1fr 2fr; }
@media (max-width: 1150px) { .g2, .g3, .g4, .g21, .g12 { grid-template-columns: 1fr; } }
.stack { display: flex; flex-direction: column; gap: 16px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); min-width: 0; transition: border-color .16s ease; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 20px 0; flex-wrap: wrap; }
.card-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.card-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.card-body { padding: 16px 20px; }
.card.pd-0 .card-body { padding: 0; }

/* ---------- KPIs ---------- */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 13px 14px; min-width: 0; }
.kpi-head { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.kpi-label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text2); font-weight: 600; }
.kpi-label .ic { color: var(--muted); }
.kpi-value { font-size: 28px; font-weight: 750; letter-spacing: -0.02em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi-value.kpi-ok { color: var(--ok); } .kpi-value.kpi-warn { color: var(--warn); } .kpi-value.kpi-danger { color: var(--danger); } .kpi-value.kpi-info { color: var(--accent); }
.kpi-sub { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
/* Hero: primero el dashboard, luego el que exige acción (warn/danger) */
body:has(#nav-dashboard.active) .kpi-row > :first-child { grid-column: span 2; }
body:has(#nav-dashboard.active) .kpi-row > :first-child:not(:has(.kpi-value.kpi-warn)):not(:has(.kpi-value.kpi-danger)) {
  background: radial-gradient(120% 130% at 0% 0%, var(--accent-soft), transparent 60%), var(--surface);
  border-color: rgba(91, 140, 255, 0.35);
}
.kpi:has(.kpi-value.kpi-warn) {
  border-color: var(--warn); box-shadow: 0 0 0 1px var(--warn);
  background: linear-gradient(0deg, var(--warn-soft), var(--warn-soft)), var(--surface);
}
.kpi:has(.kpi-value.kpi-danger) {
  border-color: var(--danger); box-shadow: 0 0 0 1px var(--danger);
  background: linear-gradient(0deg, var(--danger-soft), var(--danger-soft)), var(--surface);
}
.kpi:has(.kpi-value.kpi-warn) .kpi-value, .kpi:has(.kpi-value.kpi-danger) .kpi-value { font-size: 34px; }

/* ---------- banners ---------- */
.banner { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: 10px; border: 1px solid; font-size: 13px; }
.banner .ic { margin-top: 1px; flex: none; }
.banner b { font-weight: 700; }
.banner-info { background: var(--accent-soft); border-color: rgba(91, 140, 255, 0.35); }
.banner-info .ic { color: var(--accent); }
.banner-warn { background: var(--warn-soft); border-color: rgba(243, 181, 68, 0.4); }
.banner-warn .ic { color: var(--warn); }
.banner-danger { background: var(--danger-soft); border-color: rgba(232, 105, 117, 0.4); }
.banner-danger .ic { color: var(--danger); }
.banner-ok { background: var(--ok-soft); border-color: rgba(52, 199, 143, 0.4); }
.banner-ok .ic { color: var(--ok); }

/* ---------- badges ---------- */
/* Bug 8: white-space nowrap + texto largo = la caja se capaba al ancho de la
   card y el TEXTO se salía/recortaba contra el borde de la card. Ahora el
   texto envuelve dentro de la badge (line-height 1.3 para multi-línea). */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12.5px; font-weight: 600; line-height: 1.3;
  padding: 5px 11px; border-radius: 999px; white-space: normal;
  max-width: 100%; text-align: left; min-height: 24px;
}
/* excepción: en la barra del visor la badge es estado denso — v11: nunca
   wrap (bajar el marco en cada clic). El contenedor ya corta con ellipsis. */
.live-top .badge { white-space: nowrap; line-height: 1; }
.badge .ic { flex: none; }
.b-ok { background: var(--ok-soft); color: var(--ok); }
.b-warn { background: var(--warn-soft); color: var(--warn); }
.b-danger { background: var(--danger-soft); color: var(--danger); }
/* estado legible sin depender solo del color */
.b-ok, .b-warn, .b-danger { border: 1px solid currentColor; }
.b-info { background: var(--accent-soft); color: var(--accent); }
.b-run { background: var(--accent2-soft); color: var(--accent2); }
.b-neutral { background: var(--surface3); color: var(--text2); }
.b-violet { background: var(--violet-soft); color: var(--violet); }
.badges { display: inline-flex; gap: 5px; flex-wrap: wrap; }

/* ---------- botones ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  font: inherit; font-size: 14px; font-weight: 600;
  padding: 10px 18px; border-radius: 9px;
  border: 1px solid var(--border2); background: var(--surface2); color: var(--text);
  cursor: pointer; transition: filter .14s, background .16s, border-color .16s, transform .14s;
  white-space: nowrap; min-height: var(--tap);
}
.btn:hover { background: var(--surface3); }
.btn:active { transform: scale(.98); }
.btn-primary {
  background: var(--grad-brand); border-color: transparent; color: var(--accent-ink);
  box-shadow: 0 4px 14px rgba(91, 140, 255, 0.30);
}
.btn-primary:hover { background: var(--grad-brand); filter: brightness(1.08); }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-danger { background: var(--danger-soft); border-color: rgba(232, 105, 117, 0.5); color: var(--danger); }
.btn-danger:hover { background: rgba(232, 105, 117, 0.22); }
.btn-stop { border-style: solid; }
.btn-sm { padding: 7px 12px; font-size: 12.5px; border-radius: 7px; min-height: var(--tap-sm); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.icon-btn {
  display: inline-grid; place-items: center; width: var(--tap); height: var(--tap);
  border-radius: 8px; border: 1px solid transparent; background: transparent;
  color: var(--text2); cursor: pointer; flex: none;
}
.icon-btn:hover { background: var(--surface2); color: var(--text); border-color: var(--border); }
/* el primario manda en acciones de página/modal/drawer (copy intacta) */
.page-actions .btn:not(.btn-primary):not(.btn-danger),
.modal-actions .btn:not(.btn-primary):not(.btn-danger),
.drawer-foot .btn:not(.btn-primary):not(.btn-danger) {
  background: transparent; border-color: var(--border); color: var(--text2);
}
.page-actions .btn:not(.btn-primary):not(.btn-danger):hover { background: var(--surface2); color: var(--text); }

/* ---------- tablas ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--r-sm); -webkit-overflow-scrolling: touch;
  overflow-anchor: none; max-height: 70vh; overflow-y: auto; }
/* táctil: quita el delay de doble-tap y evita que la WebView interprete
   toques como gestos de zoom en controles */
button, a, input, select, textarea, .dt .row, .nav-item, .live-key { touch-action: manipulation; }
table.dt { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 640px; }
.dt th {
  text-align: left; font-size: 12.5px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); font-weight: 700; padding: 10px 12px;
  border-bottom: 1px solid var(--border2); white-space: nowrap;
  position: sticky; top: 0; background: var(--surface); z-index: 2;
}
.dt td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.dt tr:last-child td { border-bottom: 0; }
/* zebra (excluye sel y hover — la especificidad de :not no pisa .row) */
.dt tbody tr:nth-child(even):not(.sel):not(:hover) td { background: var(--surface2); }
.dt .al-right { text-align: right; }
.dt .td-sel, .dt .th-sel { width: 40px; padding: 10px 6px 10px 10px; }
.dt .row { cursor: pointer; }
.dt .row:hover { background: var(--surface2); }
.dt .row.sel { background: var(--accent-soft); }
.dt .row.dim { opacity: .5; }
.cell-main { font-weight: 600; }
.cell-sub { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
input[type="checkbox"] { accent-color: var(--accent); width: 20px; height: 20px; cursor: pointer; }

/* ---------- drawer ---------- */
.drawer-overlay { position: fixed; inset: 0; background: var(--overlay); opacity: 0; transition: opacity .18s; z-index: 60; }
.drawer-overlay.open { opacity: 1; }
.drawer {
  position: absolute; right: 0; top: 0; bottom: 0; width: min(540px, 94vw);
  background: var(--surface); border-left: 1px solid var(--border2);
  transform: translateX(102%); transition: transform .22s cubic-bezier(.2, .8, .25, 1);
  display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.drawer.wide { width: min(760px, 96vw); }
.drawer-overlay.open .drawer { transform: none; }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 15px 16px 12px; border-bottom: 1px solid var(--border); }
.drawer-title { font-size: 16px; font-weight: 700; }
.drawer-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.drawer-foot { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: var(--overlay); display: grid; place-items: center; opacity: 0; transition: opacity .16s; z-index: 90; padding: 16px; }
.modal-overlay.open { opacity: 1; }
.modal { width: min(470px, 94vw); background: var(--surface); border: 1px solid var(--border2); border-radius: var(--r-lg); padding: 20px; box-shadow: var(--shadow); transform: translateY(6px); transition: transform .22s cubic-bezier(.2, .8, .25, 1); }
.modal-overlay.open .modal { transform: none; }
.modal-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; margin-bottom: 12px; }
.mi-info { background: var(--accent-soft); color: var(--accent); }
.mi-danger { background: var(--danger-soft); color: var(--danger); }
.modal h3 { margin-bottom: 8px; }
.modal-body { color: var(--text2); font-size: 13.5px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* ---------- toasts ---------- */
.toast-wrap { position: fixed; top: 64px; right: 16px; z-index: 99; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, 92vw); }
.toast {
  display: flex; gap: 9px; align-items: flex-start;
  background: var(--surface2); border: 1px solid var(--border2); border-left-width: 3px;
  border-radius: 10px; padding: 10px 13px; font-size: 13px;
  box-shadow: var(--shadow); opacity: 0; transform: translateX(10px); transition: all .22s;
}
.toast.show { opacity: 1; transform: none; }
.toast .ic { margin-top: 1px; }
.toast-ok { border-left-color: var(--ok); } .toast-ok .ic { color: var(--ok); }
.toast-warn { border-left-color: var(--warn); } .toast-warn .ic { color: var(--warn); }
.toast-danger { border-left-color: var(--danger); } .toast-danger .ic { color: var(--danger); }
.toast-info { border-left-color: var(--accent); } .toast-info .ic { color: var(--accent); }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 11px 14px; border: 0; background: none; font: inherit; font-size: 14px; font-weight: 600;
  color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap;
  min-height: var(--tap);
}
.tab:hover { color: var(--text2); }
.tab.on {
  color: var(--accent); background: var(--accent-soft); border-bottom-color: transparent;
  border-radius: 10px; box-shadow: inset 0 -2px 0 var(--accent);
}
/* énfasis solo en el último paso del wizard (sin iconos), no en filtros */
.tabs:not(:has(.ic)) .tab:last-child { color: var(--accent); font-weight: 700; }
.tab-content { padding-top: 14px; }

/* ---------- timeline ---------- */
.timeline { position: relative; display: flex; flex-direction: column; }
.timeline::before { content: ''; position: absolute; left: 11px; top: 8px; bottom: 8px; width: 2px; background: var(--border); }
.tl-item { display: grid; grid-template-columns: 24px 1fr; gap: 12px; padding: 8px 0; position: relative; }
.tl-dot {
  width: 24px; height: 24px; border-radius: 50%; z-index: 1;
  display: grid; place-items: center; background: var(--surface); border: 1px solid var(--border2); color: var(--muted);
}
.tl-ok .tl-dot { color: var(--ok); background: var(--ok-soft); border-color: rgba(52, 199, 143, .5); }
.tl-warn .tl-dot { color: var(--warn); background: var(--warn-soft); border-color: rgba(243, 181, 68, .5); }
.tl-danger .tl-dot { color: var(--danger); background: var(--danger-soft); border-color: rgba(232, 105, 117, .5); }
.tl-info .tl-dot, .tl-run .tl-dot { color: var(--accent); background: var(--accent-soft); border-color: rgba(91, 140, 255, .5); }
.tl-top { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.tl-top strong { font-size: 13px; }
.tl-time { font-size: 12.5px; color: var(--muted); margin-left: auto; white-space: nowrap; }
.tl-desc { font-size: 12.5px; color: var(--text2); margin-top: 3px; }
.tl-meta { font-size: 12.5px; color: var(--muted); margin-top: 3px; font-variant-numeric: tabular-nums; }
.tl-actions { margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- rack ---------- */
.rack-wrap { width: 100%; }
.rack { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.rack-slot {
  position: relative; border-radius: 10px; padding: 8px 8px 7px;
  background: var(--surface2); border: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 4px; min-height: 64px;
}
.rack-slot::after { content: attr(title); position: absolute; left: 50%; bottom: calc(100% + 6px); transform: translateX(-50%); width: max-content; max-width: 190px; background: var(--surface3); color: var(--text); border: 1px solid var(--border2); font-size: 12.5px; padding: 5px 8px; border-radius: 7px; opacity: 0; pointer-events: none; transition: opacity .12s; z-index: 5; text-align: center; line-height: 1.35; }
.rack-slot:hover::after { opacity: 1; }
.rack-n { position: absolute; top: 5px; right: 7px; font-size: 12.5px; color: var(--muted); font-weight: 700; }
.rack-ic { color: var(--text2); margin-top: 4px; }
.rack-label { font-size: 12.5px; font-weight: 700; letter-spacing: .04em; color: var(--text2); margin-top: auto; }
.slot-adb_ok { border-color: rgba(52, 199, 143, 0.45); } .slot-adb_ok .rack-ic { color: var(--ok); }
.slot-busy { border-color: rgba(91, 140, 255, 0.55); } .slot-busy .rack-ic { color: var(--accent); }
.slot-maintenance .rack-ic { color: var(--text2); }
.slot-reconnecting { border-color: rgba(243, 181, 68, 0.55); border-style: dashed; } .slot-reconnecting .rack-ic { color: var(--warn); animation: spin 2.4s linear infinite; }
.slot-adb_unauth { border-color: rgba(243, 181, 68, 0.5); } .slot-adb_unauth .rack-ic { color: var(--warn); }
.slot-not_detected { border-color: rgba(232, 105, 117, 0.5); } .slot-not_detected .rack-ic { color: var(--danger); }
.slot-offline { border-color: rgba(232, 105, 117, 0.55); background: var(--danger-soft); } .slot-offline .rack-ic { color: var(--danger); }
.slot-error { border-color: rgba(232, 105, 117, 0.6); } .slot-error .rack-ic { color: var(--danger); }
.slot-pending { border-style: dashed; border-color: var(--border2); } .slot-pending .rack-ic { color: var(--muted); }
.slot-pending .rack-label { color: var(--muted); }
@keyframes spin { to { transform: rotate(360deg); } }
.rack-legend { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.legend-chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--text2); }
.legend-chip .ic { color: var(--muted); }
.legend-chip.slot-adb_ok .ic { color: var(--ok); } .legend-chip.slot-busy .ic { color: var(--accent); }
.legend-chip.slot-reconnecting .ic, .legend-chip.slot-adb_unauth .ic { color: var(--warn); }
.legend-chip.slot-not_detected .ic, .legend-chip.slot-offline .ic, .legend-chip.slot-error .ic { color: var(--danger); }

/* ---------- phone preview ---------- */
.phone {
  width: 108px; aspect-ratio: 9/19; border-radius: 18px; margin: 0 auto;
  border: 3px solid var(--border2); background: var(--frame-ink);
  position: relative; overflow: hidden; flex: none;
}
.phone.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.phone-notch { position: absolute; top: 4px; left: 50%; transform: translateX(-50%); width: 34px; height: 5px; border-radius: 4px; background: var(--border2); z-index: 2; }
.phone-screen { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; padding: 20px 12px 10px; text-align: center; }
.phone-screen.off { color: var(--muted); font-size: 9.5px; line-height: 1.4; }
.phone-screen.off .ic { opacity: .7; }
.phone-screen.on { align-items: stretch; justify-content: flex-start; padding-top: 16px; background: linear-gradient(165deg, rgba(91, 140, 255, 0.2), transparent 60%); }
.ph-title { display: flex; align-items: center; justify-content: center; gap: 5px; font-size: 9.5px; font-weight: 700; color: var(--accent); background: var(--accent-soft); border-radius: 6px; padding: 4px; }
.ph-line { height: 6px; border-radius: 3px; background: var(--surface3); width: 100%; }
.ph-line.l70 { width: 70%; } .ph-line.l85 { width: 85%; }
.ph-status { margin-top: auto; display: flex; align-items: center; justify-content: center; gap: 4px; font-size: 8.5px; color: var(--ok); }
.phone-home { position: absolute; bottom: 4px; left: 50%; transform: translateX(-50%); width: 26px; height: 3px; border-radius: 3px; background: var(--border2); z-index: 2; }

/* ---------- charts ---------- */
.chart { display: flex; flex-direction: column; gap: 8px; position: relative; min-width: 0; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text2); font-weight: 500; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
.chart-host { width: 100%; }
.chart-svg { width: 100%; height: auto; display: block; }
.grid-line { stroke: var(--border); stroke-width: 1; }
.axis-text { fill: var(--muted); font-size: 12.5px; font-family: var(--font); }
.ln { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.cross { stroke: var(--border2); stroke-width: 1; stroke-dasharray: 3 3; }
.cross-dot { stroke: var(--surface); stroke-width: 2; }
.chart-tip { position: fixed; z-index: 99; background: var(--surface2); border: 1px solid var(--border2); border-radius: 9px; padding: 9px 11px; font-size: 12.5px; box-shadow: var(--shadow); pointer-events: none; display: none; min-width: 160px; }
.tip-title { font-weight: 700; color: var(--text); margin-bottom: 5px; font-size: 12.5px; }
.tip-row { display: flex; gap: 7px; align-items: center; margin-top: 4px; color: var(--text2); }
.tip-row strong { color: var(--text); font-variant-numeric: tabular-nums; margin-left: auto; padding-left: 10px; }
.tip-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.tip-name { flex: 1; }

.bars-h { display: flex; flex-direction: column; gap: 9px; }
.bar-row { display: grid; grid-template-columns: 86px 1fr 74px; gap: 10px; align-items: center; }
.bar-name { font-size: 12.5px; color: var(--text2); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 12px; border-radius: 6px; background: var(--surface3); overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 6px; }
.bar-val { font-size: 12.5px; color: var(--text2); text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.bars-v { display: flex; align-items: flex-end; gap: 12px; border-bottom: 1px solid var(--border); padding-bottom: 0; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 5px; min-width: 0; }
.bar-v { width: 100%; max-width: 46px; border-radius: 6px 6px 2px 2px; min-height: 3px; }
.bar-vlabel { font-size: 12.5px; color: var(--muted); }

.donut-wrap { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.donut-svg { width: var(--donut-size, 168px); height: var(--donut-size, 168px); flex: none; }
.donut-bg { fill: none; stroke: var(--surface3); stroke-width: 14; }
.donut-center { fill: var(--text); font-size: 21px; font-weight: 800; font-family: var(--font); }
.donut-center-sub { fill: var(--muted); font-size: 9.5px; font-family: var(--font); }
.donut-legend { flex: 1; min-width: 190px; display: flex; flex-direction: column; gap: 7px; }
.donut-row { display: grid; grid-template-columns: 10px 1fr auto; gap: 9px; align-items: center; font-size: 12.5px; }
.donut-name { color: var(--text2); font-weight: 500; }
.donut-val { color: var(--text2); font-variant-numeric: tabular-nums; font-weight: 600; }
.spark-svg { display: block; width: 100%; height: auto; }

/* ---------- formularios ---------- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-label { font-size: var(--fs-label); font-weight: 600; color: var(--text2); }
.req { color: var(--danger); font-style: normal; }
.field-hint { font-size: 12.5px; color: var(--muted); }
.inp {
  background: var(--bg); border: 1px solid var(--border2); border-radius: 8px;
  color: var(--text); font: inherit; font-size: var(--fs-body); padding: 10px 12px; width: 100%;
  min-height: var(--tap);
}
.inp:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.inp::placeholder { color: var(--muted); }
textarea.inp { resize: vertical; min-height: 74px; }
select.inp { cursor: pointer; }
/* Bug 8: selector de archivo CSV — en desktop el label dice "o elegir
   archivo:" y el input queda acotado; en ≤560px (reglas abajo) el label
   dice "CSV" y el input ocupa todo el ancho de la card. */
.csv-file { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; min-width: 0; }
.csv-file-inp { max-width: 260px; min-width: 0; font-size: 12.5px; }
.csv-lbl-short { display: none; }
.tgl { position: relative; display: inline-block; width: 48px; height: 28px; border-radius: 999px; background: var(--surface3); cursor: pointer; transition: background .15s; flex: none; vertical-align: middle; }
.tgl::before { content: ""; position: absolute; inset: -8px; }
.tgl.on { background: var(--accent); }
.tgl-knob { position: absolute; top: 2px; left: 2px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 3px rgba(0,0,0,.35); }
.tgl.on .tgl-knob { left: 22px; }
.tgl-input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.form-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 16px; flex-wrap: wrap; }

/* ---------- kv / progreso / chips ---------- */
.kv { display: flex; flex-direction: column; margin: 0; }
.kv-row { display: grid; grid-template-columns: 190px 1fr; gap: 12px; padding: 7.5px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.kv-row:last-child { border-bottom: 0; }
.kv-row dt { color: var(--muted); }
.kv-row dd { margin: 0; color: var(--text); min-width: 0; overflow-wrap: anywhere; }
.prog { display: flex; flex-direction: column; gap: 5px; }
.prog-track { height: 8px; border-radius: 6px; background: var(--surface3); overflow: hidden; }
.prog-bar { height: 100%; border-radius: 6px; background: var(--accent); transition: width .3s; }
.prog-bar.ok { background: var(--ok); } .prog-bar.warn { background: var(--warn); } .prog-bar.danger { background: var(--danger); }
.prog-label { font-size: 12.5px; color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 500; padding: 5px 11px; border-radius: 999px; background: var(--surface2); border: 1px solid var(--border); color: var(--text2); white-space: nowrap; min-height: 24px; }
.chip .ic { color: var(--muted); }
.chip-btn { cursor: pointer; font-family: inherit; }
.chip-btn:hover { border-color: var(--accent); color: var(--accent); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- empty / skeleton ---------- */
.empty { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 36px 14px; color: var(--muted); }
.empty .ic { opacity: 1; color: var(--text2); }
.empty .ic svg { width: 48px; height: 48px; }
.empty-title { font-weight: 700; color: var(--text); font-size: 16px; }
.empty-desc { font-size: 13.5px; max-width: 380px; }
.empty .btn-primary { min-width: min(280px, 100%); justify-content: center; }
.skel { display: flex; flex-direction: column; gap: 8px; }
.skel-row { height: 44px; border-radius: 8px; background: linear-gradient(90deg, var(--surface2) 25%, var(--surface3) 45%, var(--surface2) 65%); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- flujos (automatizaciones) ---------- */
.flow-chain { display: flex; flex-wrap: wrap; gap: 6px; align-items: stretch; }
.flow-node {
  display: flex; align-items: center; gap: 8px; padding: 8px 11px;
  background: var(--surface2); border: 1px solid var(--border); border-radius: 10px;
  font-size: 12.5px; font-weight: 500; max-width: 250px; color: var(--text2);
}
.flow-node .ic { flex: none; }
.flow-node.ft-trigger { border-color: rgba(91, 140, 255, .5); } .flow-node.ft-trigger .ic { color: var(--accent); }
.flow-node.ft-cond { border-color: rgba(243, 181, 68, .45); } .flow-node.ft-cond .ic { color: var(--warn); }
.flow-node.ft-action { border-color: rgba(39, 205, 186, .45); } .flow-node.ft-action .ic { color: var(--accent2); }
.flow-node.ft-observe { .ic { color: var(--muted); } }
.flow-node.ft-ai { border-color: rgba(132, 101, 232, .5); background: var(--violet-soft); } .flow-node.ft-ai .ic { color: var(--violet); }
.flow-node.ft-retry { border-color: rgba(243, 181, 68, .45); } .flow-node.ft-retry .ic { color: var(--warn); }
.flow-node.ft-log .ic { color: var(--muted); }
.flow-arrow { color: var(--muted); display: grid; place-items: center; flex: none; }
.flow-meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin-top: 10px; align-items: center; }

/* ---------- pipeline (lanzamientos) ---------- */
.pipe { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 10px; }
.pipe-col { min-width: 216px; width: 216px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px; flex: none; }
.pipe-col-head { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 2px 4px 9px; }
.pipe-count { background: var(--surface3); border-radius: 999px; padding: 1px 8px; font-size: 12.5px; }
.rel-card { background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; padding: 11px; margin-top: 8px; cursor: pointer; }
.rel-card:hover { border-color: var(--border2); }
.rel-title { font-weight: 700; font-size: 13px; }
.rel-artist { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.rel-tags { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 8px; }
.rel-date { display: flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--text2); margin-top: 8px; }

/* ---------- matriz de permisos ---------- */
.mx-yes { color: var(--ok); display: inline-flex; gap: 5px; align-items: center; font-size: 12.5px; }
.mx-no { color: var(--muted); font-size: 12.5px; }

/* ---------- fases ---------- */
.phase-row { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--border); }
.phase-row:last-child { border-bottom: 0; }
.phase-ic { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none; background: var(--surface2); color: var(--muted); border: 1px solid var(--border); }
.phase-ic.cur { background: var(--accent-soft); color: var(--accent); border-color: rgba(91,140,255,.4); }
.phase-name { font-weight: 600; font-size: 13px; }
.phase-note { font-size: 12.5px; color: var(--muted); margin-top: 1px; }

/* ---------- asistente ---------- */
.chat { display: flex; flex-direction: column; gap: 10px; max-height: 320px; overflow-y: auto; padding-right: 2px; }
.chat-msg { max-width: 88%; padding: 8px 12px; border-radius: 12px; font-size: 13px; line-height: 1.45; }
.chat-user { align-self: flex-end; background: var(--accent-soft); border: 1px solid rgba(91, 140, 255, .35); border-bottom-right-radius: 4px; }
.chat-ai { align-self: flex-start; background: var(--surface2); border: 1px solid var(--border); border-bottom-left-radius: 4px; color: var(--text2); }
.chat-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }

/* ---------- misc cards ---------- */
.site-card, .box-card, .artist-card, .dist-card, .agent-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 14px; cursor: pointer; transition: border-color .12s; }
.site-card:hover, .box-card:hover, .artist-card:hover, .dist-card:hover, .agent-card:hover { border-color: var(--border2); }
.card-title { font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-subline { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.avatar-artist { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 15px; color: var(--accent-ink); flex: none; }
.alert-row { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.alert-row:last-child { border-bottom: 0; }
.alert-row .ic { margin-top: 2px; flex: none; }
.alert-row b { font-size: 13px; font-weight: 600; }
.alert-row span { display: block; font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.alert-time { margin-left: auto; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.quick-item { display: flex; align-items: center; gap: 9px; padding: 10px 12px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface2); color: var(--text2); font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; text-align: left; min-height: var(--tap); }
.quick-item:hover { border-color: var(--accent); color: var(--accent); }
.quick-item .ic { color: var(--accent); }

/* ---------- integraciones ---------- */
.int-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 14px; }
.int-card h3 { display: flex; align-items: center; gap: 8px; }
.int-detail { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.int-detail li { font-size: 12.5px; color: var(--text2); display: flex; gap: 7px; }
.int-detail .ic { color: var(--muted); flex: none; margin-top: 2px; }
.int-group-label { font-size: 12.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; margin: 18px 0 10px; }

/* ---------- Asistente IA (chat) ---------- */
.ai-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.ai-step { display: flex; gap: 10px; align-items: flex-start; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 11px 13px; }
.ai-step .ic { color: var(--violet); margin-top: 1px; flex: none; }
.ai-step b { font-size: 12.5px; display: block; }
.ai-step span { font-size: 12.5px; color: var(--muted); display: block; margin-top: 2px; line-height: 1.35; }
.ai-status { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ai-budget { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text2); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px; font-variant-numeric: tabular-nums; }
.ai-budget .ic { color: var(--muted); }
.ai-budget-bar { width: 64px; height: 5px; border-radius: 999px; background: var(--surface3); overflow: hidden; }
.ai-budget-bar > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .5s ease; }
.ai-note { font-size: 12.5px; margin-left: auto; }
.ai-chat { display: flex; flex-direction: column; height: calc(100vh - 300px); min-height: 440px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; }
.ai-chat-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface2); flex: none; }
.ai-chat-title { display: inline-flex; align-items: center; gap: 7px; font-size: 13.5px; }
.ai-chat-title .ic { color: var(--violet); }
.ai-chat-note { font-size: 12.5px; color: var(--muted); margin-left: auto; }
.ai-msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.ai-msg { display: flex; gap: 9px; max-width: 84%; animation: msgIn .3s ease both; }
.ai-msg-user { align-self: flex-end; }
.ai-msg-ai { align-self: flex-start; }
.ai-avatar { flex: none; width: 28px; height: 28px; border-radius: 9px; background: var(--violet-soft); color: var(--violet); display: grid; place-items: center; margin-top: 2px; }
.ai-bubble { background: var(--surface2); border: 1px solid var(--border); border-radius: 12px; padding: 9px 12px; font-size: 13.5px; line-height: 1.5; min-width: 0; }
.ai-msg-user .ai-bubble { background: var(--accent-soft); border-color: rgba(120, 119, 255, 0.4); }
.ai-bubble p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-meta { margin-top: 6px; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ai-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ai-action { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--text2); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 3px 9px; }
.ai-action.err { color: var(--danger); border-color: rgba(232, 105, 117, 0.4); }
.ai-pending { margin-top: 10px; border: 1px solid var(--accent); background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; animation: msgIn .25s ease both; }
.ai-pending.done { border-color: var(--border2); background: var(--surface2); }
.ai-pending-title { font-size: 12.5px; font-weight: 700; color: var(--accent); display: flex; gap: 6px; align-items: center; }
.ai-pending.done.confirmed .ai-pending-title { color: var(--ok); }
.ai-pending.done.cancelled .ai-pending-title { color: var(--muted); }
.ai-pending-body { font-size: 12.5px; color: var(--text2); margin-top: 5px; overflow-wrap: anywhere; }
.ai-pending-impact { font-size: 12.5px; color: var(--muted); margin-top: 4px; line-height: 1.4; }
.ai-pending-row { display: flex; gap: 8px; margin-top: 9px; }
.ai-typing { display: inline-flex; gap: 4px; align-items: center; padding: 5px 2px; }
.ai-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: typingDot 1.1s infinite ease-in-out; }
.ai-typing i:nth-child(2) { animation-delay: .15s; }
.ai-typing i:nth-child(3) { animation-delay: .3s; }
.ai-sugg { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.ai-sugg-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--text2); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 5px 11px; cursor: pointer; transition: border-color .15s, color .15s, transform .12s; }
.ai-sugg-chip:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }
.ai-composer { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--border); background: var(--surface2); flex: none; }
.ai-composer-row { display: flex; gap: 7px; align-items: flex-end; flex-wrap: wrap; }
.ai-atts { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
.ai-atts.in-msg { margin-top: 7px; }
.ai-att { display: inline-flex; align-items: center; gap: 5px; max-width: 220px; font-size: 12px; font-weight: 600; color: var(--text2); background: var(--surface); border: 1px solid var(--border2); border-radius: 999px; padding: 3px 6px 3px 9px; }
.ai-att.img { border-color: rgba(120, 119, 255, 0.45); color: var(--accent); }
.ai-att .ic { flex: none; opacity: .75; }
.ai-att-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }
.ai-att-x { display: grid; place-items: center; width: 18px; height: 18px; border: none; border-radius: 50%; background: var(--surface3); color: var(--muted); cursor: pointer; padding: 0; }
.ai-att-x:hover { background: var(--danger-soft); color: var(--danger); }
.ai-input { flex: 1; min-width: 180px; resize: none; max-height: 140px; min-height: var(--tap); background: var(--surface); border: 1px solid var(--border2); border-radius: 10px; padding: 9px 11px; font: inherit; font-size: var(--fs-body); color: var(--text); }
.ai-input:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.ai-send { width: var(--tap); height: var(--tap); flex: none; border-radius: 12px; border: none; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; cursor: pointer; transition: filter .15s, transform .1s; }
.ai-send:hover { filter: brightness(1.1); }
.ai-send:active { transform: scale(.94); }
.ai-send[disabled] { opacity: .5; cursor: not-allowed; }
.icon-btn.on { color: var(--violet); background: var(--violet-soft); }
.icon-btn.listening { color: var(--danger); background: var(--danger-soft); animation: micPulse 1.3s infinite; }
.ai-err { color: var(--danger); font-size: 12.5px; background: var(--danger-soft); border-radius: 10px; padding: 8px 11px; line-height: 1.45; }

/* ---------- motion / UX ---------- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
#content > * { animation: fadeUp .34s ease both; }
/* Red de seguridad (APK): si la WebView no llega a correr fadeUp (bug
   conocido: no pinta hasta el primer toque), la entrada se desactiva y el
   contenido queda VISIBLE — nunca "congelado" a opacity 0. */
#content.no-anim > * { animation: none; }
#content > :nth-child(2) { animation-delay: .05s; }
#content > :nth-child(3) { animation-delay: .1s; }
#content > :nth-child(4) { animation-delay: .15s; }
#content > :nth-child(5) { animation-delay: .2s; }
#content > :nth-child(6) { animation-delay: .25s; }
.kpi, .site-card, .box-card, .artist-card, .dist-card, .agent-card { transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease; }
.kpi:hover, .site-card:hover, .box-card:hover, .artist-card:hover, .dist-card:hover, .agent-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.nav-item { transition: background .15s ease, color .15s ease; }
.tab { transition: color .15s ease, border-color .2s ease; }
@keyframes livePulse { 0%, 100% { opacity: 1; } 50% { opacity: .5; } }
.badge.b-run { animation: livePulse 2.4s ease-in-out infinite; }
@keyframes msgIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes typingDot { 0%, 60%, 100% { transform: none; opacity: .4; } 30% { transform: translateY(-4px); opacity: 1; } }
@keyframes micPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(232, 105, 117, .35); } 50% { box-shadow: 0 0 0 6px rgba(232, 105, 117, 0); } }

/* ---------- mobile / responsive ---------- */
@media (max-width: 940px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "main"; }
  .app.side-collapsed { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 272px; z-index: 70;
    transform: translateX(-103%); transition: transform .2s;
  }
  .app.side-open .sidebar { transform: none; box-shadow: var(--shadow); }
  .side-backdrop { position: fixed; inset: 0; background: var(--overlay); z-index: 65; }
  /* Red de seguridad: el backdrop solo existe mientras el drawer está
     abierto. Aunque algún camino lo dejara huérfano (p. ej. el router
     cerrando el drawer), aquí NO se renderiza — la pantalla no queda
     oscurecida/bloqueada "hasta que toca". */
  #app:not(.side-open) ~ #side-backdrop { display: none; }
  .icon-btn.hamburger { display: inline-grid; }
  .main { padding: 14px 14px 60px; }
  /* sin barra de scroll gris/blanca flotando sobre el tema oscuro (la
     navegación es por gesto; la barra del sistema solo ensucia la UI) */
  .main { scrollbar-width: none; }
  .main::-webkit-scrollbar { width: 0; height: 0; }
  .tb-right .tb-pill.hide-tablet { display: none; }
  .kpi-value { font-size: 22px; }
  .rack { grid-template-columns: repeat(auto-fit, minmax(64px, 1fr)); }
  .kv-row { grid-template-columns: 130px 1fr; }
  .bar-row { grid-template-columns: 70px 1fr 62px; }
  .ai-msg { max-width: 94%; }
  .ai-chat { height: calc(100vh - 330px); min-height: 380px; }
  .ai-note { display: none; }
  .ai-steps { grid-template-columns: 1fr; }
  /* targets táctiles ≥44px (solo en layout táctil; desktop >940 intacto) */
  .btn { min-height: 44px; }
  .btn-sm { min-height: 38px; }
  .nav-item { min-height: 44px; }
  .icon-btn { width: 44px; height: 44px; }
  .tab { min-height: 44px; }
  .avatar { width: var(--tap); height: var(--tap); }
  /* drawer: label legible 14–15px + ruta activa FUERTE (fondo accent + barra) */
  .nav-item { font-size: 14.5px; gap: 11px; }
  .nav-item.active { background: rgba(91, 140, 255, 0.20); font-weight: 700; }
  .nav-item.active::before { top: 4px; bottom: 4px; width: 4px; }
  /* footer del drawer (PROD + colapsar): solo desktop — en móvil estorba
     y "colapsar" no aplica (el drawer ya es overlay) */
  .side-foot { display: none; }
  .nav { overscroll-behavior: contain; padding-bottom: 24px; }
  /* live: teclas táctiles ≥44px (antes 32px) */
  .live-key { min-width: 44px; height: 44px; padding: 0 12px; font-size: 14px; }
}
@media (max-width: 560px) {
  .rack { grid-template-columns: repeat(auto-fit, minmax(56px, 1fr)); }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-actions .btn { flex: 1; justify-content: center; }
  .search-box { max-width: none; }
  .topbar { padding: 0 10px; gap: 4px; }
  .tb-right { gap: 6px; }
  .tb-status { font-size: 11px; padding: 4px 9px; }
  /* la topbar de 360px no alcanza para todo: en xs el status dice "API"
     (el texto largo va en .tb-st-long) y el toggle de tema se oculta */
  .tb-st-long, .hide-xs { display: none !important; }
  /* TOPBAR XS LIMPIA (lote 1): solo ☰ + título de la página + avatar.
     Sin buscador, sin pastilla API, sin campana, sin X de sesión, sin pills */
  .topbar { flex-wrap: nowrap; }
  .tb-title {
    display: block; flex: 1 1 auto; min-width: 0;
    font-size: 15px; font-weight: 800; letter-spacing: 0.01em;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .search-box, .tb-status, .tb-pill { display: none !important; }
  /* la página NUNCA hace scroll horizontal en móvil (las tablas scrollean
     dentro de su .table-wrap) */
  .main { overflow-x: hidden; }
  /* tablas: scroll dentro de la card + 1ª col sticky (checkbox/alias) */
  .table-wrap { max-width: 100%; }
  .table-wrap .dt th:first-child,
  .table-wrap .dt td:first-child {
    position: sticky; left: 0; z-index: 1;
    background: var(--bg);
    box-shadow: 1px 0 0 var(--border);
  }
  .card .table-wrap .dt th:first-child,
  .card .table-wrap .dt td:first-child { background: var(--surface); }
  .dt .row:hover td:first-child { background: var(--surface2); }
  .dt .row.sel td:first-child { background: var(--accent-soft); }
  /* refuerzo zebra sobre sticky de 1ª col */
  .table-wrap .dt tr:nth-child(even):not(.sel):not(:hover) td:first-child { background: var(--surface2); }
  .table-wrap .dt th:first-child { z-index: 3; }
  .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { padding: 10px 11px; }
  .table-wrap table.dt { font-size: 13px; }
  .modal-actions { flex-direction: column; }
  .modal-actions .btn { width: 100%; justify-content: center; }
  .drawer-foot .btn { flex: 1; justify-content: center; }
  /* Bug 8: importar CSV en móvil — label corto "CSV" + input full-width
     dentro de la card (el native "Choose File" de 260px se salía/estorbaba) */
  .csv-file { width: 100%; gap: 8px; }
  .csv-file .csv-lbl-long { display: none; }
  .csv-file .csv-lbl-short { display: inline; }
  .csv-file-inp { flex: 1; max-width: none; width: 100%; }
  .toast-wrap { left: 8px; right: 8px; max-width: none; top: 56px; }
  .live-frame { max-width: 100%; padding: 8px 8px 6px; }
  .live-screen { max-height: min(70vh, 720px); }
  /* live: filas de teclas en wrap limpio — nada cortado, sin scroll X */
  .live-nav { flex-wrap: wrap; row-gap: 8px; }
  .live-extra { gap: 8px; }
  .live-top { gap: 4px 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- Live player (Flota — Live + ficha dispositivo) ---------- */
/* min-width:0 + width:100% — como flex-item, min-width:auto dejaba que el
   contenido nowrap (.live-top) fijara un ancho mín. MAYOR que el viewport:
   la página scrolleaba en X y las teclas se cortaban a los lados. */
.live-player { display: flex; flex-direction: column; gap: 10px; min-width: 0; width: 100%; }
/* v11: NUNCA wrap — un texto largo en el badge/meta bajaba el marco del
   teléfono en cada clic ("la página se mueve"). Una sola línea + ellipsis. */
.live-top {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px 14px;
  align-items: baseline;
  justify-content: space-between;
  min-height: 20px;
}
.live-st {
  min-height: 18px;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.live-meta {
  color: var(--muted);
  min-width: 0;
  flex: 0 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
  max-width: 48%;
}
/* Feedback de RTT: ✓ breve en acento (pulso corto, sin reflow — nowrap
   y ellipsis de arriba intactos) / warn en ámbar si ctl falla o expira. */
.live-meta.ok {
  color: var(--accent);
  animation: metaOkPulse 0.5s ease;
}
.live-meta.warn { color: var(--warn); }
@keyframes metaOkPulse {
  0% { opacity: 0.35; }
  45% { opacity: 1; }
  100% { opacity: 1; }
}

.live-frame {
  position: relative;
  background: var(--frame-ink);
  border: 1px solid var(--border2);
  border-radius: 22px;
  padding: 10px 10px 6px;
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(255,255,255,0.03);
  max-width: 420px;
  margin: 0 auto;
  outline: none;
  /* El marco entero no genera pan/zoom del contenedor al tocar
     (igual que Flota Live): en la ficha de Dispositivos un arrastre
     mínimo scrolleaba .main y el gesto se leía como swipe al teléfono. */
  touch-action: none;
  overscroll-behavior: contain;
}
.live-frame.compact { max-width: 100%; border-radius: 16px; padding: 6px 6px 4px; }
/* outline sin offset: no "salta" visualmente al enfocar con el clic */
.live-frame:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; }
.live-frame.live { border-color: rgba(52,199,143,0.45); }

.live-screen {
  position: relative;
  background: #000;
  border-radius: 14px;
  overflow: hidden;
  aspect-ratio: 9 / 19.5;
  max-height: min(68vh, 720px);
  touch-action: none;
  overscroll-behavior: contain;
}
.live-frame.compact .live-screen { max-height: 320px; aspect-ratio: 9/16; }

.live-video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  cursor: crosshair;
  touch-action: none;
  background: #000;
}

/* Overlay del cambio recién aplicado (ctl-snap): se pinta encima del vídeo
   y se apaga — el usuario VE el resultado del botón sin esperar al H.264. */
.live-flash {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  pointer-events: none;
  /* 0.08: el snap ya pinta tras decode; un fade de 0.2s retrasaba la
     aparición percibida del overlay (se sentía como clic lento). */
  transition: opacity 0.08s ease;
  z-index: 3;
  /* v8: NUNCA #000 — si el <img> se pinta antes del decode o se apaga sobre
     vídeo viejo, el fondo negro se leía como "parpadea a negro". */
  background: transparent;
}
.live-flash.on {
  opacity: 1;
}

/* Feedback en t=0 (misc): marcador/onda del toque sobre .live-frame.
   pointer-events: none — nunca roba el toque al vídeo (camino de clic v12c
   intacto). Opacidad corta: aparece y se va; el MSE sigue siendo el camino. */
.live-tap,
.live-ripple {
  position: absolute;
  z-index: 4;
  pointer-events: none;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}
.live-tap {
  width: 36px;
  height: 36px;
  background: rgba(91, 140, 255, 0.2);
  border: 2px solid rgba(91, 140, 255, 0.9);
  animation: tapPop 0.4s ease-out forwards;
}
.live-ripple {
  width: 64px;
  height: 64px;
  border: 2px solid rgba(91, 140, 255, 0.55);
  animation: tapRippleOut 0.5s ease-out forwards;
}
@keyframes tapPop {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(0.55); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1); }
}
@keyframes tapRippleOut {
  0% { opacity: 0.85; transform: translate(-50%, -50%) scale(0.3); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.1); }
}

.live-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  pointer-events: none;
  background:
    radial-gradient(ellipse at center, rgba(91,140,255,0.08), transparent 65%),
    repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(255,255,255,0.02) 2px, rgba(255,255,255,0.02) 4px);
}

.live-ov {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(8, 12, 22, 0.72);
  border: 1px solid rgba(255,255,255,0.08);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text2);
  backdrop-filter: blur(6px);
  pointer-events: none;
}
.live-ov .live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted);
  box-shadow: none;
}
.live-ov.on { color: #fff; }
.live-ov.on .live-dot {
  background: #ff3b4a;
  box-shadow: 0 0 0 0 rgba(255,59,74,0.55);
  animation: live-pulse 1.2s ease-out infinite;
}
.live-ov.on .live-ov-txt { color: #ff6b75; }
.live-ov-dev {
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@keyframes live-pulse {
  0% { box-shadow: 0 0 0 0 rgba(255,59,74,0.55); }
  70% { box-shadow: 0 0 0 8px rgba(255,59,74,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,59,74,0); }
}

.live-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 4px 4px;
}
.live-nav-gap { flex: 0 0 12px; }
.live-key {
  appearance: none;
  border: 1px solid var(--border2);
  background: var(--surface2);
  color: var(--text2);
  border-radius: 999px;
  min-width: var(--tap);
  height: var(--tap);
  padding: 0 14px;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.live-key:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text);
}
.live-key:active,
.live-key.is-press {
  transform: translateY(1px);
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.live-extra {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}
.live-single { display: flex; justify-content: center; min-width: 0; }
/* Bug 5: la fila de texto queda ANCLADA al fondo del área de scroll —
   enfocar el campo NUNCA scrollea .main (el salto de foco dejaba el marco
   cortado bajo la topbar y "toda la app" parecía moverse). La fila flota
   sobre el contenido y el marco se queda donde estaba.
   Solo en Flota Live (.live-single): dentro de la card de Dispositivos el
   sticky + foco movían el marco al tocar ("se mueve todo el teléfono"). */
.live-single .live-text-row {
  position: sticky;
  bottom: 0;
  z-index: 6;
  background: var(--bg);
  padding: 6px 0 2px;
}
.live-text-row {
  background: var(--bg);
  padding: 6px 0 2px;
}
.live-tile {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 6px;
  background: var(--surface);
  min-width: 0;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.live-tile.focused {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 8px 24px rgba(91,140,255,0.18);
}

/* ---------- Muro (Flota Live) — frames JPEG de GET /wall ----------
   Prefijo .wall-*: no toca nada de .live-* (visor/grid intactos).
   v12i: toolbar sticky, paginación, densidad y overlay de detalle —
   pensado para miles de placas (DOM acotado a la página visible). */
.wall-toolbar {
  position: sticky;
  top: 0;
  z-index: 8;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 12px;
  box-shadow: 0 4px 16px var(--shadow-ink);
}
.wall-search {
  flex: 1 1 200px;
  min-width: 150px;
  max-width: 340px;
  width: auto;
  padding: 10px 12px;
  font-size: 14px;
  min-height: var(--tap);
}
.wall-sel {
  width: auto;
  min-width: 118px;
  max-width: 190px;
  padding: 10px 12px;
  font-size: 14px;
  min-height: var(--tap);
}
.wall-fl {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text2);
  cursor: pointer;
}
.wall-tb-gap {
  flex: 0 0 auto;
  width: 1px;
  height: 22px;
  background: var(--border);
}
.wall-count {
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text2);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  white-space: nowrap;
}
.wall-msg { margin-bottom: 8px; }
.wall-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 10px;
}
.wall-grid.comfy {
  grid-template-columns: repeat(auto-fill, minmax(216px, 1fr));
  gap: 12px;
}
.wall-cell {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 6px;
  background: var(--surface);
  min-width: 0;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.wall-cell:hover { border-color: var(--accent); }
.wall-cell:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.wall-cell.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 8px 24px rgba(91,140,255,0.18);
}
.wall-img {
  display: block;
  width: 100%;
  aspect-ratio: 9 / 16;
  object-fit: contain;
  background: #000;
  border-radius: 8px;
}
.wall-ph {
  display: none;
  position: absolute;
  left: 6px;
  right: 6px;
  top: 6px;
  aspect-ratio: 9 / 16;
  place-items: center;
  text-align: center;
  padding: 8px;
  background: var(--surface2);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12.5px;
}
.wall-cell.noframe .wall-ph { display: grid; }
.wall-cell.noframe .wall-img { visibility: hidden; }
/* Stale: conserva la última foto (no tile negro) con badge de aviso */
.wall-cell.stale .wall-img { opacity: 0.72; }
.wall-cell.stale .wall-ph { display: none; }
.wall-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  margin-top: 6px;
}
.wall-label {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.wall-pick {
  display: flex;
  gap: 4px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 12.5px;
  cursor: pointer;
}
.wall-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
}
.wall-pg-info {
  font-variant-numeric: tabular-nums;
  min-width: 64px;
  text-align: center;
}

/* Detalle al clic = overlay: el grid y su scroll quedan intactos debajo */
.wall-detail {
  position: fixed;
  inset: 0;
  z-index: 85;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--overlay);
}
.wall-detail.open { display: flex; }
.wall-detail-panel {
  width: min(560px, 100%);
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}
.wall-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.wall-detail-title {
  font-size: 15px;
  font-weight: 700;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wall-detail-sub {
  font-size: 12.5px;
  color: var(--muted);
}
.wall-detail-body {
  padding: 14px;
  overflow-y: auto;
  min-width: 0;
}
