/* ------------------------------------------------------------------
   Libro de pagarés — estilo "talonario"
   Azul marino y oro tomados del emblema, sobre papel frío.
   El rojo queda reservado para vencidos y avisos.
   Cifras en monoespaciada para que las columnas cuadren a la vista.
------------------------------------------------------------------- */

:root {
    --tinta:      #0e2c47;
    --tinta-2:    #405669;
    --tinta-3:    #78899a;
    --papel:      #e6ecef;
    --tarjeta:    #ffffff;
    --linea:      #c9d5dd;
    --linea-2:    #e2e8ec;
    --oro:        #c8892a;
    --oro-claro:  #e4a83c;
    --petroleo:   #0a5a72;
    --sello:      #a2372c;
    --sello-flojo:#f3e2df;
    --cobro:      #1f6b4e;
    --cobro-flojo:#dfeee7;
    --aviso:      #8a6209;
    --aviso-flojo:#f6ecd6;

    --r:    12px;
    --r-sm: 8px;
    --sombra:   0 1px 2px rgba(14, 44, 71, .05), 0 8px 24px rgba(14, 44, 71, .07);
    --sombra-md: 0 4px 10px rgba(14, 44, 71, .08), 0 14px 32px rgba(14, 44, 71, .10);
    --rapido: .16s ease;

    --display: 'Archivo', 'Helvetica Neue', Arial, sans-serif;
    --texto:   'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --cifra:   'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

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

body {
    background: var(--papel);
    color: var(--tinta);
    font-family: var(--texto);
    font-size: 16px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

body.menu-abierto { overflow: hidden; }

a { color: var(--petroleo); text-decoration: none; transition: color var(--rapido); }
a:hover { text-decoration: underline; }

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

/* ---------- Estructura ---------- */

.barra {
    background: var(--tinta);
    color: #fff;
    border-bottom: 3px solid var(--oro-claro);
    position: sticky;
    top: 0;
    z-index: 40;
}

.barra .interior {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 28px;
    min-height: 60px;
    position: relative;
}

.marca {
    display: flex;
    align-items: center;
    gap: 11px;
    font-family: var(--display);
    font-weight: 700;
    font-size: 15px;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: #fff;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}
.marca:hover { text-decoration: none; color: #fff; }

.marca img { width: 30px; height: 30px; display: block; flex: none; }

.logo-barra {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: block;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, .22);
}

.logo-acceso {
    width: 58px;
    height: 58px;
    border-radius: 13px;
    display: block;
    margin-bottom: 16px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .28);
}

.menu { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }

.menu a {
    color: #b8c4cd;
    font-size: 13px;
    letter-spacing: .06em;
    text-transform: uppercase;
    font-weight: 500;
    padding: 8px 12px;
    border-radius: var(--r-sm);
    transition: background var(--rapido), color var(--rapido);
}
.menu a:hover { color: #fff; background: rgba(255,255,255,.08); text-decoration: none; }
.menu a.activo { color: #fff; background: rgba(255,255,255,.14); }

/* ---------- Menú hamburguesa (móvil) ---------- */

.hamburguesa {
    display: none;
    margin-left: auto;
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    border-radius: var(--r-sm);
    background: transparent;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    cursor: pointer;
    flex: none;
}
.hamburguesa:hover { background: rgba(255,255,255,.08); }
.hamburguesa span {
    display: block;
    width: 20px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
    transition: transform var(--rapido), opacity var(--rapido);
}
.hamburguesa.activo span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburguesa.activo span:nth-child(2) { opacity: 0; }
.hamburguesa.activo span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.fondo-menu {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(14, 20, 27, .45);
    z-index: 35;
}

@media (max-width: 780px) {
    .barra .interior { min-height: 56px; }
    .hamburguesa { display: flex; }

    .menu {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        margin-left: 0;
        flex-direction: column;
        gap: 2px;
        background: var(--tinta);
        border-bottom: 3px solid var(--oro-claro);
        box-shadow: var(--sombra-md);
        padding: 8px 14px 14px;
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        transition: max-height .22s ease, opacity .18s ease;
    }
    .menu.abierto { max-height: 70vh; opacity: 1; overflow-y: auto; }

    .menu a {
        padding: 13px 12px;
        font-size: 14px;
        border-bottom: 1px solid rgba(255,255,255,.08);
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    .menu a.salir { color: #f0b8ae; }

    body.menu-abierto .fondo-menu { display: block; }
}

.contenido {
    max-width: 1180px;
    margin: 0 auto;
    padding: 28px 20px 72px;
}

.pie {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 20px 40px;
    color: var(--tinta-3);
    font-size: 12px;
}

/* ---------- Cabeceras ---------- */

.encabezado {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

h1 {
    font-family: var(--display);
    font-size: 27px;
    font-weight: 700;
    letter-spacing: -.015em;
    margin: 0;
}

h2 {
    font-family: var(--display);
    font-size: 17px;
    font-weight: 600;
    margin: 0 0 12px;
}

.rotulo {
    font-family: var(--display);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--tinta-3);
    margin: 0 0 6px;
}

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

.tarjeta {
    background: var(--tarjeta);
    border: 1px solid var(--linea);
    border-radius: var(--r);
    box-shadow: var(--sombra);
    margin-bottom: 22px;
    transition: box-shadow var(--rapido);
}

.tarjeta > .cuerpo { padding: 18px 20px; }

.tarjeta > .titulo {
    padding: 13px 20px;
    border-bottom: 1px solid var(--linea-2);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.tarjeta > .titulo h2 { margin: 0; }

/* ---------- Cifras destacadas ---------- */

.cifras {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 1px;
    background: var(--linea);
    border: 1px solid var(--linea);
    border-radius: var(--r);
    overflow: hidden;
    margin-bottom: 22px;
}

.cifra {
    background: var(--tarjeta);
    padding: 16px 18px;
}

.cifra .rotulo { margin-bottom: 8px; }

.cifra .valor {
    font-family: var(--cifra);
    font-size: 25px;
    font-weight: 500;
    letter-spacing: -.02em;
    line-height: 1.1;
}

.cifra .nota { font-size: 12px; color: var(--tinta-3); margin-top: 5px; }

.cifra.acento { background: var(--tinta); color: #fff; }
.cifra.acento .rotulo { color: #93a3ae; }
.cifra.acento .nota { color: #93a3ae; }

/* ---------- Cinta de vencimientos (elemento firma) ---------- */

.cinta {
    background: var(--tarjeta);
    border: 1px solid var(--linea);
    border-radius: var(--r);
    box-shadow: var(--sombra);
    padding: 18px 20px 14px;
    margin-bottom: 22px;
    overflow-x: auto;
}

.cinta .pista {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    min-height: 132px;
    padding-top: 6px;
}

.mes-col {
    flex: 1 0 68px;
    min-width: 68px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-end;
    text-decoration: none;
}
.mes-col:hover { text-decoration: none; }

.mes-col .importe-mes {
    font-family: var(--cifra);
    font-size: 11px;
    color: var(--tinta-2);
    text-align: center;
    margin-bottom: 5px;
    white-space: nowrap;
}

.mes-col .barra-mes {
    background: var(--tinta);
    border-radius: 2px 2px 0 0;
    min-height: 3px;
    transition: background .15s ease;
}
.mes-col:hover .barra-mes { background: var(--petroleo); }
.mes-col.vacio .barra-mes { background: var(--linea); }
.mes-col.actual .barra-mes { background: var(--oro); }

.mes-col .nombre-mes {
    font-family: var(--display);
    font-size: 10px;
    letter-spacing: .1em;
    text-transform: uppercase;
    text-align: center;
    color: var(--tinta-3);
    padding-top: 7px;
    border-top: 1px solid var(--linea);
    margin-top: 0;
}
.mes-col.actual .nombre-mes { color: var(--oro); font-weight: 700; }

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

.tabla-marco { overflow-x: auto; }

table.datos {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

table.datos th {
    font-family: var(--display);
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: .13em;
    text-transform: uppercase;
    color: var(--tinta-3);
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--linea);
    white-space: nowrap;
}

table.datos td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--linea-2);
    vertical-align: middle;
}

table.datos tbody tr:hover { background: #f7f9fa; }
table.datos tbody tr:last-child td { border-bottom: none; }

.col-cliente {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.num { font-family: var(--cifra); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
th.num { text-align: right; }
.fecha { font-family: var(--cifra); font-size: 13px; white-space: nowrap; }
.fuerte { font-weight: 600; }
.tenue { color: var(--tinta-3); }
.pequeno { font-size: 12.5px; }

tr.total td {
    border-top: 2px solid var(--tinta);
    border-bottom: none;
    font-weight: 600;
    background: #f7f9fa;
}

/* ---------- Estados ---------- */

.marca-estado {
    display: inline-block;
    font-family: var(--display);
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: .09em;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 2px;
    border: 1px solid;
    white-space: nowrap;
}
.e-pendiente { color: var(--tinta-2); border-color: var(--linea); background: #f3f6f7; }
.e-proximo   { color: var(--aviso); border-color: #e2cd9c; background: var(--aviso-flojo); }
.e-vencido   { color: var(--sello); border-color: #e0b8b2; background: var(--sello-flojo); }
.e-cobrado   { color: var(--cobro); border-color: #b6d8c8; background: var(--cobro-flojo); }
.e-devuelto  { color: #fff; border-color: var(--sello); background: var(--sello); }

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

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

.campo { display: flex; flex-direction: column; gap: 6px; }

.campo label {
    font-family: var(--display);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--tinta-2);
}

.campo .pista-campo { font-size: 12px; color: var(--tinta-3); }

input[type=text], input[type=date], input[type=password],
input[type=number], input[type=search], select, textarea {
    font-family: var(--texto);
    font-size: 16px;
    color: var(--tinta);
    background: #fff;
    border: 1px solid var(--linea);
    border-radius: var(--r-sm);
    padding: 10px 12px;
    width: 100%;
    transition: border-color var(--rapido), box-shadow var(--rapido);
}

input.cifra-in { font-family: var(--cifra); }

input:focus, select:focus, textarea:focus {
    border-color: var(--tinta);
    outline: 2px solid rgba(23,33,43,.12);
    outline-offset: 0;
}

select {
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%23405669'%3E%3Cpath fill-rule='evenodd' d='M5.23 7.21a.75.75 0 011.06.02L10 11.19l3.71-3.96a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z' clip-rule='evenodd'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 18px;
    padding-right: 34px;
}

textarea { min-height: 78px; resize: vertical; }

.acciones {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid var(--linea-2);
}

.boton {
    font-family: var(--display);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .1em;
    text-transform: uppercase;
    padding: 11px 18px;
    border-radius: var(--r-sm);
    border: 1px solid var(--tinta);
    background: var(--tinta);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 40px;
    transition: background var(--rapido), box-shadow var(--rapido), transform var(--rapido);
}
.boton:hover { background: #24313e; text-decoration: none; color: #fff; box-shadow: var(--sombra); }
.boton:active { transform: translateY(1px); }

.boton.secundario { background: #fff; color: var(--tinta); }
.boton.secundario:hover { background: #f2f5f6; color: var(--tinta); }

.boton.peligro { background: #fff; color: var(--sello); border-color: #ddb4ad; }
.boton.peligro:hover { background: var(--sello); color: #fff; }

.boton.mini { font-size: 10.5px; padding: 6px 10px; letter-spacing: .08em; min-height: 30px; }

/* ---------- Filtros ---------- */

.filtros {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}
.filtros .campo { min-width: 140px; flex: 0 1 auto; }
.filtros .campo.ancho { flex: 1 1 220px; }

/* ---------- Avisos ---------- */

.aviso {
    border: 1px solid;
    border-left-width: 4px;
    border-radius: var(--r);
    padding: 12px 15px;
    margin-bottom: 18px;
    font-size: 14px;
}
.aviso.ok    { border-color: #b6d8c8; border-left-color: var(--cobro); background: var(--cobro-flojo); color: #16513b; }
.aviso.error { border-color: #e0b8b2; border-left-color: var(--sello); background: var(--sello-flojo); color: #7d2a21; }
.aviso.info  { border-color: var(--linea); border-left-color: var(--tinta-2); background: #f3f6f7; color: var(--tinta-2); }

.vacio {
    text-align: center;
    padding: 44px 20px;
    color: var(--tinta-3);
}
.vacio p { margin: 0 0 16px; }

/* ---------- Desglose inline ---------- */

.desglose {
    font-family: var(--cifra);
    font-size: 11.5px;
    color: var(--tinta-3);
    white-space: nowrap;
}

/* ---------- Acceso ---------- */

.pagina-acceso {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.caja-acceso {
    width: 100%;
    max-width: 380px;
}

.caja-acceso .sello-cab {
    text-align: center;
    background: var(--tinta);
    border-bottom: 3px solid var(--oro-claro);
    border-radius: var(--r) var(--r) 0 0;
    padding: 26px 26px 22px;
    color: #fff;
}

.caja-acceso .sello-cab .rotulo { color: #93a3ae; margin-bottom: 4px; }

.caja-acceso .sello-cab .emblema {
    width: 62px;
    height: 62px;
    display: block;
    margin: 0 auto 16px;
}

.caja-acceso .sello-cab h1 {
    font-size: 22px;
    color: #fff;
    letter-spacing: .02em;
}

.caja-acceso form {
    background: #fff;
    border: 1px solid var(--linea);
    border-top: none;
    border-radius: 0 0 var(--r) var(--r);
    padding: 24px 26px 26px;
    box-shadow: var(--sombra);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.caja-acceso .boton { width: 100%; padding: 12px; }

/* ---------- Utilidades ---------- */

.fila-acciones { display: flex; gap: 6px; justify-content: flex-end; }
.oculto { display: none; }
.sep { height: 1px; background: var(--linea-2); margin: 18px 0; }

/* ---------- Responsive: tablet ---------- */

@media (max-width: 1100px) {
    /* Columnas secundarias de las tablas de pagarés: se ocultan para que
       quepan las importantes sin necesitar scroll horizontal. */
    .col-opcional { display: none; }
    .col-cliente { max-width: 160px; }
}

@media (max-width: 900px) {
    .contenido { padding: 24px 18px 64px; }
    .rejilla { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
    .cifras { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Responsive: móvil ---------- */

@media (max-width: 780px) {
    .barra .interior { padding: 0 16px; gap: 12px; }
}

@media (max-width: 640px) {
    h1 { font-size: 21px; }
    h2 { font-size: 16px; }
    .cifra .valor { font-size: 20px; }
    .cifras { grid-template-columns: 1fr 1fr; }
    .contenido { padding: 18px 14px 56px; }
    .barra .interior { padding: 0 14px; gap: 10px; }

    .encabezado { flex-direction: column; align-items: stretch; gap: 12px; }
    .fila-acciones { justify-content: stretch; }
    .fila-acciones .boton, .fila-acciones .boton.secundario { flex: 1; }

    .tarjeta > .cuerpo { padding: 15px 16px; }
    .tarjeta > .titulo { padding: 12px 16px; }

    .rejilla { grid-template-columns: 1fr; }
    .filtros { flex-direction: column; align-items: stretch; }
    .filtros .campo { min-width: 0; width: 100%; }
    .filtros .boton { width: 100%; }

    .acciones { flex-direction: column-reverse; align-items: stretch; }
    .acciones .boton { width: 100%; }

    /* Tablas: scroll horizontal con indicio visual del contenido oculto */
    .tabla-marco {
        margin: 0 -16px;
        padding: 0 16px;
        -webkit-overflow-scrolling: touch;
    }
    .tarjeta > .tabla-marco:last-child { padding-bottom: 4px; }
    table.datos { font-size: 13px; }
    table.datos th, table.datos td { padding: 10px 9px; }

    .cinta { padding: 15px 14px 12px; margin: 0 0 22px; }
}

@media (max-width: 380px) {
    .cifras { grid-template-columns: 1fr; }
}

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

@media print {
    .barra, .menu, .acciones, .filtros, .boton { display: none !important; }
    body { background: #fff; }
    .tarjeta { box-shadow: none; }
}
