:root {
    --asse-blue: #003d82;
    --asse-light-blue: #4a90e2;
    --asse-yellow: #fbbf24;
    --success: #059669;
    --danger: #dc2626;
    --bg-page: #f8fafc;
    --bg-card: #ffffff;
    --text: #1e293b;
    --text-sec: #64748b;
    --border: #e2e8f0;
    --header-blue: #1e3a5f;
    --table-border: #adb5bd;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg-page);
    color: var(--text);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Ancho completo: la página de resultados necesita todo el espacio horizontal
   disponible para la tabla — a diferencia de .container, no limita a 1100px. */
.container-wide {
    width: 100%;
    margin: 0 auto;
    padding: 0 .75rem;
}

a {
    color: var(--asse-blue);
}

/* ══════════════════════════════════════════════
   HERO
   ══════════════════════════════════════════════ */
.hero-section {
    background: linear-gradient(135deg, var(--asse-blue) 0%, var(--asse-light-blue) 100%);
    padding: 3.5rem 0 3rem;
    color: #fff;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.hero-section::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.logout-form {
    position: absolute;
    top: 1.25rem;
    right: 1.5rem;
    z-index: 3;
}

.logout-btn {
    background: rgba(255, 255, 255, .12);
    border-color: rgba(255, 255, 255, .35);
    color: #fff;
}

.logout-btn:hover {
    background: rgba(255, 255, 255, .22);
    color: #fff;
}

.hero-eyebrow {
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .75);
    margin-bottom: .75rem;
    position: relative;
    z-index: 2;
}

.hero-icon-box {
    width: 68px;
    height: 68px;
    margin: 0 auto 1.25rem;
    background: rgba(255, 255, 255, .15);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, .3);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 2;
}

.hero-icon-box i {
    font-size: 2rem;
    color: #fff;
}

.hero-title {
    font-size: 2.4rem;
    font-weight: 800;
    margin: 0 0 .4rem;
    position: relative;
    z-index: 2;
    text-shadow: 0 4px 10px rgba(0, 0, 0, .25);
}

.hero-subtitle {
    font-size: 1.05rem;
    opacity: .92;
    max-width: 560px;
    margin: 0 auto;
    position: relative;
    z-index: 2;
}

/* ══════════════════════════════════════════════
   CARDS
   ══════════════════════════════════════════════ */
.modern-card {
    background: var(--bg-card);
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, .08);
    border: 1px solid rgba(0, 0, 0, .05);
    padding: 2.25rem;
}

.page-body {
    margin: -2.5rem auto 3rem;
    position: relative;
    z-index: 3;
}

/* ══════════════════════════════════════════════
   DROPZONE
   ══════════════════════════════════════════════ */
.upload-dropzone {
    padding: 3rem 1.5rem;
    border: 2px dashed var(--border);
    border-radius: 16px;
    background: #fbfcfe;
    cursor: pointer;
    text-align: center;
    transition: .2s ease;
}

.upload-dropzone:hover,
.upload-dropzone.dragover {
    border-color: var(--asse-light-blue);
    background: #f0f6ff;
}

.upload-dropzone i {
    font-size: 3rem;
    color: var(--success);
    margin-bottom: .75rem;
}

.upload-dropzone .dz-title {
    font-weight: 600;
    font-size: 1.05rem;
    margin-bottom: .25rem;
}

.upload-dropzone .dz-subtitle {
    color: var(--text-sec);
    font-size: .9rem;
}

.file-types {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 1.25rem;
}

.file-type {
    font-size: .8rem;
    color: var(--text-sec);
    background: #f1f5f9;
    border-radius: 999px;
    padding: .3rem .75rem;
}

.selected-files-list {
    display: flex;
    flex-direction: column;
    gap: .6rem;
    margin-top: 1.25rem;
}

.selected-file {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .7rem .9rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
}

.selected-file i {
    font-size: 1.3rem;
    color: var(--success);
    flex-shrink: 0;
}

.selected-file .sf-info {
    flex: 1;
    min-width: 0;
}

.selected-file .sf-name {
    font-weight: 600;
    font-size: .88rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.selected-file .sf-size {
    color: var(--text-sec);
    font-size: .78rem;
}

.upload-modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .6);
    backdrop-filter: blur(2px);
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.upload-modal-backdrop.show {
    display: flex;
}

.upload-modal-box {
    background: #fff;
    border-radius: 16px;
    padding: 2.5rem 2.75rem;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
    max-width: min(420px, 90vw);
}

.upload-modal-box h3 {
    margin: 1.25rem 0 .4rem;
    color: var(--asse-blue);
    font-size: 1.15rem;
}

.upload-modal-box p {
    color: var(--text-sec);
    font-size: .88rem;
    margin: 0;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid var(--border);
    border-top-color: var(--asse-blue);
    border-radius: 50%;
    animation: spin .8s linear infinite;
    margin: 0 auto;
}

.spinner-lg {
    width: 44px;
    height: 44px;
    border-width: 4px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ══════════════════════════════════════════════
   ALERTAS
   ══════════════════════════════════════════════ */
.error-box {
    display: flex;
    gap: .75rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    border-radius: 12px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    font-size: .9rem;
}

.error-box i {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.error-box p {
    margin: .15rem 0;
}

/* ══════════════════════════════════════════════
   BOTONES
   ══════════════════════════════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .65rem 1.25rem;
    border-radius: 10px;
    border: 2px solid transparent;
    font-size: .92rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: transform .12s ease, box-shadow .2s ease, background-color .2s ease;
}

.btn:active {
    transform: translateY(1px);
}

.btn-primary {
    background: linear-gradient(135deg, var(--asse-blue), var(--asse-light-blue));
    color: #fff;
    box-shadow: 0 6px 18px rgba(0, 61, 130, .28);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--asse-light-blue), var(--asse-blue));
    box-shadow: 0 8px 22px rgba(0, 61, 130, .35);
    color: #fff;
}

.btn-secondary {
    background: #fff;
    color: var(--text);
    border-color: var(--border);
}

.btn-secondary:hover {
    background: #f1f5f9;
    color: var(--text);
}

.btn-success {
    background: linear-gradient(135deg, var(--success), #047857);
    color: #fff;
    box-shadow: 0 6px 18px rgba(5, 150, 105, .28);
}

.btn-success:hover {
    box-shadow: 0 8px 22px rgba(5, 150, 105, .35);
    color: #fff;
}

/* ══════════════════════════════════════════════
   TOOLBAR + TÍTULO (página de resultados)
   ══════════════════════════════════════════════ */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: .75rem;
    padding: .6rem 0;
}

.toolbar-title {
    display: flex;
    align-items: center;
    gap: .85rem;
    min-width: 0;
}

.toolbar-title h1 {
    color: var(--header-blue);
    font-weight: 700;
    font-size: 1rem;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 480px;
}

.toolbar-actions {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
}

.btn-sm {
    padding: .4rem .8rem;
    font-size: .82rem;
    border-radius: 8px;
}

.empty-msg {
    color: var(--text-sec);
    text-align: center;
    padding: 3rem 1rem;
}

/* ══════════════════════════════════════════════
   LOGIN
   ══════════════════════════════════════════════ */
.login-card {
    max-width: 380px;
    margin: 0 auto;
}

.form-group {
    margin-bottom: 1.1rem;
}

.form-group label {
    display: block;
    font-size: .85rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: .4rem;
}

.form-input {
    width: 100%;
    padding: .65rem .85rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: .95rem;
    color: var(--text);
    font-family: inherit;
}

.form-input:focus {
    outline: none;
    border-color: var(--asse-light-blue);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, .15);
}

.login-submit {
    width: 100%;
    justify-content: center;
    margin-top: .5rem;
}

/* ══════════════════════════════════════════════
   TABLA RESUMEN
   ══════════════════════════════════════════════ */
.table-scroll {
    overflow: auto;
    border: 1px solid var(--table-border);
    border-radius: 10px;
    max-height: calc(100vh - 6rem);
}

.summary-table {
    border-collapse: collapse;
    width: 100%;
    background: #fff;
    font-size: .68rem;
    line-height: 1.25;
}

.summary-table th,
.summary-table td {
    border: 1px solid var(--table-border);
    padding: .25rem .4rem;
    text-align: left;
    vertical-align: top;
    min-width: 150px;
}

.summary-table thead th {
    background: var(--header-blue);
    color: #fff;
    text-align: center;
    font-size: .68rem;
    font-weight: 600;
    padding: .35rem .4rem;
    line-height: 1.2;
    position: sticky;
    top: 0;
    z-index: 2;
}

.summary-table .fecha-col {
    min-width: 100px;
    white-space: nowrap;
    font-weight: 600;
    background: #eef1f5;
    position: sticky;
    left: 0;
    z-index: 1;
    text-transform: capitalize;
    /* Con position:sticky + border-collapse:collapse el borde derecho
       compartido con la celda siguiente queda tapado por el repintado de la
       celda pegajosa al hacer scroll. box-shadow no se ve afectado por eso. */
    box-shadow: 1px 0 0 0 var(--table-border);
}

.summary-table thead th:first-child {
    position: sticky;
    left: 0;
    z-index: 3;
    background: var(--header-blue);
    box-shadow: 1px 0 0 0 var(--table-border);
}

.summary-table tbody tr:hover td:not(.fecha-col) {
    background: #f0f6ff;
}

.summary-table tbody tr:nth-child(even) td:not(.fecha-col) {
    background: #f8f9fa;
}

.summary-table tbody tr:nth-child(even):hover td:not(.fecha-col) {
    background: #f0f6ff;
}

/* La columna Fecha es sticky con su propio fondo — sin esto, el hover de
   fila se cortaba justo ahí y no se veía como "toda la fila". */
.summary-table tbody tr:hover td.fecha-col {
    background: #dbe7fb;
}

/* Separador visual cuando la fila siguiente pasa a otro mes */
.summary-table tbody tr.month-separator td {
    border-top: 3px solid var(--asse-blue);
}

/* ══════════════════════════════════════════════
   COMPARACIÓN CON DRIVE
   ══════════════════════════════════════════════ */
.view-tabs {
    display: flex;
    gap: .4rem;
    margin-bottom: .75rem;
    border-bottom: 1px solid var(--border);
}

.view-tab {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .5rem .9rem;
    border: none;
    background: transparent;
    color: var(--text-sec);
    font-weight: 600;
    font-size: .85rem;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.view-tab:hover {
    color: var(--asse-blue);
}

.view-tab.active {
    color: var(--asse-blue);
    border-bottom-color: var(--asse-blue);
}

.view-tab-badge {
    background: var(--danger);
    color: #fff;
    font-size: .7rem;
    font-weight: 700;
    border-radius: 999px;
    padding: .1rem .45rem;
}

.match-icon {
    font-size: .78rem;
    margin-right: .3rem;
}

.match-ok { color: var(--success); }
.match-bad { color: var(--danger); }
.match-warn { color: #d97706; }
.match-neutral { color: var(--text-sec); }

.no-match-explain {
    margin-top: .3rem;
    font-size: .7rem;
    color: var(--text-sec);
    line-height: 1.4;
}

.comparison-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: .75rem;
    margin-bottom: 1.25rem;
}

.comparison-subtitle {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .95rem;
    font-weight: 700;
    color: var(--header-blue);
    margin: 1.5rem 0 .75rem;
}

.stat-box {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: .9rem 1rem;
    text-align: center;
}

.stat-box .stat-number {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text);
}

.stat-box .stat-label {
    font-size: .78rem;
    color: var(--text-sec);
    margin-top: .15rem;
}

.stat-box.stat-ok .stat-number { color: var(--success); }
.stat-box.stat-bad .stat-number { color: var(--danger); }
.stat-box.stat-warn .stat-number { color: #d97706; }
.stat-box.stat-neutral .stat-number { color: var(--text-sec); }

.stat-box.stat-clickable {
    cursor: pointer;
    transition: transform .12s ease, box-shadow .15s ease;
}

.stat-box.stat-clickable:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, .1);
    border-color: var(--asse-light-blue);
}

/* ══════════════════════════════════════════════
   FILTROS (mes / estado)
   ══════════════════════════════════════════════ */
.table-filters {
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
    margin-bottom: .85rem;
}

.filter-select {
    padding: .45rem .7rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: .82rem;
    color: var(--text);
    background: #fff;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    background: #eef1f5;
    border-radius: 999px;
    padding: .35rem .5rem .35rem .8rem;
    font-size: .8rem;
    color: var(--text);
}

.filter-chip button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, .08);
    color: var(--text-sec);
    cursor: pointer;
    font-size: .7rem;
}

.filter-chip button:hover {
    background: var(--danger);
    color: #fff;
}

/* ══════════════════════════════════════════════
   IMPRESIÓN: horizontal, sin cromo de la app
   ══════════════════════════════════════════════ */
@media print {
    .no-print,
    .hero-section,
    .toolbar {
        display: none !important;
    }

    body,
    .page-body {
        background: #fff;
        margin: 0;
    }

    .modern-card {
        box-shadow: none;
        border: none;
        padding: 0;
    }

    .table-scroll {
        border: none;
        overflow: visible;
    }

    .summary-table .fecha-col,
    .summary-table thead th {
        position: static !important;
    }

    .summary-table,
    .summary-table th,
    .summary-table td {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    @page {
        size: landscape;
        margin: 10mm;
    }
}

/* ══════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════ */
@media (max-width: 576px) {
    .modern-card {
        padding: 1.5rem;
    }

    .hero-title {
        font-size: 1.8rem;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar-actions {
        justify-content: stretch;
    }

    .toolbar-actions .btn {
        flex: 1;
        justify-content: center;
    }
}
