* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Arial, sans-serif;
    transition: background-color var(--transition-speed),
                color var(--transition-speed),
                border-color var(--transition-speed),
                box-shadow var(--transition-speed);
}

:root {
    --transition-speed: 0.3s;
    --bg-dark: #f0f2f5;
    --bg-darker: #ffffff;
    --text-light: #1a1b1e;
    --text-gray: #4b5563;
    --primary-blue: #3b82f6;
    --accent-dark: #2563eb;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --overlay-color: rgba(255, 255, 255, 0.35);
}

/* Degradado para el fondo de la página */
body {
    background: linear-gradient(135deg, #f5f7fa 0%, #e5e9f2 100%);
    min-height: 100vh;
}

/* Header styles */
header, .circles-container, .bottom-section {
    position: relative;
    z-index: 1;
}

header {
    background-color: var(--bg-darker);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 10;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-image {
    height: 40px;
    width: auto;
    object-fit: contain;
}

.logo {
    color: var(--text-light);
    font-weight: bold;
    font-size: 1.2rem;
}

.search-bar {
    display: flex;
    align-items: center;
    flex: 1;
    max-width: 400px;
    margin: 0 2rem;
}

.search-bar input {
    padding: 0.8rem;
    border: none;
    border-radius: 20px;
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-light);
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.search-bar input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.3);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logout-button {
    background-color: transparent;
    border: 1px solid var(--primary-blue);
    color: var(--primary-blue);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.logout-button:hover {
    background-color: var(--primary-blue);
    color: white;
}

#userName {
    font-weight: 500;
    color: var(--text-light);
}

/* Main container styles */
.admin-container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem 70px 1rem; /* Padding bottom for nav bar */
}

/* Section styles */
.admin-section {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.05);
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.8);
    padding: 2rem;
    margin-bottom: 2rem;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    opacity: 1; /* Cambiado de 0 a 1 */
    transform: translateY(0); /* Cambiado de 20px a 0 */
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.admin-section:hover {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
    transform: translateY(-3px);
}

.section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-light);
    font-size: 1.3rem;
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary-blue);
}

.section-title i {
    color: var(--primary-blue);
}

/* Menu styles */
.menu-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.menu-item {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    margin-bottom: 10px;
}

.menu-item:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.menu-header {
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    background: white;
    color: var(--text-light);
    font-weight: 500;
    transition: all 0.3s ease;
    border-radius: 8px;
    margin-bottom: 5px;
    border-left: 3px solid transparent;
}

.menu-header:hover, 
.menu-header.active {
    background: var(--primary-blue);
    color: white;
    border-left-color: var(--primary-blue);
    border-left-width: 5px;
    padding-left: calc(1.5rem - 2px);
}

.menu-header.active {
    background: var(--primary-blue);
    color: white;
    border-radius: 8px 8px 0 0;
}

.menu-header i:first-child, 
.submenu a i, 
.card-icon i,
.tool-header i {
    transition: transform 0.3s ease;
}

.menu-header:hover i:first-child,
.submenu a:hover i,
.quick-card:hover .card-icon i {
    transform: scale(1.2);
}

.menu-header i:last-child {
    margin-left: auto;
    font-size: 0.8rem;
    transition: transform 0.3s ease;
}

.menu-header.active i:last-child {
    transform: rotate(180deg);
}

.submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: var(--bg-dark);
    border-radius: 0 0 8px 8px;
}

.submenu a {
    display: flex;
    align-items: center;
    padding: 0.8rem 1.5rem 0.8rem 3.5rem;
    color: var(--text-light);
    text-decoration: none;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
}

.submenu a i {
    margin-right: 10px;
    width: 20px;
    text-align: center;
}

.submenu a:hover {
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary-blue);
    border-left: 3px solid var(--primary-blue);
}

/* Panel Rápido styles */
.quick-access-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-top: 25px;
}

.quick-card {
    background: white;
    border-radius: 12px;
    padding: 20px 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--text-light);
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.05);
    position: relative;
    overflow: hidden;
    opacity: 0;
    transform: translateY(15px);
}

.quick-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 5px;
    background: var(--primary-blue);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.quick-card:hover {
    transform: translateY(-7px);
    box-shadow: 0 12px 20px rgba(59, 130, 246, 0.15);
}

.quick-card:hover::before {
    opacity: 1;
}

.card-icon {
    width: 65px;
    height: 65px;
    background: rgba(59, 130, 246, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
    color: var(--primary-blue);
    font-size: 1.7rem;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.card-icon::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.8) 0%, rgba(255,255,255,0) 70%);
    opacity: 0;
    transform: scale(0.5);
    transition: transform 0.5s ease, opacity 0.5s ease;
}

.quick-card:hover .card-icon::after {
    opacity: 0.7;
    transform: scale(1);
}

.quick-card:hover .card-icon {
    background: var(--primary-blue);
    color: white;
    box-shadow: 0 5px 15px rgba(59, 130, 246, 0.3);
}

.card-title {
    font-weight: 600;
    font-size: 1.05rem;
    margin-top: 5px;
    text-align: center;
    transition: all 0.3s ease;
}

.quick-card:hover .card-title {
    color: var(--primary-blue);
}

/* Herramientas Especiales styles */
.tools-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 25px;
    margin-top: 25px;
}

.tool-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(15px);
}

.tool-card:hover {
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
    transform: translateY(-5px);
}

.tool-header {
    background: linear-gradient(135deg, var(--primary-blue), var(--accent-dark));
    color: white;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    font-size: 1.1rem;
    position: relative;
    overflow: hidden;
}

.tool-card:hover .tool-header {
    background: linear-gradient(135deg, var(--accent-dark), var(--primary-blue));
}

.tool-header::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100px;
    height: 100%;
    background: linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.1) 100%);
    transform: skewX(-25deg) translateX(100%);
    transition: transform 0.5s ease;
}

.tool-card:hover .tool-header::after {
    transform: skewX(-25deg) translateX(70%);
}

.tool-header i {
    font-size: 1.4rem;
    background: rgba(255, 255, 255, 0.2);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.tool-content {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.tool-content p {
    color: var(--text-gray);
    margin-bottom: 20px;
    line-height: 1.5;
    font-size: 0.95rem;
    flex: 1;
}

.sync-button, .tool-button {
    background: var(--primary-blue);
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.2s ease;
    font-weight: 500;
    box-shadow: 0 4px 6px rgba(59, 130, 246, 0.2);
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
    max-width: fit-content;
}

.sync-button:hover, .tool-button:hover {
    background: var(--accent-dark);
    box-shadow: 0 6px 10px rgba(59, 130, 246, 0.3);
    transform: translateY(-2px);
}

.tool-buttons {
    display: flex;
    gap: 12px;
    margin-top: auto;
    flex-wrap: wrap;
}

/* Efecto de pulsación para los botones */
.sync-button:active, .tool-button:active {
    transform: scale(0.97);
}

/* Navigation bar styles */
.navigation-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 50px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 40px;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 100;
    padding: 5px 0;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.nav-item {
    color: var(--text-gray);
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.9em;
    transition: color 0.3s ease;
}

.nav-item:hover,
.nav-item.active {
    color: var(--primary-blue);
}

.nav-item i {
    font-size: 1.5em;
}

/* Responsive styles */
@media (max-width: 992px) {
    .quick-access-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 20px;
    }
}

@media (max-width: 768px) {
    header {
        padding: 0.5rem 1rem;
        height: auto;
        flex-direction: column;
        gap: 0.5rem;
    }

    .logo-container {
        width: 100%;
        justify-content: center;
    }

    .logo-image {
        height: 30px;
    }

    .logo {
        font-size: 1rem;
    }

    .search-bar {
        width: 100%;
        margin: 0.5rem 0;
    }

    .search-bar input {
        width: 100%;
        padding: 0.6rem;
    }

    .admin-section {
        padding: 1rem;
    }

    .section-title {
        font-size: 1.2rem;
    }

    .menu-header, .menu-link {
        padding: 0.8rem 1rem;
    }

    .submenu a {
        padding: 0.8rem 1rem 0.8rem 2.5rem;
    }

    .quick-access-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 15px;
    }
    
    .card-icon {
        width: 55px;
        height: 55px;
        font-size: 1.5rem;
    }
    
    .card-title {
        font-size: 0.95rem;
    }
    
    .tool-header {
        padding: 15px;
        font-size: 1rem;
    }
    
    .tool-header i {
        width: 35px;
        height: 35px;
        font-size: 1.2rem;
    }
    
    .tool-content {
        padding: 15px;
    }

    .tools-container {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .admin-container {
        margin: 1rem auto;
    }

    .quick-access-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .card-icon {
        width: 50px;
        height: 50px;
        font-size: 1.3rem;
        margin-bottom: 10px;
    }
    
    .card-title {
        font-size: 0.85rem;
    }
    
    .tool-card {
        max-width: 100%;
    }
    
    .sync-button, .tool-button {
        padding: 8px 15px;
        font-size: 0.8rem;
        width: 100%;
    }

    .menu-item.small {
        width: 100%;
    }
}

/* Fix para el scroll en iOS */
@supports (-webkit-touch-callout: none) {
    body {
        min-height: -webkit-fill-available;
    }
    
    .navigation-bar {
        padding-bottom: max(5px, env(safe-area-inset-bottom));
    }
}

/* Ajustes generales para dispositivos móviles */
@media screen and (max-width: 768px) {
    * {
        -webkit-tap-highlight-color: transparent;
    }
    
    body {
        overscroll-behavior-y: none; /* Previene el bounce en algunos navegadores */
    }

    /* Asegura que el contenido sea scrolleable */
    main {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Ajustes para pantallas muy pequeñas */
@media screen and (max-width: 360px) {
    .quick-access-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .card-icon {
        width: 45px;
        height: 45px;
        font-size: 1.2rem;
    }

    .card-title {
        font-size: 0.8rem;
    }
}

/* Orientación landscape en móviles */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .admin-container {
        margin: 1rem auto;
    }

    .admin-section {
        padding: 1rem;
        margin-bottom: 1rem;
    }

    .quick-access-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .tools-container {
        grid-template-columns: repeat(3, 1fr);
    }
}
/* ════════════════════════════════════════════════════════════════
   VISOR DE FACTURAS AUTOMATIZADAS — estilos específicos
   (hereda variables y base de administracion.css)
   ════════════════════════════════════════════════════════════════ */

/* ── Barra de herramientas / filtros ───────────────────────────── */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 14px;
    margin-bottom: 20px;
}

.toolbar .field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.toolbar label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-gray);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.toolbar input,
.toolbar select {
    padding: 0.6rem 0.8rem;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    background: white;
    color: var(--text-light);
    font-size: 0.9rem;
    min-width: 150px;
    transition: all 0.2s ease;
}

.toolbar input:focus,
.toolbar select:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.toolbar .spacer { flex: 1; }

/* ── Tarjetas de KPIs ──────────────────────────────────────────── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 18px;
    margin-bottom: 22px;
}

.kpi-card {
    background: white;
    border-radius: 12px;
    padding: 18px 20px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.05);
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 5px; height: 100%;
    background: var(--primary-blue);
}

.kpi-card .kpi-label {
    font-size: 0.78rem;
    color: var(--text-gray);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 6px;
}

.kpi-card .kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-light);
}

.kpi-card.green::before  { background: #16a34a; }
.kpi-card.amber::before  { background: #f59e0b; }
.kpi-card.blue::before   { background: var(--primary-blue); }

/* ── Tabla de facturas ─────────────────────────────────────────── */
.fac-table-wrap {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

table.fac-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    font-size: 0.9rem;
}

table.fac-table thead th {
    background: linear-gradient(135deg, var(--primary-blue), var(--accent-dark));
    color: white;
    text-align: left;
    padding: 12px 14px;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    white-space: nowrap;
    position: sticky;
    top: 0;
}

table.fac-table thead th.num { text-align: right; }

table.fac-table tbody td {
    padding: 11px 14px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    color: var(--text-light);
    white-space: nowrap;
}

table.fac-table tbody td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

table.fac-table tbody tr.fac-row {
    cursor: pointer;
    transition: background 0.15s ease;
}

table.fac-table tbody tr.fac-row:hover {
    background: rgba(59, 130, 246, 0.06);
}

table.fac-table tbody tr.fac-row.open {
    background: rgba(59, 130, 246, 0.09);
}

.row-caret {
    display: inline-block;
    transition: transform 0.25s ease;
    color: var(--primary-blue);
    margin-right: 6px;
}

tr.fac-row.open .row-caret { transform: rotate(90deg); }

/* ── Estados ───────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge.pendiente { background: #fef3c7; color: #92400e; }
.badge.cobrada   { background: #dcfce7; color: #166534; }
.badge.otro      { background: #e5e7eb; color: #374151; }

/* ── Fila de detalle (líneas F_LFA) ────────────────────────────── */
tr.detail-row > td {
    padding: 0 !important;
    background: var(--bg-dark);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.detail-inner {
    padding: 16px 22px 20px;
    animation: slideDown 0.25s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.detail-inner h4 {
    font-size: 0.95rem;
    color: var(--text-light);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.detail-inner h4 i { color: var(--primary-blue); }

table.lines-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}

table.lines-table th {
    background: #eef2ff;
    color: var(--accent-dark);
    text-align: left;
    padding: 9px 12px;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

table.lines-table th.num { text-align: right; }

table.lines-table td {
    padding: 9px 12px;
    border-bottom: 1px solid rgba(0,0,0,0.04);
    font-size: 0.85rem;
}

table.lines-table td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

table.lines-table tr:last-child td { border-bottom: none; }

.detail-actions {
    display: flex;
    gap: 10px;
    margin-top: 14px;
    flex-wrap: wrap;
}

/* ── Estados de carga / vacío ──────────────────────────────────── */
.state-msg {
    text-align: center;
    padding: 50px 20px;
    color: var(--text-gray);
}

.state-msg i {
    font-size: 2.5rem;
    color: var(--primary-blue);
    margin-bottom: 12px;
    display: block;
}

.spinner {
    width: 38px; height: 38px;
    border: 4px solid rgba(59, 130, 246, 0.2);
    border-top-color: var(--primary-blue);
    border-radius: 50%;
    margin: 0 auto 14px;
    animation: spin 0.8s linear infinite;
}

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

/* ── Paginación ────────────────────────────────────────────────── */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 14px;
    margin-top: 20px;
}

.pagination button {
    background: white;
    border: 1px solid rgba(0,0,0,0.1);
    color: var(--text-light);
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.pagination button:hover:not(:disabled) {
    background: var(--primary-blue);
    color: white;
    border-color: var(--primary-blue);
}

.pagination button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.pagination .page-info {
    font-size: 0.9rem;
    color: var(--text-gray);
}

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .toolbar input,
    .toolbar select { min-width: 120px; width: 100%; }
    .toolbar .field { flex: 1 1 140px; }
    table.fac-table { font-size: 0.82rem; }
    table.fac-table thead th,
    table.fac-table tbody td { padding: 9px 10px; }
    /* Ocultar columnas menos críticas en móvil */
    .col-hide-mobile { display: none; }
}

/* ── Columna de observaciones en el listado ────────────────────── */
table.fac-table td.obs-cell {
    max-width: 240px;
    white-space: normal;
    word-break: break-word;
    color: var(--text-gray);
    font-size: 0.82rem;
    line-height: 1.3;
}

/* ── Ensanchar el contenedor en el visor de facturas ───────────── */
.admin-container {
    max-width: 1800px;
}

/* Segunda columna de observaciones algo más estrecha */
table.fac-table td.obs-cell {
    max-width: 200px;
}

/* ════════════════════════════════════════════════════════════════
   SELECCIÓN Y MODAL DE ENVÍO DE FACTURAS
   ════════════════════════════════════════════════════════════════ */
.fac-check, #checkAll {
    width: 17px;
    height: 17px;
    cursor: pointer;
    accent-color: var(--primary-blue);
}

/* Overlay */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 720px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.25s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    background: linear-gradient(135deg, var(--primary-blue), var(--accent-dark));
    color: white;
    border-radius: 16px 16px 0 0;
}

.modal-head h3 {
    font-size: 1.15rem;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.2s ease;
}

.modal-close:hover { background: rgba(255, 255, 255, 0.35); }

.modal-body {
    padding: 20px 22px;
    overflow-y: auto;
}

.modal-intro {
    font-size: 0.88rem;
    color: var(--text-gray);
    margin-bottom: 16px;
    line-height: 1.5;
}

.envio-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 12px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 10px;
    margin-bottom: 10px;
    transition: all 0.2s ease;
}

.envio-row.enviada {
    background: #f0fdf4;
    border-color: #86efac;
}

.envio-info { min-width: 180px; flex-shrink: 0; }
.envio-fac { font-weight: 700; color: var(--text-light); font-size: 0.92rem; }
.envio-cli { font-size: 0.8rem; color: var(--text-gray); }

.envio-email {
    flex: 1;
    padding: 9px 12px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.envio-email:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.envio-email.sin-email {
    border-color: #f59e0b;
    background: #fffbeb;
}

.envio-estado {
    min-width: 90px;
    font-size: 0.82rem;
    text-align: right;
    flex-shrink: 0;
}

.modal-foot {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 22px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.modal-status {
    font-size: 0.85rem;
    color: var(--text-gray);
}

@media (max-width: 600px) {
    .envio-row { flex-wrap: wrap; }
    .envio-info { min-width: 100%; }
    .envio-email { min-width: 100%; }
}

.modal-aviso {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 0.83rem;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ════════════════════════════════════════════════════════════════
   MODAL DE PROGRESO — Actualizar facturas
   ════════════════════════════════════════════════════════════════ */
.modal-progreso {
    max-width: 460px;
    text-align: center;
    overflow: hidden;
}

.prog-header {
    padding: 32px 28px 20px;
}

.prog-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-blue), var(--accent-dark));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.35);
    transition: all 0.3s ease;
}

.prog-icon.ok {
    background: linear-gradient(135deg, #16a34a, #15803d);
    box-shadow: 0 8px 20px rgba(22, 163, 74, 0.35);
    animation: pop 0.4s ease;
}

.prog-icon.error {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    box-shadow: 0 8px 20px rgba(220, 38, 38, 0.35);
    animation: pop 0.4s ease;
}

@keyframes pop {
    0% { transform: scale(0.6); }
    60% { transform: scale(1.12); }
    100% { transform: scale(1); }
}

.prog-header h3 {
    font-size: 1.25rem;
    color: var(--text-light);
    margin-bottom: 6px;
}

.prog-header p {
    font-size: 0.9rem;
    color: var(--text-gray);
    line-height: 1.45;
}

/* Barra de progreso */
.prog-bar-wrap {
    height: 6px;
    background: #e5e7eb;
    margin: 0 28px;
    border-radius: 10px;
    overflow: hidden;
}

.prog-bar {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--primary-blue), var(--accent-dark));
    border-radius: 10px;
    transition: width 0.5s ease;
    position: relative;
}

.prog-bar::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg,
        rgba(255,255,255,0) 0%,
        rgba(255,255,255,0.4) 50%,
        rgba(255,255,255,0) 100%);
    animation: shimmer 1.3s infinite;
}

.prog-bar.error {
    background: linear-gradient(90deg, #dc2626, #b91c1c);
}
.prog-bar.error::after { animation: none; }

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Pasos */
.prog-steps {
    padding: 24px 28px 8px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    text-align: left;
}

.prog-step {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    border-radius: 10px;
    background: #f8fafc;
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.prog-step.activo {
    background: #eff6ff;
    border-color: #bfdbfe;
}

.prog-step.ok {
    background: #f0fdf4;
    border-color: #bbf7d0;
}

.prog-step.error {
    background: #fef2f2;
    border-color: #fecaca;
}

.prog-step-icon {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 1.1rem;
    background: #e5e7eb;
    color: #9ca3af;
    transition: all 0.3s ease;
}

.prog-step.activo .prog-step-icon {
    background: var(--primary-blue);
    color: white;
}

.prog-step.ok .prog-step-icon {
    background: #16a34a;
    color: white;
}

.prog-step.error .prog-step-icon {
    background: #dc2626;
    color: white;
}

.prog-step-title {
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--text-light);
}

.prog-step-detail {
    font-size: 0.8rem;
    color: var(--text-gray);
    margin-top: 2px;
}

.prog-foot {
    padding: 16px 28px 26px;
    display: flex;
    justify-content: center;
}

/* ════════════════════════════════════════════════════════════════
   EDICIÓN DE LÍNEAS DE ALBARÁN
   ════════════════════════════════════════════════════════════════ */
.alb-cabecera-edit {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
    padding: 14px 16px;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    border-radius: 10px;
    margin-bottom: 16px;
}

.cab-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cab-field label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-gray);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.cab-field input {
    padding: 8px 10px;
    border: 1px solid rgba(0,0,0,0.15);
    border-radius: 8px;
    font-size: 0.9rem;
    min-width: 180px;
}

.cab-field input:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

.lal-table-wrap { overflow-x: auto; }

table.lal-edit input,
table.lal-edit select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid rgba(0,0,0,0.12);
    border-radius: 6px;
    font-size: 0.85rem;
    background: white;
    transition: all 0.15s ease;
}

table.lal-edit input.num { text-align: right; font-variant-numeric: tabular-nums; }

table.lal-edit input:focus,
table.lal-edit select:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 2px rgba(59,130,246,0.15);
}

table.lal-edit td { vertical-align: middle; }

.lal-iva { cursor: pointer; }

/* Botón guardar de línea */
.lal-save-btn {
    background: #e5e7eb;
    border: none;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-gray);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lal-save-btn:hover { background: var(--primary-blue); color: white; }

.lal-save-btn.sucia {
    background: #f59e0b;
    color: white;
    animation: pulse 1.4s infinite;
}

@keyframes pulse {
    0%,100% { box-shadow: 0 0 0 0 rgba(245,158,11,0.5); }
    50% { box-shadow: 0 0 0 5px rgba(245,158,11,0); }
}

.lal-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 14px;
    flex-wrap: wrap;
    gap: 12px;
}

.lal-total {
    font-size: 0.95rem;
    color: var(--text-light);
}

.lal-total strong { color: var(--accent-dark); font-size: 1.05rem; }

/* Columna "Con IVA" destacada */
table.lal-edit td.lal-coniva,
table.lal-edit th.lal-coniva-col {
    background: #f0fdf4;
    font-weight: 600;
    color: #15803d;
}
