/* =============================================================================
   Grupo Luminotecnia — base y componentes
   Depende de tokens.css. Ni un solo color hex acá: todo sale de var(--…),
   que es lo que hace que el tema oscuro funcione sin duplicar hojas de estilo.
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

/* El atributo `hidden` tiene que ganarle a cualquier `display` de componente:
   sin esto, un .ms-count { display:inline-flex } se sigue viendo aunque JS lo
   marque como oculto. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--ground);
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: -.02em;
    text-wrap: balance;
    margin: 0;
}

h1 { font-size: 28px; }
h2 { font-size: 21px; }
h3 { font-size: 17px; }

p { margin: 0; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }

img, svg { max-width: 100%; }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 4px;
}

/* Quien pidió menos movimiento en el sistema, no recibe animaciones. */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        transition-duration: .01ms !important;
    }
}

/* Mientras se cambia de tema no hay transiciones. `theme.js` pone esta clase
   un instante antes de tocar `data-theme` y la saca en el frame siguiente.
   Sin esto, todo lo que declare `transition` sobre un color se queda con el
   color del tema anterior: la transición arranca antes de que el navegador
   recalcule el `var(--…)` y el valor no converge nunca. Se veía en el borde de
   las tarjetas y en el fondo de los botones, que quedaban del tema viejo hasta
   recargar la página. */
.theme-switching *, .theme-switching *::before, .theme-switching *::after {
    transition: none !important;
}

/* --- Layout ---------------------------------------------------------------- */

.wrap { max-width: 1140px; margin: 0 auto; padding: 0 20px; }
.stack > * + * { margin-top: 18px; }

.eyebrow {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--muted);
}

.muted { color: var(--muted); }
.small { font-size: 13px; }

/* Texto solo para lectores de pantalla: ocupa lugar cero pero sigue en el
   árbol de accesibilidad. `display: none` lo sacaría del todo. */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

/* Primer elemento enfocable de la página: invisible hasta que el teclado
   llega a él, y entonces aparece arriba de todo. */
.skip-link {
    position: absolute;
    top: -100px;
    left: 12px;
    z-index: 100;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: var(--on-accent);
    font-weight: 600;
}

.skip-link:focus { top: 12px; text-decoration: none; }

/* --- Barra superior -------------------------------------------------------- */

.topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    row-gap: 6px;
    padding: 10px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar .brand {
    display: flex;
    flex: none;
    align-items: baseline;
    gap: 9px;
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--ink);
}

.topbar .brand b { color: var(--accent-text); }
.topbar .spacer { flex: 1; }

/* Cinco grupos con icono: entran en una fila junto al logo y al usuario, y si
   la ventana es angosta la barra pasa a dos filas sola (flex-wrap). */
.topnav { display: flex; gap: 2px; flex-wrap: wrap; }

.topnav-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 10px 5px 6px;
    border: 0;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--ink-2);
    font: inherit;
    font-size: 13.5px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
}

.topnav-link:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.topnav-link.is-current,
.nav-group.is-current > .topnav-link { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }

/* El icono de cada sección lleva un color propio (--icon-* en tokens.css),
   que el layout pasa por --nav-color. Sirve para reconocer a dónde se va de
   un vistazo, sobre todo en el celular; no dice nada de estado. */
.nav-icon {
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 24px;
    height: 24px;
    border-radius: 7px;
    color: var(--nav-color, var(--ink-2));
    background: color-mix(in srgb, var(--nav-color, var(--ink-2)) 14%, transparent);
}

.nav-icon svg { width: 15px; height: 15px; }

/* --- Grupos desplegables ---------------------------------------------------
   Un grupo es un botón y, debajo, su lista. Con JS se abre al tocar (nav.js);
   sin JS se abre al pasar el mouse o al enfocar, que es peor pero funciona. */

.nav-group { position: relative; }
.nav-group-toggle .caret { width: 12px; height: 12px; margin-left: -3px; opacity: .65; }
.nav-group-toggle[aria-expanded="true"] .caret { transform: rotate(180deg); }

.nav-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 120;
    min-width: 230px;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-pop);
}

.nav-group.is-open > .nav-menu,
html:not(.has-nav-js) .nav-group:hover > .nav-menu,
html:not(.has-nav-js) .nav-group:focus-within > .nav-menu { display: block; }

.nav-menu-link {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 9px;
    border-radius: 6px;
    color: var(--ink-2);
    font-size: 13.5px;
    font-weight: 500;
    white-space: nowrap;
}

.nav-menu-link:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav-menu-link.is-current { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }

.nav-toggle { display: none; }

.usermenu { display: flex; align-items: center; gap: 8px; }
.usermenu-name { font-size: 13.5px; font-weight: 600; color: var(--ink); }

@media (max-width: 720px) {
    .topbar { gap: 8px; padding: 8px 14px; }
    .topbar .brand-logo { height: 32px; }

    /* Quién está y «Salir» bajan adentro del menú plegado: en 375 px no
       entran en la primera fila junto al logo, el tema y el botón. */
    .usermenu {
        order: 11;
        width: 100%;
        justify-content: space-between;
        margin-top: 6px;
        padding-top: 10px;
        border-top: 1px solid var(--line-soft);
    }

    .usermenu-name { flex: 1; }
    .has-nav-js .topnav:not(.is-open) ~ .usermenu { display: none; }

    .nav-toggle {
        display: inline-grid;
        place-items: center;
        width: 40px;
        height: 40px;
        border: 1px solid var(--line);
        border-radius: var(--radius-sm);
        background: var(--surface);
        color: var(--ink);
        cursor: pointer;
    }

    .nav-toggle svg { width: 20px; height: 20px; }
    .nav-toggle[aria-expanded="true"] { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
    .nav-toggle .icon-close { display: none; }
    .nav-toggle[aria-expanded="true"] .icon-open { display: none; }
    .nav-toggle[aria-expanded="true"] .icon-close { display: block; }

    /* Lista vertical a lo ancho, debajo de la barra. Con JS arranca plegada
       (ver nav.js); sin JS queda abierta. Los grupos son títulos y sus
       entradas van siempre desplegadas: un nivel más de toques no ayuda. */
    .topnav {
        order: 10;
        width: 100%;
        flex-direction: column;
        margin-top: 2px;
        padding: 10px 0 6px;
        border-top: 1px solid var(--line-soft);
    }

    .has-nav-js .topnav:not(.is-open) { display: none; }

    .topnav-link { padding: 9px 10px; gap: 12px; font-size: 15px; }

    .nav-group { display: block; }

    .nav-group-toggle {
        width: 100%;
        padding: 12px 10px 4px;
        color: var(--muted);
        font-size: 12px;
        font-weight: 600;
        letter-spacing: .06em;
        text-transform: uppercase;
        cursor: default;
        pointer-events: none;
    }

    .nav-group-toggle .caret { display: none; }
    .nav-group-toggle .nav-icon { width: 20px; height: 20px; border-radius: 6px; }
    .nav-group-toggle .nav-icon svg { width: 12px; height: 12px; }
    .nav-group.is-current > .topnav-link { background: none; color: var(--muted); }

    .nav-menu {
        display: block;
        position: static;
        min-width: 0;
        padding: 0;
        background: transparent;
        border: 0;
        box-shadow: none;
    }

    .nav-menu-link { padding: 9px 10px; gap: 12px; font-size: 15px; }
    .nav-menu-link .nav-icon, .topnav > .topnav-link .nav-icon { width: 32px; height: 32px; border-radius: 9px; }
    .nav-menu-link .nav-icon svg, .topnav > .topnav-link .nav-icon svg { width: 18px; height: 18px; }
}/* --- Pantallas sin navegación (login, error) ------------------------------- */

.bare-body { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.bare-main { width: 100%; max-width: 460px; }
.bare-theme { position: fixed; top: 16px; right: 16px; }
.auth-card { padding: 28px; }

/* --- Mensajes de una petición a la otra ------------------------------------ */

.flash {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 11px 14px;
    margin-bottom: 16px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--ink-2);
    font-size: 14px;
}

.flash svg { flex: none; margin-top: 2px; }
.flash-ok { background: var(--ok-bg); color: var(--ok); }
.flash-crit { background: var(--crit-bg); color: var(--crit); }

/* --- Tarjetas -------------------------------------------------------------- */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

/* --- Botones --------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease;
}

.btn:hover { background: var(--surface-2); text-decoration: none; }

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--on-accent);
    font-weight: 600;
}

.btn-primary:hover { background: color-mix(in srgb, var(--accent) 85%, var(--ink)); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); }

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

.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }

/* A lo ancho y más alto. Es el botón del portal: se toca con el pulgar, de
   parada en el mostrador y muchas veces con una sola mano. */
.btn-block {
    display: block;
    width: 100%;
    text-align: center;
    padding: 13px 18px;
    font-size: 15px;
}

/* --- Chips de opción única --------------------------------------------------
   Para elegir uno entre pocos. Abajo del estilo son `radio` de verdad: el
   teclado y el lector de pantalla los recorren como lo que son, y sin CSS
   siguen siendo un grupo de opciones usable. */

.chips-choice { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }

.field-legend {
    width: 100%;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-2);
    margin-bottom: 9px;
    padding: 0;
}

.chip-choice { position: relative; }

/* El input no se esconde con `display:none`: así seguiría siendo enfocable por
   teclado pero sin nada visible. Se deja encima de la etiqueta, transparente. */
.chip-choice input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    cursor: pointer;
}

.chip-choice span {
    display: block;
    padding: 9px 15px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink-2);
    font-size: 14px;
}

.chip-choice input:checked + span {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-text);
    font-weight: 600;
}

.chip-choice input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- Pestañas --------------------------------------------------------------
   Para alternar entre dos o tres vistas de la misma sección (promociones y
   novedades). Son enlaces, no botones: cada pestaña es una URL propia y tiene
   que poder abrirse en otra solapa. */

.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--line);
}

.tab {
    padding: 9px 16px;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 600;
}

.tab:hover { color: var(--ink); text-decoration: none; }

.tab.is-current { color: var(--accent-text); border-bottom-color: var(--accent); }

/* --- Contadores de cabecera --------------------------------------------------
   Van arriba de la bandeja de CX. Lo que se mira primero no es «cuántos hay»
   sino «cuántos están vencidos»: un total no le dice a nadie qué hacer con su
   mañana. */

.kpi-row { display: flex; gap: 12px; flex-wrap: wrap; }

.kpi {
    flex: 1 1 140px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.kpi-value {
    display: block;
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 700;
    line-height: 1.1;
}

.kpi-label { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.kpi-crit { border-color: var(--crit); }
.kpi-crit .kpi-value { color: var(--crit); }

/* --- Chips de lectura --------------------------------------------------------
   Etiquetas que solo se leen, sin interacción (no confundir con `.chip-choice`,
   que es un control). Las usa la ficha del producto en el portal y el perfil de
   actividad en el panel. */

.chips { display: flex; flex-wrap: wrap; gap: 7px; }

.chip {
    display: inline-flex;
    gap: 5px;
    padding: 5px 11px;
    border-radius: 999px;
    background: var(--sunken);
    border: 1px solid var(--line-soft);
    font-size: 12.5px;
}

/* --- Dos columnas ------------------------------------------------------------
   Se parte en una sola cuando no entra: en una tablet vertical dos columnas de
   tarjetas quedan demasiado angostas para leerlas. */

.split { display: grid; grid-template-columns: 1fr; gap: 14px; }

@media (min-width: 860px) {
    .split { grid-template-columns: 1fr 1fr; }
}

/* --- Fotos adjuntas y cronología ---------------------------------------------
   Las usan el portal y la bandeja de CX: son los mismos adjuntos y el mismo
   historial mirados desde los dos lados del mostrador. */

.case-photos { display: flex; gap: 8px; flex-wrap: wrap; }

.case-photos img {
    width: 96px;
    height: 96px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
}

/* La línea la dibuja el borde del <li>, sin ningún elemento extra. */
.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; }

.timeline li {
    position: relative;
    padding: 0 0 14px 16px;
    border-left: 1px solid var(--line);
    margin-left: 3px;
}

.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }

.timeline li::before {
    content: '';
    position: absolute;
    left: -4.5px;
    top: 5px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
}

.timeline li strong { display: block; font-size: 14px; }

/* --- Insignias ------------------------------------------------------------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    background: var(--surface-2);
    color: var(--ink-2);
}

.badge-ok   { background: var(--ok-bg);   color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-crit { background: var(--crit-bg); color: var(--crit); }
.badge-accent { background: var(--accent-soft); color: var(--accent-text); }

/* --- Formularios ----------------------------------------------------------- */

.field { display: block; margin-bottom: 14px; }
.field > label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }

.input, .select, .textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 14px;
}

.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.field-error { color: var(--crit); font-size: 12.5px; margin-top: 4px; }
.input[aria-invalid="true"] { border-color: var(--crit); }

/* --- Tablas ---------------------------------------------------------------- */

.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }

.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.table th, .table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line-soft); }
.table th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: var(--sunken); font-weight: 600; }
.table thead th:first-child { border-top-left-radius: var(--radius); }
.table thead th:last-child { border-top-right-radius: var(--radius); }

/* --- Cabecera fija -----------------------------------------------------------
   En escritorio la tabla vive en la página y la cabecera se pega justo debajo
   de la barra superior (su alto lo mide nav.js en --topbar-h, porque cambia
   entre una y dos filas). Un `overflow` en el contenedor rompería el sticky,
   así que ahí el envoltorio no recorta nada. En el celular las tablas son
   más anchas que la pantalla y necesitan desplazarse de costado: entonces el
   envoltorio es la caja que se desplaza, con alto acotado, y la cabecera se
   pega arriba de esa caja. `border-collapse: separate` es porque con
   `collapse` el borde de la cabecera se queda atrás al pegarse. */

.table thead th {
    position: sticky;
    top: var(--topbar-h, 0px);
    z-index: 5;
    box-shadow: inset 0 -1px 0 var(--line);
}

@media (max-width: 860px) {
    .table-wrap { max-height: 78vh; overflow: auto; }
    .table thead th { top: 0; }
}.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--sunken); }
.table .num { text-align: right; font-family: var(--font-mono); font-size: 13px; }

.empty-state { padding: 40px 20px; text-align: center; color: var(--muted); font-size: 14px; }

/* Una fila atenuada sigue siendo legible: se baja el contraste, no el tamaño.
   Un usuario inactivo tiene que poder leerse para poder reactivarlo. */
.table tr.is-muted td { opacity: .62; }

/* --- Encabezado de página y personas --------------------------------------- */

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

.person { display: flex; align-items: center; gap: 10px; }

.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--surface-2);
    flex: none;
}

.avatar-lg { width: 64px; height: 64px; margin-bottom: 8px; display: block; }

.avatar-initials {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 14px;
    color: var(--accent-text);
    background: var(--accent-soft);
}

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

@media (max-width: 560px) {
    .field-row { grid-template-columns: 1fr; }
}

/* =============================================================================
   Multi-select con AJAX — el filtro por defecto del sistema
   =============================================================================
   Portado del filtro de gltmkt (_exec_filterbar.php) y pasado a AJAX.
   Buscador adentro, "Todo / Nada", botón Aplicar y chips de lo elegido.
   Nunca un <select multiple> suelto: no se puede buscar y en celular es inusable.
   ========================================================================== */

.ms-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 10px 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.ms-bar-label {
    font-family: var(--font-mono);
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--muted);
    font-weight: 500;
}

.ms { position: relative; }

.ms-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    color: var(--ink);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}

.ms-toggle:hover { background: var(--surface-2); }
.ms-toggle[aria-expanded="true"] { border-color: var(--accent); }
.ms-toggle .ms-icon { color: var(--accent-text); display: inline-flex; }
.ms-toggle .ms-caret { color: var(--muted); transition: transform .15s ease; }
.ms-toggle[aria-expanded="true"] .ms-caret { transform: rotate(180deg); }

.ms-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--accent);
    color: var(--on-accent);
    font-size: 10.5px;
    font-weight: 700;
    border-radius: 9px;
}

.ms-menu {
    display: none;
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    z-index: 200;
    width: 280px;
    max-height: 420px;
    flex-direction: column;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-pop);
}

.ms-menu.is-open { display: flex; }

.ms-menu-head { display: flex; gap: 6px; padding: 8px; border-bottom: 1px solid var(--line-soft); }

.ms-search {
    flex: 1;
    min-width: 0;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--sunken);
    color: var(--ink);
    font: inherit;
    font-size: 13px;
}

.ms-search:focus { outline: none; border-color: var(--accent); }

.ms-mini {
    padding: 5px 9px;
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--ink-2);
    font: inherit;
    font-size: 11.5px;
    white-space: nowrap;
    cursor: pointer;
}

.ms-mini:hover { background: var(--surface-2); }

.ms-options { flex: 1; overflow-y: auto; padding: 6px; max-height: 280px; }

.ms-opt {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 8px;
    border-radius: 6px;
    font-size: 13.5px;
    color: var(--ink);
    cursor: pointer;
}

.ms-opt:hover { background: var(--sunken); }
.ms-opt input { margin: 0; cursor: pointer; accent-color: var(--accent); width: 15px; height: 15px; }
.ms-opt span { flex: 1; }
.ms-opt.is-hidden { display: none; }

.ms-empty { padding: 16px; text-align: center; color: var(--muted); font-size: 12.5px; font-style: italic; }

.ms-menu-foot { display: flex; justify-content: flex-end; gap: 6px; padding: 8px; border-top: 1px solid var(--line-soft); }

.ms-chips { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.ms-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 4px 3px 10px;
    background: var(--accent-soft);
    color: var(--accent-text);
    border-radius: 6px;
    font-size: 11.5px;
    font-weight: 600;
}

.ms-chip-x {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border: 0;
    border-radius: 4px;
    background: color-mix(in srgb, var(--accent) 22%, transparent);
    color: inherit;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
}

.ms-chip-x:hover { background: color-mix(in srgb, var(--accent) 38%, transparent); }

.ms-clear { border: 0; background: transparent; color: var(--crit); font: inherit; font-size: 11.5px; font-weight: 600; padding: 4px 8px; border-radius: 5px; cursor: pointer; }
.ms-clear:hover { background: var(--crit-bg); }

/* Estado de carga: la zona de resultados se atenúa pero no salta. */
.ms-results { position: relative; transition: opacity .15s ease; }
.ms-results[aria-busy="true"] { opacity: .45; pointer-events: none; }

/* En celular el menú ocupa el ancho disponible y no se sale de la pantalla. */
@media (max-width: 560px) {
    .ms { position: static; }
    .ms-menu { width: calc(100vw - 40px); left: 0; right: 0; }
    .ms-bar { padding: 10px; }
}

/* --- Interruptor de tema --------------------------------------------------- */

.theme-switch { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-2); border-radius: 999px; }

.theme-switch button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 26px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.theme-switch button:hover { color: var(--ink); }
.theme-switch button[aria-pressed="true"] { background: var(--surface); color: var(--accent-text); box-shadow: var(--shadow); }

/* --- Editor de horarios de sucursal ---------------------------------------- */

.hours-table td { vertical-align: middle; }
.hours-pair { display: flex; align-items: center; gap: 8px; }
.hours-pair .input { width: auto; min-width: 110px; padding: 6px 9px; font-size: 13px; }

@media (max-width: 640px) {
    .hours-pair { flex-wrap: wrap; }
    .hours-pair .input { min-width: 92px; }
}

/* --- Ficha del código QR ---------------------------------------------------- */

.qr-card { display: flex; gap: 26px; align-items: flex-start; flex-wrap: wrap; }
.qr-meta { flex: 1; min-width: 260px; }

/* Fondo blanco fijo: un QR sobre fondo oscuro no lo lee ningún celular, así
   que esta es la única superficie del sistema que NO sigue al tema. */
.qr-figure {
    background: #FFFFFF;
    padding: 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    line-height: 0;
}

.token {
    font-family: var(--font-mono);
    font-size: 13px;
    letter-spacing: .06em;
    background: var(--sunken);
    border: 1px solid var(--line-soft);
    border-radius: 5px;
    padding: 2px 7px;
}

.token-lg { font-size: 17px; padding: 5px 11px; }

/* --- Miniaturas e imágenes del catálogo (admin) ----------------------------- */

.thumb { width: 44px; height: 44px; border-radius: var(--radius-sm); object-fit: cover; background: var(--sunken); }

.thumb-empty {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed var(--line);
    color: var(--muted);
}

.checkline { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; cursor: pointer; font-size: 14px; }
.checkline input { width: 16px; height: 16px; accent-color: var(--accent); flex: none; }

.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }

.image-item {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--sunken);
}

.image-item img { display: block; width: 100%; height: 130px; object-fit: cover; }
.image-actions { display: flex; flex-direction: column; gap: 4px; padding: 8px; align-items: flex-start; }

/* =============================================================================
   Gráficos
   =============================================================================
   SVG en línea y HTML, dibujados por PHP (App\Core\Chart). Los colores salen de
   los tokens --chart-*, así que el gráfico sigue al tema sin JavaScript: es la
   razón por la que no hay canvas acá.

   Los trazos van con vector-effect:non-scaling-stroke. Sin eso, el SVG escala
   con la tarjeta y una línea de 2 px se afina o se engorda según el ancho de la
   pantalla.
   ========================================================================== */

/* El texto de un SVG escala con el viewBox, y por eso el gráfico va con tope
   arriba y piso abajo. Sin el tope, estirado a 1058 px, las marcas del eje se
   dibujaban a 19 px, del tamaño de un título. Sin el piso, a 375 px caían a
   6 px. Entre 460 y 640 el texto se mueve entre 10 y 14 px, que es donde se
   lee; abajo de eso scrollea la caja, como una tabla ancha. */
.chart-wrap { overflow-x: auto; }

.chart {
    display: block;
    width: 100%;
    min-width: 460px;
    max-width: 640px;
    height: auto;
    margin: 0 auto;
}

.chart-grid {
    stroke: var(--chart-grid);
    stroke-width: 1;
    vector-effect: non-scaling-stroke;
}

.chart-tick {
    fill: var(--muted);
    font-family: var(--font-sans);
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}

.chart-line {
    fill: none;
    stroke-width: 2;
    stroke-linejoin: round;
    stroke-linecap: round;
    vector-effect: non-scaling-stroke;
}

/* Un baño, nunca un bloque saturado. */
.chart-area { opacity: .10; stroke: none; }

/* El anillo es del color de la superficie: hace que el punto se lea donde se
   cruza con otra línea. Un borde de color agregaría tinta que no es dato. */
.chart-dot {
    stroke: var(--surface);
    stroke-width: 2;
    vector-effect: non-scaling-stroke;
}

/* Rectángulo invisible por punto: le da al navegador un tooltip nativo. */
.chart-hit { fill: transparent; }
.chart-hit:hover { fill: var(--ink); opacity: .045; }

.chart-blank {
    margin: 0;
    padding: 26px 0;
    text-align: center;
    color: var(--muted);
    font-size: 13.5px;
    font-style: italic;
}

/* -------- Leyenda ---------------------------------------------------------
   Siempre presente con dos series o más: es el canal de identidad confiable.
   Con una sola no va, porque el título ya dice qué se está mirando.
   El texto usa tokens de texto; el color lo lleva la marca de al lado. */

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    list-style: none;
    margin: 0 0 12px;
    padding: 0;
    font-size: 13px;
    color: var(--ink-2);
}

.legend-key {
    display: inline-block;
    width: 11px;
    height: 11px;
    margin-right: 7px;
    border-radius: 3px;
    vertical-align: -1px;
}

/* -------- Ranking ---------------------------------------------------------
   Barras nominales: todas del mismo color. El valor va en la punta, afuera de
   la barra, así que nunca se recorta. */

.rank { list-style: none; margin: 0; padding: 0; }
.rank-row + .rank-row { margin-top: 13px; }

.rank-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 5px;
    font-size: 13.5px;
}

.rank-label { color: var(--ink); font-weight: 500; }
a.rank-label:hover { color: var(--accent-text); }
.rank-note { color: var(--muted); font-size: 12.5px; flex: none; }

.rank-bar { display: flex; align-items: center; gap: 9px; }

/* Punta redondeada de 4px, escuadra contra la línea de base. */
.rank-fill {
    flex: 0 1 auto;
    height: 10px;
    min-width: 3px;
    border-radius: 0 4px 4px 0;
    background: var(--chart-accent);
}

.rank-value {
    flex: none;
    font-size: 12.5px;
    color: var(--ink-2);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* -------- Barra apilada ---------------------------------------------------
   El hueco de 2px es del color de la superficie y es lo que separa los tramos.
   Nunca un borde alrededor de cada uno. */

.stack-bar {
    display: flex;
    gap: 2px;
    height: 16px;
    margin-bottom: 12px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--surface);
}

.stack-seg { flex-grow: 0; flex-shrink: 1; min-width: 3px; }

/* -------- Medidor ---------------------------------------------------------
   El color lo decide el estado, no la serie, y por eso sale de los tokens de
   estado. Nunca va solo: el número lo acompaña siempre. */

.meter { display: flex; align-items: center; gap: 11px; }

.meter-track {
    flex: 1;
    height: 10px;
    border-radius: 999px;
    overflow: hidden;
    background: var(--chart-track);
}

.meter-fill { height: 100%; border-radius: 999px; }

.meter-value {
    flex: none;
    font-weight: 600;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}

.meter-ok   .meter-fill { background: var(--ok); }
.meter-ok   .meter-value { color: var(--ok); }
.meter-warn .meter-fill { background: var(--warn); }
.meter-warn .meter-value { color: var(--warn); }
.meter-crit .meter-fill { background: var(--crit); }
.meter-crit .meter-value { color: var(--crit); }

/* -------- Línea mínima del contador -------------------------------------- */

.spark { display: block; width: 120px; height: 28px; margin-top: 6px; }

/* =============================================================================
   Tablero
   ========================================================================== */

/* Variación contra el período anterior. El color lo decide la dirección BUENA,
   no el signo: que suban las visitas y que suban los vencidos son dos cosas
   distintas. La flecha va además del color — el color solo no dice nada a quien
   no lo distingue. */
.kpi-delta {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.kpi-delta .muted { font-weight: 400; }
.kpi-delta.is-good { color: var(--ok); }
.kpi-delta.is-bad  { color: var(--crit); }
.kpi-delta.is-flat { color: var(--muted); font-weight: 400; }

.kpi-hint {
    display: block;
    margin-top: 4px;
    font-size: 11.5px;
    color: var(--muted);
}

/* El contador del tablero es más ancho que el de una bandeja: lleva variante
   y aclaración abajo del número. */
.kpi-row .kpi { min-width: 168px; }

/* --- Atajos de período ---------------------------------------------------
   Son enlaces y no botones: cada período tiene su URL, se puede compartir y el
   botón «atrás» funciona. */

.period {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.period-label { font-size: 13px; font-weight: 600; color: var(--ink-2); }

.period-range {
    margin-left: auto;
    font-size: 12.5px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.chip-link {
    display: inline-flex;
    align-items: center;
    padding: 6px 13px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink-2);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
}

.chip-link:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }

.chip-link.is-current {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-text);
    font-weight: 600;
}

.chip-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- Logo del Grupo en la barra del panel ----------------------------------
   Mismo mecanismo que el logo de unidad del portal: dos imágenes, tres estados. */
.topbar .brand-logo { display: block; height: 40px; width: auto; }
.topbar .brand-logo-dark { display: none; }

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .topbar .brand-logo-light { display: none; }
    :root:not([data-theme="light"]) .topbar .brand-logo-dark { display: block; }
}

:root[data-theme="dark"] .topbar .brand-logo-light { display: none; }
:root[data-theme="dark"] .topbar .brand-logo-dark { display: block; }

/* --- Portada pública (gltclientes.com/) ------------------------------------
   La única página sin QR ni cuenta. Dice de quién es el sitio y para qué sirve. */
.landing { display: grid; gap: 28px; max-width: 900px; margin: 0 auto; }
.landing-hero h1 { font-size: clamp(26px, 4vw, 38px); line-height: 1.15; margin: 6px 0 14px; max-width: 22ch; }
.landing-lead { color: var(--ink-2); font-size: 17px; line-height: 1.55; max-width: 62ch; margin: 0; }
.landing-units { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.landing-unit .eyebrow { margin: 8px 0 8px; }
.landing-unit-logo { margin: 0; min-height: 34px; }
.landing-logo { display: block; height: 34px; width: auto; }
.landing-logo-dark { display: none; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .landing-logo-light { display: none; }
    :root:not([data-theme="light"]) .landing-logo-dark { display: block; }
}
:root[data-theme="dark"] .landing-logo-light { display: none; }
:root[data-theme="dark"] .landing-logo-dark { display: block; }
.landing-how h2 { margin: 0 0 12px; }
.landing-steps { margin: 0 0 16px; padding-left: 22px; display: grid; gap: 10px; color: var(--ink-2); line-height: 1.5; }
.landing-steps strong { color: var(--ink); }
.landing-footer { border-top: 1px solid var(--line); padding-top: 18px; display: grid; gap: 6px; }
.landing-footer p { margin: 0; }

/* --- Calcomanías imprimibles (admin/qr/{id}/calcomania y /qr/calcomanias) --
   Medidas en mm porque el destino es papel: 50 × 50 con marcas de corte. */
.stickers-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; max-width: 760px; margin: 0 auto 18px; }
.stickers { display: grid; justify-content: center; gap: 0; }
.stickers-sheet { grid-template-columns: repeat(3, 50mm); column-gap: 8mm; row-gap: 6mm; }
.sticker {
    box-sizing: border-box; width: 50mm; height: 50mm; padding: 3mm 3mm 2.5mm;
    display: flex; flex-direction: column; align-items: center; justify-content: space-between;
    background: var(--sticker-bg); color: var(--sticker-ink);
    outline: 0.25mm solid var(--sticker-cut); text-align: center; overflow: hidden;
    break-inside: avoid; page-break-inside: avoid;
}
.sticker-logo { height: 6mm; width: auto; max-width: 40mm; object-fit: contain; }
.sticker-brand { margin: 0; font-weight: 700; font-size: 11pt; letter-spacing: 0.04em; text-transform: uppercase; }
.sticker-qr { width: 30mm; height: 30mm; image-rendering: pixelated; }
.sticker-text { margin: 0; font-size: 7.5pt; line-height: 1.2; font-weight: 600; color: var(--sticker-distri); }
.sticker[data-channel="retail"] .sticker-text { color: var(--sticker-retail); }
.sticker[data-channel="corporate"] .sticker-text { color: var(--sticker-corp); }
.sticker-name { margin: 0; font-size: 6.5pt; line-height: 1.15; color: var(--sticker-muted); max-width: 44mm; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media print {
    .stickers-toolbar, .bare-theme, .flash { display: none !important; }
    .bare-body, .bare-main { background: var(--sticker-bg) !important; margin: 0; padding: 0; }
    .stickers { gap: 0; }
    .sticker { outline-color: var(--sticker-cut); -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* --- Matriz de permisos de un rol -------------------------------------- */

.role-matrix-module td { background: var(--sunken); padding-top: 12px; padding-bottom: 8px; }
.role-matrix select.input { padding: 6px 10px; font-size: 13px; }

/* --- Constructor de encuestas ------------------------------------------------
   Dos columnas: las tarjetas de preguntas a la izquierda, la vista previa del
   celular pegada a la derecha. Debajo de 900 px la vista previa baja. */

.sb { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
.sb-main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.sb-side { position: sticky; top: calc(var(--topbar-h, 0px) + 16px); }
.sb-save { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.sb-status { color: var(--muted); }
.sb-status.is-dirty { color: var(--warn); font-weight: 600; }
.sb-status.is-saved { color: var(--ok); }
.sb-status.is-error { color: var(--crit); font-weight: 600; }

.sb-questions { display: flex; flex-direction: column; gap: 12px; }

.sb-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.sb-card.is-dragging { opacity: .5; }
.sb-card.is-inactive { opacity: .7; border-style: dashed; }
.sb-card-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line-soft); flex-wrap: wrap; }
.sb-card-head .spacer { flex: 1; }
.sb-handle { display: inline-flex; color: var(--muted); cursor: grab; padding: 4px; }
.sb-handle:active { cursor: grabbing; }
.sb-number { font-family: var(--font-display); font-weight: 700; font-size: 13px; color: var(--accent-text); min-width: 18px; }
.sb-type { width: auto; padding: 5px 30px 5px 10px; font-size: 13px; }
.sb-card-body { padding: 14px 16px 6px; display: flex; flex-direction: column; gap: 10px; }
.sb-label { font-size: 16px; font-weight: 500; }
.sb-hint { font-size: 13px; }
.sb-card-foot { padding: 6px 16px 12px; display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; }
.sb-required { margin: 0; }

.sb-options { display: flex; flex-direction: column; gap: 6px; }
.sb-option { display: flex; align-items: center; gap: 8px; }
.sb-option-mark { width: 14px; height: 14px; border: 2px solid var(--line); border-radius: 50%; flex: none; }
.sb-option .input { flex: 1; padding: 6px 10px; font-size: 14px; }
.sb-add-option { align-self: flex-start; }

.sb-add-row { display: flex; flex-wrap: wrap; gap: 8px; }
.sb-add-row .btn { display: inline-flex; align-items: center; gap: 7px; }

/* La vista previa: un celular chico con la marca de la unidad arriba. */
.sb-phone { border-radius: 30px; background: var(--ink); padding: 10px; box-shadow: var(--shadow-pop); }
.sb-phone-top { background: var(--surface); color: var(--accent-text); font-family: var(--font-display); font-weight: 800; letter-spacing: .02em; text-transform: uppercase; font-size: 14px; padding: 16px 16px 10px; border-radius: 22px 22px 0 0; border-bottom: 1px solid var(--line-soft); }
.sb-phone-screen { background: var(--ground); border-radius: 0 0 22px 22px; padding: 14px; height: 460px; overflow: auto; display: flex; flex-direction: column; gap: 10px; }
.sb-pv-eyebrow { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent-text); font-weight: 600; }
.sb-pv-title { font-family: var(--font-display); font-weight: 700; font-size: 18px; line-height: 1.15; color: var(--ink); }
.sb-pv-intro { font-size: 12px; color: var(--muted); line-height: 1.4; }
.sb-pv-q { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.sb-pv-label { font-size: 12.5px; font-weight: 600; color: var(--ink); line-height: 1.3; }
.sb-pv-hint { font-size: 11px; color: var(--muted); }
.sb-pv-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.sb-pv-chip { padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: 11px; color: var(--ink-2); }
.sb-pv-chip.is-on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.sb-pv-nps { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.sb-pv-nps .sb-pv-chip { text-align: center; border-radius: 6px; padding: 6px 0; }
.sb-pv-textarea { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 10px; font-size: 11px; color: var(--muted); min-height: 40px; }
.sb-pv-button { margin-top: 6px; background: var(--accent); color: var(--on-accent); text-align: center; padding: 9px; border-radius: 8px; font-size: 12px; font-weight: 600; }

@media (max-width: 900px) {
    .sb { grid-template-columns: 1fr; }
    .sb-side { position: static; }
    .sb-phone { max-width: 320px; }
}
/* Saltos («después de esta pregunta»): una fila por respuesta posible, con
   el destino a lo ancho para que se lea entero. */
.sb-branches { width: 100%; margin-top: 4px; padding-top: 10px; border-top: 1px dashed var(--line-soft); }
.sb-branches-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sb-branches-head p { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.sb-branch { display: grid; grid-template-columns: minmax(120px, 1fr) minmax(0, 2fr); gap: 8px; align-items: center; margin-top: 8px; }
.sb-branch-when { font-size: 13px; color: var(--ink-2); display: flex; align-items: center; gap: 8px; min-width: 0; }
.sb-branch-when span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-branch-arrow { flex: none; color: var(--muted); }
.sb-branch .input { width: 100%; padding: 6px 30px 6px 10px; font-size: 13px; }
.sb-pv-branch { font-size: 10.5px; color: var(--accent-text); font-style: italic; margin-top: 2px; }
.sb-branches-note { margin-top: 6px; }
