/* =========================================================
   VARIABLES
   ========================================================= */

:root {

    --primary: #2563eb;
    --primary-hover: #1d4ed8;

    --success: #16a34a;
    --danger: #dc2626;

    --background: #f3f4f6;
    --surface: #ffffff;

    --text: #1f2937;
    --muted: #6b7280;

    --border: #e5e7eb;

    --shadow:
        0 4px 12px rgba(0, 0, 0, 0.06);

}


/* =========================================================
   RESET
   ========================================================= */

* {

    box-sizing: border-box;

    margin: 0;

    padding: 0;

}


body {

    font-family:
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    background: var(--background);

    color: var(--text);

    min-height: 100vh;

}


button,
input,
select {

    font-family: inherit;

}


button {

    cursor: pointer;

}


/* =========================================================
   APP
   ========================================================= */

.app {

    width: 100%;

    max-width: 1400px;

    margin: 0 auto;

    padding: 2rem;

}


/* =========================================================
   HEADER
   ========================================================= */

.header {

    background: var(--surface);

    border-radius: 14px;

    padding: 1.5rem 2rem;

    display: flex;

    align-items: center;

    justify-content: space-between;

    gap: 1rem;

    box-shadow: var(--shadow);

    margin-bottom: 1.5rem;

}


.header h1 {

    font-size: 1.8rem;

}


.header p {

    color: var(--muted);

    margin-top: 0.25rem;

}


.header-actions {

    display: flex;

    gap: 0.75rem;

    flex-wrap: wrap;

}


/* =========================================================
   BUTTONS
   ========================================================= */

.btn {

    border: none;

    border-radius: 8px;

    padding: 0.7rem 1rem;

    font-size: 0.9rem;

    font-weight: 600;

    transition:
        background-color 0.2s,
        transform 0.1s;

}


.btn:active {

    transform: scale(0.97);

}


.btn-primary {

    background: var(--primary);

    color: white;

}


.btn-primary:hover {

    background: var(--primary-hover);

}


.btn-excel {

    background: #dcfce7;

    color: #166534;

}


.btn-excel:hover {

    background: #bbf7d0;

}


.btn-pdf {

    background: #fee2e2;

    color: #991b1b;

}


.btn-pdf:hover {

    background: #fecaca;

}


.btn-secondary {

    background: #e5e7eb;

    color: #374151;

}


.btn-secondary:hover {

    background: #d1d5db;

}


/* =========================================================
   RESUMEN
   ========================================================= */

.resumen {

    display: grid;

    grid-template-columns:
        repeat(4, minmax(0, 1fr));

    gap: 1rem;

    margin-bottom: 1.5rem;

}


.resumen-card {

    background: var(--surface);

    border-radius: 12px;

    padding: 1.25rem 1.5rem;

    box-shadow: var(--shadow);

    display: flex;

    flex-direction: column;

    gap: 0.35rem;

}


.resumen-card-destacada {

    background: var(--primary);

}


.resumen-card-destacada .resumen-label {

    color: rgba(255, 255, 255, 0.8);

}


.resumen-card-destacada strong {

    color: white;

}


.resumen-label {

    color: var(--muted);

    font-size: 0.85rem;

}


.resumen-card strong {

    font-size: 1.6rem;

}


/* =========================================================
   PANEL
   ========================================================= */

.panel {

    background: var(--surface);

    border-radius: 14px;

    box-shadow: var(--shadow);

    margin-bottom: 1.5rem;

    overflow: hidden;

}


.panel-header {

    padding: 1.5rem;

    border-bottom: 1px solid var(--border);

    display: flex;

    justify-content: space-between;

    align-items: center;

    gap: 1rem;

}


.panel-header h2 {

    font-size: 1.2rem;

}


.panel-header p {

    color: var(--muted);

    font-size: 0.85rem;

    margin-top: 0.25rem;

}


/* =========================================================
   FILTROS
   ========================================================= */

.filtros-container {

    margin: 1.25rem;

    padding: 1.25rem;

    background: #f8fafc;

    border: 1px solid var(--border);

    border-radius: 12px;

}


.filtros-header {

    display: flex;

    justify-content: space-between;

    align-items: center;

    gap: 1rem;

    margin-bottom: 1.25rem;

}


.filtros-header h3 {

    margin-bottom: 0.25rem;

    font-size: 1rem;

}


.filtros-header p {

    color: var(--muted);

    font-size: 0.8rem;

}


.filtros-grid {

    display: grid;

    grid-template-columns:
        repeat(4, minmax(0, 1fr));

    gap: 1rem;

}


.filtro-group {

    display: flex;

    flex-direction: column;

}


.filtro-busqueda {

    grid-column: span 2;

}


.filtro-group label {

    font-size: 0.8rem;

    font-weight: 600;

    margin-bottom: 0.45rem;

    color: #374151;

}


.filtro-group input,
.filtro-group select {

    width: 100%;

    height: 42px;

    padding: 0.65rem 0.75rem;

    border: 1px solid var(--border);

    border-radius: 8px;

    background: white;

    color: var(--text);

    font-size: 0.9rem;

    outline: none;

}


.filtro-group input:focus,
.filtro-group select:focus {

    border-color: var(--primary);

    box-shadow:
        0 0 0 3px rgba(37, 99, 235, 0.1);

}


.btn-limpiar {

    width: auto;

    margin: 0;

    background: white;

    color: #374151;

    border: 1px solid var(--border);

}


.btn-limpiar:hover {

    background: #f3f4f6;

}


.filtros-resultado {

    margin-top: 1rem;

    padding-top: 0.9rem;

    border-top: 1px solid var(--border);

    color: var(--muted);

    font-size: 0.8rem;

}


/* =========================================================
   TABLE
   ========================================================= */

.tabla-container {

    width: 100%;

    overflow-x: auto;

}


table {

    width: 100%;

    border-collapse: collapse;

    min-width: 900px;

}


thead {

    background: #f8fafc;

}


th {

    padding: 0.9rem 1rem;

    text-align: left;

    font-size: 0.75rem;

    text-transform: uppercase;

    letter-spacing: 0.03em;

    color: var(--muted);

    border-bottom: 1px solid var(--border);

    white-space: nowrap;

}


td {

    padding: 0.9rem 1rem;

    border-bottom: 1px solid var(--border);

    font-size: 0.9rem;

    white-space: nowrap;

}


tbody tr:hover {

    background: #f8fafc;

}


td.numero {

    font-weight: 600;

}


th.importe,
td.importe {
    text-align: right;
}

th.centro,
td.centro {
    text-align: center;
}


.tabla-vacia {

    text-align: center;

    padding: 3rem;

    color: var(--muted);

}


/* =========================================================
   TICKET
   ========================================================= */

.ticket-si {

    color: var(--success);

    font-weight: 600;

}


.ticket-no {

    color: var(--muted);

}


.btn-ticket {

    border: none;

    background: #eff6ff;

    color: var(--primary);

    padding: 0.45rem 0.7rem;

    border-radius: 6px;

    font-size: 0.8rem;

    font-weight: 600;

}


.btn-ticket:hover {

    background: #dbeafe;

}


/* =========================================================
   FORMULARIO
   ========================================================= */

.formulario-panel {

    max-width: 1000px;

    margin-left: auto;

    margin-right: auto;

}


.form-grid {

    padding: 1.5rem;

    display: grid;

    grid-template-columns:
        repeat(4, minmax(0, 1fr));

    gap: 1rem;

}


.form-grid.importes {

    padding-top: 0;

}


.form-group {

    display: flex;

    flex-direction: column;

}


.form-group-large {

    grid-column: span 2;

}


.form-group label {

    font-size: 0.85rem;

    font-weight: 600;

    margin-bottom: 0.45rem;

}


.form-group input {

    width: 100%;

    padding: 0.75rem;

    border: 1px solid var(--border);

    border-radius: 8px;

    outline: none;

    font-size: 0.95rem;

    background: white;

}


.form-group input:focus {

    border-color: var(--primary);

    box-shadow:
        0 0 0 3px rgba(37, 99, 235, 0.1);

}


.form-group small {

    color: var(--muted);

    font-size: 0.75rem;

    margin-top: 0.4rem;

}


.opcional {

    color: var(--muted);

    font-weight: normal;

}


.archivo-group {

    padding: 0 1.5rem 1.5rem;

}


.archivo-group input[type="file"] {

    cursor: pointer;

}


/* =========================================================
   FORM ACTIONS
   ========================================================= */

.form-actions {

    padding: 0 1.5rem 1.5rem;

    display: flex;

    justify-content: flex-end;

    gap: 0.75rem;

}


.form-actions .btn {

    min-width: 130px;

}


/* =========================================================
   CLOSE
   ========================================================= */

.btn-cerrar {

    width: 35px;

    height: 35px;

    border: none;

    border-radius: 50%;

    background: #f3f4f6;

    color: #4b5563;

    font-size: 1.4rem;

    line-height: 1;

}


.btn-cerrar:hover {

    background: #e5e7eb;

}


/* =========================================================
   MENSAJES
   ========================================================= */

.mensaje {

    margin: 0 1.5rem 1.5rem;

    padding: 0.9rem;

    border-radius: 8px;

    text-align: center;

    font-size: 0.9rem;

    font-weight: 500;

}


.exito {

    background: #dcfce7;

    color: #166534;

    border: 1px solid #bbf7d0;

}


.error {

    background: #fee2e2;

    color: #991b1b;

    border: 1px solid #fecaca;

}


.oculto {

    display: none;

}


/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 1000px) {

    .filtros-grid {

        grid-template-columns:
            repeat(2, minmax(0, 1fr));

    }

}


@media (max-width: 1000px) {

    .resumen {

        grid-template-columns:
            repeat(2, minmax(0, 1fr));

    }

}


@media (max-width: 900px) {

    .app {

        padding: 1rem;

    }


    .header {

        flex-direction: column;

        align-items: flex-start;

    }


    .header-actions {

        width: 100%;

    }


    .header-actions .btn {

        flex: 1;

    }


    .form-grid {

        grid-template-columns:
            repeat(2, minmax(0, 1fr));

    }


    .form-group-large {

        grid-column: span 2;

    }

}


@media (max-width: 700px) {

    .filtros-grid {

        grid-template-columns: 1fr;

    }


    .filtro-busqueda {

        grid-column: span 1;

    }


    .filtros-header {

        flex-direction: column;

        align-items: stretch;

    }


    .btn-limpiar {

        width: 100%;

    }

}


@media (max-width: 600px) {

    .resumen {

        grid-template-columns: 1fr;

    }


    .panel-header {

        flex-direction: column;

        align-items: flex-start;

    }


    .form-grid {

        grid-template-columns: 1fr;

        padding: 1rem;

    }


    .form-group-large {

        grid-column: span 1;

    }


    .archivo-group {

        padding: 0 1rem 1rem;

    }


    .form-actions {

        padding: 0 1rem 1rem;

        flex-direction: column-reverse;

    }


    .form-actions .btn {

        width: 100%;

    }

}

/* =========================================================
   BOTÓN ELIMINAR
   ========================================================= */
.btn-eliminar {
    border: none;
    background: #fee2e2;
    color: #991b1b;
    padding: 0.45rem 0.6rem;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}

.btn-eliminar:hover {
    background: #fecaca;
}

/* =========================================================
   LOGIN OVERLAY
   ========================================================= */
.login-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}
.login-box {
    background: white;
    padding: 2.5rem;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    text-align: center;
    width: 90%;
    max-width: 400px;
}
.login-box h2 { color: #1f2937; margin-bottom: 0.5rem; }
.login-box p { color: #6b7280; margin-bottom: 1.5rem; font-size: 0.9rem; }
.login-box input {
    width: 100%; padding: 0.75rem; border: 1px solid #d1d5db;
    border-radius: 6px; margin-bottom: 1rem; text-align: center; font-size: 1.1rem;
    box-sizing: border-box;
}
.error-text { color: #dc2626; margin-top: 1rem; font-size: 0.9rem; font-weight: bold; }