/* Sistema de Gestión — hoja de estilos base de la intranet.
   Misma familia visual que la tienda pública (tienda.css), con la marca ISCO:
   negro y grafito, el dorado de la S y fondo marfil, pero más sobria, porque aquí se trabaja.
   (Los nombres --noche-… y --azul-… son de la paleta anterior; se conservan para no tocar
   cada pantalla, pero ya valen grafito.)

   Los tokens de marca vienen de tokens.css; aquí se redefinen SOLO para la
   intranet, así las ~900 referencias a var(--azul…) de las plantillas toman la
   paleta nueva sin tocar cada pantalla. La portada no carga este fichero. */


:root {
    /* Antes venían de un @import de tokens.css (una hoja más en cadena antes de pintar);
       la intranet ya redefinía todos menos --blanco. */
    --blanco: #ffffff;
    /* Paleta (compartida en espíritu con portada.css) */
    --noche-950: #050505;
    --noche-900: #0b0b0c;
    --noche-800: #1b1b1e;
    --noche-700: #2b2b30;
    --noche-500: #4f4f57;
    --oro: #e3ff00;
    --oro-claro: #eeff66;
    --oro-oscuro: #5f7000;
    --marfil: #f7f5f0;
    --linea: #e6e2d8;
    --linea-fuerte: #d3cec1;

    /* Tokens de marca, reinterpretados para la intranet */
    --azul: #2b2b30;            /* acción principal y enlaces */
    --azul-intenso: #0b0b0c;    /* hover / énfasis */
    --azul-vivo: #4f4f57;       /* extremo claro de los degradados heredados */
    --azul-tinta: #141416;      /* texto principal */
    --azul-gris: #5b6178;       /* texto secundario */
    --azul-hielo: #f3f2ed;      /* fondos suaves */
    --azul-borde: #e6e2d8;      /* bordes */
    --exito: #1d7a4f;
    --peligro: #b3261e;         /* sólo «Cerrar sesión» y errores */
    --alerta: #b7791f;
    --naranja: #c2621d;         /* botones de peligro (convención de la app) */
    --sombra: 0 1px 2px rgba(11, 11, 12, .04), 0 12px 32px rgba(11, 11, 12, .07);
    --sombra-boton: none;
    --radio: 14px;

    --serif: "Chakra Petch", "Manrope", Arial, sans-serif;   /* titulares ISCO (antes Cormorant) */
    --sans: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    --t: .2s ease;
}

* { box-sizing: border-box; }

body {
    font-family: var(--sans);
    font-size: 15px;
    line-height: 1.5;
    margin: 0;
    padding: 0 16px 40px;
    /* Marfil con un enrejado dorado finísimo, como papel de embalaje fino. */
    background-color: var(--marfil);
    background-image:
        radial-gradient(90% 60% at 50% 100%, rgba(227, 255, 0, .10), transparent 70%),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='44' height='44' viewBox='0 0 44 44'%3E%3Cpath d='M22 0 44 22 22 44 0 22Z' fill='none' stroke='%23c9a96e' stroke-opacity='.16' stroke-width='.6'/%3E%3Ccircle cx='22' cy='22' r='.9' fill='%23c9a96e' fill-opacity='.28'/%3E%3C/svg%3E");
    background-attachment: fixed, scroll;
    min-height: 100vh;
    position: relative;
    color: var(--azul-tinta);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

::selection { background: var(--oro-claro); color: var(--noche-950); }
a { color: var(--azul); }

/* ===== Barra superior ===== */
.barra-app {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--noche-900);
    color: #fff;
    border-bottom: 1px solid rgba(227, 255, 0, .35);
    margin: 0 -16px 34px;
}
.barra-app-fila {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 22px;
    height: 64px;
    display: flex;
    align-items: center;
    gap: 18px;
}
.barra-marca { display: flex; align-items: center; gap: 14px; text-decoration: none; color: inherit; }
/* Sobre la barra oscura va el logo claro de ISCO (img/isco-logo-blanco.svg: letras blancas, S dorada). */
.barra-marca .logo-marca {
    height: 30px;
    width: auto;
    display: block;
}
.barra-marca .marca-sub {
    padding-left: 14px;
    border-left: 1px solid rgba(255, 255, 255, .18);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .22em;
    text-transform: uppercase;
    color: var(--oro);
}
.barra-usuario {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 16px;
}
.barra-usuario .quien { text-align: right; line-height: 1.25; }
.barra-usuario .quien strong { display: block; font-size: 13.5px; font-weight: 600; }
.barra-usuario .quien small { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: rgba(255, 255, 255, .5); }
.barra-enlace {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 36px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, .16);
    color: rgba(255, 255, 255, .85);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: border-color var(--t), color var(--t);
}
.barra-enlace:hover { border-color: var(--oro); color: var(--oro-claro); }
.barra-enlace svg { width: 16px; height: 16px; }
/* El único elemento rojo de la app es «Cerrar sesión». */
.barra-enlace.salir { color: #f2a19b; border-color: rgba(242, 161, 155, .3); }
.barra-enlace.salir:hover { color: #fff; background: var(--peligro); border-color: var(--peligro); }

/* ===== Fondo de la intranet =====
   Franja azul noche bajo la cabecera con hilos dorados (js/fondo-intranet.js);
   se desvanece hacia el marfil y las tarjetas blancas flotan encima. */
.fondo-intranet {
    position: absolute; left: 0; right: 0; top: 0; height: 340px;
    z-index: 0; pointer-events: none; overflow: hidden;
    background:
        radial-gradient(60% 130% at 92% -10%, rgba(227, 255, 0, .30), transparent 60%),
        radial-gradient(55% 110% at 0% 0%, rgba(79, 79, 87, .60), transparent 70%),
        linear-gradient(180deg, #0b0b0c 0%, #141416 60%, #1b1b1e 100%);
    /* Borde inferior en arco suave, rematado con un filo dorado. */
    border-bottom-left-radius: 50% 46px;
    border-bottom-right-radius: 50% 46px;
    box-shadow: 0 1px 0 rgba(227, 255, 0, .55), 0 18px 40px -20px rgba(11, 11, 12, .45);
}
.fondo-intranet canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
@media (max-width: 720px) { .fondo-intranet { height: 260px; border-bottom-left-radius: 50% 26px; border-bottom-right-radius: 50% 26px; } }
.container, .pie-app { position: relative; z-index: 1; }

/* ===== Contenedor principal ===== */
.container {
    max-width: 680px;
    margin: 0 auto;
    background: #fff;
    padding: 36px 34px;
    border-radius: var(--radio);
    border: 1px solid var(--linea);
    box-shadow: var(--sombra);
}
.container-wide { max-width: min(1180px, 96vw); }

h2 {
    font-family: var(--serif);
    color: var(--noche-950);
    margin: 0 0 8px;
    font-size: 32px;
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: -.005em;
    font-variant-numeric: lining-nums;
}
h3 {
    color: var(--azul-tinta);
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 10px;
}

/* ===== Formularios ===== */
label {
    display: block;
    margin: 16px 0 6px;
    font-weight: 700;
    font-size: 11.5px;
    color: var(--azul-gris);
    text-transform: uppercase;
    letter-spacing: .1em;
}
/* Una etiqueta que envuelve una casilla u opción se lee como frase, no como rótulo. */
label:has(> input[type="checkbox"]), label:has(> input[type="radio"]) {
    text-transform: none; letter-spacing: 0; font-size: 13.5px; font-weight: 600; color: var(--azul-tinta);
}
input[type="text"], input[type="password"], input[type="date"],
input[type="time"], input[type="email"], input[type="number"],
input[type="search"], input[type="tel"], input[type="file"], select, textarea {
    width: 100%;
    padding: 11px 14px;
    margin-bottom: 10px;
    border: 1px solid var(--linea-fuerte);
    border-radius: 10px;
    font-size: 15px;
    font-family: inherit;
    color: var(--azul-tinta);
    background: #fff;
    transition: border-color var(--t), box-shadow var(--t);
}
input:hover, select:hover, textarea:hover { border-color: #b9b3a4; }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--noche-700);
    box-shadow: 0 0 0 4px rgba(43, 43, 48, .1);
}
input[type="file"]::file-selector-button {
    margin-right: 12px;
    padding: 6px 12px;
    border: 0;
    border-radius: 8px;
    background: var(--noche-800);
    color: #fff;
    font: 600 13px var(--sans);
    cursor: pointer;
}
input[type="checkbox"], input[type="radio"] { accent-color: var(--noche-800); }
textarea { resize: vertical; height: 80px; }

/* ===== Botones =====
   Sólidos, sin degradados ni saltos: azul noche para lo principal, verde para
   confirmar, naranja para lo delicado (convención de la app). */
button, .btn {
    display: inline-block;
    padding: 12px 20px;
    background: var(--noche-800);
    color: #fff;
    border: 1px solid transparent;
    border-radius: 10px;
    font-size: 14.5px;
    font-weight: 700;
    font-family: inherit;
    letter-spacing: .02em;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    box-shadow: none;
    transition: background var(--t), box-shadow var(--t), border-color var(--t);
}
button:hover, .btn:hover {
    background: var(--noche-700);
    box-shadow: 0 6px 18px -6px rgba(11, 11, 12, .45);
}
button:active, .btn:active { transform: translateY(1px); }
button:focus-visible, .btn:focus-visible { outline: 2px solid var(--oro-oscuro); outline-offset: 2px; }
button:disabled {
    background: #d9d6cd;
    color: #8a8778;
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}
.btn-block { width: 100%; }

.btn-primary { background: var(--noche-800); }
.btn-success { background: var(--exito); box-shadow: none; }
.btn-success:hover { background: #17633f; box-shadow: 0 6px 18px -6px rgba(29, 122, 79, .5); }
/* Botones «peligro» en naranja: el único botón rojo de la app es Cerrar sesión. */
.btn-danger { background: var(--naranja); box-shadow: none; }
.btn-danger:hover { background: #a65218; box-shadow: 0 6px 18px -6px rgba(194, 98, 29, .5); }
.btn-purple { background: #4d3a7a; box-shadow: none; }
.btn-purple:hover { background: #3e2e64; }
.btn-warning { background: var(--alerta); box-shadow: none; }
.btn-warning:hover { background: #9c6618; }

/* ===== Navegación ===== */
.back { margin-bottom: 20px; }
.back a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--azul-gris);
    text-decoration: none;
    font-weight: 600;
    font-size: 13px;
    padding: 6px 14px 6px 10px;
    border-radius: 999px;
    background: transparent;
    border: 1px solid var(--linea);
    transition: border-color var(--t), color var(--t);
}
.back a:hover { border-color: var(--noche-800); color: var(--noche-900); }

/* ===== Tablas (estilo global) =====
   Cabecera clara y fina en lugar del bloque azul: se lee mejor y pesa menos. */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 15px;
    border: 1px solid var(--linea);
    border-radius: 12px;
    overflow: hidden;
    font-variant-numeric: tabular-nums;
}
th {
    background: #f6f4ee;
    color: var(--azul-gris);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .1em;
    padding: 12px 12px;
    text-align: left;
    border-bottom: 1px solid var(--linea);
}
td {
    padding: 12px 12px;
    border-bottom: 1px solid #efece4;
    text-align: left;
    font-size: 14px;
    background: #fff;
}
tr:last-child td { border-bottom: none; }
tbody tr:hover td, table tr:hover td { background: #faf9f5; }
tr.total td {
    font-weight: 800;
    background: #f6f4ee;
    color: var(--noche-900);
    border-top: 1px solid var(--linea-fuerte);
}

/* ===== Mensajes ===== */
.flash-success, .flash-error, .alert-warning {
    padding: 13px 16px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-weight: 600;
    font-size: 14px;
    border: 1px solid;
    border-left-width: 3px;
}
.flash-success { background: #eef6f1; color: #17633f; border-color: #cfe4d8; border-left-color: var(--exito); }
.flash-error   { background: #fbefed; color: #8f231c; border-color: #efd0cc; border-left-color: var(--peligro); }
.alert-warning { background: #fbf4e6; color: #7a5413; border-color: #ecdcb8; border-left-color: var(--alerta); font-weight: 500; }

.nota-tasa { color: var(--azul-gris); font-size: 14px; }

/* ===== Pie ===== */
.pie-app {
    max-width: 680px;
    margin: 26px auto 0;
    text-align: center;
    color: var(--azul-gris);
    font-size: 12px;
    letter-spacing: .06em;
}
.pie-app strong { color: var(--noche-800); font-weight: 700; }

/* ===== Notificaciones (toasts) ===== */
#toasts {
    position: fixed; top: 76px; right: 16px; z-index: 9999;
    display: flex; flex-direction: column; gap: 10px; max-width: 340px;
}
.toast {
    background: #fff;
    border-radius: 12px;
    padding: 13px 16px 13px 18px;
    border: 1px solid var(--linea);
    box-shadow: 0 18px 40px -12px rgba(11, 11, 12, .35);
    border-left: 3px solid var(--noche-700);
    cursor: pointer;
    animation: toast-in .25s ease-out;
}
.toast .t-titulo {
    font-weight: 700; font-size: 13.5px; color: var(--noche-900);
    display: flex; align-items: center; gap: 8px;
}
.toast .t-titulo::before {
    content: ""; width: 7px; height: 7px; border-radius: 50%;
    background: var(--oro-oscuro); flex-shrink: 0;
}
.toast .t-msg { font-size: 13px; color: var(--azul-gris); margin-top: 4px; }
.toast.entrante { border-left-color: var(--alerta); }
.toast.aprobada { border-left-color: var(--exito); }
.toast.rechazada { border-left-color: var(--naranja); }
.toast.despacho { border-left-color: var(--noche-500); }
.toast.enviada  { border-left-color: var(--noche-900); }
.toast.devuelta { border-left-color: var(--alerta); }
.toast.comision { border-left-color: var(--exito); }
@keyframes toast-in { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: none; } }

/* Regiones en vivo (data-vivo): el bloque se repinta solo cada pocos segundos.
   Este halo dorado avisa de que lo que se ve acaba de cambiar sin recargar. */
.vivo-cambio {
    border-radius: var(--radio);
    animation: vivo-flash 1.6s ease-out;
}
@keyframes vivo-flash {
    from { box-shadow: 0 0 0 5px rgba(227, 255, 0, .45); }
    to   { box-shadow: 0 0 0 5px rgba(227, 255, 0, 0); }
}

/* ===== Iconos de línea (sprite en _iconos.html) ===== */
.ic {
    width: 1.2em;
    height: 1.2em;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Iconos dentro del texto: alineados con la línea, del color del texto. */
.ic { vertical-align: -0.22em; }
button:has(> .ic), .btn:has(> .ic), a.btn-pdf:has(> .ic), a.btn-mini:has(> .ic) {
    display: inline-flex; align-items: center; justify-content: center; gap: .45em;
}
button > .ic, .btn > .ic { width: 1.1em; height: 1.1em; }
h3 > .ic, h4 > .ic, h5 > .ic, summary > .ic { color: var(--oro-oscuro); margin-right: .3em; }
h3 > .ic { width: 1em; height: 1em; }
.meta > .ic, .sec > .ic, .dato > .ic { color: var(--oro-oscuro); width: 1.05em; height: 1.05em; margin-right: .2em; }
/* Puntos de estado (sustituyen a los círculos de colores de antes). */
.punto-estado { display: inline-block; width: .62em; height: .62em; border-radius: 50%;
    margin-right: .35em; vertical-align: .05em; background: var(--azul-gris); }
.punto-estado.rojo     { background: #d64545; box-shadow: 0 0 0 3px rgba(214, 69, 69, .18); }
.punto-estado.amarillo { background: #d9a400; box-shadow: 0 0 0 3px rgba(217, 164, 0, .18); }
.punto-estado.verde    { background: #1d9a5f; box-shadow: 0 0 0 3px rgba(29, 154, 95, .18); }

/* ===== Móvil ===== */
@media (max-width: 720px) {
    body { padding: 0 12px 28px; }
    .barra-app { margin: 0 -12px 18px; }
    .barra-app-fila { padding: 0 14px; height: 58px; gap: 10px; }
    .barra-marca .logo-marca { height: 26px; }
    .barra-marca .marca-sub, .barra-usuario .quien, .barra-enlace .txt { display: none; }
    .barra-enlace { width: 36px; padding: 0; justify-content: center; }
    .container { padding: 24px 18px; border-radius: 12px; }
    h2 { font-size: 27px; }
    #toasts { top: 66px; left: 12px; right: 12px; max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ===== Impresión ===== */
@media print {
    body { background: #fff; padding: 0; }
    .barra-app, .pie-app, #toasts, .fondo-intranet { display: none !important; }
    .container { border: 0; box-shadow: none; padding: 0; max-width: none; }
}

/* ===== Origen de los pedidos =====
   Cuatro canales con su punto de color: web (dorado), WhatsApp (verde),
   vendedor (azul) y oficina (ciruela). Mismo código en etiquetas y filtros. */
.origen {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px 3px 8px;
    border-radius: 999px;
    background: #f6f4ee;
    border: 1px solid var(--linea);
    color: var(--azul-tinta);
    font-size: 11.5px;
    font-weight: 700;
    white-space: nowrap;
}
.origen::before, .filtro-origen .punto {
    content: "";
    width: 7px; height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--color-origen, var(--azul-gris));
}
.origen-web      { --color-origen: var(--oro-oscuro); }
.origen-whatsapp { --color-origen: #1f9e5f; }
.origen-vendedor { --color-origen: var(--noche-500); }
.origen-oficina  { --color-origen: #6b4f9a; }

.filtro-origen {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 6px 0 18px;
}
.filtro-origen-titulo {
    margin-right: 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--azul-gris);
}
.filtro-origen a {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 34px;
    padding: 0 12px;
    border: 1px solid var(--linea-fuerte);
    border-radius: 999px;
    background: #fff;
    color: var(--azul-tinta);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: border-color var(--t), background var(--t);
}
.filtro-origen a:hover { border-color: var(--noche-800); }
.filtro-origen a .n {
    min-width: 20px;
    padding: 1px 6px;
    border-radius: 999px;
    background: #f3f2ed;
    color: var(--azul-gris);
    font-size: 11px;
    font-weight: 700;
    text-align: center;
}
.filtro-origen a.activo { background: var(--noche-900); border-color: var(--noche-900); color: #fff; }
.filtro-origen a.activo .n { background: var(--oro); color: var(--noche-950); }
.filtro-origen a.por-construir:not(.activo) { color: var(--azul-gris); border-style: dashed; }
.filtro-origen .pronto {
    font-size: 9.5px;
    font-weight: 800;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--oro-oscuro);
}
.filtro-origen a.activo .pronto { color: var(--oro-claro); }

/* =====================================================================
   Marco de la aplicación con sesión: menú lateral + barra superior.
   (_navegacion.html; datos en services/navegacion.py)
   - ≥ 1100 px: menú lateral fijo a la izquierda.
   - < 1100 px: el menú es un cajón que se abre con el botón de menú.
   - < 720 px (teléfono): además, barra inferior con los atajos del rol.
   ===================================================================== */
:root {
    --ancho-nav: 264px;
    --alto-barra: 60px;
    --alto-inferior: 64px;
    --pagina-max: 1240px;
}

/* ----- Menú lateral ----- */
.nav-app {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--ancho-nav);
    z-index: 80;
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(120% 40% at 0% 0%, rgba(79, 79, 87, .35), transparent 70%),
        linear-gradient(180deg, var(--noche-900), var(--noche-950));
    color: rgba(255, 255, 255, .78);
    border-right: 1px solid rgba(227, 255, 0, .22);
}
.nav-cabeza {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--alto-barra);
    padding: 0 18px 0 20px;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
    flex-shrink: 0;
}
.nav-marca { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.nav-marca .logo-marca { height: 26px; width: auto; display: block; }
.nav-marca .marca-sub {
    padding-left: 12px;
    border-left: 1px solid rgba(255, 255, 255, .18);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .22em;
    text-transform: uppercase;
    color: var(--oro);
}
.nav-cabeza .nav-cerrar { display: none; }
.nav-cuerpo {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px 18px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, .14) transparent;
}
.nav-seccion + .nav-seccion { margin-top: 6px; }
.nav-titulo {
    margin: 18px 10px 6px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: rgba(227, 255, 0, .75);
}
.nav-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 38px;
    padding: 7px 10px;
    margin: 1px 0;
    border-radius: 9px;
    color: rgba(255, 255, 255, .78);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.25;
    cursor: pointer;
    transition: background var(--t), color var(--t);
}
.nav-link .ic { width: 18px; height: 18px; color: rgba(231, 212, 169, .62); transition: color var(--t); }
.nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-link:hover .ic { color: var(--oro-claro); }
.nav-link:focus-visible { outline: 2px solid var(--oro); outline-offset: -2px; }
.nav-link.activo { background: rgba(227, 255, 0, .16); color: #fff; }
.nav-link.activo .ic { color: var(--oro); }
.nav-link.activo::before {
    content: "";
    position: absolute;
    left: -12px; top: 8px; bottom: 8px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--oro);
}
.nav-texto { flex: 1; min-width: 0; }

/* Grupos desplegables */
.nav-grupo > summary { list-style: none; }
.nav-grupo > summary::-webkit-details-marker { display: none; }
.nav-flecha { width: 14px !important; height: 14px !important; margin-left: auto; transition: transform var(--t); opacity: .55; }
.nav-grupo[open] > summary .nav-flecha { transform: rotate(90deg); }
.nav-hijos { margin: 2px 0 6px 19px; padding-left: 12px; border-left: 1px solid rgba(255, 255, 255, .1); }
.nav-hijo { min-height: 34px; padding: 6px 10px; font-size: 13px; font-weight: 500; }
.nav-hijo .ic { width: 16px; height: 16px; }
.nav-hijo.activo::before { left: -13px; }
.nav-subtitulo {
    margin: 10px 10px 2px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .38);
}

/* Contadores de pendientes */
.nav-badge {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--oro);
    color: var(--noche-950);
    font-size: 11px;
    font-weight: 800;
    line-height: 20px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.nav-badge.urgente { background: #e0483a; color: #fff; }
.nav-badge[hidden] { display: none; }
.nav-grupo > summary .nav-badge { margin-left: auto; }
.nav-grupo > summary .nav-badge:not([hidden]) + .nav-flecha { margin-left: 4px; }

/* Usuario y salida, al pie del menú */
.nav-pie { flex-shrink: 0; padding: 12px 14px 16px; border-top: 1px solid rgba(255, 255, 255, .07); }
.nav-usuario { display: flex; align-items: center; gap: 10px; padding: 4px 6px 10px; }
.nav-usuario .quien { line-height: 1.25; min-width: 0; }
.nav-usuario strong { display: block; color: #fff; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-usuario small { font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: rgba(255, 255, 255, .45); }
.avatar {
    width: 34px; height: 34px; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--oro-claro), var(--oro));
    color: var(--noche-950);
    font-size: 12.5px; font-weight: 800; letter-spacing: .02em;
}
.nav-salir {
    display: flex; align-items: center; gap: 9px;
    padding: 8px 10px;
    border-radius: 9px;
    color: #f2a19b;
    font-size: 13px; font-weight: 600;
    text-decoration: none;
    transition: background var(--t), color var(--t);
}
.nav-salir .ic { width: 17px; height: 17px; }
.nav-salir:hover { background: rgba(179, 38, 30, .22); color: #fff; }
.nav-velo { position: fixed; inset: 0; z-index: 70; background: rgba(3, 7, 22, .5); backdrop-filter: blur(2px); }
.nav-velo[hidden] { display: none; }

/* ----- Barra superior (con sesión) ----- */
body:has(> .nav-app) { padding: 0 32px 48px calc(var(--ancho-nav) + 32px); }
.barra-app.barra-con-menu {
    margin: 0 -32px 28px;
    background: rgba(247, 245, 240, .88);
    backdrop-filter: saturate(1.4) blur(10px);
    -webkit-backdrop-filter: saturate(1.4) blur(10px);
    color: var(--azul-tinta);
    border-bottom: 1px solid var(--linea);
}
.barra-con-menu .barra-app-fila { max-width: none; height: var(--alto-barra); padding: 0 32px; gap: 14px; }
/* (.barra-app delante para ganar a «button:has(> .ic)», que lo haría visible) */
.barra-app .barra-menu {
    display: none;
    width: 40px; height: 40px; padding: 0;
    align-items: center; justify-content: center;
    background: #fff; color: var(--noche-900);
    border: 1px solid var(--linea-fuerte); border-radius: 10px;
}
.barra-menu:hover { background: #fff; border-color: var(--noche-800); box-shadow: none; }
.barra-menu .ic { width: 20px; height: 20px; }
.barra-con-menu .barra-marca.solo-movil { display: none; }
.barra-con-menu .barra-marca .logo-marca { filter: none; height: 24px; }
.migas {
    display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
    min-width: 0;
    font-size: 13px; color: var(--azul-gris);
}
.migas a { color: var(--azul-gris); text-decoration: none; font-weight: 600; }
.migas a:hover { color: var(--noche-900); }
.migas-sep { color: var(--linea-fuerte); }
.migas-actual { color: var(--noche-900); font-weight: 700; }
.barra-derecha { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.barra-tasa {
    display: inline-flex; align-items: center; gap: 7px;
    height: 32px; padding: 0 12px;
    border: 1px solid var(--linea); border-radius: 999px;
    background: #fff;
    font-size: 13px; font-weight: 700; color: var(--noche-900);
    font-variant-numeric: tabular-nums; white-space: nowrap;
}
.barra-tasa .etq { font-size: 10px; letter-spacing: .14em; color: var(--oro-oscuro); }
.barra-con-menu .avatar { width: 34px; height: 34px; }

/* ----- Área de trabajo: dos anchos y un mismo borde izquierdo ----- */
body:has(> .nav-app) .container {
    max-width: 860px;
    margin: 0;
    min-width: 0;
}
body:has(> .nav-app) .container-wide { max-width: var(--pagina-max); }
body:has(> .nav-app) .pie-app { max-width: var(--pagina-max); margin: 28px 0 0; text-align: left; }
/* El «Volver al menú» sobra: el menú está siempre a la vista y las migas dicen dónde
   estás. Los «volver» a otra pantalla (p. ej. a la lista) se quedan. */
body:has(> .nav-app) .back:has(> a[href="/inicio"]) { display: none; }

/* ----- Barra inferior del teléfono ----- */
.barra-inferior { display: none; }

@media (max-width: 1099px) {
    body:has(> .nav-app) { padding: 0 24px 40px; }
    .barra-app.barra-con-menu { margin: 0 -24px 22px; }
    .barra-con-menu .barra-app-fila { padding: 0 24px; }
    .barra-app .barra-menu { display: inline-flex; }
    .nav-app {
        transform: translateX(-102%);
        transition: transform .25s ease;
        box-shadow: 24px 0 60px -20px rgba(3, 7, 22, .6);
        width: min(300px, 86vw);
    }
    .nav-app.abierto { transform: none; }
    .nav-cabeza .nav-cerrar {
        display: inline-flex; align-items: center; justify-content: center;
        width: 36px; height: 36px; padding: 0;
        background: transparent; color: rgba(255, 255, 255, .7);
        border: 1px solid rgba(255, 255, 255, .14); border-radius: 9px;
    }
    .nav-cerrar:hover { background: rgba(255, 255, 255, .08); box-shadow: none; }
    .nav-cerrar .ic { width: 18px; height: 18px; }
    body.menu-abierto { overflow: hidden; }
}

@media (max-width: 719px) {
    body:has(> .nav-app) {
        padding: 0 12px calc(var(--alto-inferior) + 24px + env(safe-area-inset-bottom));
    }
    .barra-app.barra-con-menu { margin: 0 -12px 16px; }
    .barra-con-menu .barra-app-fila { padding: 0 14px; height: 56px; }
    /* En el teléfono el menú se abre desde la barra inferior. */
    .barra-app .barra-menu, .migas { display: none; }
    .barra-con-menu .barra-marca.solo-movil { display: flex; }
    .barra-tasa { height: 30px; padding: 0 10px; font-size: 12.5px; }
    .barra-con-menu .avatar { width: 32px; height: 32px; font-size: 12px; }
    body:has(> .nav-app) .container { padding: 22px 16px; border-radius: 14px; }
    body:has(> .nav-app) .pie-app { display: none; }

    .barra-inferior {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
        display: flex;
        height: calc(var(--alto-inferior) + env(safe-area-inset-bottom));
        padding: 0 4px env(safe-area-inset-bottom);
        background: rgba(255, 255, 255, .96);
        backdrop-filter: blur(10px);
        border-top: 1px solid var(--linea);
        box-shadow: 0 -10px 30px -18px rgba(11, 11, 12, .35);
    }
    .barra-inferior > a, .barra-inferior > button {
        position: relative;
        flex: 1;
        display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
        min-width: 0;
        padding: 6px 2px 0;
        background: none; border: 0; border-radius: 0; box-shadow: none;
        color: var(--azul-gris);
        font: 600 10.5px var(--sans); letter-spacing: 0;
        text-decoration: none;
    }
    .barra-inferior > a:hover, .barra-inferior > button:hover { background: none; box-shadow: none; color: var(--noche-900); }
    .barra-inferior .ic { width: 22px; height: 22px; }
    .barra-inferior span:not(.nav-badge) { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .barra-inferior .activo { color: var(--noche-900); }
    .barra-inferior .activo::before {
        content: ""; position: absolute; top: 0; left: 28%; right: 28%;
        height: 3px; border-radius: 0 0 3px 3px; background: var(--oro-oscuro);
    }
    .barra-inferior .nav-badge {
        position: absolute; top: 4px; left: calc(50% + 6px);
        min-width: 18px; height: 18px; line-height: 18px; font-size: 10.5px;
        border: 2px solid #fff;
    }
    #toasts { top: 64px; }

    /* Tablas: se desplazan dentro de su caja, nunca ensanchan la página. */
    table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    th, td { white-space: nowrap; }
    td { white-space: normal; min-width: 72px; }
}

/* =====================================================================
   Jerarquía de botones
   1. Principal (sólido): la acción que completa la tarea. Una por vista.
   2. Secundario (borde): navegar, cancelar, descargar, ver más.
   3. Terciario (texto): enlaces de apoyo.
   ===================================================================== */
.btn-secundario, button.btn-secundario {
    background: #fff;
    color: var(--noche-800);
    border: 1px solid var(--linea-fuerte);
    box-shadow: none;
}
.btn-secundario:hover, button.btn-secundario:hover {
    background: #faf9f5;
    border-color: var(--noche-800);
    color: var(--noche-900);
    box-shadow: none;
}
.btn-secundario .ic { color: var(--oro-oscuro); }
.btn-terciario {
    background: none; border: 0; box-shadow: none;
    padding: 8px 4px;
    color: var(--noche-700);
    font-weight: 700;
    text-decoration: underline; text-decoration-color: var(--linea-fuerte); text-underline-offset: 3px;
}
.btn-terciario:hover { background: none; box-shadow: none; text-decoration-color: currentColor; }
/* Un grupo de acciones: la principal manda, las demás la acompañan a su lado. */
.acciones-fila { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 14px; }
.acciones-fila.derecha { justify-content: flex-end; }
@media (max-width: 719px) {
    .acciones-fila > .btn, .acciones-fila > button { flex: 1 1 100%; }
}
/* Botón pequeño dentro de una tabla: secundario y compacto. */
.btn-tabla { padding: 6px 12px; font-size: 13px; white-space: nowrap; }
/* Separación coherente entre un botón principal y el secundario que lo sigue. */
.btn-block + .btn-block { margin-top: 10px; }
