/* ============================================================
   VARIABLES — TEMA OSCURO (default)
============================================================ */
:root {
    --bg:        #050816;
    --bg2:       #080d1e;
    --bg3:       #0c1228;
    --bg4:       #111827;
    --bg-pill:   rgba(255,255,255,0.03);
    --bg-input:  rgba(255,255,255,0.06);
    --hover-bg:  rgba(0,178,255,0.05);
    --blue:      #00B2FF;
    --cyan:      #00E5FF;
    --blue-dim:  #0077b6;
    --blue-dark: #00182e;
    --blue-glow: rgba(0,178,255,0.18);
    --blue-glow2:rgba(0,178,255,0.35);
    --red:       #FF3B3B;
    --orange:    #FF8C00;
    --green:     #00E676;
    --yellow:    #FFD600;
    --text:      #EAF6FF;
    --text-dim:  #7A8CA5;
    --text-muted:#3a4f66;
    --border:    rgba(0,178,255,0.12);
    --border2:   rgba(0,178,255,0.28);
    /* Dot inactivo del carrusel (Última detección) — mismo valor que ya
       tenía .hud-dot hardcodeado, para que el modo oscuro no cambie. */
    --dot-inactive: rgba(255,255,255,0.18);
    --sidebar-w: 220px;
    --topbar-h:  51px;
    /* Safe area — Android notch/cámara. env() es cero en browsers sin notch.  */
    --safe-top:    env(safe-area-inset-top,    0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --font:      'Inter', system-ui, sans-serif;
    --mono:      'JetBrains Mono', monospace;
    --radius:    10px;
    --radius-sm: 6px;
    --transition: 0.2s cubic-bezier(0.4,0,0.2,1);
}

/* ============================================================
   VARIABLES — TEMA CLARO
   Redefine el mismo set de variables del :root oscuro. --green,
   --red y --orange se mantienen igual porque ya contrastan bien
   sobre fondo blanco. Se extendieron --blue-dim/--blue-dark/
   --blue-glow2 (no listadas en el spec original) porque el resto
   del stylesheet ya las consume (scrollbars, glows secundarios) y
   dejarlas en sus valores oscuros se vería apagado sobre fondo claro.
============================================================ */
html[data-theme="light"] {
    --bg:        #F4F7FC;
    --bg2:       #FFFFFF;
    --bg3:       #E8EFF9;
    --bg4:       #DFE7F2;
    --bg-pill:   var(--bg3);
    --bg-input:  var(--bg3);
    --hover-bg:  rgba(0,136,204,0.06);
    --blue:      #0088CC;
    --cyan:      #00A3B8;
    --blue-dim:  #0077b6;
    --blue-dark: #C9DCEC;
    --blue-glow: rgba(0,136,204,0.08);
    --blue-glow2:rgba(0,136,204,0.18);
    --border:    rgba(0,136,204,0.10);
    --border2:   rgba(0,136,204,0.22);
    --text:      #0F172A;
    --text-dim:  #475569;
    --text-muted:#94A3B8;
    /* Dot inactivo del carrusel — el rgba(255,255,255,...) del modo
       oscuro es casi invisible sobre el fondo claro de la tarjeta.
       --text-muted ya está calibrado en este mismo bloque para
       contrastar bien sobre blanco — mismo criterio, sin color fijo. */
    --dot-inactive: var(--text-muted);
}

/* Transición suave global al cambiar de tema — solo color, sin afectar
   layout/lag (ningún transform ni propiedad costosa de repintar). */
body,
.sidebar,
.card,
.section {
    transition: background-color 0.25s ease, border-color 0.25s ease, color 0.2s ease;
}



/* ============================================================
   RESET
============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; background: var(--bg); }
body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    min-height: 100%;
    overflow-x: hidden;
    /* Empujar toda la app debajo de la barra del sistema Android */
    padding-top: var(--safe-top);
    /* Reserva inferior: solo safe-bottom — con el layout acotado (.main
       height fija + scroll en .content) la barra de navegación ya no puede
       tapar contenido; el colchón extra de +50px de la era del documento-
       que-scrollea era franja muerta y se recuperó para el contenido. */
    padding-bottom: var(--safe-bottom);
}
a { cursor: pointer; text-decoration: none; }
button { cursor: pointer; font-family: var(--font); }

/* ============================================================
   LAYOUT
============================================================ */
.sidebar {
    position: fixed;
    top: var(--safe-top); left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--bg2);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform var(--transition);
}

.main {
    margin-left: var(--sidebar-w);
    /* Altura acotada al viewport real, restando el mismo padding-top/
       padding-bottom que body ya aplica (safe-top arriba, safe-bottom+50px
       abajo) — así el total (padding body + esta altura) da exactamente
       100vh. body no se toca en absoluto: con esta cuenta exacta, su
       altura natural ya no excede el viewport.
       Reemplaza el min-height:100% anterior, que no hacía nada (percentage
       height contra un ancestro sin altura explícita se trata como no
       especificado — confirmado en la auditoría).
       overflow:hidden — red de seguridad física: la matemática de arriba
       es correcta, pero .content es quien realmente tiene que contener
       su contenido (overflow-y:auto). Si algo se desborda de .content
       por cualquier motivo, esto evita que escape hacia .main y de ahí
       hacia body/html, reactivando el scroll de documento completo
       (visto en secciones largas como Zonas/Configuración). */
    height: calc(100vh - var(--safe-top) - var(--safe-bottom));
    /* Fallback → fix real: 100vh no se recalcula de forma confiable en
       WebView Android cuando el teclado virtual aparece/desaparece,
       dejando .main con una altura vieja mientras el viewport real ya
       cambió — eso es lo que dejaba el hueco vacío al entrar a una
       pantalla que dispara foco/teclado. dvh (dynamic viewport height)
       es soporte nativo del navegador pensado exactamente para esto, no
       un hack de compositor — se recalcula solo cuando cambia el
       viewport visible. Navegadores sin soporte simplemente ignoran esta
       línea y se quedan con el cálculo en vh de arriba. */
    height: calc(100dvh - var(--safe-top) - var(--safe-bottom));
    /* overflow:hidden (ambos ejes) ELIMINADO — bloqueaba el gesto táctil
       de scroll vertical hacia .content en todas las secciones excepto
       Lugares Conocidos.
       overflow-x:hidden — Lugares Conocidos es la única sección que
       fuerza una tabla con table-layout:fixed siempre visible en móvil
       (#sec-lugares .nom-table-wrap{display:block!important}); sin
       contención horizontal acá, esa tabla puede desbordar hacia los
       lados.
       Nota: esto deja overflow-y computado en "auto" — la spec de CSS
       Overflow promueve CUALQUIER "visible" a "auto" si el otro eje no
       es visible/clip, sin importar si "visible" es explícito o el
       default (ya lo probamos: declarar overflow-y:visible a mano NO
       evita esto, es una combinación imposible). Confirmado inofensivo
       acá: .main nunca tiene overflow vertical propio real (su altura ya
       es exacta por la fórmula de arriba), así que ese "auto" nunca
       activa nada — a diferencia de #sec-lugares y .nom-table-wrap, que
       SÍ se veían afectados por esto mismo (ya corregidos quitándoles su
       overflow-x propio, ya que .content/.main alcanzan para contener lo
       horizontal sin que cada hijo lo redeclare). */
    overflow-x: hidden;
    position: relative;   /* ancla para .content en position:absolute */
    display: flex;
    flex-direction: column;
    transition: margin var(--transition);
}

/* ============================================================
   SIDEBAR
============================================================ */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 16px;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-icon {
    font-size: 1.2rem;
    color: var(--cyan);
    text-shadow: 0 0 12px var(--cyan);
}

.logo-text {
    font-family: var(--mono);
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    color: var(--text);
}

.logo-accent {
    color: var(--blue);
    text-shadow: 0 0 10px rgba(0,178,255,0.5);
}

.sidebar-close {
    display: none;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1rem;
    padding: 4px 8px;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition);
    position: relative;
}

.nav-item:hover {
    background: var(--blue-glow);
    color: var(--text);
}

.nav-item.active {
    background: linear-gradient(90deg, var(--blue-glow2), var(--blue-glow));
    color: var(--blue);
    border: 1px solid var(--border2);
}

.nav-item.active .nav-icon { text-shadow: 0 0 10px var(--cyan); }

.nav-icon {
    font-size: 1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.nav-badge {
    margin-left: auto;
    background: var(--blue);
    color: #000;
    border-radius: 10px;
    padding: 1px 7px;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sf-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sf-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
    transition: background 0.5s, box-shadow 0.5s;
}

.sf-dot.online  { background: var(--green); box-shadow: 0 0 8px var(--green); animation: sfPulse 2s ease-in-out infinite; }
.sf-dot.connect { background: var(--blue); box-shadow: 0 0 8px var(--blue); animation: sfBlink 1s step-end infinite; }
.sf-dot.recovering { background: var(--blue); box-shadow: 0 0 8px var(--blue); animation: sfBlink 1s step-end infinite; }

@keyframes sfPulse { 0%,100% { box-shadow: 0 0 8px var(--green); } 50% { box-shadow: 0 0 16px var(--green), 0 0 24px rgba(0,230,118,0.3); } }
@keyframes sfBlink { 0%,100% { opacity:1 } 50% { opacity:0.3 } }

.sf-label {
    font-family: var(--mono);
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    color: var(--text-dim);
}

.sf-clock {
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

.sf-version {
    font-family: var(--mono);
    font-size: 0.62rem;
    color: var(--text-muted);
    opacity: 0.5;
    margin-left: 6px;
    user-select: none;
    -webkit-user-select: none;
}

/* ============================================================
   BLOQUE DE CUENTA — pie del sidebar, debajo de sidebar-footer.
   Clic navega a Configuración → tarjeta de licencia (ver app.js).
============================================================ */
.sidebar-account {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 16px;
    border: none;
    border-top: 1px solid var(--border);
    background: none;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s;
}

.sidebar-account:hover {
    background: var(--bg3);
}

.sidebar-account-avatar {
    position: relative;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    flex-shrink: 0;
    overflow: hidden;
    background: var(--bg3);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-account-foto {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
}

.sidebar-account-inicial {
    font-family: var(--mono);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-dim);
}

.sidebar-account-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;   /* permite que el email largo trunque en vez de desbordar */
    flex: 1;
}

.sidebar-account-nombre {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-account-email {
    font-family: var(--mono);
    font-size: 0.66rem;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 99;
    backdrop-filter: blur(2px);
}

/* ============================================================
   TOPBAR
============================================================ */
.topbar {
    /* Con la Fase 1 (.main de altura acotada), .topbar es un hijo flex
       normal — ya no necesita compensar el safe-area por su cuenta: body
       (línea 92) ya empuja todo .main, .topbar incluida, hacia abajo
       exactamente safe-top una vez. El height/padding-top que tenía acá
       antes duplicaba ese mismo espacio — quitado. */
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px;
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    padding: 4px;
}

.hamburger span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text-dim);
    border-radius: 2px;
    transition: all var(--transition);
}

.topbar-title {
    font-weight: 600;
    font-size: 1rem;
    line-height: 1;
    color: var(--text);
    flex: 1;
    /* Causa confirmada del hueco/clicks interceptados en "Editar zona" y
       "Editar nomenclatura": .topbar tiene height fija (--topbar-h,
       56px) que NO crece con el contenido. Un título de 2 palabras en
       pantalla angosta envolvía a 2 líneas, desbordando el topbar hacia
       abajo — como .topbar tiene z-index:100 (muy por encima de
       .section.active, z-index:1), ese desborde tapaba visualmente el
       inicio de la sección Y capturaba los toques que el usuario veía
       dirigidos a los botones de más abajo. Título de una sola línea,
       con elipsis si no cabe — nunca vuelve a envolver, sin importar
       cuán largo sea un título futuro. No toca position/height/overflow
       de .main/.content, no es un hack de compositor. */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* Oculto únicamente en Dashboard — libera espacio para los toggles de
   la topbar. Reutiliza el mismo :has() ya usado en este archivo
   (.content:has(#sec-dashboard.active)) sobre el estado .active que
   goTo() ya gestiona — sin ningún cambio de JS. En el resto de
   secciones #topbarTitle sigue mostrando su título normalmente. */
body:has(#sec-dashboard.active) #topbarTitle {
    display: none;
}

/* Indicador CONECTADO/PAUSADO — oculto únicamente en Dashboard. En el
   resto de secciones sigue visible exactamente como siempre (sin
   ninguna regla adicional necesaria — el default ya lo muestra). */
body:has(#sec-dashboard.active) #waPill {
    display: none;
}

.topbar-grupos-wa {
    display: none;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
    overflow-x: auto;
}
body:has(#sec-dashboard.active) .topbar-grupos-wa {
    display: flex;
}
.grupo-wa-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
    cursor: pointer;
    opacity: 1;
    transition: opacity 0.15s;
}
.grupo-wa-item.inactivo {
    opacity: 0.45;
}
.grupo-wa-avatar-wrap {
    position: relative;
    width: 30px;
    height: 30px;
}
.grupo-wa-avatar-wrap img,
.grupo-wa-avatar-wrap > div {
    border: 2px solid var(--border) !important;
}
.grupo-wa-item.activo .grupo-wa-avatar-wrap img,
.grupo-wa-item.activo .grupo-wa-avatar-wrap > div {
    border-color: #00E676 !important;
}
.grupo-wa-item.inactivo .grupo-wa-avatar-wrap img,
.grupo-wa-item.inactivo .grupo-wa-avatar-wrap > div {
    border-color: var(--text-muted) !important;
    filter: grayscale(0.8);
}
.grupo-wa-label {
    font-family: var(--mono);
    font-size: 0.55rem;
    letter-spacing: 0.03em;
    color: var(--text-dim);
    max-width: 46px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============================================================
   TOPBAR — TOGGLES RÁPIDOS
   (Auto-Pausa / Modo Guerra / Botón flotante — reubicados desde
   el dashboard, ahora a la izquierda de la píldora de WhatsApp)
============================================================ */
.topbar-quick-toggles {
    display: none;
    align-items: center;
    gap: 15px;
    flex-shrink: 0;
}
/* Visible únicamente en Dashboard — en el resto de secciones del menú
   lateral (Configuración, Auto-Pausa, Lugares Conocidos, Modo Guerra,
   OCR, etc.) permanece oculto. Mismo :has() ya usado en este archivo. */
body:has(#sec-dashboard.active) .topbar-quick-toggles {
    display: flex;
}
/* Solo en Dashboard (título oculto arriba) el grupo se empuja hacia la
   derecha, pegado a la píldora de WhatsApp — margin-left:auto consume
   el espacio libre SIN forzar el ancho del grupo (a diferencia de
   flex:1, que expandía el contenedor más allá de su contenido real y
   permitía que los botones — flex-shrink:0 — se desbordaran hacia la
   izquierda, invadiendo la zona del hamburguesa). El hamburguesa
   conserva su espacio propio siempre, como hermano flex anterior fijo.
   En el resto de secciones, el título (flex:1) sigue empujando el
   grupo hacia la derecha exactamente como siempre. */
body:has(#sec-dashboard.active) .topbar-quick-toggles {
    margin-left: auto;
}

.wa-status-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--bg3);
    font-family: var(--mono);
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    color: var(--text-dim);
    transition: all 0.5s;
}

.wa-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: all 0.5s;
}

.wa-status-pill.online  { border-color: rgba(0,230,118,0.4); color: var(--green); }

.wa-status-pill.online .wa-dot { background: var(--green); box-shadow: 0 0 6px var(--green); }
.wa-status-pill.paused  { border-color: rgba(255,140,0,0.4); color: var(--orange); }
.wa-status-pill.paused .wa-dot { background: var(--orange); box-shadow: 0 0 6px var(--orange); animation: sfBlink 1.2s step-end infinite; }
.wa-status-pill.connect { border-color: rgba(0,178,255,0.4); color: var(--blue); }
.wa-status-pill.connect .wa-dot { background: var(--blue); }
.wa-status-pill.recovering { border-color: rgba(0,178,255,0.4); color: var(--blue); }
.wa-status-pill.recovering .wa-dot { background: var(--blue); box-shadow: 0 0 6px var(--blue); animation: sfBlink 1s step-end infinite; }

/* ============================================================
   CONTENT / SECTIONS
============================================================ */
.content {
    /* OPCIÓN NUCLEAR — abandona flex para la altura de .content. Anclado
       físicamente a los bordes de .main (que ahora es position:relative)
       en vez de depender de ningún cálculo de flex-basis/altura, que el
       WebView venía ignorando en secciones muy altas (Configuración).
       top = lo que mide .topbar (ya no es un hermano flex de .content,
       así que hay que restarlo a mano); bottom:0 estira hasta el borde
       físico inferior de .main. Geométrico, no depende de que el motor
       "adivine" nada. */
    position: absolute;
    top: var(--topbar-h, 56px);
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px;
    overflow-x: hidden;
    overflow-y: auto;   /* .content sigue siendo el único scroll container del dashboard */
}

/* Dashboard: el padding-top de 20px de .content (arriba) deja un hueco
   notoriamente más grande entre el header y la primera tarjeta que el
   gap:10px que .dash-grid ya usa entre tarjetas. Se acota SOLO el
   padding-top, SOLO cuando el dashboard está activo — izquierda/derecha/
   abajo de .content quedan en 20px sin cambios, y ninguna otra sección
   (Configuración, Restaurantes, etc.) se ve afectada. No toca el tamaño
   ni el padding interno de ninguna tarjeta.
   6px a propósito — POR DEBAJO del gap:10px entre tarjetas (ver
   .dash-grid), no igual ni por encima: el pedido explícito es que el
   hueco header→primera tarjeta quede ligeramente MENOR que el hueco
   entre tarjetas, no el mismo ritmo. */
.content:has(#sec-dashboard.active) {
    padding-top: 6px;
}

/* Título de la topbar — oculto únicamente en Dashboard, para liberar
   espacio a favor de los íconos de acción. Reutiliza el mismo patrón
   :has() de arriba; .main es el ancestro común de .topbar y .content,
   así que reacciona a la misma clase .active que goTo() ya pone en la
   sección activa — sin tocar esa función ni ninguna lógica JS. */
.main:has(#sec-dashboard.active) .topbar-title {
    display: none;
}

.section { display: none; }
.section.active {
    display: block;
    animation: fadeIn 0.2s ease;
    /* Mismo fix que .btn-primary/select, aplicado al contenedor de la
       sección activa en vez de elemento por elemento — cubre de una sola
       vez todo lo que vive adentro (botones, íconos de editar/eliminar,
       inputs de búsqueda, listas con scroll propio) contra la
       desincronización visual/hit-test del compositor de este WebView.
       También evita que la sección quede "despromovida" de su capa
       propia una vez que termina la animación fadeIn (que sí promueve
       una capa temporal via transform, pero solo mientras anima). */
    position: relative;
    z-index: 1;
}

@keyframes fadeIn { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:translateY(0); } }

/* ============================================================
   CARDS
============================================================ */
.card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.card:hover { border-color: var(--border2); }

.card-label {
    font-family: var(--mono);
    font-size: 0.62rem;
    letter-spacing: 0.18em;
    color: var(--text-dim);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-label::before {
    content: '';
    display: inline-block;
    width: 3px;
    height: 12px;
    background: var(--blue);
    border-radius: 2px;
    box-shadow: 0 0 6px var(--blue);
}

/* ============================================================
   DASHBOARD GRID
============================================================ */
/* El dashboard llena el 100% de .content (posible: .content tiene altura
   definida) — la fila de Actividad Reciente (1fr) absorbe todo el espacio
   restante en vez de dejar hueco muerto. Mismo patrón que #sec-logs. */
#sec-dashboard.active {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.dash-grid {
    /* EXPERIMENTO AISLADO — reemplaza flex:1;min-height:0 por height:100%.
       .dash-grid era simultáneamente ítem flex (de #sec-dashboard.active,
       que sigue siendo display:flex) Y contenedor grid — con height:100%
       en vez de flex, resuelve su tamaño de forma directa, sin depender
       del algoritmo de flex-grow. Único cambio de este experimento — todo
       lo demás de esta regla queda igual. Si el bug desaparece, confirma
       la hipótesis del empalme flex→grid; si persiste, queda descartada. */
    height: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    /* minmax(0,1fr) en vez de 1fr solo: un track 1fr sin límite tiene
       mínimo implícito basado en el contenido ("auto"), que fluctúa
       mientras el terminal de logs carga contenido async — causaba que
       .card--quicklogs se corriera de a poco hacia arriba, aun con
       .content/.main y las otras dos cards ya confirmadas estables. */
    grid-template-rows: auto minmax(0, 1fr);
    gap: 10px;
    /* prevent any child from causing horizontal overflow */
    min-width: 0;
}

.card--status  { grid-column: 1; min-width: 0; }
.card--quickops { grid-column: 2; min-width: 0; }
.card--quicklogs {
    /* Card normal, apilada — su alto lo decide su propio contenido, no el
       grid. .quicklog (adentro) es la única pieza con scroll interno. */
    grid-column: 1 / -1; min-width: 0; margin-top: 6px;
}

/* ============================================================
   FILA RÁPIDA DE TOGGLES — ahora vive en .topbar-quick-toggles
   (Auto-Pausa / Modo Guerra / Botón flotante — solo icono)
============================================================ */
.topbar-quick-toggles .qtoggle-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* El guerra-toggle original, reducido a solo-icono dentro de esta fila.
   No se toca su lógica JS (className/active), solo se ocultan sus
   piezas de switch y se muestra el icono. */
.topbar-quick-toggles .guerra-toggle {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
    border-radius: 50%;
    transition: background var(--transition), transform var(--transition);
}
.topbar-quick-toggles .guerra-toggle:active { transform: scale(0.9); background: var(--bg3); }

.topbar-quick-toggles .gt-track,
.topbar-quick-toggles .gt-state { display: none; }

.qtoggle-icon {
    font-size: 19px;
    line-height: 1;
    display: block;
    filter: grayscale(1) opacity(0.5);
    transition: filter 0.3s;
}

/* Estados activos — color + glow propio de cada switch */
#apToggle.active .qtoggle-icon {
    filter: drop-shadow(0 0 7px rgba(0,255,255,0.85)) drop-shadow(0 0 14px rgba(0,255,255,0.45));
}
#guerraToggle.active .qtoggle-icon {
    filter: drop-shadow(0 0 7px rgba(255,59,59,0.85)) drop-shadow(0 0 14px rgba(255,59,59,0.45));
}
#overlayToggle.active .qtoggle-icon {
    filter: drop-shadow(0 0 7px rgba(0,178,255,0.85)) drop-shadow(0 0 14px rgba(0,178,255,0.45));
}

/* Campana de Modo Humano — resplandor amarillo mientras haya >=1 pedido
   pendiente en cola (independiente de si hay un bloqueador "activo" en
   el sentido de obtenerProximoBloqueador() — cualquier pendiente cuenta).
   Badge rojo superpuesto en la esquina superior derecha, estilo contador
   de WhatsApp — no ocupa espacio propio (position:absolute dentro de
   .qtoggle-wrap, que ya es position:relative), así que no descuadra el
   resto del header ni en móvil. */
#modoHumanoBtn.hay-cola .qtoggle-icon {
    filter: drop-shadow(0 0 7px rgba(255,204,0,0.9)) drop-shadow(0 0 14px rgba(255,204,0,0.5));
}
#modoHumanoBadge {
    position: absolute;
    top: -1px;
    right: -1px;
    min-width: 11px;
    height: 11px;
    padding: 0 3px;
    border-radius: 999px;
    background: var(--red);
    color: #fff;
    font-size: 0.48rem;
    font-weight: 700;
    line-height: 11px;
    text-align: center;
    box-shadow: 0 0 0 2px var(--bg2);
    pointer-events: none;
}

/* Candado de Modo Humano — mismo patrón de glow que los demás toggles,
   activado por la misma clase .active que ya aplica setModoHumanoToggle()
   (sin cambios de lógica, solo estilo). El ícono 🔒/🔓 lo alterna JS. */
#modoHumanoToggle.active .qtoggle-icon {
    filter: drop-shadow(0 0 7px rgba(255,204,0,0.9)) drop-shadow(0 0 14px rgba(255,204,0,0.5));
}

/* Popover de la cola — reemplaza visualmente el modal de pantalla
   completa. Ancho fijo dentro de .qtoggle-wrap (ya position:relative),
   así que no requiere ningún cálculo de coordenadas en JS. Clases
   propias (mh-popover-anchor/mh-popover), no tocan .modal-backdrop/.modal
   genéricas que usa el resto de los modales de la app. */
.mh-popover-anchor {
    position: absolute;
    top: calc(100% + 10px);
    right: -6px;
    z-index: 210;
}
.mh-popover {
    width: min(320px, calc(100vw - 24px));
    max-height: min(420px, 70vh);
    background: var(--bg2);
    border: 1px solid var(--border2);
    border-radius: var(--radius);
    box-shadow: 0 12px 40px rgba(0,0,0,0.45), 0 0 24px rgba(255,204,0,0.08);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    animation: mhPopoverIn 0.16s ease;
}
.mh-popover::-webkit-scrollbar { width: 4px; }
.mh-popover::-webkit-scrollbar-thumb { background: var(--blue-dark); border-radius: 2px; }
@keyframes mhPopoverIn {
    from { opacity: 0; transform: translateY(-6px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
@media (max-width: 480px) {
    .mh-popover-anchor { right: -10px; }
    .mh-popover { width: min(280px, calc(100vw - 20px)); }
}

/* Botón de ACCIÓN (no toggle) — respuesta rápida 👍. Mismo tamaño/
   espaciado que los switches de al lado, sin pista ni estado ON/OFF. */
.qtoggle-action {
    background: none;
    border: none;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    cursor: pointer;
    padding: 0;
    border-radius: 50%;
}
.qtoggle-action:active .qtoggle-icon {
    transform: scale(0.88);
}
/* Destello de confirmación — se agrega/quita por JS al enviar OK, sin
   ningún toast ni modal. */
.qtoggle-action.enviado .qtoggle-icon {
    filter: drop-shadow(0 0 7px rgba(0,230,118,0.9)) drop-shadow(0 0 14px rgba(0,230,118,0.55));
    animation: respuestaRapidaFlash 0.5s ease-out;
}
@keyframes respuestaRapidaFlash {
    0%   { transform: scale(1); }
    35%  { transform: scale(1.25); }
    100% { transform: scale(1); }
}

/* Badge de countdown Auto-Pausa — esquina del icono ⚡ */
.qtoggle-wrap .ap-timer {
    position: absolute;
    top: -4px;
    right: -12px;
    background: var(--bg2);
    border: 1px solid var(--cyan);
    border-radius: 8px;
    padding: 1px 5px;
    font-size: 0.52rem;
}

/* ============================================================
   DASHBOARD — PANEL DE OPERACIÓN RÁPIDA
   (Restaurantes por categoría / Zonas — pills táctiles premium)
   La fuente de verdad del estado sigue siendo .rest-cb.checked
   (no se toca su lógica JS); aquí solo se oculta visualmente y
   el estilo "activo/inactivo" se deriva vía :has() sobre el item.
============================================================ */
.card--quickops {
    display: flex;
    flex-direction: column;
    gap: 8px;
    height: 320px; /* Altura fija en desktop */
    overflow-y: auto;
    overflow-x: hidden;
}

.card--quickops::-webkit-scrollbar { width: 3px; }
.card--quickops::-webkit-scrollbar-thumb { background: var(--blue-dark); border-radius: 2px; }


.qops-block { min-width: 0; }

.qops-title {
    font-family: var(--mono);
    font-size: 0.62rem;
    letter-spacing: 0.14em;
    color: var(--text-dim);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.qops-title-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.qops-title-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-family: var(--mono);
    font-size: 0.6rem;
    letter-spacing: 0.04em;
    padding: 2px 6px;
    border-radius: 10px;
    cursor: pointer;
    white-space: nowrap;
}
.qops-title-btn:hover { border-color: var(--blue); color: var(--blue); }
.qops-title-btn.is-selected {
    background: var(--blue);
    border-color: var(--blue);
    color: #fff;
}

.qops-list {
    display: flex;
    flex-direction: column;
    /* max-height/overflow-y eliminados: .qops-list ya no scrollea por su
       cuenta — crece libremente, el scroll ahora vive en .card--quickops */
}

/* ── Pill base: aplica a cualquier .qops-item dentro de las listas rápidas ── */
#qopsRestList .qops-item,
#qopsZonaList .qops-item {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 20px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    background: var(--bg-pill);
    border: 1px solid rgba(0,178,255,0.08);
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.12s ease;
}

/* Checkbox nativo oculto visualmente: el estado sigue viviendo en .rest-cb.checked */
#qopsRestList .rest-cb,
#qopsZonaList .rest-cb {
    display: none;
}

.qops-name {
    font-size: 0.78rem;
    color: var(--text);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
}

/* ── Estado inactivo (default): gris muy suave, texto atenuado ── */
#qopsRestList .qops-item .qops-name,
#qopsZonaList .qops-item .qops-name {
    color: var(--text-dim);
}

/* ── Efecto táctil: leve escala de presión ── */
#qopsRestList .qops-item:active,
#qopsZonaList .qops-item:active {
    transform: scale(0.96);
}

/* ── Restaurantes ACTIVO: azul translúcido elegante ── */
#qopsRestList .qops-item:has(.rest-cb.checked) {
    background: rgba(0,178,255,0.15);
    border-color: var(--border2);
    box-shadow: 0 0 10px rgba(0,178,255,0.12);
}
#qopsRestList .qops-item:has(.rest-cb.checked) .qops-name {
    color: var(--cyan);
    text-shadow: 0 0 8px rgba(0,229,255,0.35);
}

/* ── Zonas ACTIVO: verde/cian suave, misma familia visual de la app ── */
#qopsZonaList .qops-item:has(.rest-cb.checked) {
    background: rgba(0,230,118,0.13);
    border-color: rgba(0,230,118,0.4);
    box-shadow: 0 0 10px rgba(0,230,118,0.10);
}
#qopsZonaList .qops-item:has(.rest-cb.checked) .qops-name {
    color: var(--green);
    text-shadow: 0 0 8px rgba(0,230,118,0.30);
}

/* ── Restaurantes: grid 2 columnas, pills compactas ── */
#qopsRestList {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px 8px;
    max-height: none;
    overflow: visible;
}
#qopsRestList .qops-item {
    padding: 5px 6px 5px 8px;
    justify-content: space-between;
    gap: 6px;
}
#qopsRestList .qops-name {
    font-size: 0.71rem;
    white-space: normal;
    line-height: 1.12;
    text-align: left;
    flex: 1 1 auto;
}

/* ── Avatar stack: fotos superpuestas de los restaurantes activos del grupo ──
   Reutiliza _crearAvatarRestEl / _getFotoRestaurante — sin llamadas nuevas. */
.hud-avatar-stack {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}
.hud-avatar-stack-item,
.hud-avatar-stack-more {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid var(--bg2);
    margin-left: -7px;
    flex-shrink: 0;
    object-fit: cover;
    display: block;
}
.hud-avatar-stack-item:first-child,
.hud-avatar-stack-more:first-child {
    margin-left: 0;
}
/* z-index secuencial ascendente: el primer avatar queda AL FONDO y cada
   siguiente se apila por encima, hasta llegar a la burbuja "+N", que
   siempre queda al frente de todo, nítida y sin recortes. */
.hud-avatar-stack-item:nth-child(1) { z-index: 1; }
.hud-avatar-stack-item:nth-child(2) { z-index: 2; }
.hud-avatar-stack-item:nth-child(3) { z-index: 3; }
.hud-avatar-stack-item:nth-child(4) { z-index: 4; }
.hud-avatar-stack-more {
    background: var(--bg4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.5rem;
    font-family: var(--mono);
    color: var(--text-dim);
    z-index: 5;
}

/* ── Zonas: grid 3 columnas, pills compactas, nombres capitalizados ── */
#qopsZonaList {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px 6px;
    max-height: none;
    overflow: visible;
}
#qopsZonaList .qops-item {
    padding: 4px 4px;
}
#qopsZonaList .qops-name {
    font-size: 0.65rem;
    white-space: normal;
    line-height: 1.08;
    text-transform: capitalize;
}


/* ============================================================
   QOPS — POPUP DE SELECCIÓN INDIVIDUAL (long-press en grupo)
   Contextual, flotante, sin layout shift — tema oscuro coherente.
============================================================ */
.qops-popup-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(2px);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    transition: opacity 0.18s ease;
}
.qops-popup-backdrop.show { opacity: 1; }

.qops-popup {
    background: var(--bg2);
    border: 1px solid var(--border2);
    border-radius: var(--radius);
    width: 100%;
    max-width: 300px;
    max-height: 70vh;
    padding: 14px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6), 0 0 30px rgba(0,178,255,0.12);
    display: flex;
    flex-direction: column;
    gap: 8px;
    transform: scale(0.94) translateY(6px);
    transition: transform 0.18s ease;
}
.qops-popup-backdrop.show .qops-popup {
    transform: scale(1) translateY(0);
}

.qops-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.qops-popup-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.9rem;
    padding: 2px 6px;
    border-radius: 4px;
    cursor: pointer;
    transition: all var(--transition);
}
.qops-popup-close:hover { background: rgba(255,59,59,0.15); color: var(--red); }

.qops-popup-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
    max-height: 46vh;
}
.qops-popup-list::-webkit-scrollbar { width: 3px; }
.qops-popup-list::-webkit-scrollbar-thumb { background: var(--blue-dark); border-radius: 2px; }

.qops-popup-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 4px;
    border-radius: 6px;
    cursor: pointer;
    transition: background var(--transition);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}
.qops-popup-item:hover { background: var(--blue-glow); }

/* ── Avatar circular en la fila del popup: orden [Checkbox] → [Avatar] → [Nombre] ── */
.qops-popup-avatar {
    flex-shrink: 0;
}

.qops-popup-name {
    font-size: 0.78rem;
    color: var(--text);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.qops-popup-name.inactive { color: var(--text-muted); }

/* ============================================================
   STATUS RING — BOTÓN FLOTANTE PRINCIPAL (premium HUD)
============================================================ */
.sr-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 4px 0 4px;
}

/* El anillo ES el botón */
.sr {
    width: 110px; height: 110px;
    border-radius: 50%;
    border: 2px solid var(--border2);
    background: var(--bg3);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    position: relative;
    cursor: pointer;
    transition: transform 0.18s cubic-bezier(0.34,1.56,0.64,1), border-color 0.4s, box-shadow 0.4s;
    /* reset button styles */
    outline: none;
    padding: 0;
    /* outer decorative ring via outline */
    outline: 1px solid transparent;
    outline-offset: 8px;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Halo orbital — elemento decorativo extra */
.sr-halo {
    position: absolute;
    inset: -10px;
    border-radius: 50%;
    border: 1px solid transparent;
    pointer-events: none;
    transition: border-color 0.4s, opacity 0.4s;
}

/* Hint TAP visible sutil debajo del texto */
.sr-tap-hint {
    font-family: var(--mono);
    font-size: 0.38rem;
    letter-spacing: 0.22em;
    color: var(--text-muted);
    opacity: 0.45;
    margin-top: 2px;
    transition: opacity 0.3s;
}

/* Al hover mostrar tap hint */
.sr:hover .sr-tap-hint { opacity: 0.85; }

/* Presionado: escala down como botón táctil real */
.sr:active { transform: scale(0.93) !important; }

/* Hover genérico: ligera escala hacia arriba */
.sr:hover { transform: scale(1.04); }

/* ── Estado: conectado (ACTIVO) ── */
.sr.online {
    border-color: var(--green);
    background: radial-gradient(ellipse at center, rgba(0,230,118,0.08) 0%, var(--bg3) 70%);
    box-shadow:
        0 0 24px rgba(0,230,118,0.35),
        0 0 60px rgba(0,230,118,0.12),
        inset 0 0 20px rgba(0,230,118,0.08);
    animation: breatheOnline 3s ease-in-out infinite;
    outline-color: rgba(0,230,118,0.2);
}
.sr.online .sr-halo {
    border-color: rgba(0,230,118,0.3);
    animation: haloExpand 3s ease-in-out infinite;
}

/* ── Estado: pausado ── */
.sr.paused {
    border-color: var(--orange);
    background: radial-gradient(ellipse at center, rgba(255,140,0,0.07) 0%, var(--bg3) 70%);
    box-shadow:
        0 0 20px rgba(255,140,0,0.3),
        0 0 50px rgba(255,140,0,0.1),
        inset 0 0 16px rgba(255,140,0,0.06);
    animation: breathePaused 4s ease-in-out infinite;
    outline-color: rgba(255,140,0,0.18);
}
.sr.paused .sr-halo {
    border-color: rgba(255,140,0,0.25);
    animation: haloExpand 4s ease-in-out infinite;
}

/* ── Estado: conectando ── */
.sr.connect {
    border-color: var(--cyan);
    box-shadow: 0 0 18px rgba(0,229,255,0.2);
    animation: breatheConnect 1.8s ease-in-out infinite;
}
.sr.connect .sr-halo {
    border-color: rgba(0,229,255,0.2);
    animation: haloExpand 1.8s ease-in-out infinite;
}

/* ── Estado: recuperando sesión — visualmente distinto de "connect"
   (spin real en vez de blink) para que el cliente entienda que es algo
   activo/en progreso, no solo "esperando", mientras el sistema verifica
   si la sesión de WhatsApp realmente se perdió antes de pedir vincular
   de nuevo. Mismo color base que connect (cyan) — es una variante del
   mismo concepto "trabajando", no un estado de alarma. ── */
.sr.recovering {
    border-color: var(--cyan);
    box-shadow: 0 0 18px rgba(0,229,255,0.2);
    animation: breatheConnect 1.8s ease-in-out infinite;
}
.sr.recovering .sr-halo {
    border-color: rgba(0,229,255,0.2);
    animation: haloExpand 1.8s ease-in-out infinite;
}
.sr.recovering .sr-icon {
    color: var(--cyan);
    text-shadow: 0 0 14px var(--cyan);
    animation: spinRecovering 1.1s linear infinite;
    display: inline-block;
}
.sr.recovering .sr-text { color: var(--blue); }

@keyframes spinRecovering { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* ── Keyframes ── */
@keyframes breatheOnline {
    0%, 100% {
        box-shadow: 0 0 18px rgba(0,230,118,0.28), 0 0 50px rgba(0,230,118,0.1), inset 0 0 14px rgba(0,230,118,0.06);
    }
    50% {
        box-shadow: 0 0 38px rgba(0,230,118,0.55), 0 0 80px rgba(0,230,118,0.2), inset 0 0 28px rgba(0,230,118,0.14);
    }
}
@keyframes breathePaused {
    0%, 100% {
        box-shadow: 0 0 14px rgba(255,140,0,0.22), 0 0 40px rgba(255,140,0,0.08), inset 0 0 10px rgba(255,140,0,0.04);
    }
    50% {
        box-shadow: 0 0 30px rgba(255,140,0,0.48), 0 0 65px rgba(255,140,0,0.16), inset 0 0 22px rgba(255,140,0,0.1);
    }
}
@keyframes breatheConnect {
    0%, 100% { box-shadow: 0 0 10px rgba(0,229,255,0.18); }
    50%       { box-shadow: 0 0 28px rgba(0,229,255,0.45); }
}
@keyframes haloExpand {
    0%    { transform: scale(1);    opacity: 0.6; }
    65%   { transform: scale(1.22); opacity: 0;   }
    100%  { transform: scale(1);    opacity: 0;   }
}
@keyframes blink { 0%,100% { opacity:1 } 50% { opacity:0.2 } }

/* Animación click feedback: burst de escala */
@keyframes ringClick {
    0%   { transform: scale(1); }
    30%  { transform: scale(0.91); }
    70%  { transform: scale(1.06); }
    100% { transform: scale(1); }
}
.sr.click-feedback { animation: ringClick 0.32s cubic-bezier(0.34,1.56,0.64,1) !important; }

/* ── Icono central ── */
.sr-icon {
    font-size: 1.6rem;
    color: var(--text-muted);
    transition: color 0.4s, text-shadow 0.4s, transform 0.3s;
    line-height: 1;
}

.sr.online  .sr-icon { color: var(--green);  text-shadow: 0 0 18px var(--green), 0 0 30px rgba(0,230,118,0.4); }
.sr.paused  .sr-icon { color: var(--orange); text-shadow: 0 0 14px rgba(255,140,0,0.7); }
.sr.connect .sr-icon { color: var(--cyan);   text-shadow: 0 0 14px var(--cyan); animation: blink 1.2s step-end infinite; }

/* ── Texto de estado ── */
.sr-text {
    font-family: var(--mono);
    font-size: 0.52rem;
    letter-spacing: 0.18em;
    color: var(--text-muted);
    transition: color 0.4s;
    font-weight: 600;
}

.sr.online  .sr-text { color: var(--green); }
.sr.paused  .sr-text { color: var(--orange); }
.sr.connect .sr-text { color: var(--blue); }

.bot-toggle {
    background: none;
    border: none;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0;
}

.bt-track {
    width: 52px; height: 26px;
    border-radius: 13px;
    border: 1px solid var(--text-muted);
    background: var(--bg3);
    position: relative;
    transition: all 0.3s;
}

.bt-thumb {
    position: absolute;
    top: 4px; left: 4px;
    width: 16px; height: 16px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: all 0.3s;
}

.bot-toggle.active .bt-track {
    border-color: var(--green);
    background: rgba(0,230,118,0.12);
    box-shadow: 0 0 10px rgba(0,230,118,0.25);
}
.bot-toggle.active .bt-thumb { left: 30px; background: var(--green); box-shadow: 0 0 8px rgba(0,230,118,0.6); }

/* PAUSADO: visible en naranja */
.bot-toggle:not(.active) .bt-track {
    border-color: rgba(255,140,0,0.5);
    background: rgba(255,140,0,0.08);
}
.bot-toggle:not(.active) .bt-thumb { background: var(--orange); box-shadow: 0 0 6px rgba(255,140,0,0.5); }

.bt-state {
    font-family: var(--mono);
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    color: var(--orange);     /* PAUSADO visible */
    transition: color 0.3s;
    min-width: 55px;
}

.bot-toggle.active .bt-state { color: var(--green); }

/* Bot actions — fila compacta horizontal */
.bot-actions {
    display: flex;
    gap: 6px;
    padding: 0 0 2px;
    margin-top: 10px;
}

.btn-action {
    flex: 1;
    border: 1px solid var(--border);
    background: var(--bg3);
    color: var(--text-dim);
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.72rem;
    font-weight: 500;
    transition: all var(--transition);
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.btn-restart:hover { border-color: var(--blue); color: var(--blue); box-shadow: 0 0 10px rgba(0,178,255,0.2); }
.btn-disc:hover    { border-color: var(--red);  color: var(--red);  box-shadow: 0 0 10px rgba(255,59,59,0.2); }

/* Card compact variant for bot control */
/* min-height:324px eliminado — reemplazado por height:320px fija +
   overflow-y:auto en la regla base de .card--quickops (arriba). El
   padding se mantiene. */
.card--quickops { padding: 14px 18px; }
/* min-height: la sonda v3 midió esta fila del grid fluctuando entre 161px
   y 172.264px SOLO por cambios de texto en el anillo/píldora de estado
   ("OFFLINE"→"CONECTANDO"→"AUTENTICADO"→"ONLINE") durante reconexiones de
   WhatsApp — la fila es `auto` en el grid, así que cada cambio de ancho
   de texto recalculaba la fila entera y corría .card--quickops/.card--
   quicklogs hasta 254px de golpe (confirmado con la sonda: mutaciones en
   .card--status correlacionadas 1:1 con saltos de .top en las 3 cards).
   172.264px era el máximo real observado — el margen cubre estados con
   texto más largo que no llegamos a capturar en la prueba.
   min-height:180px ELIMINADO: descartado como causa principal en
   experimento controlado (turno previo — remover produjo cambio mínimo);
   ya no necesario con .card--quickops como contenedor de scroll fijo. */
.card--status { padding: 6px 18px 2px; }

/* Quicklog */
.quicklog {
    /* Altura propia y fija — ya no depende de flex:1 del padre (que dejó
       de ser flex) ni de ningún cálculo de viewport/grid. .card--quicklogs
       es una card normal que crece con su contenido; esta es la única
       pieza que scrollea internamente. */
    height: 280px;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.quicklog::-webkit-scrollbar { width: 3px; }
.quicklog::-webkit-scrollbar-thumb { background: var(--blue-dark); border-radius: 2px; }

.ql-entry {
    font-family: var(--mono);
    font-size: 0.72rem;
    color: var(--text-dim);
    padding: 2px 0;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
    line-height: 1.4;
    animation: logSlide 0.15s ease;
}

.ql-entry.ok    { color: var(--green); }
.ql-entry.error { color: var(--red); }
.ql-entry.warn  { color: var(--yellow); }
.ql-entry.info  { color: var(--blue); }

/* VINCULACIÓN (Pairing Code) — pantalla fullscreen */
.vinc-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    padding-top: calc(24px + var(--safe-top));
    padding-bottom: calc(24px + var(--safe-bottom));
}

.vinc-card {
    width: 100%;
    max-width: 360px;
    background: var(--bg2);
    border: 1px solid var(--border2);
    border-radius: var(--radius);
    padding: 28px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    box-shadow: 0 0 30px var(--blue-glow);
}

.vinc-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.vinc-step {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.vinc-title {
    font-family: var(--mono);
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--text);
    text-align: center;
}

.vinc-sub {
    font-size: 0.75rem;
    color: var(--text-dim);
    text-align: center;
    line-height: 1.4;
}

.vinc-btn { width: 100%; }

.vinc-code {
    font-family: var(--mono);
    font-size: 1.8rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    color: var(--cyan);
    text-shadow: 0 0 14px rgba(0,229,255,0.4);
    background: var(--bg3);
    border: 1px solid var(--border2);
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    width: 100%;
    text-align: center;
}

.vinc-countdown {
    font-family: var(--mono);
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    color: var(--orange);
}

/* ============================================================
   TOOLBAR
============================================================ */
.toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.toolbar-title {
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1;
    color: var(--text);
    flex: 1;
}

.search-input {
    flex: 1;
    min-width: 160px;
    background: var(--bg2);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.875rem;
    padding: 9px 14px;
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.search-input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 10px var(--blue-glow);
}

/* ============================================================
   BUTTONS
============================================================ */
.btn-primary {
    background: var(--blue);
    color: #000;
    border: none;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    transition: all var(--transition);
    white-space: nowrap;
    /* position:relative + z-index — fuerza un contexto de apilamiento
       propio. Confirmado con rastreo de toques real: elementFromPoint()
       dentro del propio rectángulo del botón devolvía .content en vez
       del botón — una desincronización entre la capa visual y la de
       hit-test del compositor de este WebView, no un problema de CSS
       box-model ni de JS. Esto le da al botón su propia capa de
       pintado/hit-test, evitando la ambigüedad. */
    position: relative;
    z-index: 1;
}

.btn-primary:hover { background: var(--cyan); box-shadow: 0 0 14px rgba(0,229,255,0.4); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-ghost {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    transition: all var(--transition);
}

.btn-ghost:hover { border-color: var(--blue); color: var(--blue); }

.btn-sm {
    padding: 5px 11px;
    font-size: 0.72rem;
}

.btn-icon-sm {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.9rem;
    padding: 4px 6px;
    border-radius: 4px;
    transition: all var(--transition);
    line-height: 1;
}

.btn-icon-sm:hover { color: var(--red); background: rgba(255,59,59,0.1); }

/* ============================================================
   RESTAURANTES
============================================================ */
.grupo-block {
    margin-bottom: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.grupo-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg3);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background var(--transition);
}

.grupo-header:hover { background: var(--bg4); }

.grupo-name {
    font-family: var(--mono);
    font-size: 0.7rem;
    letter-spacing: 0.14em;
    color: var(--blue);
    flex: 1;
}

.grupo-count {
    font-size: 0.65rem;
    color: var(--text-muted);
    background: var(--blue-dark);
    border-radius: 10px;
    padding: 2px 8px;
}

.grupo-quickbtns {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.btn-quick {
    font-family: var(--mono);
    font-size: 0.55rem;
    letter-spacing: 0.08em;
    padding: 2px 7px;
    border-radius: 4px;
    border: 1px solid var(--border2);
    background: var(--blue-dark);
    color: var(--blue);
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-quick:hover {
    background: var(--blue);
    color: #000;
    box-shadow: 0 0 8px rgba(0,178,255,0.3);
}

.btn-quick.off {
    border-color: rgba(255,59,59,0.3);
    background: rgba(255,59,59,0.06);
    color: var(--red);
}

.btn-quick.off:hover {
    background: var(--red);
    color: #fff;
    box-shadow: 0 0 8px rgba(255,59,59,0.3);
}

.grupo-chevron {
    color: var(--text-muted);
    font-size: 0.7rem;
    transition: transform var(--transition);
}

.grupo-block.collapsed .grupo-chevron { transform: rotate(-90deg); }
.grupo-block.collapsed .grupo-items   { display: none; }

.grupo-items {
    padding: 6px 0;
}

.rest-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    border-bottom: 1px solid rgba(0,178,255,0.04);
    transition: background var(--transition);
}

.rest-item:last-child { border-bottom: none; }
.rest-item:hover { background: var(--blue-glow); }
.rest-item.hidden { display: none; }

.rest-cb {
    width: 15px; height: 15px;
    border: 1px solid var(--text-muted);
    border-radius: 3px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
    position: relative;
}

.rest-cb.checked {
    border-color: var(--blue);
    background: var(--blue-dark);
    box-shadow: 0 0 6px var(--blue-glow);
}

.rest-cb.checked::after {
    content: '✓';
    font-size: 0.65rem;
    color: var(--blue);
    position: absolute;
}

.rest-name {
    flex: 1;
    font-size: 0.85rem;
    color: var(--text);
}

.rest-name.inactive { color: var(--text-muted); text-decoration: line-through; }

.rest-actions { display: flex; gap: 4px; opacity: 0; transition: opacity var(--transition); }
.rest-item:hover .rest-actions { opacity: 1; }

/* ============================================================
   ZONAS
============================================================ */
/* ============================================================
   ZONAS — vista compacta + expandible
============================================================ */

/* Card base */
.info-rows {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    gap: 12px;
}

.info-row:last-child { border-bottom: none; }

.info-label {
    font-family: var(--mono);
    font-size: 0.65rem;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    flex-shrink: 0;
}

.info-val {
    font-family: var(--mono);
    font-size: 0.65rem;
    color: var(--text);
    text-align: right;
    word-break: break-all;
}

.zona-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 4px;
    overflow: hidden;
    transition: border-color var(--transition);
}

.zona-card:hover       { border-color: var(--border2); }
.zona-card.expandida   { border-color: var(--border2); }
.zona-card.activa      { border-left: 2px solid rgba(0,230,118,0.5); }

/* ── Fila compacta ── */
.zona-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    cursor: pointer;
    user-select: none;
    min-height: 38px;
}

/* Dot — botón de activar/desactivar */
.zona-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
    border: none;
    cursor: pointer;
    padding: 0;
    transition: background 0.2s, box-shadow 0.2s;
}

.zona-card.activa .zona-dot {
    background: var(--green);
    box-shadow: 0 0 6px var(--green);
}

.zona-dot:hover {
    opacity: 0.7;
    transform: scale(1.25);
}

/* Nombre */
.zona-name {
    font-family: var(--mono);
    font-size: 0.76rem;
    letter-spacing: 0.08em;
    color: var(--text);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Handle drag */
.zona-handle {
    font-size: 0.75rem;
    color: var(--text-muted);
    flex-shrink: 0;
    cursor: grab;
    padding: 0 2px;
    user-select: none;
    touch-action: none;
    transition: color 0.15s;
    line-height: 1;
}

.zona-handle:hover  { color: var(--text); }
.zona-handle:active { cursor: grabbing; }

/* Badge nomenclatura — es un button clickeable */
.zona-nom-badge {
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--text-muted);
    flex-shrink: 0;
    width: 18px;
    text-align: center;
    transition: color 0.2s, transform 0.1s;
    /* reset button */
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    line-height: 1;
}

.zona-nom-badge:hover  { transform: scale(1.3); }
.zona-nom-badge.on     { color: var(--green); }

/* Chevron */
.zona-chevron {
    font-size: 0.65rem;
    color: var(--text-muted);
    flex-shrink: 0;
    width: 12px;
    text-align: center;
    transition: color 0.2s;
}

.zona-card.expandida .zona-chevron { color: var(--text); }

/* ── Detalle expandido ── */
.zona-detail {
    border-top: 1px solid var(--border);
    padding: 10px 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.zona-patron {
    font-family: var(--mono);
    font-size: 0.63rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Card flotante durante drag */
.zona-card.zona-dragging {
    opacity: 0.85;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    pointer-events: none;
    border-color: var(--border2);
}

/* Placeholder que ocupa el hueco durante drag */
.zona-drag-placeholder {
    border: 1px dashed var(--border2);
    border-radius: var(--radius);
    background: rgba(0,178,255,0.04);
    margin-bottom: 4px;
    box-sizing: border-box;
}

/* Botones de acción en detalle */
.zona-actions {
    display: flex;
    gap: 8px;
    margin-top: 2px;
}

.zona-actions .btn-icon-sm {
    font-size: 0.65rem;
    padding: 3px 10px;
    border-radius: 4px;
    gap: 4px;
}

.zona-actions .btn-icon-sm.danger:hover {
    color: var(--red);
    background: rgba(255,59,59,0.1);
    border-color: rgba(255,59,59,0.3);
}

/* ============================================================
   BARRIOS
============================================================ */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.data-table th {
    background: var(--bg3);
    font-family: var(--mono);
    font-size: 0.6rem;
    letter-spacing: 0.15em;
    color: var(--text-muted);
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 10px 14px;
    border-bottom: 1px solid rgba(0,178,255,0.05);
    color: var(--text);
    font-family: var(--mono);
    font-size: 0.78rem;
}

.data-table tbody tr:hover { background: var(--blue-glow); }
.data-table tbody tr:last-child td { border-bottom: none; }

.zona-pill {
    display: inline-block;
    font-family: var(--mono);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    padding: 2px 9px;
    border-radius: 9px;
    background: var(--blue-dark);
    color: var(--blue);
    border: 1px solid transparent;
}

/* ============================================================
   FORMS
============================================================ */
.form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-field label {
    font-family: var(--mono);
    font-size: 0.6rem;
    letter-spacing: 0.15em;
    color: var(--text-dim);
}

input[type="text"],
input[type="tel"],
input[type="number"],
textarea,
select {
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.85rem;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
    width: 100%;
}

input:focus, textarea:focus, select:focus {
    border-color: var(--blue);
    box-shadow: 0 0 10px var(--blue-glow);
}

input::placeholder, textarea::placeholder { color: var(--text-muted); }

select {
    appearance: none;
    cursor: pointer;
    /* Mismo fix que .btn-primary/.cfg-select-native — contexto de
       apilamiento propio contra la desincronización visual/hit-test del
       compositor de este WebView. Aplicado a TODOS los select de una
       sola vez, no solo al de Auto-Pausa donde se detectó. */
    position: relative;
    z-index: 1;
}
select option { background: var(--bg3); }

/* ── Select dinámico con botón de recarga ── */
.cfg-select-wrap {
    position: relative;
    display: flex;
    align-items: stretch;
    gap: 0;
}

/* Flecha personalizada del select — caret neon */
.cfg-select-wrap::after {
    content: '▾';
    position: absolute;
    right: 42px;   /* deja espacio para el botón reload */
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.75rem;
    color: var(--blue);
    pointer-events: none;
    z-index: 1;
    line-height: 1;
}

.cfg-select-wrap select {
    flex: 1;
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    padding-right: 32px;  /* espacio para la flecha interna */
    border-right: none;
}

.cfg-select-wrap select:focus {
    border-color: var(--blue);
    box-shadow: 0 0 10px var(--blue-glow);
    z-index: 1;
}

.cfg-select-reload {
    flex-shrink: 0;
    width: 36px;
    background: var(--bg4);
    border: 1px solid var(--border);
    border-left: none;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-muted);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.cfg-select-reload:hover:not(:disabled) {
    background: var(--blue-dark);
    color: var(--blue);
    border-color: var(--blue);
    box-shadow: 0 0 8px var(--blue-glow);
}

/* Select simple con flecha neón — mismo caret que .cfg-select-wrap,
   pero sin reservar espacio para un botón de recarga al lado. Solo
   agrega el indicador visual de "desplegable"; no cambia tamaño,
   colores base ni comportamiento del <select>. */
.cfg-select-simple-wrap {
    position: relative;
}

.cfg-select-simple-wrap::after {
    content: '▾';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.75rem;
    color: var(--blue);
    pointer-events: none;
    z-index: 1;
    line-height: 1;
}

.cfg-select-simple-wrap select {
    padding-right: 32px;
}

.cfg-select-reload:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.cfg-select-hint {
    font-family: var(--mono);
    font-size: 0.6rem;
    letter-spacing: 0.06em;
    min-height: 14px;
    margin-top: 2px;
    color: var(--text-muted);
    transition: color var(--transition);
}

.cfg-select-hint.ok      { color: var(--green); }
.cfg-select-hint.err     { color: var(--red); }
.cfg-select-hint.loading { color: var(--blue); opacity: 0.7; }

/* ── Buscador de moderador/grupo ── */
.mod-dropdown-search {
    width: 100%;
    background: var(--bg2);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.82rem;
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
    margin-bottom: 6px;
}

.mod-dropdown-search:focus {
    border-color: var(--blue);
    box-shadow: 0 0 10px var(--blue-glow);
}

.mod-dropdown-search::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

.mod-dropdown-search:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.regex-hint {
    font-family: var(--mono);
    font-size: 0.65rem;
    min-height: 16px;
    transition: color var(--transition);
}

.regex-hint.valid   { color: var(--green); }
.regex-hint.invalid { color: var(--red); }

.form-feedback {
    font-family: var(--mono);
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    padding: 6px 0;
    min-height: 24px;
    transition: all var(--transition);
}

.form-feedback.ok  { color: var(--green); }
.form-feedback.err { color: var(--red); }

/* ============================================================
   LOGS / TERMINAL
============================================================ */
.log-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toggle-small {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--text-dim);
    cursor: pointer;
}

.toggle-small input { accent-color: var(--blue); cursor: pointer; }

.log-counter {
    font-family: var(--mono);
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-left: auto;
}

/* La sección Logs llena el 100% de .content (posible porque .content ya
   tiene altura definida por el layout acotado) y el terminal toma el
   espacio restante por flex — cero aritmética de viewport, sin volver a
   restar topbar/safe-area que .main ya descontó. Specificity: el id le
   gana a .section.active (display:block). */
#sec-logs.active {
    display: flex;
    flex-direction: column;
    height: 100%;
}
#sec-logs .toolbar { flex-shrink: 0; }

.terminal {
    background: #020408;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    /* flex:1 = todo el espacio que queda tras el toolbar; min-height:0
       permite encogerse por debajo del contenido (los logs siguen
       scrolleando adentro vía su propio overflow-y). Reemplaza el
       height: calc(100vh - topbar - 100px - safe-bottom) anterior, que
       restaba alturas ya descontadas por .main y desbordaba .content
       (medido: 630px de terminal vs 600px de espacio interno real). */
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-family: var(--mono);
    font-size: 0.78rem;
    line-height: 1.5;
}

.terminal::-webkit-scrollbar { width: 4px; }
.terminal::-webkit-scrollbar-track { background: transparent; }
.terminal::-webkit-scrollbar-thumb { background: var(--blue-dark); border-radius: 2px; }

.log-entry {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    animation: logSlide 0.15s ease;
    padding: 9px 12px;
    margin-bottom: 5px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
    border-left: 3px solid var(--border);
}

@keyframes logSlide { from { opacity:0; transform:translateX(-4px); } to { opacity:1; transform:translateX(0); } }

.log-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    background: var(--text-muted);
    color: var(--bg);
    margin-top: 1px;
}

.log-entry--ok    { border-left-color: var(--green); }
.log-entry--ok    .log-icon { background: var(--green); }
.log-entry--error { border-left-color: var(--red); }
.log-entry--error .log-icon { background: var(--red); }
.log-entry--warn  { border-left-color: var(--yellow); }
.log-entry--warn  .log-icon { background: var(--yellow); }
.log-entry--info  { border-left-color: var(--blue); }
.log-entry--info  .log-icon { background: var(--blue); }

.log-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.log-ts   { color: var(--text-muted); font-size: 0.65rem; font-family: var(--mono); }
.log-msg  { color: var(--text-dim); word-break: break-word; font-size: 0.8rem; line-height: 1.4; }
.log-msg.ok    { color: var(--green); }
.log-msg.error { color: var(--red); }
.log-msg.warn  { color: var(--yellow); }
.log-msg.info  { color: var(--blue); }

/* Eventos técnicos — ocultos salvo modo administrador activo */
.log-entry--tecnico { display: none; }
body.admin-mode .log-entry--tecnico {
    display: flex;
    opacity: 0.7;
}

/* Cualquier control marcado admin-only (Logs Debug, etc.) — mismo criterio */
.admin-only { display: none !important; }
body.admin-mode .admin-only { display: flex !important; }

/* ============================================================
   CONFIGURACIÓN
============================================================ */
.config-layout {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ============================================================
   MODAL
============================================================ */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: fadeIn 0.15s ease;

/* CAUSA REAL de "Editar/Agregar nomenclatura no hacen nada": #modalNom
   se abre desde DENTRO de #modalZona, que sigue visible detrás (nunca
   se cierra). Ambos backdrops comparten el mismo z-index:200 genérico
   de arriba — con z-index empatado, el navegador apila por orden en el
   DOM, y #modalZona aparece DESPUÉS que #modalNom en index.html, así
   que se pintaba encima y capturaba los toques, aunque el usuario viera
   el modal de nomenclatura "debajo" a través del fondo semitransparente.
   #modalNom necesita quedar SIEMPRE por encima cuando ambos coinciden
   abiertos, sin depender del orden del HTML. */
}
#modalNom.modal-backdrop {
    z-index: 250;
}

.modal {
    background: var(--bg2);
    border: 1px solid var(--border2);
    border-radius: var(--radius);
    width: 100%;
    max-width: 420px;
    max-height: 92vh;
    padding: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6), 0 0 40px rgba(0,178,255,0.1);
    display: flex;
    flex-direction: column;
    /* Mismo fix que .section.active/.btn-primary/select — los modales
       viven fuera de .content, como hermanos, así que ese fix no los
       cubre. Se aplica acá directo, cubriendo todos los modales de la
       app (Zona, Restaurante, Nomenclatura, Lugares Conocidos) de una
       sola vez. */
    position: relative;
    z-index: 1;
    gap: 16px;
    overflow-y: auto;
    scroll-behavior: smooth;
}

.modal::-webkit-scrollbar { width: 4px; }
.modal::-webkit-scrollbar-thumb { background: var(--blue-dark); border-radius: 2px; }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    font-size: 0.95rem;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all var(--transition);
}

.modal-close:hover { background: rgba(255,59,59,0.15); color: var(--red); }

.modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* Valor de solo lectura — usado para "ZONA" en el modal de nomenclatura:
   ya no es un <select> visible, la zona queda fija automáticamente.
   Mismo lenguaje visual que un input, sin editable. */
.form-static-value {
    font-family: var(--mono);
    font-size: 0.95rem;
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    color: var(--text-dim);
}

/* Tarjetas de nomenclatura dentro del modal de edición de zona. Nombre
   "zona-nom-*" (no "nom-card") a propósito — evita colisionar con las
   clases .nom-card/.nom-card-header/etc. ya existentes del sistema de
   tarjetas móvil de la vieja sección de Nomenclaturas (más abajo en
   este archivo), que tienen reglas propias distintas. */
.zona-nom-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
    margin-bottom: 6px;
}
.zona-nom-card-resumen {
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--text);
}
.zona-nom-card-acciones {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}
.zona-nom-card-vacio {
    font-size: 0.85rem;
    color: var(--text-dim);
    padding: 10px 2px;
}


/* ============================================================
   RESPONSIVE MOBILE
============================================================ */

/* ============================================================
   SWITCHES CONFIG
============================================================ */
.cfg-switches {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.cfg-switch-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    position: relative;
}

.cfg-switch-row:last-child { border-bottom: none; }

.cfg-switch-label {
    font-size: 0.82rem;
    color: var(--text);
    flex: 1;
    user-select: none;
}

.cfg-switch-hint {
    font-family: var(--mono);
    font-size: 0.58rem;
    color: var(--text-muted);
    letter-spacing: 0.06em;
    flex: 1;
    text-align: right;
    padding-right: 10px;
    user-select: none;
}

/* Hide native checkbox */
.cfg-sw-input {
    position: absolute;
    opacity: 0;
    width: 0; height: 0;
    pointer-events: none;
}

.cfg-sw-track {
    width: 40px;
    height: 22px;
    border-radius: 11px;
    border: 1px solid var(--text-muted);
    background: var(--bg3);
    position: relative;
    flex-shrink: 0;
    transition: all 0.25s;
    display: inline-block;
}

.cfg-sw-thumb {
    position: absolute;
    top: 3px; left: 3px;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: all 0.25s;
}

.cfg-sw-input:checked + .cfg-sw-track {
    border-color: var(--blue);
    background: var(--blue-dark);
    box-shadow: 0 0 8px rgba(0,178,255,0.25);
}

.cfg-sw-input:checked + .cfg-sw-track .cfg-sw-thumb {
    left: 21px;
    background: var(--blue);
    box-shadow: 0 0 6px rgba(0,178,255,0.6);
}

/* ============================================================
   BOTONES SISTEMA
============================================================ */
.sist-btns {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.btn-sist {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg3);
    color: var(--text-dim);
    font-size: 0.82rem;
    font-weight: 500;
    transition: all var(--transition);
    text-align: left;
    width: 100%;
}

.sist-icon {
    font-size: 1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.btn-sist--export:hover {
    border-color: var(--blue);
    color: var(--blue);
    background: var(--blue-glow);
    box-shadow: 0 0 10px rgba(0,178,255,0.15);
}

.btn-sist--import:hover {
    border-color: var(--cyan);
    color: var(--cyan);
    background: rgba(0,229,255,0.06);
    box-shadow: 0 0 10px rgba(0,229,255,0.15);
}

.btn-sist--restart:hover {
    border-color: var(--orange);
    color: var(--orange);
    background: rgba(255,140,0,0.06);
    box-shadow: 0 0 10px rgba(255,140,0,0.15);
}


/* ============================================================
   CARD ESTADÍSTICAS
============================================================ */
/* ============================================================
   HUD INLINE — Panel derecho del círculo (det-inline)
   Layout: label arriba pequeño + emoji+valor abajo.
   Bloques distribuidos en todo el ancho disponible.
============================================================ */

/* ── Fila KPIs: WIN / LOSS / WINRATE — ocupa todo el ancho ── */
/* ============================================================
   HUD STATS — fila superior (WIN | LOSS | WINRATE)
   Design: separadores verticales finos, SVG icons neon,
           fuente ligera tipo dashboard imagen 2.
============================================================ */

/* ── SVG icons ── */
.hud-ico {
    width: 1.4em;
    height: 1.4em;
    flex-shrink: 0;
    vertical-align: middle;
}
.hud-ico--sm {
    width: 1.8em;
    height: 1.8em;
}

/* ── Fila KPIs (WIN/LOSS/WINRATE) — eliminada del layout ── */
.hud-kpis {
    display: none;
}

/* divisor entre KPIs y métodos — también se oculta al no haber KPIs */
.hud-kpis + .hud-row-sep {
    display: none;
}

.hud-kpi {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 2px;
    flex: 1;
    padding: 2px 10px 2px 6px;
}
.hud-kpi:first-child { padding-left: 2px; }

.hud-kpi-lbl {
    font-family: var(--mono);
    font-size: 0.48rem;
    letter-spacing: 0.16em;
    color: var(--text-dim);
    opacity: 0.7;
    line-height: 1;
    text-transform: uppercase;
}

.hud-kpi-val {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--mono);
    font-size: 0.92rem;
    font-weight: 600;
    line-height: 1;
    letter-spacing: 0.02em;
}

/* colors */
.hud-kpi--green { color: var(--green); }
.hud-kpi--green .hud-kpi-lbl { color: var(--green); opacity: 0.55; }
.hud-kpi--red   { color: #ff4d6a; }
.hud-kpi--red   .hud-kpi-lbl { color: #ff4d6a; opacity: 0.55; }
.hud-kpi--cyan  { color: var(--cyan, #00e5ff); }
.hud-kpi--cyan  .hud-kpi-lbl { color: var(--cyan, #00e5ff); opacity: 0.55; }

/* separador vertical fino */
.hud-sep {
    width: 1px;
    align-self: stretch;
    background: rgba(255,255,255,0.08);
    flex-shrink: 0;
    margin: 4px 0;
}

/* divisor horizontal entre fila KPI y fila métodos */
.hud-row-sep {
    width: 100%;
    height: 1px;
    background: rgba(255,255,255,0.07);
    margin: 2px 0 1px;
}

/* ── Fila métodos ── */
.hud-methods {
    display: flex;
    align-items: stretch;
    width: 100%;
    gap: 0;
}

.hud-m {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 1px;
    flex: 1;
    padding: 1px 8px 1px 6px;
}
.hud-m:first-child { padding-left: 2px; }

.hud-m-lbl {
    font-family: var(--mono);
    font-size: 0.48rem;
    letter-spacing: 0.14em;
    color: var(--text-dim);
    opacity: 0.7;
    line-height: 1;
    text-transform: uppercase;
}

.hud-m-val {
    display: flex;
    align-items: center;
    gap: 5px;
    font-family: var(--mono);
    font-size: 0.92rem;
    font-weight: 600;
    line-height: 1;
}

/* method colors */
.hud-m--fast  { color: #FFD600; }
.hud-m--fast  .hud-m-lbl { color: #FFD600; opacity: 0.5; }
.hud-m--ocr   { color: #a0b4cc; }
.hud-m--ocr   .hud-m-lbl { color: #a0b4cc; opacity: 0.5; }
.hud-m--ia    { color: var(--cyan, #00e5ff); }
.hud-m--ia    .hud-m-lbl { color: var(--cyan, #00e5ff); opacity: 0.5; }
.hud-m--audio { color: #b094e0; }
.hud-m--audio .hud-m-lbl { color: #b094e0; opacity: 0.5; }

/* ── Divisor principal ── */
.hud-div {
    width: 100%;
    height: 1px;
    background: rgba(255,255,255,0.08);
    margin: 2px 0 1px;
}

/* ── Sección última detección ── */
/* hud-last-area: ver definición canónica más abajo (junto a hud-swipe-content) */

/* dot indicator — NUNCA participa en el layout flex */
/* Así su posición no fluctúa con el texto del restaurante ni con sub-pixel rendering */
.hud-nav-dot {
    width        : 6px;
    height       : 6px;
    border-radius: 50%;
    background   : var(--text-dim);
    opacity      : 0.35;
    flex-shrink  : 0;
    pointer-events: none;
}

/* ── Dots de paginación — centrados respecto al bloque de detección ── */
.hud-dots {
    display        : flex;
    justify-content: center;
    align-items    : center;
    gap            : 8px;
    margin-top     : 6px;
    margin-bottom  : 2px;
    min-height     : 10px;
    width          : 100%;
    padding-left   : 14px;
    padding-right  : 14px;
    visibility     : hidden;   /* reserva espacio siempre; JS usa visibility en vez de display */
}

.hud-dot {
    width        : 6px;
    height       : 6px;
    border-radius: 50%;
    background   : var(--dot-inactive);
    flex-shrink  : 0;
    transition   : transform .25s ease, background .25s ease, box-shadow .25s ease;
    transform    : scale(0.83);
}

.hud-dot.active {
    /* C2: escalar desde 1 (6px) en vez de cambiar width/height */
    transform  : scale(1);
    background: var(--cyan, #00e5ff);
    box-shadow:
        0 0 6px var(--cyan, #00e5ff),
        0 0 12px rgba(0,229,255,0.4);
}

/* ── Estado vacío ── */
.hud-det {
    font-family: var(--mono);
    font-size: 0.58rem;
    color: var(--text-muted);
    opacity: 0.4;
    font-style: italic;
    min-height: 54px;      /* igual al contenido real: rest + zona + meta-row */
    display: flex;
    align-items: center;
}

/* ── Datos de detección ── */
.hud-det-data {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    width: 100%;
    overflow: visible;
    flex-shrink: 0;
    padding-left: 0;      /* alineado con el borde izquierdo del label ÚLTIMA DETECCIÓN */
}

.hud-rest {
    display: block;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    /* Hasta 2 líneas — line-clamp nativo */
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    white-space: normal;
    word-break: break-word;
    width: 100%;
    min-width: 0;
    line-height: 1.2;
    letter-spacing: -0.01em;
    text-shadow: 0 0 18px rgba(234,246,255,0.12);
}

.hud-zona {
    font-family: var(--mono);
    font-size: 0.70rem;
    color: var(--text-dim);
    white-space: normal;
    word-break: break-word;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    opacity: 0.9;
}

/* Línea de filtro/barrio — misma jerarquía visual que zona, secundaria al restaurante */
.hud-filtro {
    font-family: var(--mono);
    font-size: 0.68rem;
    color: var(--text-dim);
    white-space: normal;
    word-break: break-word;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    opacity: 0.75;
}

.hud-meta-row {
    display    : flex;
    align-items: center;
    gap        : 6px;
    flex-wrap  : nowrap;   /* nunca baja a segunda línea */
    margin-top : 1px;
    min-width  : 0;
    width      : 100%;
    overflow   : hidden;
}

/* ── Badge PENDIENTE / GANADO / PERDIDO ── */
.hud-badge {
    font-family: var(--mono);
    font-size: 0.60rem;
    font-weight: 600;
    letter-spacing: 0.07em;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(255,255,255,0.06);
    color: var(--text-muted);
    border: 1px solid rgba(255,255,255,0.12);
    white-space: nowrap;
    flex-shrink: 0;        /* nunca se encoge ni baja */
    transition: background 0.3s, color 0.3s, border-color 0.3s;
}
.hud-badge--ganado {
    background: rgba(0,230,118,0.14);
    color: var(--green);
    border-color: rgba(0,230,118,0.35);
    animation: badgeIn 0.4s ease;
}
.hud-badge--perdido {
    background: rgba(255,77,106,0.12);
    color: #ff4d6a;
    border-color: rgba(255,77,106,0.28);
    animation: badgeIn 0.4s ease;
}
@keyframes badgeIn {
    from { opacity: 0; transform: scale(0.88); }
    to   { opacity: 1; transform: scale(1); }
}

/* ── Info row: tiempo, método, velocidad ── */
.hud-ago, .hud-metodo, .hud-veloc {
    font-family: var(--mono);
    font-size: 0.66rem;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.hud-ago {
    color      : var(--text-muted);
    opacity    : 0.8;
    flex       : 0 0 60px;    /* no crece, no encoge, siempre 60px */
    min-width  : 60px;
    max-width  : 60px;
    display    : block;       /* block dentro del flex-row — no inline-block ni inline-flex */
    text-align : left;
    white-space: nowrap;
    overflow   : hidden;
    text-overflow: ellipsis;
}
.hud-metodo  { color: var(--text-muted); opacity: 0.72; }
.hud-veloc   { color: var(--cyan, #00e5ff); opacity: 0.85; }

/* separadores tipo "•" entre items de meta-row */
.hud-metodo::before {
    content: "•";
    color: var(--text-dim);
    opacity: 0.4;
    font-size: 0.55rem;
    margin-right: 2px;
}
.hud-ago::before { display: none; }   /* tiene emoji propio — sin punto antes */

/* ── Flash animations ── */
.flash { animation: kpiFlash 0.6s ease; }
@keyframes kpiFlash {
    0%   { opacity: 1; transform: scale(1.2); }
    100% { opacity: 1; transform: scale(1); }
}



/* ============================================================
   TEXTAREA REGEX — reemplaza input de una línea
============================================================ */
.regex-textarea {
    width: 100%;
    min-height: 280px;
    resize: vertical;
    font-family: var(--mono);
    font-size: 0.82rem;
    line-height: 1.8;
    padding: 12px 14px;
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
    /* wrap automático — sin scroll horizontal */
    white-space: pre-wrap;
    overflow-wrap: break-word;
    word-break: break-word;
    overflow-x: hidden;
    overflow-y: auto;
    tab-size: 2;
}

.regex-textarea:focus {
    border-color: var(--blue);
    box-shadow: 0 0 14px var(--blue-glow);
    background: var(--bg2);
}

.regex-textarea::placeholder { color: var(--text-muted); opacity: 0.6; }

/* ============================================================
   SUBSECTION TITLE — separador dentro de sección zonas
============================================================ */
.subsection-title {
    font-family: var(--mono);
    font-size: 0.62rem;
    letter-spacing: 0.2em;
    color: var(--text-dim);
    padding: 18px 0 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.subsection-title::before {
    content: '';
    display: inline-block;
    width: 3px;
    height: 12px;
    background: var(--blue);
    border-radius: 2px;
    box-shadow: 0 0 6px var(--blue);
    flex-shrink: 0;
}

.subsection-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* ============================================================
   EDITAR RESTAURANTE — btn edit in rest-item
============================================================ */
.btn-edit-rest {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 2px 5px;
    border-radius: 3px;
    cursor: pointer;
    transition: all var(--transition);
    line-height: 1;
}
.btn-edit-rest:hover {
    color: var(--blue);
    background: var(--blue-dark);
    box-shadow: 0 0 6px rgba(0,178,255,0.2);
}

/* ============================================================
   ⚔️ MODO GUERRA TOGGLE
============================================================ */
.guerra-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 5px 0;
    border-bottom: 1px solid var(--border);
    margin: 0;
}

.guerra-info {
    display: flex;
    align-items: center;
    gap: 7px;
    flex: 1;
    min-width: 0;
}

.guerra-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
    line-height: 1.3;
}

.guerra-title {
    font-family: var(--mono);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--text);
}

.guerra-toggle {
    background: none;
    border: none;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    cursor: pointer;
    padding: 0;
}

.gt-track {
    width: 44px;
    height: 22px;
    border-radius: 11px;
    border: 1px solid var(--text-muted);
    background: var(--bg3);
    position: relative;
    transition: all 0.3s;
}

.gt-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: all 0.3s;
}

.gt-state {
    font-family: var(--mono);
    font-size: 0.65rem;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    min-width: 24px;
    transition: color 0.3s;
}

/* GUERRA ACTIVA — rojo/naranja agresivo */
@keyframes guerraPulse {
    0%   { box-shadow: 0 0 0 0 rgba(255, 59, 59, 0.4); }
    70%  { box-shadow: 0 0 0 8px rgba(255, 59, 59, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 59, 59, 0); }
}
.guerra-toggle.active .gt-track {
    border-color: var(--red);
    background: rgba(255, 59, 59, 0.12);
    box-shadow: 0 0 12px rgba(255, 59, 59, 0.35);
    animation: guerraPulse 2s ease-out infinite;
}
.guerra-toggle.active .gt-thumb {
    left: 25px;
    background: var(--red);
    box-shadow: 0 0 8px rgba(255, 59, 59, 0.7);
}
.guerra-toggle.active .gt-state {
    color: var(--red);
    text-shadow: 0 0 8px rgba(255, 59, 59, 0.5);
}
.guerra-toggle.active ~ * .guerra-title,
.guerra-row:has(.guerra-toggle.active) .guerra-title {
    color: var(--red);
    text-shadow: 0 0 8px rgba(255, 59, 59, 0.3);
}

/* card sin label: compensar el padding-top para que el contenido no flote */
.card--no-label {
    padding-top: 14px;
    padding-bottom: 14px;
}
.status-inner-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

/* sr-wrap: padding-left aleja el círculo del borde izquierdo de la card; margin-top lo sube */
.status-inner-row .sr-wrap {
    padding: 0 0 2px 14px;
    flex-shrink: 0;
    margin-top: -14px;
}

/* Panel derecho con HUD — siempre a la derecha del círculo */
.det-inline {
    flex: 1;
    min-width: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 1px;
    padding-left: 14px;
    opacity: 0.9;
    margin-top: -14px;   /* sube las métricas para alinear con el label WHATSAPP */
}

/* Área última detección — altura reservada fija para no colapsar layout */
.hud-last-area {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 2px;
    height: auto;
    min-height: 96px;     /* ampliado: más espacio para restaurante multilinea + zona + meta */
    overflow: visible;
    position: relative;
    flex-shrink: 0;
}

/* Wrapper interno animable — creado por JS en initHudSwipe() */
.hud-swipe-content {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-width: 0;
    width: 100%;
    height: auto;
    overflow: visible;
    flex-shrink: 0;
}

/* ── Animaciones de carrusel ── */
@keyframes hudSlideInLeft {
    from { opacity: 0; transform: translateX(-18px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes hudSlideInRight {
    from { opacity: 0; transform: translateX(18px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes hudSlideOutLeft {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(-18px); }
}
@keyframes hudSlideOutRight {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(18px); }
}

.hud-swipe-content.hud-slide-in-left  { animation: hudSlideInLeft  0.18s ease-out forwards; }
.hud-swipe-content.hud-slide-in-right { animation: hudSlideInRight 0.18s ease-out forwards; }
.hud-swipe-content.hud-slide-out-left  { animation: hudSlideOutLeft  0.10s ease-in  forwards; }
.hud-swipe-content.hud-slide-out-right { animation: hudSlideOutRight 0.10s ease-in  forwards; }

/* ── Barra de navegación: label izquierda, badge derecha ── */
.hud-nav-bar {
    display         : flex;
    align-items     : center;
    justify-content : space-between;
    height          : 22px;
    width           : 100%;
    margin-bottom   : 4px;
}

/* Badge dentro de nav-bar: empujado al extremo derecho */
.hud-nav-bar .hud-badge {
    margin-left : auto;
    flex-shrink : 0;
}

.hud-nav-lbl {
    font-family   : var(--mono);
    font-size     : 0.52rem;
    letter-spacing: 0.14em;
    color         : var(--text-dim);
    opacity       : 0.75;
    text-transform: uppercase;
    user-select   : none;
    flex          : 1;
    min-width     : 0;
    overflow      : hidden;
    text-overflow : ellipsis;
    white-space   : nowrap;
}

/* Móvil: mantener el mismo layout horizontal (no stack) */
/* ============================================================
   RESPONSIVE MÓVIL — max-width: 768px
   Desktop NO se toca. Todos los cambios aquí.
============================================================ */
@media (max-width: 768px) {

    /* Tope superior: mismo patrón que --safe-bottom. body es el único
       punto de control — empuja .main/.topbar/.content de una sola vez.
       env(safe-area-inset-top) puede resolver a 0px en este WebView
       igual que safe-bottom. */
    body {
        padding-top: max(var(--safe-top), 24px);
    }

    /* ── Sidebar: oculta por defecto, desliza al abrir ── */
    .sidebar {
        transform: translateX(-100%);
        width: min(82vw, 260px);
        box-shadow: none;
        /* Corte físico: html ahora tiene background propio (arriba), así
           que acortar la caja del sidebar ya no deja hueco negro detrás.
           Los paddings de .sidebar-account y .section.active:not(#sec-
           dashboard) se mantienen sin cambios — siguen protegiendo el
           contenido por encima de este nuevo borde. */
        bottom: max(var(--safe-bottom), 48px);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 30px rgba(0,0,0,0.55);
        /* EXPERIMENTO — el clip-path recorta 2px hacia adentro desde el
           fondo (en vez de exactamente en 0) para evadir el artefacto de
           anti-aliasing que deja el WebView al guillotinar un blur de
           30px justo en el borde de la coordenada de recorte. */
        /* Revertido: morder 2px hizo la línea MÁS ancha (se comía 2px del
           propio fondo blanco de .sidebar, exponiendo más overlay detrás).
           Esto confirma que la línea NO depende del clip-path ni del blur
           del box-shadow — existe igual en 0, sin recorte. Hipótesis de
           artefacto de render descartada con evidencia. */
        clip-path: inset(0 -40px 0 0);
    }

    .sidebar-overlay.open { display: block; }

    /* Alinear el velo con el mismo corte físico de .sidebar — hoy tiene
       inset:0 y oscurece 48px más abajo que el sidebar, creando un salto
       de contraste (blanco puro -> zona teñida) justo en el borde del
       menú. Con el mismo corte, esa franja muestra --bg claro en vez de
       overlay oscuro, sin salto brusco. */
    .sidebar-overlay {
        bottom: max(var(--safe-bottom), 48px);
    }

    /* Main: sin margen lateral (sidebar no empuja). Altura original —
       fondo hasta el borde real; el resguardo del contenido vive en el
       padding de .section, no acortando .main. #sec-dashboard/.dash-grid
       siguen tomando 100% de lo que .main les entregue sin problema. */
    .main {
        margin-left: 0;
        /* Mismo piso que body (24px) y que .sidebar (48px) — si .main no
           usa el mismo max(), el total (padding-top de body + height de
           .main) deja de sumar 100vh exacto, reabriendo el scroll de
           documento completo que la Fase 1 ya había resuelto. */
        height: calc(100vh - max(var(--safe-top), 24px) - max(var(--safe-bottom), 48px));
    }

    /* Hamburger visible en móvil */
    .hamburger { display: flex; }

    /* ── Content: padding reducido ── */
    .content { padding: 20px 8px 2px; }

    /* El padre real asume el control directo — las cards pasan a ser
       hijas directas de #sec-dashboard.active (ver .dash-grid abajo).
       gap:6px — mismo valor que .content:has(#sec-dashboard.active)
       usa para el padding-top (header→primera tarjeta), a pedido
       explícito: los 3 espacios (header→card1, card1→card2, card2→card3)
       deben verse idénticos. */
    #sec-dashboard.active {
        display: flex;
        flex-direction: column;
        gap: 6px;
    }

    /* ── Dash-grid: EXPERIMENTO — display:contents. Tanto el calc() como
       el height:100% dieron el MISMO número exacto (466.5px en vez de
       680.5px esperado), lo cual descarta la fórmula como causa y apunta
       a un problema de anidamiento entre dos niveles de flex encadenados
       (#sec-dashboard → .dash-grid). Con display:contents, .dash-grid
       desaparece del árbol de caja — sus 3 cards pasan a ser hijas
       directas de #sec-dashboard.active, evadiendo el nivel de anidado
       problemático por completo. ── */
    .dash-grid {
        display: contents;
    }

    /* TARJETA SUPERIOR */
    .card--status {
        flex: 0 0 auto;
        min-height: auto;
    }

    /* TARJETA CENTRAL: Restaurantes absorbe los píxeles exactos sobrantes y scrollea */
    .card--quickops {
        flex: 1 1 0;
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
    }

    /* TARJETA INFERIOR: Actividad Reciente se pega al fondo */
    .card--quicklogs {
        flex: 0 0 auto;
        margin-top: 0;
    }

    /* ── Colchón de contenido — fondos (.sidebar, .main) llegan hasta el
       borde físico; el contenido interactivo se protege con padding.
       60px de piso real, en vez de los 20px insuficientes del primer
       intento. #sec-dashboard queda excluido: cero efecto sobre
       display:contents/flex del dashboard.
       .sidebar-account SIN padding-bottom propio: era redundante desde
       que .sidebar pasó a bottom:max(...) — dos descuentos apilados
       sobre el mismo problema (caja cortada + padding interno). ── */
    .section.active:not(#sec-dashboard) {
        padding-bottom: max(calc(var(--safe-bottom) + 12px), 80px);
    }

    /* ── Fila de toggles rápidos (topbar): compacta en móvil ── */
    .topbar-quick-toggles { gap: 2px; }
    .topbar-quick-toggles .guerra-toggle { padding: 5px; }
    .qtoggle-icon { font-size: 19px; }
    /* .qops-list max-height:118px eliminado — .qops-list ya no scrollea
       por su cuenta (paso 1), el scroll de móvil lo maneja .card--quickops
       con su height:250px + overflow-y:auto */

    /* ── Card principal: SIEMPRE horizontal — círculo izquierda, HUD derecha ── */
    .status-inner-row {
        flex-direction: row;
        align-items: center;
        gap: 8px;
    }

    /* sr-wrap: sin padding lateral extra en móvil */
    .status-inner-row .sr-wrap {
        padding: 4px 0 4px 6px;
        flex-shrink: 0;
    }

    /* ── Círculo TAP: 92×92 px ── */
    .sr {
        width: 92px;
        height: 92px;
    }

    /* ── det-inline: ocupa el espacio restante, alineado a la izquierda ── */
    .det-inline {
        flex: 1;
        min-width: 0;
        padding-left: 14px;
        align-items: stretch;  /* stretch — hijos siempre al ancho completo, no al contenido */
        gap: 2px;
        opacity: 1;
    }

    /* ── HUD KPIs: misma distribución horizontal en móvil ── */
    /* ── HUD KPIs mobile — inherit desktop layout ── */
    .hud-kpi { padding: 3px 6px 3px 4px; }
    .hud-kpi-lbl { font-size: 0.50rem; letter-spacing: 0.14em; }
    .hud-kpi-val { font-size: 0.88rem; gap: 4px; }
    .hud-ico     { width: 1.3em; height: 1.3em; }

    /* ── HUD Methods mobile ── */
    .hud-m { padding: 1px 5px 1px 3px; }
    .hud-m-lbl  { font-size: 0.50rem; letter-spacing: 0.12em; }
    .hud-m-val  { font-size: 0.78rem; gap: 3px; }
    .hud-ico--sm { width: 1.6em; height: 1.6em; }

    /* ── HUD detección mobile ── */
    .hud-rest      { font-size: 1.0rem; }
    .hud-zona      { font-size: 0.68rem; }
    .hud-filtro    { font-size: 0.66rem; }
    .hud-badge     { font-size: 0.58rem; padding: 2px 7px; }
    .hud-ago, .hud-metodo, .hud-veloc { font-size: 0.64rem; }
    .hud-det       { font-size: 0.58rem; }

    .hud-meta-row { gap: 4px; }
    .hud-div { margin: 2px 0 1px; }
    /* hud-last-area y hud-swipe-content usan height:auto — sin override necesario */

    /* ── Quicklog: altura fija, más chica en móvil que en desktop ── */
    .quicklog { height: 130px; }

    .ql-entry { font-size: 0.68rem; }

    /* ── Bot actions: fila compacta ── */
    .bot-actions {
        flex-direction: row;
        gap: 6px;
    }

    .btn-action { font-size: 0.68rem; padding: 6px 8px; }

    /* ── Regex textarea ── */
    .regex-textarea { min-height: 320px; font-size: 0.8rem; }

    /* ── Modal: ancho completo ── */
    .modal { max-width: 100%; padding: 16px; }

    /* ── Zona header: permite wrap ── */
    .zona-row     { flex-wrap: nowrap; }  /* fila compacta no wrappea en móvil */

    /* ── Grupo quickbtns: compactos ── */
    .btn-quick     { font-size: 0.5rem; padding: 2px 5px; }
    .grupo-quickbtns { gap: 3px; }

    /* ── Tabla: scroll horizontal si necesita ── */
    .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

    /* ── Terminal logs ── */
    /* (override de height:60vh eliminado — el terminal ahora se
       dimensiona por flex dentro de #sec-logs, ver regla base) */
}

/* ============================================================
   MEJORAS PREMIUM — UX visual sin layout shifts
============================================================ */

/* 1. Animación de nueva detección: fade + slide 150ms */
@keyframes detReveal {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.det-reveal {
    animation: detReveal 0.15s ease forwards;
    will-change: opacity, transform;
}

/* 2. Bump de contador KPI al cambiar valor */
@keyframes numBump {
    0%   { transform: scale(1); }
    45%  { transform: scale(1.12); }
    100% { transform: scale(1); }
}
.num-bump {
    animation: numBump 0.18s ease;
    display: inline-block;
}

/* 3. Colores de latencia */
.veloc--fast { color: var(--green);         opacity: 0.9; }
.veloc--mid  { color: #FFD600;              opacity: 0.9; }
.veloc--slow { color: #ff4d6a;              opacity: 0.9; }

/* 4. Badge PENDIENTE premium */
.hud-badge:not(.hud-badge--ganado):not(.hud-badge--perdido) {
    background: rgba(255,255,255,0.07);
    border-color: rgba(255,255,255,0.22);
    box-shadow: 0 0 6px rgba(255,255,255,0.06);
}

/* 5. Dot activo premium — definición canónica consolidada */
.hud-nav-dot {
    transition: background 0.35s ease, box-shadow 0.35s ease, opacity 0.35s ease;
}
.hud-nav-dot.dot--active {
    background: var(--green);
    opacity: 1;
    box-shadow: 0 0 7px var(--green), 0 0 14px rgba(0,230,118,0.25);
}

/* 6. Pill CONECTADO — pulso sutil cada 3s */
@keyframes pillPulse {
    0%, 80%, 100% { box-shadow: 0 0 0 0 rgba(0,230,118,0); }
    40%            { box-shadow: 0 0 0 5px rgba(0,230,118,0.18); }
}
.wa-status-pill.online {
    animation: pillPulse 3s ease-out infinite;
}

/* 7. Touch/hover feedback en botones de acción */
.btn-action,
.guerra-toggle,
.btn-restart,
.btn-disc {
    transition: transform 0.12s ease, opacity 0.12s ease, box-shadow 0.12s ease;
    -webkit-tap-highlight-color: transparent;
}
.btn-action:active,
.guerra-toggle:active,
.btn-restart:active,
.btn-disc:active {
    transform: scale(0.97);
    opacity: 0.88;
}
@media (hover: hover) {
    .btn-action:hover,
    .guerra-toggle:hover,
    .btn-restart:hover,
    .btn-disc:hover {
        transform: scale(1.01);
    }
}

/* ============================================================
   MANTENIMIENTO — botones naranja (historial) y rojo (stats)
============================================================ */

.btn-sist--historial:hover {
    border-color: var(--orange, #ff8c00);
    color: var(--orange, #ff8c00);
    background: rgba(255,140,0,0.07);
    box-shadow: 0 0 10px rgba(255,140,0,0.18);
}

.btn-sist--resetstats:hover {
    border-color: #ff4d6a;
    color: #ff4d6a;
    background: rgba(255,77,106,0.07);
    box-shadow: 0 0 10px rgba(255,77,106,0.18);
}

.btn-sist--historial:active,
.btn-sist--resetstats:active {
    transform: scale(0.97);
    opacity: 0.88;
}

/* ── Licencia — panel premium ── */
.lic-premium {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 18px 10px 14px;
    text-align: center;
}

.lic-premium-status {
    font-family: var(--mono);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    padding: 5px 16px;
    border-radius: 6px;
    border: 1px solid;
    margin-bottom: 6px;
}

.lic-status--activa {
    color: var(--green);
    background: rgba(0,230,118,0.08);
    border-color: rgba(0,230,118,0.3);
    text-shadow: 0 0 10px rgba(0,230,118,0.4);
}

.lic-status--por-vencer {
    color: var(--yellow);
    background: rgba(255,214,0,0.08);
    border-color: rgba(255,214,0,0.35);
    text-shadow: 0 0 10px rgba(255,214,0,0.35);
}

.lic-status--vencida {
    color: var(--red);
    background: rgba(255,59,59,0.08);
    border-color: rgba(255,59,59,0.3);
    text-shadow: 0 0 10px rgba(255,59,59,0.3);
}

.lic-status--revocada {
    color: var(--red);
    background: rgba(255,59,59,0.14);
    border-color: rgba(255,59,59,0.45);
    text-shadow: 0 0 10px rgba(255,59,59,0.3);
}

.lic-status--sin-licencia {
    color: var(--text-dim);
    background: rgba(122,140,165,0.08);
    border-color: var(--border);
}

.lic-premium-foto {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
    margin-bottom: 4px;
}

.lic-premium-email {
    font-family: var(--mono);
    font-size: 0.66rem;
    color: var(--text-dim);
    letter-spacing: 0.02em;
    margin-top: -2px;
}

.lic-premium-cliente {
    font-family: var(--mono);
    font-size: 0.72rem;
    color: var(--text);
    letter-spacing: 0.04em;
}

.lic-premium-expiry {
    font-family: var(--mono);
    font-size: 0.68rem;
    color: var(--text-dim);
    letter-spacing: 0.04em;
}

.lic-premium-date {
    font-family: var(--mono);
    font-size: 0.62rem;
    color: var(--text-muted);
    margin-top: 2px;
    letter-spacing: 0.06em;
}

/* Opciones del select con foto — se implementa via custom dropdown overlay */
.mod-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    width: 100%;
    z-index: 500;
    background: var(--bg3);
    border: 1px solid var(--border2);
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    max-height: 240px;
    overflow-y: auto;
}

.mod-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 12px;
    cursor: pointer;
    font-family: var(--mono);
    font-size: 0.68rem;
    color: var(--text);
    transition: background var(--transition);
    border-bottom: 1px solid var(--border);
}

.mod-dropdown-item:last-child { border-bottom: none; }

.mod-dropdown-item:hover,
.mod-dropdown-item.selected {
    background: rgba(0,178,255,0.08);
    color: var(--cyan);
}

.mod-dropdown-item img {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border2);
    flex-shrink: 0;
}

.mod-dropdown-item .mod-di-avatar-ph {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--bg4);
    border: 1px solid var(--border2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.mod-dropdown-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Módulo Moderadores — nombre real (👤) vs. fallback numérico (⚠️) y
   el identificador secundario, cuando el nombre sí es real. */
.mod-dropdown-name-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    line-height: 1.3;
}

.mod-dropdown-name-warn {
    color: var(--orange);
}

.mod-dropdown-id-secundario {
    font-size: 0.6rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Módulo independiente de Asignación (participante ↔ restaurante) —
   misma paleta/estructura que .mod-dropdown-item, en tarjetas en vez
   de lista de un solo click (acá cada fila tiene su propio control). */
.asig-participantes-list {
    max-height: 320px;
    overflow-y: auto;
    border: 1px solid var(--border2);
    border-radius: var(--radius-sm);
    background: var(--bg3);
}

.asig-participante-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    font-family: var(--mono);
    font-size: 0.68rem;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.asig-participante-item:last-child { border-bottom: none; }

.asig-participante-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.asig-participante-nombre {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.asig-participante-id {
    font-size: 0.6rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.asig-participantes-vacio {
    padding: 14px 12px;
    font-family: var(--mono);
    font-size: 0.68rem;
    color: var(--text-muted);
    text-align: center;
}

/* Foco visible por teclado — accesibilidad de ambos módulos */
.mod-dropdown-item:focus-visible,
.asig-participante-item select:focus-visible {
    outline: 2px solid var(--cyan);
    outline-offset: -2px;
}

@media (max-width: 560px) {
    .asig-participante-item {
        gap: 8px;
    }
    .asoc-restaurante-select {
        max-width: 100%;
        flex: 1 1 100%;
        margin-top: 4px;
    }
}

.asoc-restaurante-select {
    flex-shrink: 0;
    max-width: 110px;
    font-family: var(--mono);
    font-size: 0.62rem;
    color: var(--text);
    background: var(--bg4);
    border: 1px solid var(--border2);
    border-radius: var(--radius-sm);
    padding: 3px 4px;
}

.mod-select-container {
    position: relative;
    /* overflow: visible es necesario para que el dropdown absoluto no quede cortado */
    overflow: visible;
}

.mod-selected-display {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg3);
    border: 1px solid var(--border2);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    cursor: pointer;
    font-family: var(--mono);
    font-size: 0.68rem;
    color: var(--text);
    transition: border-color var(--transition);
    min-height: 38px;
}

/* Lista compacta de moderadores seleccionados, debajo del selector —
   un chip por moderador, con check + avatar + nombre. */
.mod-selected-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.mod-selected-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg3);
    border: 1px solid var(--border2);
    border-radius: 999px;
    padding: 3px 10px 3px 6px;
    font-family: var(--mono);
    font-size: 0.66rem;
    color: var(--text);
}

.mod-selected-check {
    color: var(--cyan);
    font-weight: 700;
    flex-shrink: 0;
}

.mod-selected-avatar-wrap {
    display: flex;
    flex-shrink: 0;
}

.mod-selected-name {
    white-space: nowrap;
}

.mod-selected-display:hover {
    border-color: var(--blue);
}

.mod-selected-display.open {
    border-color: var(--cyan);
}

.mod-selected-display .mod-sel-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mod-selected-display .mod-sel-arrow {
    color: var(--text-muted);
    font-size: 0.6rem;
    transition: transform var(--transition);
    flex-shrink: 0;
}

.mod-selected-display.open .mod-sel-arrow {
    transform: rotate(180deg);
}

.mod-selected-display[disabled],
.mod-selected-display.disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

/* Buscador de grupo */
#grupoSearch {
    margin-bottom: 6px;
}

/* ── Foto restaurante — Dashboard última detección ── */
#sv2LastRest {
    display: block;
    min-width: 0;
    overflow: hidden;
}

#sv2RestNombre {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 1.12rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.15;
    letter-spacing: -0.01em;
}

/* ── Foto restaurante — Lista Restaurantes ── */
.rest-avatar {
    flex-shrink: 0;
    border-radius: 50%;
    display: block;
}

/* Transición suave al cargar la foto */
.rest-item img.rest-avatar {
    animation: restAvatarFadeIn 0.25s ease;
}

@keyframes restAvatarFadeIn {
    from { opacity: 0; transform: scale(0.85); }
    to   { opacity: 1; transform: scale(1); }
}

/* ============================================================
   REGEX EDITOR — buscador + overlay de highlights
============================================================ */

/* ── Wrap que contiene overlay + textarea ── */
.regex-editor-wrap {
    position: relative;
    width: 100%;
}

/* ── Overlay de resaltado (espejo del textarea) ── */
.regex-highlight-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    /* Mismos valores visuales que .regex-textarea */
    font-family: var(--mono);
    font-size: 0.82rem;
    line-height: 1.8;
    padding: 12px 14px;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    word-break: break-word;
    overflow: hidden;
    border: 1px solid transparent;   /* ocupa mismo espacio que el borde del textarea */
    border-radius: var(--radius-sm);
    color: transparent;               /* texto invisible — solo los marks se ven */
    tab-size: 2;
    z-index: 1;
    /* Scroll se sincroniza via JS */
}

.regex-highlight-overlay mark {
    background: rgba(255, 214, 0, 0.35);
    border-radius: 2px;
    color: transparent;
    outline: 1px solid rgba(255, 214, 0, 0.55);
}

/* Coincidencia activa (la que está seleccionada) */
.regex-highlight-overlay mark.regex-match--active {
    background: rgba(0, 229, 255, 0.40);
    outline: 1px solid rgba(0, 229, 255, 0.80);
}

/* El textarea queda encima del overlay con fondo transparente cuando hay búsqueda activa */
.regex-editor-wrap.searching .regex-textarea {
    background: transparent;
    position: relative;
    z-index: 2;
    caret-color: var(--cyan);
}

/* Fondo del wrap cuando está en modo búsqueda (lo ve el usuario) */
.regex-editor-wrap.searching {
    background: var(--bg3);
    border-radius: var(--radius-sm);
}

.regex-editor-wrap.searching .regex-textarea:focus {
    background: transparent;
    box-shadow: none;
    border-color: var(--blue);
}

/* ── Barra de búsqueda ── */
.regex-search-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 5px 8px;
    transition: border-color var(--transition);
}

.regex-search-bar:focus-within {
    border-color: var(--blue);
    box-shadow: 0 0 8px var(--blue-glow);
}

.regex-search-input-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
}

.regex-search-icon {
    font-size: 1rem;
    color: var(--text-muted);
    flex-shrink: 0;
    line-height: 1;
    margin-top: -1px;
}

.regex-search-input {
    flex: 1;
    background: transparent !important;
    border: none !important;
    padding: 2px 0 !important;
    font-size: 0.78rem !important;
    color: var(--text) !important;
    font-family: var(--mono) !important;
    box-shadow: none !important;
    outline: none !important;
    min-width: 0;
}

.regex-search-input::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

.regex-search-count {
    font-family: var(--mono);
    font-size: 0.65rem;
    color: var(--text-dim);
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 48px;
    text-align: right;
}

.regex-search-count.has-results { color: var(--yellow); }
.regex-search-count.no-results  { color: var(--red); }

/* ── Botones de navegación ── */
.regex-search-nav {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}

.regex-nav-btn {
    background: var(--bg4);
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-size: 1rem;
    font-weight: 700;
    line-height: 1;
    width: 26px;
    height: 26px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    padding: 0;
    cursor: pointer;
}

.regex-nav-btn:hover:not(:disabled) {
    border-color: var(--blue);
    color: var(--cyan);
    background: var(--blue-glow);
}

.regex-nav-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

.regex-nav-btn--clear {
    font-size: 0.65rem;
    font-weight: 400;
}

.regex-nav-btn--clear:hover:not(:disabled) {
    border-color: var(--red);
    color: var(--red);
    background: rgba(255,59,59,0.1);
}

/* ── Barra de verificación ── */
.regex-verify-bar {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.regex-verify-input-wrap {
    display: flex;
    gap: 6px;
    align-items: center;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 5px 8px;
    transition: border-color var(--transition);
}

.regex-verify-input-wrap:focus-within {
    border-color: var(--blue-dim);
}

.regex-verify-btn {
    background: var(--bg4);
    border: 1px solid var(--border2);
    color: var(--blue);
    font-family: var(--mono);
    font-size: 0.65rem;
    letter-spacing: 0.08em;
    padding: 4px 10px;
    border-radius: 4px;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all var(--transition);
    cursor: pointer;
}

.regex-verify-btn:hover {
    background: var(--blue-glow);
    border-color: var(--cyan);
    color: var(--cyan);
    box-shadow: 0 0 8px var(--blue-glow);
}

.regex-verify-btn:active {
    transform: scale(0.97);
}

.regex-verify-result {
    font-family: var(--mono);
    font-size: 0.68rem;
    letter-spacing: 0.05em;
    min-height: 18px;
    padding: 2px 4px;
    transition: all var(--transition);
}

.regex-verify-result.found {
    color: var(--green);
}

.regex-verify-result.not-found {
    color: var(--red);
}

.regex-verify-result.partial {
    color: var(--yellow);
}

/* ============================================================
   NOMENCLATURAS
============================================================ */

/* ── Stats bar ─────────────────────────────────────────────── */
.nom-stats-bar {
    display: flex;
    align-items: center;
    gap: 0;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 20px;
    margin-bottom: 2px;
}

.nom-stat {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    flex: 1;
}

.nom-stat--update {
    flex: 1.6;
}

.nom-stat-sep {
    width: 1px;
    height: 32px;
    background: var(--border);
    flex-shrink: 0;
    margin: 0 20px;
}

.nom-stat-val {
    font-family: var(--mono);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--cyan);
    line-height: 1;
    text-shadow: 0 0 12px rgba(0,229,255,0.3);
}

.nom-stat-val--sm {
    font-size: 0.78rem;
    text-shadow: none;
    color: var(--text);
    font-weight: 500;
}

.nom-stat-lbl {
    font-family: var(--mono);
    font-size: 0.55rem;
    letter-spacing: 0.16em;
    color: var(--text-muted);
}

/* ── Tabla ────────────────────────────────────────────────── */
.nom-center {
    text-align: center;
}

.nom-check-on {
    color: var(--green);
    font-weight: 700;
}

.nom-check-off {
    color: var(--text-muted);
}

.nom-actions-cell {
    white-space: nowrap;
    text-align: right;
    padding-right: 10px !important;
}

.nom-btn-edit {
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 3px 6px;
    border-radius: 4px;
    border: none;
    background: none;
    cursor: pointer;
    transition: all var(--transition);
}

.nom-btn-edit:hover {
    color: var(--blue);
    background: var(--blue-dark);
    box-shadow: 0 0 6px rgba(0,178,255,0.2);
}

.nom-btn-del--act {
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 3px 6px;
    border-radius: 4px;
    border: none;
    background: none;
    cursor: pointer;
    transition: all var(--transition);
}

.nom-btn-del--act:hover {
    color: var(--red);
    background: rgba(255,59,59,0.1);
}

.nom-empty {
    text-align: center;
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 0.08em;
    padding: 30px 0;
}

/* ── Probar dirección ──────────────────────────────────────── */
.nom-probe-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.nom-probe-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

@keyframes nomProbeReveal {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.nom-probe-anim {
    animation: nomProbeReveal 0.18s ease;
}

.nom-probe-result {
    padding: 14px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.nom-res-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 14px;
}

.nom-res-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nom-res-lbl {
    font-family: var(--mono);
    font-size: 0.55rem;
    letter-spacing: 0.16em;
    color: var(--text-muted);
}

.nom-res-val {
    font-family: var(--mono);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
}

.nom-res-zona--match {
    color: var(--cyan);
    text-shadow: 0 0 10px rgba(0,229,255,0.35);
}

.nom-res-zona--miss {
    color: var(--text-dim);
}

.nom-match-label {
    font-family: var(--mono);
    font-size: 0.55rem;
    letter-spacing: 0.14em;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.nom-match-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.nom-match-range {
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--text);
    background: var(--bg4);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 2px 8px;
}

.nom-match-sep {
    color: var(--text-muted);
    font-size: 0.7rem;
}

.nom-res-motivos {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nom-motivo {
    font-family: var(--mono);
    font-size: 0.68rem;
    color: var(--yellow);
    letter-spacing: 0.04em;
}

/* ── Modal ────────────────────────────────────────────────── */
.nom-modal {
    max-width: 480px;
}

.nom-modal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 12px;
}

.nom-modal-checks {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.nom-check-row {
    display: flex;
    align-items: center;
    gap: 7px;
    cursor: pointer;
    user-select: none;
}

.nom-check-row input[type="checkbox"] {
    accent-color: var(--blue);
    width: 15px;
    height: 15px;
    cursor: pointer;
}

.nom-check-label {
    font-family: var(--mono);
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    color: var(--text-dim);
}

/* ── Solapamientos — tabla ──────────────────────────────────── */
.nom-row--conflict {
    background: rgba(255, 140, 0, 0.06);
    border-left: 2px solid var(--orange);
    position: relative;
}

.nom-row--conflict:hover {
    background: rgba(255, 140, 0, 0.1);
}

.nom-conflict-icon {
    display: inline-block;
    font-size: 0.7rem;
    color: var(--orange);
    text-shadow: 0 0 8px rgba(255, 140, 0, 0.6);
    cursor: help;
    vertical-align: middle;
    line-height: 1;
    margin-right: 2px;
    animation: nomConflictPulse 2.4s ease-in-out infinite;
}

@keyframes nomConflictPulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.5; }
}

/* ── Solapamientos — modal ──────────────────────────────────── */
.nom-conflict-warn {
    margin: 8px 0 4px;
    padding: 10px 12px;
    background: rgba(255, 140, 0, 0.08);
    border: 1px solid rgba(255, 140, 0, 0.35);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--orange);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nom-conflict-title {
    font-family: var(--mono);
    font-size: 0.55rem;
    letter-spacing: 0.16em;
    color: var(--orange);
    margin-bottom: 4px;
}

.nom-conflict-item {
    font-family: var(--mono);
    font-size: 0.68rem;
    color: var(--text-dim);
    line-height: 1.4;
}

.nom-conflict-item strong {
    color: var(--orange);
    font-weight: 600;
}

/* ── Responsive móvil ─────────────────────────────────────── */
@media (max-width: 768px) {
    .nom-stats-bar {
        padding: 12px 14px;
    }

    .nom-stat-sep {
        margin: 0 12px;
    }

    .nom-stat-val {
        font-size: 1.05rem;
    }

    .nom-res-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .nom-modal-grid {
        grid-template-columns: 1fr 1fr;
    }

    /* ── Vista de tarjetas móvil ── */
    #nomTableWrap {
        display: none;
    }

    .nom-cards-list {
        display: flex !important;
    }
}

/* ============================================================
   NOM-CARDS — estilos base (siempre cargados, ocultos en desktop)
============================================================ */

/* Contenedor — oculto por defecto; el media query lo activa */
.nom-cards-list {
    display: none;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
}

/* Tarjeta individual */
.nom-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color var(--transition);
}

.nom-card:hover {
    border-color: var(--border2);
}

/* Tarjeta en conflicto — mismo lenguaje visual que .nom-row--conflict */
.nom-card--conflict {
    background: rgba(255, 140, 0, 0.06);
    border-left: 3px solid var(--orange);
}

.nom-card--conflict:hover {
    background: rgba(255, 140, 0, 0.1);
}

/* Cabecera: zona + botones de acción */
.nom-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px 8px;
    border-bottom: 1px solid var(--border);
}

.nom-card-zona {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.nom-card-zona .zona-pill {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.nom-card-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

/* Cuerpo de la tarjeta */
.nom-card-body {
    padding: 10px 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Fila etiqueta + valor */
.nom-card-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.nom-card-lbl {
    font-family: var(--mono);
    font-size: 0.52rem;
    letter-spacing: 0.14em;
    color: var(--text-muted);
    flex-shrink: 0;
    width: 68px;     /* alineación vertical de valores */
}

.nom-card-val {
    font-family: var(--mono);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
}

.nom-card-val--dim {
    color: var(--text-muted);
    font-weight: 400;
}

/* Badges de indicadores booleanos */
.nom-card-indicators {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 2px;
}

.nom-card-badge {
    font-family: var(--mono);
    font-size: 0.52rem;
    letter-spacing: 0.1em;
    padding: 2px 7px;
    border-radius: 3px;
    border: 1px solid transparent;
}

.nom-card-badge--on {
    color: var(--green);
    background: rgba(0, 230, 118, 0.08);
    border-color: rgba(0, 230, 118, 0.25);
}

.nom-card-badge--off {
    color: var(--text-muted);
    background: transparent;
    border-color: var(--border);
}

/* ============================================================
   LUGARES CONOCIDOS — banda compacta de metainfo
============================================================ */

/* Grid de cabecera: ahora ocupa 1 sola columna (banda completa) */
/* ============================================================
   LUGARES CONOCIDOS — info panel compacto (reemplaza lc-header-grid)
============================================================ */
.lc-info-panel {
    display: flex;
    align-items: stretch;
    gap: 0;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
    overflow: hidden;
}

.lc-info-left {
    flex: 1;
    padding: 10px 14px;
    border-right: 1px solid var(--border);
}

.lc-info-title {
    font-family: var(--mono);
    font-size: 0.65rem;
    letter-spacing: 0.12em;
    color: var(--cyan);
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 7px;
}

.lc-info-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.lc-info-list li {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.76rem;
    color: var(--text-dim);
    line-height: 1.2;
}

/* Badges inline dentro de la lista */
.lc-info-badge {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 8px;
    font-family: var(--mono);
    font-size: 0.60rem;
    letter-spacing: 0.06em;
    font-weight: 700;
    flex-shrink: 0;
    border: 1px solid transparent;
}

.lc-ib-zona {
    background: rgba(0, 119, 182, 0.25);
    color: #4fc3f7;
    border-color: rgba(0, 178, 255, 0.35);
}

.lc-ib-sug {
    background: rgba(230, 126, 34, 0.20);
    color: #ffb347;
    border-color: rgba(255, 140, 0, 0.35);
}

.lc-ib-exc {
    background: rgba(229, 57, 53, 0.18);
    color: #ef5350;
    border-color: rgba(255, 59, 59, 0.35);
}

.lc-info-right {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    padding: 10px 14px;
    flex-shrink: 0;
}

/* reutiliza .lc-prio-label / .lc-prio-chain / .lc-prio-step del bloque anterior */

/* ============================================================
   LUGARES CONOCIDOS — proporciones de columnas en tabla
============================================================ */
.nom-table .col-nombre   { width: 42%; }
.nom-table .col-tipo     { width: 16%; }
.nom-table .col-zona     { width: 28%; }
.nom-table .col-acciones { width: 14%; }

/* ============================================================
   LUGARES CONOCIDOS — badges de tipo mejorados (más visibles)
============================================================ */
/* sugerencia: naranja */
.lc-badge-sug {
    background: rgba(230, 126, 34, 0.22) !important;
    color: #ffb347 !important;
    border-color: rgba(255, 140, 0, 0.40) !important;
    font-size: 0.62rem;
}

/* excluir: rojo */
.lc-badge-exc {
    background: rgba(229, 57, 53, 0.20) !important;
    color: #ef5350 !important;
    border-color: rgba(255, 59, 59, 0.40) !important;
}

/* En móvil: info panel apila verticalmente */
@media (max-width: 540px) {
    .lc-info-panel {
        flex-direction: column;
    }
    .lc-info-left {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    .lc-info-right {
        padding: 8px 14px;
    }
    .nom-table .col-nombre   { width: 50%; }
    .nom-table .col-tipo     { width: 18%; }
    .nom-table .col-zona     { width: 0; }
    .nom-table .col-acciones { width: 32%; }
}



/* ============================================================
   LUGARES CONOCIDOS — toolbar con buscador + botón
============================================================ */
.lc-toolbar-row {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    margin-bottom: 8px;
}

.lc-toolbar-row .lc-search-icon {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1rem;
    pointer-events: none;
    line-height: 1;
    z-index: 1;
}

.lc-toolbar-row input {
    flex: 1;
    min-width: 0;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.82rem;
    padding: 9px 12px 9px 32px;
    outline: none;
    transition: border-color var(--transition);
}

.lc-toolbar-row input:focus {
    border-color: var(--border2);
}

/* Botón + Agregar compacto dentro del toolbar */
.lc-add-btn {
    flex-shrink: 0;
    white-space: nowrap;
    padding: 8px 12px !important;
    font-size: 0.78rem !important;
    height: 36px;
}

/* ============================================================
   LUGARES CONOCIDOS — tabla desktop
============================================================ */
.nom-table-wrap {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    /* overflow-x/overflow-y ELIMINADOS — mismo error que en #sec-lugares:
       overflow-x:hidden + overflow-y:visible es una combinación imposible
       en CSS computado (la spec promueve "visible" a "auto" en cualquier
       eje si el otro no es visible/clip, sin importar si "visible" era
       explícito). .content/.main ya contienen el desborde horizontal de
       la tabla — este wrapper no necesita declarar el suyo propio. */
    margin-bottom: 8px;
}

.nom-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    table-layout: fixed;  /* columnas no desborden el viewport */
}

.nom-table thead th {
    font-family: var(--mono);
    font-size: 0.62rem;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    text-align: left;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nom-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}

.nom-table tbody tr:last-child {
    border-bottom: none;
}

.nom-table tbody tr:hover {
    background: rgba(0, 178, 255, 0.04);
}

.nom-table tbody td {
    padding: 9px 14px;
    vertical-align: middle;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Columna acciones */
.nom-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    white-space: nowrap;
}

/* ============================================================
   LUGARES CONOCIDOS — cards móvil
============================================================ */
.nom-cards {
    display: none;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
}

.nom-cards .nom-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color var(--transition);
}

.nom-cards .nom-card:hover {
    border-color: var(--border2);
}

.nom-cards .nom-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
}

.nom-cards .nom-card-header strong {
    font-size: 0.85rem;
    color: var(--text);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nom-cards .nom-card-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

/* badges de tipo: ver bloque "badges de tipo mejorados" más arriba */

/* ============================================================
   MODAL — Lugar Conocido (usa .modal-backdrop + .modal)
============================================================ */
#mLcZonaHint {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-top: 5px;
    line-height: 1.4;
}

#mLcZonaRow label {
    display: block;
    margin-top: 14px;
    margin-bottom: 5px;
}

/* ============================================================
   LUGARES CONOCIDOS — tabla SIEMPRE visible, cards SIEMPRE ocultas
   (el JS las usa para compat, no se renderizan)
   Scope acotado a #sec-lugares para no interferir con Nomenclaturas en móvil
============================================================ */
#sec-lugares .nom-table-wrap {
    display: block !important;
}

#sec-lugares .nom-cards {
    display: none !important;
}

/* lc-pill-zona: ver bloque "badges de tipo mejorados" más arriba */

/* ============================================================
   LUGARES CONOCIDOS — footer de paginación
============================================================ */
.lc-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    border-top: 1px solid var(--border);
    background: var(--bg3);
    border-radius: 0 0 var(--radius) var(--radius);
}

.lc-footer-total {
    font-family: var(--mono);
    font-size: 0.68rem;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

/* ============================================================
   LUGARES CONOCIDOS — responsive móvil
   Prevenir overflow horizontal en toda la sección
============================================================ */
#sec-lugares {
    /* overflow-x/overflow-y ELIMINADOS por completo — el intento anterior
       (overflow-x:hidden + overflow-y:visible explícito) era imposible en
       CSS: la spec de Overflow promueve CUALQUIER "visible" a "auto" en
       el eje que sea, si el otro eje no es visible/clip — sin importar
       si "visible" fue explícito o el default. No hay combinación de
       overflow-x:hidden + overflow-y:visible que sobreviva computada.
       .content ya tiene su propio overflow-x:hidden (y ahora .main
       también) — contienen cualquier desborde horizontal de la tabla sin
       que #sec-lugares necesite declarar el suyo. Sin overflow propio
       acá, #sec-lugares vuelve a comportarse igual que cualquier otra
       sección (ninguna otra declara overflow en absoluto). */
    max-width: 100%;
    box-sizing: border-box;
}

#sec-lugares * {
    box-sizing: border-box;
    max-width: 100%;
}

/* En móvil: texto de prioridad más pequeño */
@media (max-width: 480px) {
    .lc-prio-step {
        font-size: 0.58rem;
    }

    .lc-prio-label {
        font-size: 0.58rem;
    }
}

/* =========================
   IA DIRECTA
   ========================= */

.iad-lista {
    display: flex;
    flex-direction: column;
}

.iad-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 16px;
    border-bottom: 1px solid var(--border);
    gap: 12px;
    transition: background 0.15s;
}

.iad-row:last-child {
    border-bottom: none;
}

.iad-row:hover {
    background: var(--hover-bg);
}

.iad-nombre {
    font-family: var(--mono);
    font-size: 0.88rem;
    color: var(--text-primary);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.iad-empty {
    padding: 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.82rem;
}

.iad-btn-del {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1rem;
    padding: 4px 6px;
    border-radius: 4px;
    line-height: 1;
    flex-shrink: 0;
    transition: color 0.15s, background 0.15s;
}

.iad-btn-del:hover {
    color: var(--danger, #ff4d6d);
    background: rgba(255, 77, 109, 0.1);
}

.iad-form-wrap {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    margin-top: 12px;
}

/* Badge activo/inactivo — solo visual, no afecta lógica */
.iad-badge {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    flex-shrink: 0;
    white-space: nowrap;
    letter-spacing: 0.02em;
}

.iad-badge-activo {
    background: rgba(52, 199, 89, 0.15);
    color: #34c759;
    border: 1px solid rgba(52, 199, 89, 0.3);
}

.iad-badge-inactivo {
    background: rgba(142, 142, 147, 0.12);
    color: var(--text-muted);
    border: 1px solid rgba(142, 142, 147, 0.2);
}

/* SELECT en formulario IA Directa */
#iadSelectNombre {
    width: 100%;
    background: var(--input-bg, var(--card-bg));
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 0.9rem;
    appearance: auto;
}

/* ============================================================
   AUTO-PAUSA INTELIGENTE
   ============================================================ */

/* Timer inline en la fila de Auto-Pausa (60s / MANUAL) */
.ap-timer {
    font-family: var(--mono);
    font-size: 0.63rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--cyan);
    text-shadow: 0 0 6px rgba(0, 255, 255, 0.4);
    white-space: nowrap;
    flex-shrink: 0;
}

@keyframes apBadgePulse {
    0%   { opacity: 1; }
    50%  { opacity: 0.5; }
    100% { opacity: 1; }
}

.ap-timer[data-activa="1"] {
    animation: apBadgePulse 1.5s ease-in-out infinite;
}

/* Switch Auto-Pausa activo — color cian */
#apToggle.active .gt-track {
    border-color: var(--cyan);
    background: rgba(0, 255, 255, 0.1);
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.3);
    animation: none;
}
#apToggle.active .gt-thumb {
    left: 25px;
    background: var(--cyan);
    box-shadow: 0 0 7px rgba(0, 255, 255, 0.6);
}
#apToggle.active .gt-state {
    color: var(--cyan);
    text-shadow: 0 0 7px rgba(0, 255, 255, 0.4);
}
.guerra-row:has(#apToggle.active) .guerra-title {
    color: var(--cyan);
    text-shadow: 0 0 7px rgba(0, 255, 255, 0.25);
}

/* Switch Botón flotante activo — color azul, mismo patrón que apToggle */
#overlayToggle.active .gt-track {
    border-color: var(--blue);
    background: rgba(0, 178, 255, 0.1);
    box-shadow: 0 0 10px rgba(0, 178, 255, 0.3);
    animation: none;
}
#overlayToggle.active .gt-thumb {
    left: 25px;
    background: var(--blue);
    box-shadow: 0 0 7px rgba(0, 178, 255, 0.6);
}
#overlayToggle.active .gt-state {
    color: var(--blue);
    text-shadow: 0 0 7px rgba(0, 178, 255, 0.4);
}
.guerra-row:has(#overlayToggle.active) .guerra-title {
    color: var(--blue);
    text-shadow: 0 0 7px rgba(0, 178, 255, 0.25);
}

/* Última guerra-row: sin borde inferior */
.card--no-label .guerra-row:last-of-type {
    border-bottom: none;
}

/* Select nativo para config */
.cfg-select-native {
    width: 100%;
    background: var(--input-bg, var(--bg3));
    color: var(--text-primary, var(--text));
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 0.88rem;
    font-family: var(--mono);
    appearance: auto;
    margin-top: 6px;
    /* Mismo fix que .btn-primary — contexto de apilamiento propio contra
       la desincronización visual/hit-test del compositor de este WebView. */
    position: relative;
    z-index: 1;
}

/* Lista de checkboxes de restaurantes */
.ap-rest-hint {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin: 4px 0 8px;
}

.ap-rest-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 340px;
    overflow-y: auto;
    padding: 4px 0;
}

.ap-rest-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.83rem;
    color: var(--text);
    cursor: pointer;
    padding: 4px 0;
    user-select: none;
}

.ap-rest-item input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: var(--cyan);
    flex-shrink: 0;
    cursor: pointer;
}

.ap-rest-item:hover span {
    color: var(--cyan);
}

/* Restaurantes disponibles (sin Auto-Pausa configurada) — texto atenuado */
.ap-rest-item--disponible span {
    color: var(--text-muted);
    font-style: italic;
}
.ap-rest-item--disponible:hover span {
    color: var(--cyan);
}

/* Badge "Modo guerra" — identifica de un vistazo los restaurantes con
   bypass selectivo configurado, dentro de la lista de Modo Guerra por
   Restaurante. */
.mg-badge {
    display: inline-block;
    font-size: 0.6rem;
    font-family: var(--mono);
    letter-spacing: 0.04em;
    padding: 1px 7px;
    border-radius: 999px;
    background: rgba(255, 140, 0, 0.15);
    color: var(--orange, #ff8c00);
    border: 1px solid rgba(255, 140, 0, 0.35);
    margin-left: 6px;
}

/* Buscador */
.ap-search-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-input, rgba(255,255,255,0.06));
    border: 1px solid var(--border, rgba(255,255,255,0.12));
    border-radius: 6px;
    padding: 5px 10px;
    margin-bottom: 8px;
}
.ap-search-icon {
    font-size: 0.85rem;
    flex-shrink: 0;
    opacity: 0.7;
}
.ap-search-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    font-size: 0.82rem;
    font-family: inherit;
    min-width: 0;
}
.ap-search-input::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

/* Toolbar: tabs + botones rápidos */
.ap-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

/* Tabs Todos / Configurados */
.ap-filter-tabs {
    display: flex;
    gap: 4px;
}
.ap-filter-tab {
    font-size: 0.71rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    padding: 3px 10px;
    border-radius: 4px;
    border: 1px solid var(--border, rgba(255,255,255,0.15));
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.ap-filter-tab.active {
    background: var(--cyan);
    color: #000;
    border-color: var(--cyan);
}
.ap-filter-tab:not(.active):hover {
    border-color: var(--cyan);
    color: var(--cyan);
}

/* Botones rápidos Todos / Ninguno */
.ap-quick-btns {
    display: flex;
    gap: 4px;
}
.ap-quick-btn {
    font-size: 0.71rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    padding: 3px 10px;
    border-radius: 4px;
    border: 1px solid var(--border, rgba(255,255,255,0.15));
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}
.ap-quick-btn:hover {
    border-color: var(--cyan);
    color: var(--cyan);
}

/* Separador entre grupos */
.ap-group-separator {
    height: 1px;
    background: var(--border, rgba(255,255,255,0.1));
    margin: 6px 0;
}

/* Encabezado de grupo CONFIGURADOS / DISPONIBLES */
.ap-group-header {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 2px 0 4px;
    text-transform: uppercase;
}
.ap-group-header--configurados {
    color: var(--cyan);
}
.ap-group-header--disponibles {
    color: var(--text-muted);
}

/* ============================================================
   RESPONSIVE PREMIUM — 360px a 430px (Android móvil / APK WebView)
   Objetivo: legibilidad > compacidad. No empequeñecer iconos críticos.
============================================================ */
@media (max-width: 430px) {

    /* ── Safe-area extra en móviles muy compactos ── */
    .topbar {
        padding-left: 10px;
        padding-right: 10px;
        gap: 6px;
    }
    .topbar-title { font-size: 0.88rem; }
    .topbar-quick-toggles { gap: 0; }
    .topbar-quick-toggles .guerra-toggle { padding: 4px; }
    .qtoggle-icon { font-size: 19px; }
    .wa-status-pill { gap: 4px; }

    /* ── Card status: padding controlado ── */
    .card--status { padding: 12px 12px 10px; }

    /* ── Círculo TAP: igual que 768px, no reducir más ── */
    .sr {
        width: 88px;
        height: 88px;
    }
    .sr-text { font-size: 0.60rem; }

    /* ── det-inline: ligera compresión sin perder legibilidad ── */
    .det-inline {
        padding-left: 10px;
        gap: 1px;
        margin-top: -8px;
    }

    /* ── KPIs: labels visibles, valores legibles ── */
    .hud-kpi-lbl, .hud-m-lbl {
        font-size: 0.48rem;
        letter-spacing: 0.10em;
    }
    .hud-kpi-val { font-size: 0.80rem; gap: 3px; }
    .hud-m-val   { font-size: 0.76rem; gap: 3px; }

    /* Iconos: NO reducir por debajo de 1.2em — ilegibles en pantallas físicas pequeñas */
    .hud-ico     { width: 1.2em; height: 1.2em; }
    .hud-ico--sm { width: 1.4em; height: 1.4em; }

    /* ── Restaurante: máximo 2 líneas, fuente legible ── */
    .hud-rest {
        font-size: 0.96rem;
        -webkit-line-clamp: 2;
        line-height: 1.22;
    }

    /* ── Zona y filtro ── */
    .hud-zona   { font-size: 0.66rem; }
    .hud-filtro { font-size: 0.64rem; }

    /* ── Meta-row: wrap permitido en 360px extremos ── */
    .hud-meta-row {
        flex-wrap: wrap;
        gap: 2px 6px;
    }
    .hud-ago {
        flex: 0 0 auto;
        min-width: unset;
        max-width: unset;
    }
    .hud-ago, .hud-metodo, .hud-veloc { font-size: 0.62rem; }

    /* ── Badge ── */
    .hud-badge { font-size: 0.56rem; padding: 2px 6px; }

    /* ── Última detección: espacio generoso ── */
    .hud-det       { font-size: 0.55rem; min-height: 48px; }
    .hud-last-area { min-height: 88px; }

    /* ── Topbar legible ── */
    .topbar-title       { font-size: 1.0rem; }
    .wa-status-pill     { font-size: 0.62rem; padding: 4px 10px; }

    /* ── Botones de acción ── */
    .bot-actions .btn-action {
        flex: 1 1 calc(50% - 3px);
        min-width: 0;
        font-size: 0.68rem;
    }
}

/* ============================================================
   PATCH — Zonas sin .rest-cb + celda Norte/Sur a prueba de overflow
   La píldora de zona ahora guarda su estado ACTIVO directamente en
   .qops-item.checked (ya no existe el div .rest-cb oculto dentro de
   #qopsZonaList). Esta regla sustituye por orden de cascada a la
   variante :has(.rest-cb.checked) definida más arriba, que dejó de
   tener nodo al que engancharse.
============================================================ */
#qopsZonaList .qops-item.checked {
    background: rgba(0,230,118,0.13);
    border-color: rgba(0,230,118,0.4);
    box-shadow: 0 0 10px rgba(0,230,118,0.10);
}
#qopsZonaList .qops-item.checked .qops-name {
    color: var(--green);
    text-shadow: 0 0 8px rgba(0,230,118,0.30);
}

/* ── Celda fusionada Sur0 / Sur: UNA sola columna estándar del grid de 3
   (sin grid-column explícito → toma su posición natural de 1 celda),
   heredando de forma explícita el fondo, borde, radio y padding-cero de
   una .qops-item normal, dividida al 50% en dos mitades independientes. ── */
#qopsZonaList .qops-item-fusionado-sur {
    grid-column: auto;
    box-sizing: border-box;
    display: flex;
    align-items: stretch;
    width: 100%;
    height: 100%;
    min-width: 0;
    padding: 0;
    gap: 0;
    overflow: hidden;
    background: var(--bg-pill);
    border: 1px solid rgba(0,178,255,0.08);
    border-radius: 20px;
}
.qops-sur-half {
    box-sizing: border-box;
    flex: 1 1 50%;
    width: 50%;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px 2px;
    font-size: 0.65rem;
    line-height: 1.08;
    text-transform: capitalize;
    color: var(--text-dim);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background 0.2s ease, color 0.2s ease, transform 0.12s ease;
}
.qops-sur-half:first-child {
    border-right: 1px solid rgba(0,178,255,0.14);
}
.qops-sur-half:active {
    transform: scale(0.96);
}
.qops-sur-half.checked {
    background: rgba(0,230,118,0.13);
    color: var(--green);
    text-shadow: 0 0 8px rgba(0,230,118,0.30);
}

/* ============================================================
   THEME SELECTOR — segmented control (Oscuro / Claro), sec-config
============================================================ */
.theme-selector-group {
    display: flex;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 3px;
    gap: 3px;
    width: 100%;
    max-width: 280px;
}
.theme-btn {
    flex: 1 1 50%;
    border: none;
    background: transparent;
    color: var(--text-dim);
    font-family: var(--mono);
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}
.theme-btn:active {
    transform: scale(0.97);
}
.theme-btn.active {
    background: var(--blue-glow2);
    color: var(--text);
    box-shadow: 0 0 10px var(--blue-glow);
}

/* ============================================================
   MODO COMPACTO — dashboard optimizado para ventana flotante/multiwindow
   Activado por el usuario en Configuración > Apariencia (dashboardCompacto
   en bot.config, aplicado como clase .compact-dashboard en <body> desde
   app.js). TODO bajo el prefijo .compact-dashboard — el dashboard normal
   (sin esta clase) queda exactamente igual, cero reglas de arriba tocadas.

   Reutiliza el MISMO mecanismo que ya existe para el breakpoint móvil
   (@media max-width:768px, ver ".dash-grid { display: contents }" más
   arriba en este archivo): disolver el grid en flex-items directos de
   #sec-dashboard.active (que ya es flex-column, sin depender de ningún
   media query) es lo que permite que .card--quickops absorba el espacio
   libre en vez de dejar hueco muerto donde vivía .card--quicklogs.
============================================================ */

/* 1. Ocultar Actividad Reciente por completo */
.compact-dashboard .card--quicklogs {
    display: none;
}

/* 2. .dash-grid deja de ser grid — status queda fijo arriba, quickops se
   lleva TODO el espacio que antes usaba el grid de 2 filas. */
.compact-dashboard .dash-grid {
    display: contents;
}
.compact-dashboard .card--status {
    flex: 0 0 auto;
    min-height: auto;
}
.compact-dashboard .card--quickops {
    flex: 1 1 0;
    min-height: 0;
    height: auto;   /* pisa el height:320px fijo de desktop (línea ~704) */
    overflow-y: auto;
    overflow-x: hidden;
}

/* 3. Restaurantes y zonas comparten el ÚNICO scroll de .card--quickops
   (ya definido en el punto 2 de arriba: overflow-y:auto en la tarjeta) —
   sin overflow propio en cada .qops-block, igual que el modo normal.
   Antes cada bloque tenía su propio scroll (max-height/overflow-y en
   restaurantes, flex:1 en zonas) — eso partía la experiencia en dos
   desplazamientos independientes dentro de la misma tarjeta. */

/* 4. Altura uniforme de fila en la grilla de zonas — todas las filas del
   grid, tengan 1 o 2 líneas de texto, ocupan la altura de una celda de
   DOS líneas (ej. "Av Centenario Norte"). Sin esto, CSS Grid calcula la
   altura de cada fila de forma independiente según su propio contenido
   más alto — filas con texto corto quedaban más bajas que filas con
   texto largo, dando alturas inconsistentes.
   El valor sale de los datos reales ya declarados para #qopsZonaList
   .qops-name (font-size:0.65rem, line-height:1.08) y #qopsZonaList
   .qops-item (padding:4px arriba+abajo = 8px) — no es un número inventado:
   2 líneas × 0.65rem × 1.08 + 8px de padding. minmax() con "auto" como
   techo evita cortar contenido si algún nombre de zona fuera aún más
   largo. align-content:start (ya declarado antes) mantiene el espacio
   sobrante fuera de las filas, debajo de la grilla. */
.compact-dashboard #qopsZonaList {
    align-content: start;
    grid-auto-rows: minmax(calc(2 * 0.65rem * 1.08 + 8px), auto);
}

/* 5. Última detección — versión compacta (menos padding/alto) */
.compact-dashboard .card--status {
    padding: 12px 14px;
}
.compact-dashboard .hud-last-area {
    min-height: 64px;
}
.compact-dashboard .hud-nav-bar {
    height: 18px;
    margin-bottom: 2px;
}

/* 6. EXTRA — ventana con altura muy chica (floating window redimensionada):
   fuerza el mismo layout SIN requerir que el usuario haya activado la
   preferencia. Mismas reglas que arriba, gatilladas por altura en vez de
   por la clase — no depende de .compact-dashboard, así que funciona
   incluso con el modo compacto apagado. Si el usuario YA lo activó, esto
   es simplemente redundante (mismas reglas, sin conflicto).
   :not(.compact-dashboard-off) — si el usuario desactivó el switch
   EXPLÍCITAMENTE (no es lo mismo que "nunca lo activó"), esa elección
   gana sobre el forzado automático por altura. Causa raíz real del bug
   "ON→OFF no se aplica hasta reabrir": esta regla ignoraba la clase por
   completo, así que en ventanas bajas seguía forzando el aspecto
   compacto sin importar el switch. */
@media (max-height: 480px) {
    body:not(.compact-dashboard-off) .dash-grid { display: contents; }
    body:not(.compact-dashboard-off) .card--status { flex: 0 0 auto; min-height: auto; padding: 12px 14px; }
    body:not(.compact-dashboard-off) .card--quicklogs { display: none; }
    body:not(.compact-dashboard-off) .card--quickops {
        flex: 1 1 0;
        min-height: 0;
        height: auto;
        overflow-y: auto;
        overflow-x: hidden;
    }
    body:not(.compact-dashboard-off) .hud-last-area { min-height: 64px; }
}

/* ============================================================
   ESTILO DEL BOTÓN FLOTANTE — vista previa en miniatura, dentro de
   Configuración → Apariencia. Reutiliza .theme-btn/.theme-selector-group
   como contenedor (mismo mecanismo que el selector de tema, sin
   duplicar layout) — solo agrega el mini-preview visual arriba del
   texto de cada botón. No es un render real del botón nativo (eso es
   Canvas de Android, imposible de reproducir en CSS) — es una
   aproximación de colores/forma para que el usuario reconozca cuál es
   cuál antes de elegir.
============================================================ */

.estilo-boton-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 10px 8px;
}

.estilo-boton-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    width: 22px;
    height: 44px;
    border-radius: 11px;
    padding: 4px 0;
}

.estilo-boton-preview--veneno {
    background: #111111;
    border: 1px solid #2A2A2A;
}

.estilo-boton-preview--autoclicker {
    background: #0D0D0D;
    border: 1px solid transparent;   /* la referencia no muestra borde exterior */
}

.ebp-circ {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid #4A4A4A;
}

.estilo-boton-preview--veneno .ebp-circ {
    border-color: #2A2A2A;
}

.estilo-boton-preview--veneno .ebp-circ--on {
    border-color: #00E676;
    box-shadow: 0 0 4px #00E676;   /* referencia visual del glow — solo en la miniatura VENENO */
}

.estilo-boton-preview--autoclicker .ebp-circ {
    border-color: #4A4A4A;   /* plano, sin glow — fiel a la referencia */
}

/* ============================================================
   OCR POR RESTAURANTE
============================================================ */

/* ── Lista de restaurantes ── */
.ocr-rest-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 6px;
    cursor: pointer;
    transition: background 0.15s;
}
.ocr-rest-card:hover { background: var(--bg4); }
.ocr-rest-nombre { font-size: 0.85rem; color: var(--text); }
.ocr-rest-estado {
    font-family: var(--mono);
    font-size: 0.62rem;
    letter-spacing: 0.08em;
    padding: 3px 8px;
    border-radius: 20px;
}
.ocr-rest-estado.configurado { background: rgba(0,230,118,0.12); color: var(--green); }
.ocr-rest-estado.pendiente   { background: rgba(255,255,255,0.06); color: var(--text-muted); }

/* ── Galería de recientes ── */
.ocr-recientes-galeria {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 8px 0;
}
.ocr-reciente-thumb {
    position: relative;
    flex-shrink: 0;
    width: 72px;
    height: 72px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
}
.ocr-reciente-thumb:hover { border-color: var(--blue); }
.ocr-reciente-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ocr-reciente-thumb.fallo { border-color: var(--red); }
.ocr-reciente-thumb.fallo::after {
    content: '⚠';
    position: absolute;
    top: 2px; right: 2px;
    background: var(--red);
    color: #fff;
    font-size: 0.6rem;
    width: 16px; height: 16px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}
.ocr-recientes-toolbar { margin-top: 8px; }

/* ── Editor — layout de 2 columnas ── */
.ocr-editor-layout {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}
.ocr-editor-imagen-wrap {
    position: relative;
    flex: 1 1 480px;
    max-width: 640px;
    line-height: 0; /* evita el espacio fantasma bajo la img */
    user-select: none;
}
.ocr-editor-imagen-wrap img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.ocr-editor-panel {
    flex: 1 1 260px;
    min-width: 240px;
}
.ocr-editor-acciones {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

/* ── Caja de región sobre la imagen ── */
.ocr-region-box {
    position: absolute;
    border: 2px solid var(--blue);
    background: rgba(0,178,255,0.10);
    cursor: move;
    box-sizing: border-box;
    /* Bloquea el scroll/pan nativo del navegador sobre este elemento —
       sin esto, un arrastre hacia abajo puede interpretarse como "el
       usuario quiere hacer scroll de la página" ANTES de que el
       preventDefault() de JS llegue a tener efecto. Es la causa más
       probable de "la página scrollea al arrastrar". */
    touch-action: none;
}
.ocr-region-box.inactiva {
    border-color: var(--border2);
    background: transparent;
    cursor: default;
    pointer-events: none;
    touch-action: auto; /* inactiva no intercepta nada — el scroll debe funcionar normal encima suyo */
}
.ocr-region-box .ocr-region-label {
    position: absolute;
    top: -20px;
    left: -2px;
    font-family: var(--mono);
    font-size: 0.62rem;
    color: var(--blue);
    background: var(--bg);
    padding: 1px 6px;
    border-radius: 4px;
    white-space: nowrap;
    pointer-events: none;
}

/* ── Manija central de mover — tipo cruz, como los editores de recorte
   de fotos. El cuerpo completo del recuadro YA es arrastrable (ver JS),
   esta es una afordancia explícita adicional, más visible y más fácil
   de agarrar en el centro. ── */
.ocr-region-move-handle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: move;
    touch-action: none;
}
.ocr-region-move-handle::after {
    content: '✛';
    font-size: 22px;
    line-height: 1;
    color: var(--blue);
    text-shadow: 0 0 6px rgba(0,178,255,0.9), 0 1px 3px rgba(0,0,0,0.6);
}

/* ── Manijas de esquina — hit-area real de 44x44px (mínimo táctil
   recomendado), independiente del punto visual, que sigue siendo chico
   (el ::after). El div en sí es transparente/invisible; solo se ve el
   punto centrado adentro. ── */
.ocr-region-handle {
    position: absolute;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
}
.ocr-region-handle::after {
    content: '';
    width: 14px;
    height: 14px;
    background: var(--blue);
    border-radius: 50%;
    border: 2px solid var(--bg);
    box-shadow: 0 0 4px rgba(0,178,255,0.7);
}
/* Offset = -22px = mitad del hit-area (44px) — el CENTRO del área
   táctil queda exactamente sobre la esquina del recuadro, mitad adentro
   mitad afuera, igual que en editores de recorte estándar. */
.ocr-region-handle.nw { top: -22px; left: -22px; cursor: nwse-resize; }
.ocr-region-handle.ne { top: -22px; right: -22px; cursor: nesw-resize; }
.ocr-region-handle.sw { bottom: -22px; left: -22px; cursor: nesw-resize; }
.ocr-region-handle.se { bottom: -22px; right: -22px; cursor: nwse-resize; }

/* ── Fila de región en el panel lateral ── */
.ocr-region-row {
    padding: 10px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
}
.ocr-region-row.activa { border-color: var(--blue); }
.ocr-region-row-top {
    display: flex;
    align-items: center;
    gap: 6px;
}
.ocr-region-row-top input[type="text"] {
    flex: 1;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 5px 8px;
    color: var(--text);
    font-size: 0.78rem;
}
.ocr-region-resultado {
    margin-top: 6px;
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--text-dim);
    word-break: break-word;
}
.ocr-region-resultado.vacio { color: var(--text-muted); font-style: italic; }

/* ── Plantillas guardadas (lista debajo del editor) ── */
.ocr-plantilla-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 6px;
}
.ocr-plantilla-thumb { width: 40px; height: 40px; border-radius: 6px; object-fit: cover; }
.ocr-plantilla-nombre { flex: 1; font-size: 0.8rem; color: var(--text); }
