/* ═══════════════════════════════════════════════════════════════════════
   NÚCLEO — tokens y piezas sueltas compartidas por todo el sistema.

   Antes cada plantilla traía su propio bloque <style> con su propia copia
   de los colores, los botones y los campos de formulario: seis pantallas de
   acceso repetían el MISMO CSS palabra por palabra, así que cambiar el azul
   de marca obligaba a editar nueve archivos y siempre se quedaba uno atrás.
   Todo eso vive aquí una sola vez.

   El sistema tiene dos mundos:

     · claro  — el panel de trabajo (base.html): fondo perla, tarjetas
                blancas y tinta azul pizarra. Se usa horas seguidas, con
                tablas y formularios largos, así que manda la legibilidad.
     · oscuro — portada y pantallas de acceso (.mundo-oscuro en <html>).
                Son la primera impresión del producto y se ven un minuto.

   Los dos usan LOS MISMOS nombres de variable y las MISMAS clases: el mundo
   oscuro solo reescribe los valores. Por eso .btn, .input o .badge se ven
   correctos en ambos lados sin una sola regla duplicada.

   Compatibilidad: las variables viejas (--navy, --blue, --shadow-lg…) siguen
   existiendo porque decenas de plantillas las usan en estilos propios. Se
   conservan los nombres y solo se afinaron los valores.
   ═══════════════════════════════════════════════════════════════════════ */

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

:root {
    /* ── La paleta ─────────────────────────────────────────────────────────
       Seis tonos de un mismo azul pizarra, del casi negro al gris perla.
       Todo el sistema sale de aquí: el panel los usa en claro (fondo perla,
       tarjetas blancas, tinta oscura) y la portada en oscuro. */
    --abismo:  #06141B;
    --noche:   #11212D;
    --pizarra: #253745;
    --acero:   #4A5C6A;
    --niebla:  #9BA8AB;
    --perla:   #CCD0CF;

    /* ── Tinta ─────────────────────────────────────────────────────────── */
    --ink-900:    #06141B;
    --ink-800:    #0b1a23;
    --ink-700:    #11212D;
    --ink-600:    #253745;
    --navy:       #11212D;   /* compat */
    --navy-mid:   #11212D;   /* compat */
    --navy-light: #253745;   /* compat */
    --blue:       #4A5C6A;   /* compat */
    --blue-mid:   #4A5C6A;   /* compat */

    /* ── Acento ────────────────────────────────────────────────────────────
       OJO: este es el color fijo de la interfaz del programa y a propósito
       NO sale de cuenta.color_primario. Ese campo es solo para el formato
       de las cotizaciones (ver configuracion_formato.html y generar_pdf.py)
       y no debe mover los colores del sistema.

       En claro el acento es la pizarra: 11.9:1 sobre blanco, así que sirve
       igual de enlace que de relleno con texto blanco encima. */
    --accent:           #253745;
    --accent-dk:        #11212D;
    --accent-brillante: #4A5C6A;
    --accent-suave:     rgba(37,55,69,.08);
    --accent-glow:      rgba(37,55,69,.18);
    --cyan:             #9BA8AB;
    /* Texto encima de un relleno de acento. En oscuro el acento es claro y
       esto se invierte. */
    --sobre-accent:     #ffffff;

    /* El botón principal: la píldora de tinta. */
    --boton:            #11212D;
    --boton-hover:      #253745;
    --sobre-boton:      #ffffff;

    /* ── Superficies del mundo claro ───────────────────────────────────── */
    --surface:      #ffffff;
    --surface-2:    #EBEEEE;
    --surface-3:    #DFE3E3;
    --border:       #E3E7E7;
    --border-fuerte:#CCD0CF;

    /* ── Texto ─────────────────────────────────────────────────────────────
       --text-3 es el acero de la paleta: 6.8:1 sobre blanco y 5.9:1 sobre
       --surface-2, por arriba del 4.5:1 que pide WCAG. La niebla (#9BA8AB)
       no llega a 3:1 sobre blanco, así que nunca es color de texto. */
    --text-1: #06141B;
    --text-2: #253745;
    --text-3: #4A5C6A;

    /* ── Semáforo ──────────────────────────────────────────────────────────
       Oscurecidos para que se lean como texto sobre fondo claro. El mundo
       oscuro los vuelve a subir de brillo más abajo. */
    --success: #097f57;
    --warning: #a66200;
    --danger:  #d42d4a;
    --success-suave: rgba(9,127,87,.10);
    --warning-suave: rgba(166,98,0,.11);
    --danger-suave:  rgba(212,45,74,.09);
    --success-borde: rgba(9,127,87,.28);
    --warning-borde: rgba(166,98,0,.30);
    --danger-borde:  rgba(212,45,74,.26);

    /* ── Forma ─────────────────────────────────────────────────────────────
       Esquinas generosas y botones en píldora: el panel es un conjunto de
       piezas blandas sobre un fondo perla, no una rejilla de cajas. */
    --radius:    22px;
    --radius-sm: 14px;
    --radius-lg: 28px;

    /* Sin borde visible en las tarjetas: las separa del fondo perla una
       sombra corta y otra larga muy tenue, teñidas de la tinta y no de
       negro puro. */
    --shadow:    0 1px 2px rgba(6,20,27,.04), 0 10px 28px -16px rgba(6,20,27,.16);
    --shadow-lg: 0 2px 6px rgba(6,20,27,.06), 0 24px 48px -20px rgba(6,20,27,.30);

    --sidebar-w: 84px;
    --nav-h:     76px;

    /* ── Tipografía ────────────────────────────────────────────────────────
       Geist para la interfaz y Geist Mono para todo lo que sea cantidad:
       precios, existencias, folios, fechas. La mono tiene cifras de ancho
       fijo, así que una columna de importes queda alineada sin trucos.
       Ambas autoalojadas en static/vendor/googlefonts/geist.css. */
    --fuente:      'Geist', 'Inter', 'Plus Jakarta Sans', system-ui, sans-serif;
    --fuente-dato: 'Geist Mono', 'DM Mono', ui-monospace, monospace;
    /* Archivo, un poco expandida, solo para titulares. Ver geist.css. */
    --fuente-display: 'Archivo', 'Geist', system-ui, sans-serif;

    /* Curva de salida exponencial: arranca rápido y frena suave. */
    --salida: cubic-bezier(.22,1,.36,1);
}

/* ═══ MUNDO OSCURO ═══════════════════════════════════════════════════════
   Mismos nombres, otros valores. Se activa con class="mundo-oscuro" en el
   <html> de la portada y de las pantallas de acceso: la misma paleta, de
   la noche hacia la perla. */
.mundo-oscuro {
    --surface:      #11212D;
    --surface-2:    #0b1a23;
    --surface-3:    #253745;
    --border:       rgba(204,208,207,.10);
    --border-fuerte:rgba(204,208,207,.20);

    --text-1: #E8EBEA;
    --text-2: #CCD0CF;
    --text-3: #9BA8AB;

    --accent:       #CCD0CF;
    --accent-dk:    #E8EBEA;
    --accent-suave: rgba(204,208,207,.10);
    --accent-glow:  rgba(204,208,207,.22);
    --sobre-accent: #06141B;

    --boton:        #CCD0CF;
    --boton-hover:  #E8EBEA;
    --sobre-boton:  #06141B;

    --success: #5fd3a4;
    --warning: #f2c25b;
    --danger:  #ff7a7a;
    --success-suave: rgba(95,211,164,.13);
    --warning-suave: rgba(242,194,91,.13);
    --danger-suave:  rgba(255,122,122,.13);
    --success-borde: rgba(95,211,164,.32);
    --warning-borde: rgba(242,194,91,.32);
    --danger-borde:  rgba(255,122,122,.32);

    --shadow:    inset 0 1px 0 rgba(204,208,207,.06), 0 18px 40px -20px rgba(0,0,0,.7);
    --shadow-lg: inset 0 1px 0 rgba(204,208,207,.08), 0 40px 80px -30px rgba(0,0,0,.85);
}

/* ═══ BASE ══════════════════════════════════════════════════════════════ */
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--fuente);
    /* En rem para que crezca junto con el resto en pantallas grandes
       (ver "Pantallas grandes y teles" en panel.css). */
    font-size: .9375rem;
    line-height: 1.55;
    color: var(--text-1);
    background: var(--surface-2);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Geist trae cifras proporcionales por omisión; en una app que es casi
       toda números conviene lo contrario en todos lados. */
    font-variant-numeric: tabular-nums;
}

.mundo-oscuro body {
    background:
        radial-gradient(900px 600px at 0% 0%, rgba(155,168,171,.20), transparent 62%),
        linear-gradient(180deg, var(--noche) 0%, var(--abismo) 70%) fixed;
    background-color: var(--abismo);
}

a { text-decoration: none; color: inherit; }

h1, h2, h3, h4 {
    font-weight: 600;
    letter-spacing: -.025em;
    line-height: 1.15;
    text-wrap: balance;
}

/* Los titulares de verdad —los que ocupan media pantalla— van en Archivo
   con el eje de ancho abierto. Los títulos chicos de tarjeta se quedan en
   Geist: a 15px la diferencia no se nota y sí se nota el cambio de ritmo. */
.display,
.hero h1,
.seccion-titulo h2,
.cierre h2,
.page-header h1,
.logo-title,
.marca-texto {
    font-family: var(--fuente-display);
    font-stretch: 112%;
}

/* Cifras y folios: mono, para que las columnas cuadren. */
.dato, .cifra {
    font-family: var(--fuente-dato);
    font-variant-numeric: tabular-nums;
    letter-spacing: -.02em;
}

/* ── Superficies del navegador ─────────────────────────────────────────────
   Selección, cursor de texto, barra de desplazamiento y anillo de foco son
   parte del diseño aunque no las dibujemos nosotros. Sin esto, cada una
   aparece con el color por omisión del navegador, que no pertenece a
   ningún sistema. */
::selection { background: var(--pizarra); color: #fff; }
.mundo-oscuro ::selection { background: rgba(204,208,207,.30); color: #fff; }

input, textarea, select { caret-color: var(--accent); }

* { scrollbar-width: thin; scrollbar-color: var(--border-fuerte) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border-fuerte);
    border: 3px solid transparent;
    background-clip: content-box;
    border-radius: 100px;
}
::-webkit-scrollbar-thumb:hover { background-color: var(--text-3); background-clip: content-box; }

/* Un solo anillo de foco para todo el sistema, visible en ambos mundos.
   :focus-visible y no :focus, para que no aparezca al hacer clic con el
   ratón pero sí al llegar con el tabulador. */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ═══ BOTONES ═══════════════════════════════════════════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 100px;
    font-family: var(--fuente);
    font-size: .875rem;
    font-weight: 550;
    letter-spacing: -.01em;
    line-height: 1.2;
    cursor: pointer;
    border: 1px solid transparent;
    white-space: nowrap;
    transition: background .18s ease, border-color .18s ease,
                color .18s ease, box-shadow .18s ease, transform .12s ease;
}

.btn:active { transform: translateY(.5px) scale(.995); }

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

.btn-grande { padding: 14px 28px; font-size: .95rem; }
.btn-chico  { padding: 7px 13px; font-size: .8rem; }

.btn-primary, .btn-primario {
    background: var(--boton);
    color: var(--sobre-boton);
    box-shadow: 0 1px 2px rgba(6,20,27,.14), 0 8px 18px -10px rgba(6,20,27,.45);
}
.btn-primary:hover, .btn-primario:hover {
    background: var(--boton-hover);
    box-shadow: 0 2px 4px rgba(6,20,27,.16), 0 12px 24px -12px rgba(6,20,27,.5);
}

.btn-outline, .btn-fantasma {
    background: transparent;
    color: var(--text-1);
    border-color: var(--border-fuerte);
    background: var(--surface);
}
.btn-outline:hover, .btn-fantasma:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-suave);
}

.btn-dark {
    background: var(--ink-700);
    color: #fff;
}
.btn-dark:hover { background: var(--ink-600); }

/* Botón claro sobre tinta: el contrario del primario, para la portada. */
.btn-claro {
    background: var(--perla);
    color: var(--ink-900);
    font-weight: 600;
}
.btn-claro:hover {
    background: #fff;
    box-shadow: 0 0 0 4px rgba(204,208,207,.16);
}

.btn-sutil {
    background: transparent;
    color: var(--text-2);
}
.btn-sutil:hover { background: var(--surface-3); color: var(--text-1); }

/* El giro de "cargando" que usan los formularios de acceso. */
.spinner {
    display: none;
    width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,.3);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: girar .6s linear infinite;
}
.loading .spinner  { display: block; }
.loading .btn-text { display: none; }
.loading .btn-icon { display: none; }
@keyframes girar { to { transform: rotate(360deg); } }

/* ═══ CAMPOS ════════════════════════════════════════════════════════════ */
label {
    display: block;
    font-size: .78rem;
    font-weight: 550;
    color: var(--text-2);
    margin-bottom: 7px;
    letter-spacing: 0;
    /* Sin VERSALITAS: en español las mayúsculas sostenidas pierden los
       acentos visuales de las palabras largas ("DESCRIPCIÓN DEL PRODUCTO")
       y se leen más lento. El peso y el color ya separan la etiqueta. */
    text-transform: none;
}

.field { margin-bottom: 18px; }

.field-hint, .campo-nota {
    font-size: .78rem;
    color: var(--text-3);
    margin-top: 6px;
}

.input, .field input, .field select, .field textarea {
    width: 100%;
    padding: 11px 14px;
    background: var(--surface);
    border: 1px solid var(--border-fuerte);
    border-radius: var(--radius-sm);
    font-family: var(--fuente);
    font-size: .9rem;
    color: var(--text-1);
    outline: none;
    transition: border-color .18s, box-shadow .18s, background .18s;
}

.input::placeholder,
.field input::placeholder,
.field textarea::placeholder { color: var(--text-3); }

.input:hover,
.field input:hover { border-color: var(--text-3); }

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

/* El anillo del campo ya comunica el foco; el outline general encima se ve
   como un doble borde. */
.input:focus-visible,
.field input:focus-visible,
.field select:focus-visible,
.field textarea:focus-visible { outline: none; }

.input-wrap { position: relative; display: flex; align-items: center; }

.input-wrap .input-icon {
    position: absolute; left: 14px;
    color: var(--text-3);
    font-size: .85rem;
    pointer-events: none;
    transition: color .18s;
}
.input-wrap:focus-within .input-icon { color: var(--accent); }
/* En estas pantallas el <i> va después del <input> (para que el ícono quede
   encima), así que no hay selector de hermano que valga: todos los
   .input-wrap del sistema llevan ícono a la izquierda. */
.input-wrap input { padding-left: 40px; }
.input-wrap.sin-icono input { padding-left: 14px; }

.toggle-pass {
    position: absolute; right: 10px;
    background: none; border: none;
    color: var(--text-3);
    cursor: pointer;
    font-size: .85rem;
    padding: 6px;
    border-radius: 6px;
    transition: color .18s, background .18s;
}
.toggle-pass:hover { color: var(--text-1); background: var(--surface-3); }

/* ═══ AVISOS ════════════════════════════════════════════════════════════ */
.alert {
    display: none;
    align-items: flex-start;
    gap: 10px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    font-size: .85rem;
    margin-bottom: 20px;
    border: 1px solid;
    animation: entrar .25s var(--salida);
}
.alert.show { display: flex; }
.alert i { margin-top: .18em; flex-shrink: 0; }
.alert.error   { background: var(--danger-suave);  border-color: var(--danger-borde);  color: var(--danger); }
.alert.success { background: var(--success-suave); border-color: var(--success-borde); color: var(--success); }
.alert.info    { background: var(--accent-suave); border-color: var(--accent-glow); color: var(--accent); }

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

/* ═══ ETIQUETAS ═════════════════════════════════════════════════════════ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: .74rem;
    font-weight: 550;
    line-height: 1.45;
    white-space: nowrap;
}

.badge-blue   { background: var(--accent-suave); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent-glow); }
.badge-green  { background: var(--success-suave); color: var(--success); }
.badge-yellow { background: var(--warning-suave); color: var(--warning); }
.badge-red    { background: var(--danger-suave);  color: var(--danger); }
.badge-gris   { background: var(--surface-3); color: var(--text-2); }

/* ═══ TABLAS ════════════════════════════════════════════════════════════ */
.table-wrap { overflow-x: auto; }

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

thead th {
    padding: 12px 16px;
    text-align: left;
    font-size: .78rem;
    font-weight: 550;
    color: var(--text-3);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    letter-spacing: 0;
}

tbody td {
    padding: 13px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-1);
    vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .15s; }
tbody tr:hover { background: rgba(155,168,171,.10); }

/* ═══ ESTELAS ═══════════════════════════════════════════════════════════
   La luz difusa que entra por la esquina de la portada: un brillo perla
   que se apaga hacia el azul noche. Antes eran filamentos azules (las
   imágenes de scripts/generar_estelas.py); con la paleta pizarra basta un
   degradado. Siempre detrás del contenido y siempre inerte al ratón. */
.estelas {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}
.estelas-oscuro {
    background:
        radial-gradient(60% 70% at 8% 0%, rgba(204,208,207,.22), transparent 70%),
        radial-gradient(50% 60% at 100% 30%, rgba(74,92,106,.25), transparent 70%);
}
.estelas-claro {
    background:
        radial-gradient(60% 80% at 0% 0%, rgba(255,255,255,.9), transparent 70%),
        radial-gradient(50% 70% at 100% 0%, rgba(155,168,171,.22), transparent 70%);
}

/* ═══ ANIMACIÓN DE ENTRADA ══════════════════════════════════════════════
   Un solo gesto, escalonado: el contenido sube al lugar que ya ocupa. */
@keyframes subir {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: none; }
}

.anim { animation: subir .5s var(--salida) both; }
.anim-d1 { animation-delay: .04s; }
.anim-d2 { animation-delay: .08s; }
.anim-d3 { animation-delay: .12s; }
.anim-d4 { animation-delay: .16s; }
.anim-d5 { animation-delay: .20s; }
.anim-d6 { animation-delay: .24s; }

/* Quien pidió menos movimiento en su sistema operativo no lo pidió como
   sugerencia. */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}

/* ─── "¿Cómo pagó?" (static/js/metodo-pago.js) ─────────────────────── */
.dialogo-pago { border: none; border-radius: var(--radius); padding: 22px; width: min(380px, calc(100vw - 32px));
    background: var(--surface); color: var(--text-1); box-shadow: var(--shadow-lg); }
.dialogo-pago::backdrop { background: rgba(15, 23, 42, .45); }
.dialogo-pago h2 { margin: 0 0 4px; font-size: 1.05rem; }
.dialogo-pago p { margin: 0 0 14px; font-size: 0.82rem; color: var(--text-3); }
.dialogo-pago .opciones-pago { display: grid; gap: 8px; }
.dialogo-pago .opciones-pago .btn { justify-content: flex-start; width: 100%; }
.dialogo-pago .opciones-pago .btn i { width: 18px; text-align: center; }
.dialogo-pago .cancelar-pago { margin-top: 12px; width: 100%; justify-content: center; }
