/* ============================================
   GESTOR DE FACTURACIÓN ESCOLAR - Estilos
   ============================================ */

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #dbeafe;
    --success: #16a34a;
    --success-hover: #15803d;
    --warning: #d97706;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --purple: #7c3aed;

    --sidebar-bg: #1e293b;
    --sidebar-hover: #334155;
    --sidebar-active: #2563eb;
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #ffffff;
    --sidebar-width: 260px;

    --bg: #f1f5f9;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --text: #334155;
    --text-light: #64748b;
    --text-dark: #0f172a;

    --radius: 8px;
    --radius-sm: 4px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);

    --transition: all 0.2s ease;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

/* ======= LOGIN ======= */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
}

.login-card {
    background: var(--card-bg);
    padding: 2.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo i {
    font-size: 3rem;
    color: var(--primary);
}

.login-logo h1 {
    font-size: 1.5rem;
    color: var(--text-dark);
    margin-top: 0.5rem;
}

.login-logo p {
    color: var(--text-light);
    font-size: 0.875rem;
}

.error-text {
    color: var(--danger);
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

/* ======= LAYOUT ======= */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ======= SIDEBAR ======= */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: var(--transition);
}

.sidebar-header {
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header i {
    font-size: 1.5rem;
    color: var(--primary);
}

.sidebar-header span {
    font-size: 1.125rem;
    font-weight: 700;
    color: #fff;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: var(--transition);
    font-size: 0.9375rem;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.nav-item.active {
    background: var(--sidebar-active);
    color: var(--sidebar-text-active);
}

.nav-item i {
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.1);
}

/* ======= MAIN CONTENT ======= */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
}

.topbar {
    background: var(--card-bg);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.btn-icon {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text);
    cursor: pointer;
    padding: 0.375rem;
    border-radius: var(--radius-sm);
}

.btn-icon:hover {
    background: var(--bg);
}

.user-info {
    font-size: 0.875rem;
    color: var(--text-light);
}

.content-area {
    padding: 1.5rem;
    flex: 1;
}

/* ======= SECTIONS ======= */
.content-section {
    display: none;
}

.content-section.active {
    display: block;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.section-header h2 {
    font-size: 1.5rem;
    color: var(--text-dark);
}

.header-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ======= STATS ======= */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: #fff;
}

.bg-blue { background: var(--primary); }
.bg-green { background: var(--success); }
.bg-orange { background: var(--warning); }
.bg-purple { background: var(--purple); }

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-dark);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-light);
}

/* ======= CARDS ======= */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.card-header h3 {
    font-size: 1.125rem;
    color: var(--text-dark);
}

.card-body {
    padding: 1.25rem;
}

/* ======= TABLES ======= */
.table-responsive {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    background: var(--bg);
    font-weight: 600;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-light);
    white-space: nowrap;
}

.table tbody tr:hover {
    background: #f8fafc;
}

.table-sm th,
.table-sm td {
    padding: 0.5rem;
}

.table-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

/* ======= BUTTONS ======= */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-success {
    background: var(--success);
    color: #fff;
}
.btn-success:hover { background: var(--success-hover); }

.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover { background: var(--danger-hover); }

.btn-warning {
    background: var(--warning);
    color: #fff;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-outline:hover { background: var(--bg); }

.btn-sm {
    padding: 0.25rem 0.625rem;
    font-size: 0.8125rem;
}

.btn-block {
    width: 100%;
    justify-content: center;
}

.btn-icon-sm {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    color: var(--text-light);
    font-size: 0.9375rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.btn-icon-sm:hover { color: var(--text-dark); background: var(--bg); }
.btn-icon-sm.text-danger:hover { color: var(--danger); }
.btn-icon-sm.text-primary:hover { color: var(--primary); }

/* ======= FORMS ======= */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.375rem;
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-dark);
}

.form-control {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    color: var(--text);
    background: #fff;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-text {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 0.25rem;
}

.radio-group {
    display: flex;
    gap: 1.5rem;
    padding: 0.5rem 0;
}

.radio-label,
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.875rem;
    cursor: pointer;
}

.checkbox-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.5rem;
}

.checkbox-list label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    cursor: pointer;
}

.checkbox-list label:hover {
    background: var(--bg);
}

.filters {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.filters .form-control {
    width: auto;
    min-width: 180px;
}

.global-scope-bar {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.94);
    border-bottom: 1px solid var(--border);
}

.global-scope-bar .form-control {
    min-width: 160px;
    width: auto;
}

/* ======= MODALS ======= */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    overflow-y: auto;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 500px;
    max-height: calc(100vh - 2rem);
    max-height: calc(100dvh - 2rem);
    display: flex;
    flex-direction: column;
    min-height: 0;
    margin: auto 0;
    overflow: hidden;
}

.modal > form {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
}

.modal-lg { max-width: 700px; }
.modal-sm { max-width: 400px; }
.modal-registrar-cobro { max-width: 620px; }

.modal-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.modal-header h3 {
    font-size: 1.125rem;
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
    line-height: 1;
}

.btn-close:hover { color: var(--text-dark); }

.modal-body {
    padding: 1.25rem;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
}

.modal-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* ======= ALERTS ======= */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.alert-info {
    background: var(--primary-light);
    color: var(--primary);
    border: 1px solid #93c5fd;
}

.aviso-cobro-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border: 1px solid #93c5fd;
    border-radius: var(--radius-sm);
    background: var(--primary-light);
}

.aviso-cobro-summary-item {
    min-width: 0;
}

.aviso-cobro-summary-item span {
    display: block;
    margin-bottom: 0.25rem;
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 600;
}

.aviso-cobro-summary-item strong {
    display: block;
    color: var(--primary);
    font-size: 0.875rem;
    overflow-wrap: anywhere;
}

.aviso-cobro-summary-total strong {
    color: var(--primary-dark);
}

@media (max-width: 640px) {
    .aviso-cobro-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.report-chart {
    display: grid;
    gap: 0.75rem;
    margin: 1rem 0;
}

.report-chart-row {
    display: grid;
    grid-template-columns: minmax(120px, 180px) 1fr auto;
    gap: 0.75rem;
    align-items: center;
}

.report-bar {
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--bg);
}

.report-bar div {
    height: 100%;
    border-radius: inherit;
    background: var(--primary);
}

/* ======= TOAST ======= */
#toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: var(--card-bg);
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    animation: slideIn 0.3s ease;
    border-left: 4px solid var(--primary);
    min-width: 280px;
}

.toast.toast-success { border-left-color: var(--success); }
.toast.toast-error { border-left-color: var(--danger); }
.toast.toast-warning { border-left-color: var(--warning); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ======= LOADING ======= */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.8);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ======= BADGES ======= */
.badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-borrador { background: #fef3c7; color: #92400e; }
.badge-generada { background: var(--primary-light); color: var(--primary); }
.badge-enviada { background: #d1fae5; color: #065f46; }
.badge-pagada { background: #dcfce7; color: #166534; }

.badge-particular { background: #e0e7ff; color: #3730a3; }
.badge-convenio { background: #fef3c7; color: #92400e; }
.badge-obra_social { background: #d1fae5; color: #065f46; }

/* ======= FACTURA PREVIEW ======= */
.factura-preview {
    background: #fff;
    border: 1px solid var(--border);
    padding: 2rem;
    font-size: 0.875rem;
}

.factura-preview .factura-header {
    display: flex;
    justify-content: space-between;
    border-bottom: 2px solid var(--text-dark);
    padding-bottom: 1rem;
    margin-bottom: 1rem;
}

.factura-preview .factura-title {
    font-size: 1.5rem;
    font-weight: 700;
}

.factura-preview .factura-datos {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.factura-preview table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

.factura-preview table th,
.factura-preview table td {
    padding: 0.5rem;
    border: 1px solid var(--border);
}

.factura-preview table th {
    background: var(--bg);
}

.factura-preview .factura-total {
    text-align: right;
    font-size: 1.25rem;
    font-weight: 700;
}

.aviso-preview-periodos {
    margin-top: 1.25rem;
}

.aviso-preview-periodos h4 {
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.aviso-preview-periodos table {
    margin-bottom: 0;
}

.factura-info-header {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--bg);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
}

.factura-totales {
    border-top: 2px solid var(--border);
    padding-top: 0.75rem;
}

.total-row {
    display: flex;
    justify-content: space-between;
    padding: 0.25rem 0;
    font-size: 0.9375rem;
}

.total-final {
    font-weight: 700;
    font-size: 1.125rem;
    border-top: 1px solid var(--border);
    padding-top: 0.5rem;
    margin-top: 0.25rem;
}

/* ======= UTILITIES ======= */
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mb-2 { margin-bottom: 0.5rem; }
.text-muted { color: var(--text-light); }
.text-sm { font-size: 0.875rem; }
.text-danger { color: var(--danger) !important; }
.text-success { color: var(--success) !important; }
.text-primary { color: var(--primary) !important; }

/* ======= STAT CARD COLORS (new) ======= */
.bg-teal { background: #0d9488; }
.bg-red { background: var(--danger); }

/* ======= TOPBAR CENTER (escuela selector) ======= */
.topbar-center {
    flex: 1;
    display: flex;
    justify-content: center;
    padding: 0 1rem;
}

.topbar-center .form-control {
    width: auto;
    min-width: 220px;
    max-width: 360px;
    font-size: 0.875rem;
}

/* ======= BADGE ROLE ======= */
.badge-role {
    display: inline-block;
    padding: 0.2rem 0.625rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--primary-light);
    color: var(--primary);
    margin-left: 0.5rem;
}

/* ======= DASHBOARD ESCUELA LABEL ======= */
.dashboard-escuela {
    font-size: 0.875rem;
    color: var(--text-light);
    margin-bottom: 1rem;
}

/* ======= FORM CONTROL SM ======= */
.form-control-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.8125rem;
}

.input-with-action {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.5rem;
    align-items: center;
}

@media (max-width: 520px) {
    .input-with-action {
        grid-template-columns: 1fr;
    }
}

.alumno-matriz-cell {
    display: grid;
    gap: 0.2rem;
    min-width: 170px;
}

.alumno-matriz-select {
    min-width: 170px;
}

.alumno-descuento-label {
    display: inline-flex;
    align-items: center;
    margin-left: 0.2rem;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1;
}

.alumno-descuento-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    min-width: 2.6rem;
    width: auto;
    white-space: nowrap;
}

.alumno-descuento-btn .alumno-descuento-label {
    margin-left: 0;
}

#alumnos-seleccionados-count {
    font-weight: 700;
}

/* ======= MX-2 UTILITY ======= */
.mx-2 { margin-left: 0.5rem; margin-right: 0.5rem; }

/* ======= BTN-ACTION (permission-controlled) ======= */
.btn-action[hidden] {
    display: none !important;
}

/* ======= TAG / ETIQUETA BADGES ======= */
.tag-badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 500;
    background: #e0e7ff;
    color: #3730a3;
    margin-right: 0.25rem;
    margin-bottom: 0.125rem;
}

/* ======= COMEDOR GRID ======= */
.comedor-navigation {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.comedor-navigation span {
    font-weight: 600;
    min-width: 160px;
    text-align: center;
}

#comedor-tabla {
    font-size: 0.8125rem;
}

#comedor-tabla th,
#comedor-tabla td {
    padding: 0.375rem 0.25rem;
    text-align: center;
    min-width: 32px;
}

#comedor-tabla th:first-child,
#comedor-tabla td:first-child {
    text-align: left;
    min-width: 140px;
    position: sticky;
    left: 0;
    background: var(--card-bg);
    z-index: 1;
}

#comedor-tabla thead th:first-child {
    background: var(--bg);
}

#comedor-tabla input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--primary);
}

/* ======= REPORTES ======= */
.reporte-filters {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: flex-end;
    margin-bottom: 1rem;
}

.reporte-filters .form-group {
    margin-bottom: 0;
}

#reporte-resultado {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    min-height: 200px;
}

#reporte-resultado .table {
    margin-top: 1rem;
}

#reporte-resultado h3 {
    font-size: 1.125rem;
    color: var(--text-dark);
    margin-bottom: 0.5rem;
}

#reporte-resultado p {
    color: var(--text-light);
    font-size: 0.875rem;
}

/* ======= ANOTACIONES ======= */
#anotaciones-lista {
    max-height: 400px;
    overflow-y: auto;
}

.anotacion-item {
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
}

.anotacion-item .anotacion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
}

.anotacion-item .anotacion-tipo {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--primary);
}

.anotacion-item .anotacion-fecha {
    font-size: 0.75rem;
    color: var(--text-light);
}

.anotacion-item .anotacion-texto {
    font-size: 0.875rem;
    color: var(--text);
}

/* ======= PLANTILLAS ======= */
.variables-reference {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin-top: 1rem;
}

.variables-reference h4 {
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.variables-reference code {
    display: inline-block;
    background: #fff;
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
    font-size: 0.75rem;
    border: 1px solid var(--border);
    margin: 0.125rem;
    font-family: 'Consolas', 'Monaco', monospace;
}

/* ======= PLANTILLA TEXTAREA ======= */
#plantilla-form textarea {
    min-height: 150px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.8125rem;
}

/* ======= ALERT ACTIVA BADGE ======= */
.badge-activa { background: #dcfce7; color: #166534; }
.badge-inactiva { background: #fef2f2; color: #991b1b; }

/* ======= FACTURA VENCIMIENTO INFO ======= */
.vencimiento-info {
    background: var(--primary-light);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.5rem;
    font-size: 0.8125rem;
}

.vencimiento-info strong {
    display: block;
    font-size: 0.75rem;
    color: var(--text-light);
    margin-bottom: 0.125rem;
}

/* ======= GENERAR FACTURAS MODO TOGGLE ======= */
#gen-items-panel,
#gen-matriz-panel {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    margin-top: 0.5rem;
}

/* ======= SIDEBAR NAV OVERFLOW ======= */
.sidebar-nav {
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.2) transparent;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
}

/* ======= ESTADO BADGES (extended) ======= */
.badge-anulada { background: #fef2f2; color: #991b1b; }
.badge-vencida { background: #fff7ed; color: #9a3412; }
.badge-parcial { background: #fefce8; color: #854d0e; }

/* ======= INTEGRACIONES / TESORERIA ======= */
.integration-list {
    display: grid;
    gap: 0.75rem;
}

.integration-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
}

.integration-card-main,
.integration-card-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.integration-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    background: var(--primary-light);
}

.integration-tutorial {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #f8fafc;
    padding: 0.75rem 0.875rem;
}

.integration-tutorial summary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-dark);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 700;
    list-style: none;
}

.integration-tutorial summary::-webkit-details-marker {
    display: none;
}

.integration-tutorial summary::after {
    content: '\f078';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 0.7rem;
    color: var(--text-light);
    margin-left: auto;
    transition: transform 0.2s ease;
}

.integration-tutorial[open] summary::after {
    transform: rotate(180deg);
}

.integration-tutorial ol {
    margin: 0.75rem 0 0;
    padding-left: 1.25rem;
    color: var(--text);
    font-size: 0.84rem;
    line-height: 1.55;
}

.integration-tutorial li + li {
    margin-top: 0.35rem;
}

.integration-tutorial code {
    font-size: 0.78rem;
    white-space: normal;
}

.integration-tutorial p {
    margin: 0.75rem 0 0;
}

.integration-tutorial.compact {
    padding: 0.625rem 0.75rem;
}

.integration-tutorial.compact ol {
    font-size: 0.8rem;
}

/* ======= COMEDOR RESUMEN ======= */
.comedor-resumen {
    display: flex;
    gap: 1.5rem;
    margin-top: 0.75rem;
    font-size: 0.875rem;
    color: var(--text-light);
}

.comedor-resumen strong {
    color: var(--text-dark);
}

/* ======= PRINT STYLES ======= */

/* ======= SEARCH RESULTS DROPDOWN (padre/tutor selector) ======= */
.search-results-dropdown {
    position: relative;
    max-height: 180px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    background: #fff;
    display: none;
    z-index: 10;
}

.search-results-dropdown.active {
    display: block;
}

.search-results-dropdown .search-result-item {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.search-results-dropdown .search-result-item:hover {
    background: var(--bg);
}

.search-results-dropdown .search-result-item.disabled {
    opacity: 0.5;
    cursor: default;
    background: #f9fafb;
}

.search-results-dropdown .search-no-results {
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    color: var(--text-light);
}

.selected-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-top: 0.375rem;
}

.selected-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 999px;
    font-size: 0.8125rem;
    font-weight: 500;
}

.selected-tag .remove-tag {
    cursor: pointer;
    font-size: 0.875rem;
    line-height: 1;
    margin-left: 0.125rem;
    font-weight: 700;
}

.selected-tag .remove-tag:hover {
    color: var(--danger);
}

@media print {
    .sidebar, .topbar, .section-header, .filters, .modal-overlay, #toast-container {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
    }

    .content-area {
        padding: 0 !important;
    }

    .card {
        box-shadow: none !important;
        border: 1px solid #ddd;
    }

    #reporte-resultado {
        box-shadow: none !important;
    }
}

/* ======= RESPONSIVE ======= */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    }

    .filters {
        flex-direction: column;
    }

    .filters .form-control {
        width: 100%;
        min-width: auto;
    }

    .modal-overlay {
        align-items: flex-start;
        padding: 0.5rem;
    }

    .modal {
        max-height: calc(100vh - 1rem);
        max-height: calc(100dvh - 1rem);
    }

    .modal-footer {
        flex-wrap: wrap;
    }

    .factura-info-header {
        grid-template-columns: 1fr;
    }

    .header-actions {
        width: 100%;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .topbar-center {
        display: none;
    }

    .topbar-center .form-control {
        min-width: auto;
        width: 100%;
    }

    .vencimiento-info {
        grid-template-columns: 1fr;
    }

    .comedor-navigation {
        flex-wrap: wrap;
    }

    .reporte-filters {
        flex-direction: column;
    }
}

/* ==================================================
   MODERN THEME OVERRIDES
   ================================================== */

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: rgba(37, 99, 235, 0.14);
    --success: #0f9d58;
    --success-hover: #0c7d46;
    --warning: #d97706;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --purple: #7c3aed;
    --teal: #0f766e;
    --bg: #edf3fb;
    --card-bg: rgba(255, 255, 255, 0.88);
    --border: rgba(148, 163, 184, 0.24);
    --text: #334155;
    --text-light: #64748b;
    --text-dark: #0f172a;
    --sidebar-bg: linear-gradient(180deg, #0b1220 0%, #111b2e 50%, #0f172a 100%);
    --sidebar-hover: rgba(255, 255, 255, 0.08);
    --sidebar-active: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #ffffff;
    --sidebar-width: 280px;
    --radius: 22px;
    --radius-sm: 14px;
    --shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
    --shadow-md: 0 18px 42px rgba(15, 23, 42, 0.1);
    --shadow-lg: 0 28px 70px rgba(15, 23, 42, 0.16);
    --transition: all 0.22s ease;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Manrope', 'Sora', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.16), transparent 30%),
        radial-gradient(circle at top right, rgba(15, 118, 110, 0.12), transparent 26%),
        linear-gradient(180deg, #f8fbff 0%, #edf3fb 55%, #e8eef8 100%);
    line-height: 1.55;
}

h1, h2, h3, .login-logo h1, .dashboard-hero-copy h3,
.section-header h2, .card-header h3, .topbar-brand strong,
.topbar-school-summary strong {
    font-family: 'Fraunces', Georgia, serif;
    letter-spacing: -0.03em;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(15, 23, 42, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(15, 23, 42, 0.02) 1px, transparent 1px);
    background-size: 44px 44px;
    mask-image: radial-gradient(circle at center, black 55%, transparent 100%);
    opacity: 0.35;
}

.login-screen {
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(circle at 20% 20%, rgba(37, 99, 235, 0.34), transparent 30%),
        radial-gradient(circle at 80% 10%, rgba(14, 165, 233, 0.18), transparent 24%),
        linear-gradient(135deg, #08111f 0%, #0f172a 45%, #16243d 100%);
}

.login-screen::before,
.login-screen::after {
    content: '';
    position: absolute;
    border-radius: 999px;
    filter: blur(24px);
    opacity: 0.55;
}

.login-screen::before {
    width: 320px;
    height: 320px;
    background: rgba(37, 99, 235, 0.28);
    top: -90px;
    left: -110px;
}

.login-screen::after {
    width: 260px;
    height: 260px;
    background: rgba(15, 118, 110, 0.25);
    right: -70px;
    bottom: -80px;
}

.login-card {
    position: relative;
    z-index: 1;
    max-width: 460px;
    padding: 2.75rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 28px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(18px);
    box-shadow: var(--shadow-lg);
}

.login-kicker {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    padding: 0.35rem 0.8rem;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.1);
    color: #1d4ed8;
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.login-logo i {
    font-size: 3.35rem;
    background: linear-gradient(135deg, var(--primary), var(--purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-logo h1 {
    font-size: 1.85rem;
    letter-spacing: -0.03em;
}

.login-logo p {
    margin-top: 0.35rem;
    color: var(--text-light);
    max-width: 28ch;
    margin-left: auto;
    margin-right: auto;
}

.login-form {
    margin-top: 2rem;
}

.login-form .form-group {
    margin-bottom: 1.15rem;
}

.login-form label {
    margin-bottom: 0.5rem;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    color: #334155;
}

.login-form .form-control {
    height: 3.35rem;
    padding: 0.9rem 1rem;
    border-radius: 16px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    border: 1px solid rgba(148, 163, 184, 0.34);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
    font-size: 0.96rem;
}

.login-form .form-control::placeholder {
    color: #94a3b8;
}

.login-form .form-control:hover {
    border-color: rgba(100, 116, 139, 0.42);
}

.login-form .form-control:focus {
    background: #ffffff;
}

.login-form .btn {
    height: 3.4rem;
    margin-top: 0.45rem;
    border-radius: 18px;
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    box-shadow: 0 16px 26px rgba(37, 99, 235, 0.22);
}

.login-form .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 18px 28px rgba(37, 99, 235, 0.28);
}

.login-form .btn:active {
    transform: translateY(0);
}

.login-card .error-text {
    min-height: 1.4rem;
    margin-top: 0.9rem;
    font-size: 0.88rem;
    font-weight: 600;
}

.app-layout {
    background: transparent;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid rgba(148, 163, 184, 0.14);
    box-shadow: 16px 0 40px rgba(15, 23, 42, 0.18);
}

.sidebar-header {
    padding: 1.35rem 1.5rem;
    min-height: 76px;
}

.sidebar-header span {
    letter-spacing: -0.02em;
}

.sidebar-nav {
    padding: 1rem 0.75rem;
}

.nav-item {
    margin: 0.15rem 0.5rem;
    border-radius: 16px;
    padding: 0.8rem 1rem;
    color: rgba(226, 232, 240, 0.76);
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    transform: translateX(2px);
}

.nav-item.active {
    background: var(--sidebar-active);
    color: var(--sidebar-text-active);
    box-shadow: 0 12px 26px rgba(37, 99, 235, 0.35);
}

.sidebar-footer {
    padding: 1rem 1.25rem 1.35rem;
}

.main-content {
    margin-left: var(--sidebar-width);
    background: transparent;
}

.topbar {
    background: rgba(255, 255, 255, 0.82);
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
    backdrop-filter: blur(18px);
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.06);
    gap: 1rem;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    min-width: 220px;
}

.topbar-brand {
    display: grid;
    gap: 0.1rem;
}

.topbar-kicker {
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-light);
}

.topbar-brand strong {
    font-size: 1.04rem;
    color: var(--text-dark);
}

.topbar-center {
    flex: 1;
    display: flex;
    justify-content: center;
    padding: 0 1rem;
}

.school-switcher {
    display: grid;
    gap: 0.35rem;
    width: min(100%, 360px);
    color: var(--text-light);
    font-size: 0.75rem;
    font-weight: 700;
}

.topbar-center .form-control {
    min-width: 320px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    background: rgba(248, 250, 252, 0.9);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.topbar-school-summary {
    display: grid;
    gap: 0.08rem;
    padding: 0.55rem 0.8rem;
    border-radius: 16px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    background: rgba(248, 250, 252, 0.8);
    min-width: 200px;
}

.topbar-school-summary strong {
    font-size: 0.94rem;
    color: var(--text-dark);
}

.topbar-school-summary small {
    font-size: 0.74rem;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: 18px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    background: rgba(255, 255, 255, 0.82);
}

.badge-role,
.user-info {
    border-radius: 999px;
}

.badge-role {
    background: rgba(37, 99, 235, 0.12);
    color: var(--primary);
    padding: 0.4rem 0.75rem;
    font-weight: 700;
}

.user-info {
    padding: 0.4rem 0.8rem;
    background: rgba(15, 23, 42, 0.05);
    color: var(--text-dark);
}

.content-area {
    padding: 1.5rem;
    max-width: 1680px;
    width: 100%;
    margin: 0 auto;
}

.section-header {
    margin-bottom: 1.25rem;
    gap: 0.75rem;
}

.section-header h2 {
    font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem);
    letter-spacing: -0.04em;
}

.section-header-dashboard {
    align-items: flex-end;
}

.dashboard-escuela-label {
    margin-top: 0.2rem;
    font-size: 0.92rem;
    color: var(--text-light);
}

.dashboard-header-chip,
.dashboard-card-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 0.8rem;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.dashboard-hero {
    display: grid;
    grid-template-columns: 1.5fr 0.95fr;
    gap: 1.25rem;
    margin-bottom: 1.25rem;
    padding: 1.5rem;
    border: 1px solid rgba(148, 163, 184, 0.18);
    background:
        radial-gradient(circle at top right, rgba(37, 99, 235, 0.14), transparent 28%),
        radial-gradient(circle at bottom left, rgba(15, 118, 110, 0.08), transparent 25%),
        rgba(255, 255, 255, 0.86);
}

.dashboard-hero-copy h3 {
    margin-top: 0.4rem;
    font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2.35rem);
    line-height: 1.1;
    letter-spacing: -0.05em;
    color: var(--text-dark);
}

.dashboard-eyebrow {
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--primary);
}

.dashboard-insight {
    max-width: 56ch;
    margin-top: 0.85rem;
    color: var(--text-light);
    font-size: 0.98rem;
}

.dashboard-hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1.25rem;
}

.dashboard-hero-side {
    display: grid;
    gap: 1rem;
}

.dashboard-health-card,
.dashboard-empty-state {
    border-radius: 22px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    background: rgba(248, 250, 252, 0.86);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.dashboard-health-card {
    padding: 1rem;
}

.dashboard-health-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.85rem;
    font-size: 0.88rem;
}

.dashboard-health-head strong {
    color: var(--text-dark);
}

.dashboard-progress {
    width: 100%;
    height: 14px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.14);
    overflow: hidden;
}

.dashboard-progress span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--primary), var(--teal));
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.35);
}

.dashboard-micro-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}

.dashboard-micro-stat {
    padding: 0.85rem 0.9rem;
    border-radius: 18px;
    background: #fff;
    border: 1px solid rgba(148, 163, 184, 0.16);
}

.dashboard-micro-stat span {
    display: block;
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text-dark);
}

.dashboard-micro-stat small {
    display: block;
    margin-top: 0.15rem;
    color: var(--text-light);
    font-size: 0.76rem;
}

.dashboard-empty-state {
    display: flex;
    align-items: flex-start;
    gap: 0.9rem;
    padding: 1rem;
    color: var(--text-light);
}

.dashboard-empty-state i {
    font-size: 1.1rem;
    color: var(--primary);
    margin-top: 0.15rem;
}

.dashboard-empty-state strong {
    display: block;
    color: var(--text-dark);
    font-size: 0.92rem;
}

.dashboard-empty-state p {
    margin-top: 0.2rem;
    font-size: 0.84rem;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(300px, 0.72fr);
    gap: 1.25rem;
}

.dashboard-main-column,
.dashboard-side-column {
    display: grid;
    gap: 1.25rem;
}

.dashboard-kpis {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.stat-card-premium {
    padding: 1.15rem;
    border: 1px solid rgba(148, 163, 184, 0.16);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.92));
    box-shadow: var(--shadow);
}

.stat-card-premium:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.dashboard-panels {
    display: grid;
    gap: 1.25rem;
}

.dashboard-panel {
    height: 100%;
}

.dashboard-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.15rem;
}

.dashboard-card-header h3 {
    font-size: 1.02rem;
    letter-spacing: -0.02em;
}

.dashboard-card-header p {
    margin-top: 0.2rem;
    font-size: 0.84rem;
}

.dashboard-list {
    display: grid;
    gap: 0.75rem;
    min-height: 96px;
}

.dashboard-list > * {
    padding: 0.9rem 1rem;
    border-radius: 16px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.96));
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.04);
}

.dashboard-list:empty::before {
    content: 'Sin datos todavia';
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 96px;
    border: 1px dashed rgba(148, 163, 184, 0.28);
    border-radius: 18px;
    color: var(--text-light);
    background: rgba(248, 250, 252, 0.72);
}

.facturas-resumen {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 0.85rem;
    margin-bottom: 1rem;
}

.facturas-resumen-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 0.75rem;
}

.facturas-resumen-item {
    padding: 1rem;
    border-radius: 18px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.95), rgba(255, 255, 255, 0.95));
}

.facturas-resumen-card {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 1rem;
    border-radius: 18px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.98), rgba(255, 255, 255, 0.94));
}

.facturas-resumen-label {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--primary);
}

.facturas-resumen-item strong {
    color: var(--text-dark);
}

.facturas-resumen-card strong {
    display: block;
    color: var(--text-dark);
    font-size: 1.15rem;
    letter-spacing: -0.03em;
}

.facturas-resumen-card small {
    color: var(--text-light);
}

.table-responsive {
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, 0.14);
    background: rgba(255, 255, 255, 0.78);
}

.table {
    background: transparent;
}

.table th {
    background: rgba(248, 250, 252, 0.96);
    color: #475569;
    font-size: 0.74rem;
    letter-spacing: 0.12em;
}

.table td {
    color: var(--text);
}

.table tbody tr:hover {
    background: rgba(37, 99, 235, 0.04);
}

.card {
    border: 1px solid rgba(148, 163, 184, 0.16);
    background: var(--card-bg);
    backdrop-filter: blur(14px);
    box-shadow: var(--shadow);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    background: rgba(248, 250, 252, 0.72);
}

.card-body {
    color: var(--text);
}

.btn {
    border-radius: 14px;
    font-weight: 700;
    letter-spacing: 0.01em;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.4) inset;
}

.btn-primary,
.btn-success,
.btn-warning,
.btn-danger {
    border: 1px solid transparent;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
}

.btn-success {
    background: linear-gradient(135deg, var(--success), var(--success-hover));
}

.btn-warning {
    background: linear-gradient(135deg, #f59e0b, var(--warning));
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444, var(--danger-hover));
}

.btn-outline {
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(148, 163, 184, 0.24);
}

.btn-action {
    padding: 0.7rem 1rem;
    border-radius: 14px;
}

.btn-icon,
.btn-icon-sm {
    border-radius: 12px;
}

.form-control {
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(148, 163, 184, 0.24);
}

.form-control:focus {
    border-color: rgba(37, 99, 235, 0.65);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.filters {
    gap: 0.85rem;
}

.filters .form-control {
    min-width: 190px;
}

.checkbox-list,
.search-results-dropdown {
    background: rgba(255, 255, 255, 0.96);
    border-color: rgba(148, 163, 184, 0.22);
}

.search-results-dropdown .search-result-item {
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.modal-overlay {
    background: rgba(15, 23, 42, 0.58);
    backdrop-filter: blur(10px);
}

.modal {
    border-radius: 24px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    box-shadow: var(--shadow-lg);
}

.modal-header,
.modal-footer {
    background: rgba(248, 250, 252, 0.8);
}

.modal-body {
    background: rgba(255, 255, 255, 0.95);
}

.alert {
    border-radius: 18px;
}

.alert-info {
    background: rgba(219, 234, 254, 0.88);
    border-color: rgba(96, 165, 250, 0.35);
}

.badge {
    border-radius: 999px;
    font-weight: 700;
}

.badge-role {
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.16);
}

.badge-borrador,
.badge-generada,
.badge-enviada,
.badge-pagada,
.badge-particular,
.badge-convenio,
.badge-obra_social,
.badge-anulada,
.badge-vencida,
.badge-parcial {
    border: 1px solid rgba(148, 163, 184, 0.1);
}

.badge-vencida {
    background: rgba(254, 215, 170, 0.65);
    color: #9a3412;
}

.badge-parcial {
    background: rgba(253, 224, 71, 0.22);
    color: #854d0e;
}

.factura-preview {
    border-radius: 20px;
    background: #fff;
}

.factura-preview .factura-header,
.factura-info-header {
    border-radius: 18px;
}

#reporte-resultado {
    min-height: 260px;
    padding: 0.5rem 0;
}

#btn-exportar-reporte {
    white-space: nowrap;
}

#dashboard-empty-state {
    display: flex;
}

.dashboard-hero,
.dashboard-panel,
.facturas-resumen-item {
    transition: var(--transition);
}

.dashboard-hero:hover,
.dashboard-panel:hover,
.facturas-resumen-item:hover {
    transform: translateY(-2px);
}

.content-section.active {
    animation: fadeUp 0.35s ease;
}

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

@media (max-width: 1200px) {
    .dashboard-hero,
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-main-column,
    .dashboard-side-column {
        gap: 1rem;
    }
}

@media (max-width: 992px) {
    .topbar {
        gap: 0.75rem;
        flex-wrap: wrap;
    }

    .topbar-left,
    .topbar-right {
        width: 100%;
        justify-content: space-between;
    }

    .topbar-center {
        order: 3;
        flex-basis: 100%;
        justify-content: stretch;
    }

    .topbar-center .form-control {
        min-width: 0;
        width: 100%;
    }

    .dashboard-micro-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    .login-card {
        width: calc(100% - 1.5rem);
        padding: 1.5rem;
        border-radius: 22px;
    }

    .content-area {
        padding: 1rem;
    }

    .dashboard-hero,
    .card,
    .dashboard-health-card {
        border-radius: 18px;
    }

    .dashboard-hero-actions {
        flex-direction: column;
    }

    .dashboard-micro-stats {
        grid-template-columns: 1fr;
    }

    .facturas-resumen {
        grid-template-columns: 1fr;
    }
}

/* ==================================================
   WORK MODE OVERRIDES
   Interfaz compacta y orientada a carga operativa.
   ================================================== */

:root {
    --primary: #1d4ed8;
    --primary-hover: #1e40af;
    --primary-light: #dbeafe;
    --success: #15803d;
    --success-hover: #166534;
    --warning: #b45309;
    --danger: #b91c1c;
    --danger-hover: #991b1b;
    --purple: #6d28d9;
    --teal: #0f766e;
    --sidebar-bg: #172033;
    --sidebar-hover: #223047;
    --sidebar-active: #1d4ed8;
    --sidebar-width: 230px;
    --bg: #f4f6f8;
    --card-bg: #ffffff;
    --border: #d7dde5;
    --text: #263241;
    --text-light: #647184;
    --text-dark: #111827;
    --radius: 6px;
    --radius-sm: 4px;
    --shadow: none;
    --shadow-md: none;
    --shadow-lg: none;
    --transition: none;
}

html {
    scroll-behavior: auto;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    background: var(--bg);
    line-height: 1.4;
}

body::before,
.login-screen::before,
.login-screen::after {
    display: none;
}

h1,
h2,
h3,
.login-logo h1,
.dashboard-hero-copy h3,
.section-header h2,
.card-header h3,
.topbar-brand strong,
.topbar-school-summary strong {
    font-family: inherit;
    letter-spacing: 0;
}

.login-screen {
    background: #172033;
}

.login-card {
    max-width: 380px;
    padding: 1.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    backdrop-filter: none;
}

.login-logo {
    margin-bottom: 1.25rem;
}

.login-logo i {
    font-size: 2rem;
    color: var(--primary);
    background: none;
    -webkit-text-fill-color: currentColor;
}

.login-logo h1 {
    font-size: 1.35rem;
}

.login-logo p {
    max-width: none;
}

.login-form {
    margin-top: 1rem;
}

.login-form .form-control,
.login-form .btn {
    height: auto;
    border-radius: var(--radius-sm);
    box-shadow: none;
}

.login-form .btn:hover,
.nav-item:hover,
.stat-card-premium:hover,
.card:hover,
.dashboard-hero:hover,
.dashboard-panel:hover,
.facturas-resumen-item:hover {
    transform: none;
    box-shadow: none;
}

.sidebar {
    box-shadow: none;
    border-right: 1px solid #0f172a;
}

.sidebar-header {
    min-height: 54px;
    padding: 0.85rem 1rem;
}

.sidebar-header i {
    font-size: 1rem;
}

.sidebar-header span {
    font-size: 0.98rem;
}

.sidebar-nav {
    padding: 0.5rem;
}

.nav-item {
    margin: 0;
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
}

.nav-item i {
    width: 18px;
    font-size: 0.9rem;
}

.nav-item.active {
    box-shadow: none;
}

.sidebar-footer {
    padding: 0.75rem;
}

.main-content {
    margin-left: var(--sidebar-width);
    background: var(--bg);
}

.topbar {
    min-height: 54px;
    padding: 0.5rem 1rem;
    background: #fff;
    border-bottom: 1px solid var(--border);
    backdrop-filter: none;
    box-shadow: none;
}

.topbar-left {
    min-width: 160px;
    gap: 0.5rem;
}

.topbar-brand {
    display: block;
}

.topbar-brand strong {
    font-size: 1rem;
}

.topbar-kicker,
.login-kicker,
.dashboard-eyebrow,
.dashboard-card-chip,
.section-eyebrow {
    display: none;
}

.topbar-center {
    justify-content: flex-start;
    padding: 0;
}

.school-switcher {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: min(100%, 420px);
    font-size: 0.8rem;
}

.school-switcher span {
    white-space: nowrap;
}

.topbar-center .form-control {
    min-width: 220px;
    max-width: 320px;
    border-radius: var(--radius-sm);
    background: #fff;
    box-shadow: none;
}

.topbar-right {
    gap: 0.5rem;
}

.topbar-school-summary,
.topbar-user {
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
}

.topbar-school-summary {
    min-width: 0;
}

.topbar-school-summary small {
    display: none;
}

.badge-role,
.user-info {
    padding: 0.2rem 0.45rem;
    border-radius: var(--radius-sm);
}

.content-area {
    max-width: none;
    padding: 1rem;
}

.section-header {
    margin-bottom: 0.85rem;
    gap: 0.5rem;
}

.section-header h2 {
    font-size: 1.25rem;
}

.section-header-dashboard {
    align-items: center;
}

.dashboard-escuela-label {
    margin-top: 0.1rem;
    font-size: 0.84rem;
}

.dashboard-header-chip {
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    background: #fff;
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 0.78rem;
    font-weight: 600;
}

.dashboard-hero {
    grid-template-columns: minmax(0, 1fr) minmax(320px, 0.9fr);
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 1rem;
    border: 1px solid var(--border);
    background: #fff;
}

.dashboard-hero-copy h3 {
    margin: 0;
    font-size: 1rem;
    line-height: 1.3;
}

.dashboard-insight {
    max-width: none;
    margin-top: 0.35rem;
    font-size: 0.86rem;
}

.dashboard-hero-actions {
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.dashboard-hero-side {
    gap: 0.5rem;
}

.dashboard-health-card,
.dashboard-empty-state {
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: #fff;
    box-shadow: none;
}

.dashboard-health-card {
    padding: 0.75rem;
}

.dashboard-health-head {
    margin-bottom: 0.5rem;
    font-size: 0.82rem;
}

.dashboard-health-head strong {
    font-size: 0.82rem;
    font-weight: 600;
}

.dashboard-progress {
    height: 8px;
}

.dashboard-progress span {
    background: var(--primary);
    box-shadow: none;
}

.dashboard-micro-stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.dashboard-micro-stat {
    padding: 0.45rem 0.55rem;
    border-radius: var(--radius-sm);
    background: #f8fafc;
}

.dashboard-micro-stat span {
    font-size: 0.98rem;
}

.dashboard-micro-stat small {
    font-size: 0.72rem;
}

.dashboard-empty-state {
    padding: 0.65rem;
}

.dashboard-empty-state p {
    margin-top: 0.1rem;
}

.dashboard-grid {
    grid-template-columns: minmax(0, 1.5fr) minmax(300px, 0.8fr);
    gap: 1rem;
}

.dashboard-main-column,
.dashboard-side-column,
.dashboard-panels {
    gap: 1rem;
}

.stats-grid,
.dashboard-kpis {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.75rem;
}

.stat-card,
.stat-card-premium {
    padding: 0.75rem;
    border: 1px solid var(--border);
    background: #fff;
}

.stat-icon {
    width: 34px;
    height: 34px;
    font-size: 0.95rem;
    border-radius: var(--radius-sm);
}

.stat-value {
    font-size: 1.12rem;
}

.stat-label {
    font-size: 0.78rem;
}

.card {
    border: 1px solid var(--border);
    background: #fff;
    backdrop-filter: none;
}

.card-header,
.dashboard-card-header,
.modal-header,
.modal-footer {
    padding: 0.75rem 1rem;
    background: #f8fafc;
}

.card-header h3,
.dashboard-card-header h3 {
    font-size: 0.98rem;
}

.dashboard-card-header p {
    margin-top: 0.1rem;
    font-size: 0.78rem;
}

.card-body {
    padding: 1rem;
}

.dashboard-list {
    gap: 0.5rem;
    min-height: 72px;
}

.dashboard-list > * {
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sm);
    background: #fff;
    box-shadow: none;
}

.dashboard-list:empty::before {
    min-height: 72px;
    border-radius: var(--radius-sm);
    background: #fafafa;
}

.facturas-resumen,
.facturas-resumen-grid {
    gap: 0.65rem;
}

.facturas-resumen-item,
.facturas-resumen-card {
    padding: 0.75rem;
    border-radius: var(--radius);
    background: #fff;
}

.facturas-resumen-label {
    color: var(--text-light);
    letter-spacing: 0;
    text-transform: none;
}

.table-responsive {
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: #fff;
}

.table th,
.table td {
    padding: 0.55rem 0.65rem;
}

.table th {
    background: #f3f6f9;
    letter-spacing: 0;
}

.table tbody tr:hover {
    background: #f8fafc;
}

.btn {
    border-radius: var(--radius-sm);
    font-weight: 600;
    box-shadow: none;
}

.btn-primary,
.btn-success,
.btn-warning,
.btn-danger {
    background-image: none;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-success:hover {
    background: var(--success-hover);
}

.btn-warning {
    background: var(--warning);
    color: #fff;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: var(--danger-hover);
}

.btn-action {
    padding: 0.5rem 0.75rem;
}

.form-control {
    border-radius: var(--radius-sm);
    background: #fff;
}

.form-control:focus {
    box-shadow: 0 0 0 2px var(--primary-light);
}

.filters {
    gap: 0.5rem;
}

.modal-overlay {
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: none;
}

.modal {
    border-radius: var(--radius);
}

.alert,
.factura-preview,
.factura-preview .factura-header,
.factura-info-header {
    border-radius: var(--radius);
}

.content-section.active {
    animation: none;
}

@media (max-width: 1200px) {
    .dashboard-hero,
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 992px) {
    .topbar-left,
    .topbar-right {
        width: auto;
    }

    .topbar-center {
        order: initial;
        flex-basis: auto;
    }

    .dashboard-micro-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    .main-content {
        margin-left: 0;
    }

    .content-area {
        padding: 0.75rem;
    }

    .topbar {
        align-items: flex-start;
    }

    .topbar-left,
    .topbar-right {
        width: 100%;
    }

    .topbar-center {
        display: flex;
        order: 3;
        width: 100%;
    }

    .school-switcher {
        align-items: flex-start;
        flex-direction: column;
        width: 100%;
    }

    .topbar-center .form-control {
        width: 100%;
        max-width: none;
    }

    .dashboard-hero-actions {
        flex-direction: row;
    }

    .dashboard-micro-stats {
        grid-template-columns: 1fr 1fr;
    }

.dashboard-hero,
.card,
.dashboard-health-card {
    border-radius: var(--radius);
}
}

/* Dashboard overflow guards */
#sec-dashboard,
#sec-dashboard * {
    min-width: 0;
}

.dashboard-hero,
.dashboard-grid,
.dashboard-main-column,
.dashboard-side-column,
.dashboard-panels,
.dashboard-panel,
.dashboard-kpis,
.dashboard-health-card,
.dashboard-empty-state {
    min-width: 0;
}

.stat-card,
.stat-card-premium {
    min-width: 0;
}

.stat-info {
    min-width: 0;
}

.stat-value,
.dashboard-micro-stat span {
    max-width: 100%;
    line-height: 1.15;
    overflow-wrap: anywhere;
}

.stat-label,
.dashboard-micro-stat small,
.dashboard-card-header p,
.dashboard-escuela-label,
.dashboard-insight {
    overflow-wrap: anywhere;
}

.dashboard-card-header {
    min-width: 0;
}

.dashboard-card-header > div {
    min-width: 0;
}

.dashboard-list-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) max-content;
    align-items: center;
    gap: 0.75rem;
}

.dashboard-list-item > div {
    min-width: 0;
}

.dashboard-list-item > div:last-child {
    max-width: 100%;
}

.dashboard-list-item strong,
.dashboard-list-item small {
    overflow-wrap: anywhere;
}

.dashboard-list-item .badge {
    max-width: 100%;
    white-space: normal;
    text-align: center;
}

.dashboard-hero-actions .btn-action {
    min-width: 0;
    justify-content: center;
    white-space: normal;
}

/* ======= ITEMS POR NIVEL ======= */
#table-items .items-level-row td {
    padding: 0;
    background: #f3f6f9;
    border-bottom: 1px solid var(--border);
}

#table-items .items-level-row:hover {
    background: transparent;
}

#table-items .items-level-toggle {
    width: 100%;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.65rem 0.75rem;
    border: 0;
    background: transparent;
    color: var(--text-dark);
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    text-align: left;
}

#table-items .items-level-toggle:hover,
#table-items .items-level-toggle:focus {
    background: rgba(37, 99, 235, 0.06);
    outline: none;
}

#table-items .items-level-title {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#table-items .items-level-title i:not(.items-level-caret) {
    width: 1rem;
    color: var(--primary);
    text-align: center;
}

#table-items .items-level-caret {
    width: 0.85rem;
    color: var(--text-light);
    text-align: center;
}

#table-items .items-level-count {
    flex: 0 0 auto;
    padding: 0.18rem 0.45rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #fff;
    color: var(--text-light);
    font-size: 0.75rem;
    line-height: 1.2;
}

#table-items .items-level-empty td {
    background: #fff;
}

@media (max-width: 768px) {
    .dashboard-hero-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dashboard-header-chip {
        max-width: 100%;
        white-space: normal;
    }
}

@media (max-width: 520px) {
    #table-items .items-level-toggle {
        align-items: flex-start;
        flex-direction: column;
    }

    .dashboard-hero-actions,
    .dashboard-micro-stats {
        grid-template-columns: 1fr;
    }

    .dashboard-list-item {
        grid-template-columns: 1fr;
        align-items: start;
    }

    .dashboard-list-item > div:last-child {
        text-align: left !important;
    }
}
