:root {
    --primary-red: #DC143C;
    --dark-red: #B01030;
    --light-red: #FF6B6B;
    --gradient-red: linear-gradient(135deg, #DC143C 0%, #B01030 100%);
    --sidebar-dark: #1a1d2e;
    --sidebar-darker: #151824;
    --bg-light: #f8f9fa;
    --bg-white: #ffffff;
    --text-dark: #2c3e50;
    --text-light: #6c757d;
    --text-white: #ffffff;
    --border-color: #e9ecef;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --sidebar-width: 260px;
}

* {
    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-light);
    color: var(--text-dark);
    line-height: 1.6;
    font-size: 14px;
}

/* Login Page Styles */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient-red);
    padding: 20px;
}

.login-box {
    background: white;
    padding: 40px 30px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    animation: slideIn 0.5s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header-logos {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 18px;
}

/* Tamaño por logo en login (modificar cada uno por separado) */
.login-header-logos img.logo-icon {
    width: 56px;
    height: 56px;
    object-fit: contain;
}

.login-header-logos img.logo-cr {
    width: 140px;
    height: 140px;
    object-fit: contain;
}

.login-header-sep {
    width: 2px;
    height: 44px;
    background: var(--primary-red);
    border-radius: 1px;
    flex-shrink: 0;
}

.login-header h1 {
    color: var(--primary-red);
    font-size: 2rem;
    margin-bottom: 8px;
    font-weight: 700;
}

.login-header p {
    color: var(--text-light);
    font-size: 0.9rem;
}

/* Dashboard Layout */
.dashboard-container {
    display: flex;
    min-height: 100vh;
    background: var(--bg-light);
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-dark);
    color: white;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 25px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header-logos {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

/* Tamaño por logo en sidebar (modificar cada uno por separado) */
.sidebar-header-logos img.logo-icon {
    width: 60px;
    height: 60px;
    object-fit: contain;
}

.sidebar-header-logos img.logo-cr {
    width: 120px;
    height: 120px;
    object-fit: contain;
}

.sidebar-header-sep {
    width: 2px;
    height: 32px;
    background: var(--primary-red);
    border-radius: 1px;
    flex-shrink: 0;
}

.sidebar-header h2 {
    font-size: 1.3rem;
    margin-bottom: 5px;
    font-weight: 700;
    color: var(--primary-red);
}

.sidebar-header p {
    font-size: 0.85rem;
    opacity: 0.8;
    margin-bottom: 3px;
}

.sidebar-header small {
    font-size: 0.75rem;
    opacity: 0.6;
    background: rgba(220, 20, 60, 0.2);
    padding: 3px 8px;
    border-radius: 4px;
    display: inline-block;
}

.sidebar-menu {
    list-style: none;
    padding: 15px 0;
}

.sidebar-menu li {
    margin-bottom: 3px;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    border-left: 3px solid transparent;
}

.sidebar-menu a:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
    border-left-color: var(--primary-red);
}

.sidebar-menu a.active {
    background: rgba(220, 20, 60, 0.15);
    color: white;
    border-left-color: var(--primary-red);
    font-weight: 500;
}

.sidebar-menu a::before {
    content: "●";
    margin-right: 12px;
    font-size: 0.6rem;
    opacity: 0.5;
}

.sidebar-menu a.active::before {
    opacity: 1;
    color: var(--primary-red);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 20px;
    min-height: 100vh;
    width: calc(100% - var(--sidebar-width));
}

/* Top Bar */
.top-bar {
    background: white;
    padding: 20px 25px;
    border-radius: var(--radius);
    margin-bottom: 25px;
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.top-bar h1 {
    color: var(--text-dark);
    font-size: 1.6rem;
    font-weight: 700;
    margin: 0;
}

.top-bar p {
    color: var(--text-light);
    font-size: 0.85rem;
    margin: 5px 0 0 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.user-info span {
    font-weight: 500;
    color: var(--text-dark);
}

.top-bar-dashboard .top-bar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.top-bar-dashboard .live-indicator {
    font-size: 0.8rem;
    color: var(--success);
    font-weight: 600;
}

.top-bar-dashboard .last-update {
    font-size: 0.8rem;
    color: var(--text-light);
}

.top-bar-dashboard .user-role-badge {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-dark);
    padding: 4px 10px;
    background: var(--bg-light);
    border-radius: var(--radius-sm);
}

/* Dashboard fullscreen: todo visible en una pantalla */
.dashboard-fullscreen-wrap {
    min-height: 0;
    background: var(--bg-light);
}

.dashboard-content-area {
    /* flujo normal fuera de fullscreen */
}

.dashboard-fullscreen-wrap.is-fullscreen {
    padding: 10px 14px;
    height: 100vh;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    background: var(--bg-light);
}

/* Barra superior compacta en fullscreen */
.dashboard-fullscreen-wrap.is-fullscreen .top-bar-dashboard {
    padding: 8px 12px;
    margin-bottom: 8px;
    flex-shrink: 0;
}

.dashboard-fullscreen-wrap.is-fullscreen .top-bar-dashboard h1 {
    font-size: 1.05rem;
    margin: 0;
}

.dashboard-fullscreen-wrap.is-fullscreen .top-bar-dashboard p {
    display: none;
}

/* Área de contenido en grid 2 columnas; en fullscreen se puede scrollear todo */
.dashboard-fullscreen-wrap.is-fullscreen .dashboard-content-area {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto auto;
    gap: 10px;
    flex: none;
    min-height: auto;
    overflow: visible;
}

.dashboard-fullscreen-wrap.is-fullscreen .dashboard-row-1 {
    grid-column: 1 / -1;
    grid-row: 1;
}

.dashboard-fullscreen-wrap.is-fullscreen .dashboard-row-2-left {
    grid-column: 1 / -1;
    grid-row: 2;
    margin-bottom: 0;
    min-height: auto;
    overflow: visible;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.dashboard-fullscreen-wrap.is-fullscreen .dashboard-row-3-left {
    grid-column: 1;
    grid-row: 3;
    margin-bottom: 0;
    min-height: auto;
    overflow: visible;
}

.dashboard-fullscreen-wrap.is-fullscreen .dashboard-row-3-right {
    grid-column: 2;
    grid-row: 3;
    margin-bottom: 0;
    min-height: auto;
    overflow: visible;
}


.dashboard-fullscreen-wrap.is-fullscreen .dashboard-row-3-right .dashboard-activity-table {
    max-height: 280px;
    overflow-y: auto;
}

.dashboard-fullscreen-wrap.is-fullscreen .dashboard-quick-actions {
    display: none;
}

/* Tarjetas y bloques más compactos en fullscreen */
.dashboard-fullscreen-wrap.is-fullscreen .card {
    padding: 12px 14px;
    margin-bottom: 0;
}

.dashboard-fullscreen-wrap.is-fullscreen .card-header {
    padding-bottom: 8px;
    margin-bottom: 10px;
}

.dashboard-fullscreen-wrap.is-fullscreen .card-header h3 {
    font-size: 0.95rem;
}

.dashboard-fullscreen-wrap.is-fullscreen .stats-grid {
    gap: 10px;
    margin-bottom: 10px;
}

.dashboard-fullscreen-wrap.is-fullscreen .stat-card {
    padding: 12px 14px;
}

.dashboard-fullscreen-wrap.is-fullscreen .stat-card-icon {
    width: 36px;
    height: 36px;
    right: 12px;
    top: 12px;
    font-size: 1rem;
}

.dashboard-fullscreen-wrap.is-fullscreen .stat-card h4 {
    font-size: 0.7rem;
    margin-bottom: 4px;
}

.dashboard-fullscreen-wrap.is-fullscreen .stat-card .stat-value {
    font-size: 1.4rem;
    margin-bottom: 2px;
}

.dashboard-fullscreen-wrap.is-fullscreen .stat-card .stat-change {
    font-size: 0.75rem;
}

.dashboard-fullscreen-wrap.is-fullscreen .progress-section {
    margin-bottom: 12px;
}

.dashboard-fullscreen-wrap.is-fullscreen .progress-bar-container {
    height: 6px;
}

.dashboard-fullscreen-wrap.is-fullscreen .progress-label,
.dashboard-fullscreen-wrap.is-fullscreen .progress-value {
    font-size: 0.8rem;
}

/* Tabla de actividad más compacta en fullscreen */
.dashboard-fullscreen-wrap.is-fullscreen .table-container {
    max-height: none;
}

.dashboard-fullscreen-wrap.is-fullscreen table {
    min-width: 400px;
    font-size: 0.8rem;
}

.dashboard-fullscreen-wrap.is-fullscreen table th,
.dashboard-fullscreen-wrap.is-fullscreen table td {
    padding: 6px 10px;
}

/* Concejales más compactos en fullscreen */
.dashboard-fullscreen-wrap.is-fullscreen .concejal-stats-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
}

.dashboard-fullscreen-wrap.is-fullscreen .concejal-stat-item {
    padding: 10px;
}

.dashboard-fullscreen-wrap.is-fullscreen .concejal-stat-name {
    font-size: 0.85rem;
    margin-bottom: 4px;
}

.dashboard-fullscreen-wrap.is-fullscreen .concejal-stat-nums {
    font-size: 0.8rem;
}

/* Participación + Progreso por Barrio juntos, sin espacio */
.dashboard-left-col {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.dashboard-barrios-card {
    margin-top: 0;
}

.dashboard-left-col .card + .card {
    margin-top: 0;
}

/* Dos columnas (Participación + Barrios | Mesas) más compactas en fullscreen */
.dashboard-fullscreen-wrap.is-fullscreen .dashboard-two-col {
    gap: 10px;
    margin-bottom: 0;
}

.dashboard-fullscreen-wrap.is-fullscreen .dashboard-two-col .card {
    padding: 12px 14px;
}

.dashboard-fullscreen-wrap.is-fullscreen .dashboard-left-col .card + .card {
    margin-top: 0;
}

.dashboard-fullscreen-wrap.is-fullscreen .dashboard-barrios-card {
    margin-top: 0;
}

.dashboard-fullscreen-wrap.is-fullscreen .dashboard-row-2-left #barrio-stats-container {
    max-height: 220px;
    overflow-y: auto;
}

.dashboard-fullscreen-wrap.is-fullscreen .dashboard-two-col [style*="font-size: 1.8rem"] {
    font-size: 1.35rem !important;
}

.dashboard-fullscreen-wrap.is-fullscreen .dashboard-two-col [style*="margin-top: 25px"] {
    margin-top: 12px !important;
}

.dashboard-fullscreen-wrap.is-fullscreen #mesas-activas-container {
    gap: 10px;
}

.dashboard-fullscreen-wrap.is-fullscreen #mesas-activas-container > div {
    padding: 10px !important;
}

/* Concejales en dashboard */
.concejal-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.concejal-stat-item {
    padding: 14px;
    background: var(--bg-light);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.concejal-stat-name {
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 6px;
}

.concejal-stat-nums {
    font-size: 0.9rem;
    color: var(--text-light);
}

/* Form Styles */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-dark);
    font-weight: 500;
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    padding: 11px 15px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    transition: all 0.2s ease;
    background: white;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-red);
    box-shadow: 0 0 0 3px rgba(220, 20, 60, 0.1);
}

/* Buttons */
.btn {
    padding: 11px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary-red);
    color: white;
}

.btn-primary:hover {
    background: var(--dark-red);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-sm {
    padding: 7px 14px;
    font-size: 0.85rem;
}

/* Alert Messages */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    animation: slideIn 0.3s ease;
    border-left: 4px solid;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border-left-color: var(--success);
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border-left-color: var(--danger);
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border-left-color: var(--warning);
}

/* Cards */
.card {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}

.card-header {
    border-bottom: 2px solid var(--bg-light);
    padding-bottom: 12px;
    margin-bottom: 18px;
}

.card-header h3 {
    color: var(--text-dark);
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}

/* Statistics Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 18px;
    margin-bottom: 25px;
}

.stat-card {
    background: white;
    padding: 18px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}

.stat-card-icon {
    position: absolute;
    right: 18px;
    top: 18px;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    opacity: 0.9;
}

.stat-card-icon.red {
    background: rgba(220, 20, 60, 0.1);
    color: var(--primary-red);
}

.stat-card-icon.green {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.stat-card-icon.yellow {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.stat-card-icon.blue {
    background: rgba(59, 130, 246, 0.1);
    color: var(--info);
}

.stat-card h4 {
    color: var(--text-light);
    font-size: 0.75rem;
    margin-bottom: 8px;
    text-transform: uppercase;
    font-weight: 500;
    letter-spacing: 0.5px;
}

.stat-card .stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 8px;
}

.stat-card .stat-change {
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 5px;
}

.stat-change.positive {
    color: var(--success);
}

.stat-change.negative {
    color: var(--danger);
}

/* Progress Bars */
.progress-section {
    margin-bottom: 20px;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    gap: 10px;
    flex-wrap: wrap;
}

.progress-label {
    font-size: 0.9rem;
    color: var(--text-dark);
    font-weight: 500;
}

.progress-value {
    font-size: 0.9rem;
    color: var(--text-light);
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background: var(--bg-light);
    border-radius: 10px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--gradient-red);
    border-radius: 10px;
    transition: width 0.5s ease;
}

/* Table Styles */
.table-container {
    overflow-x: auto;
    background: white;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}

.dashboard-activity-table {
    max-height: 320px;
    overflow: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

table thead {
    background: var(--bg-light);
}

table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-dark);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

table tbody tr:hover {
    background: var(--bg-light);
}

table tbody tr:last-child td {
    border-bottom: none;
}

/* Filas del padrón coloreadas por estado (Verde/Amarillo/Rojo) - fila completa en Admin, PC y Padron */
table tbody tr.row-padron-verde,
table tbody tr.row-padron-verde td {
    background-color: #22c55e !important;
    color: #fff !important;
}
table tbody tr.row-padron-verde:hover,
table tbody tr.row-padron-verde:hover td {
    background-color: #16a34a !important;
    color: #fff !important;
}
table tbody tr.row-padron-amarillo,
table tbody tr.row-padron-amarillo td {
    background-color: #eab308 !important;
    color: #1f2937 !important;
}
table tbody tr.row-padron-amarillo:hover,
table tbody tr.row-padron-amarillo:hover td {
    background-color: #ca8a04 !important;
    color: #fff !important;
}
table tbody tr.row-padron-rojo,
table tbody tr.row-padron-rojo td {
    background-color: #ef4444 !important;
    color: #fff !important;
}
table tbody tr.row-padron-rojo:hover,
table tbody tr.row-padron-rojo:hover td {
    background-color: #dc2626 !important;
    color: #fff !important;
}

/* Badge dentro de fila coloreada: contraste */
table tbody tr.row-padron-verde .badge,
table tbody tr.row-padron-amarillo .badge,
table tbody tr.row-padron-rojo .badge {
    color: #1f2937 !important;
    background: rgba(255,255,255,0.9) !important;
}

.badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.badge-primary {
    background: rgba(220, 20, 60, 0.1);
    color: var(--primary-red);
}

/* Filter Bar */
.filter-bar {
    background: white;
    padding: 18px 20px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.filter-bar .form-group {
    margin-bottom: 0;
}

.filter-bar .form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-dark);
}

.filter-bar .filter-hint {
    color: var(--text-light);
    font-size: 0.85rem;
    margin-top: 5px;
    display: block;
}

.filter-grid {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 1rem 1.25rem;
    align-items: end;
}

.filter-grid .form-group {
    min-width: 0;
}

.filter-grid .flex.gap-10 {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.5rem;
    align-items: center;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: 25px;
    border-radius: var(--radius);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideIn 0.3s ease;
    box-shadow: var(--shadow-lg);
}

.modal-content-wide {
    max-width: 90%;
    width: 720px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--bg-light);
}

.modal-header h3 {
    color: var(--text-dark);
    font-size: 1.2rem;
    font-weight: 600;
}

.close-modal {
    font-size: 1.8rem;
    cursor: pointer;
    color: var(--text-light);
    line-height: 1;
    transition: color 0.2s;
}

.close-modal:hover {
    color: var(--text-dark);
}

/* Mobile Menu Button */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 1001;
    background: var(--primary-red);
    color: white;
    border: none;
    width: 45px;
    height: 45px;
    border-radius: 8px;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: var(--shadow);
    align-items: center;
    justify-content: center;
}

.mobile-menu-btn:active {
    transform: scale(0.95);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .main-content {
        padding: 15px;
    }
    
    table {
        font-size: 0.9rem;
    }
}

@media (max-width: 768px) {
    :root {
        --sidebar-width: 0px;
    }

    .mobile-menu-btn {
        display: flex;
    }

    .sidebar {
        transform: translateX(-100%);
        width: 280px;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 15px;
        padding-top: 70px;
    }

    .top-bar {
        flex-direction: column;
        align-items: flex-start;
        padding: 15px;
        margin-top: 10px;
    }

    .top-bar h1 {
        font-size: 1.3rem;
        margin-bottom: 8px;
    }

    .top-bar p {
        font-size: 0.8rem;
    }

    .user-info {
        width: 100%;
        justify-content: space-between;
        margin-top: 10px;
        padding-top: 10px;
        border-top: 1px solid var(--border-color);
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .stat-card {
        padding: 15px;
    }

    .stat-card-icon {
        width: 36px;
        height: 36px;
        font-size: 1rem;
        right: 15px;
        top: 15px;
    }

    .stat-card .stat-value {
        font-size: 1.5rem;
    }

    .stat-card h4 {
        font-size: 0.7rem;
    }

    .filter-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .filter-grid .flex.gap-10 {
        justify-content: flex-start;
    }

    .card {
        padding: 15px;
        margin-bottom: 15px;
    }

    .card-header h3 {
        font-size: 1rem;
    }

    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 600px;
    }

    table th,
    table td {
        padding: 10px 8px;
        font-size: 0.85rem;
    }

    .btn {
        padding: 10px 18px;
        font-size: 0.85rem;
    }

    .btn-sm {
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    .modal-content {
        padding: 20px;
        margin: 10px;
        max-height: calc(100vh - 20px);
    }

    .form-control {
        padding: 10px 12px;
        font-size: 16px; /* Previene zoom en iOS */
    }

    .login-box {
        padding: 30px 20px;
        margin: 10px;
    }

    .sidebar-header {
        padding: 20px 15px;
    }

    .sidebar-header h2 {
        font-size: 1.1rem;
    }

    .sidebar-menu a {
        padding: 10px 15px;
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    body {
        font-size: 13px;
    }

    .mobile-menu-btn {
        width: 40px;
        height: 40px;
        font-size: 1.3rem;
        top: 10px;
        left: 10px;
    }

    .main-content {
        padding: 10px;
        padding-top: 60px;
    }

    .top-bar {
        padding: 12px;
    }

    .top-bar h1 {
        font-size: 1.1rem;
    }

    .top-bar p {
        font-size: 0.75rem;
    }

    .login-box {
        padding: 25px 18px;
    }

    .login-header h1 {
        font-size: 1.5rem;
    }

    .login-header p {
        font-size: 0.85rem;
    }

    .stat-card {
        padding: 12px;
    }

    .stat-card .stat-value {
        font-size: 1.3rem;
    }

    .stat-card h4 {
        font-size: 0.65rem;
    }

    .card {
        padding: 12px;
    }

    table {
        min-width: 500px;
        font-size: 0.8rem;
    }

    table th,
    table td {
        padding: 8px 6px;
        font-size: 0.75rem;
    }

    .badge {
        padding: 4px 10px;
        font-size: 0.7rem;
    }

    .btn {
        padding: 9px 16px;
        font-size: 0.8rem;
        width: 100%;
    }

    .btn-sm {
        padding: 5px 10px;
        font-size: 0.75rem;
        width: auto;
    }

    .modal-content {
        padding: 15px;
    }

    .form-group {
        margin-bottom: 15px;
    }

    .form-control {
        padding: 9px 10px;
    }

    .alert {
        padding: 12px 15px;
        font-size: 0.85rem;
    }

    .sidebar {
        width: 260px;
    }
}

/* Landscape orientation on mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .main-content {
        padding-top: 60px;
    }

    .mobile-menu-btn {
        top: 10px;
        left: 10px;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .btn,
    .sidebar-menu a,
    .mobile-menu-btn {
        min-height: 44px; /* Minimum touch target size */
    }

    table th,
    table td {
        padding: 12px 8px; /* Larger touch targets */
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .stat-card-icon {
        font-size: 1.1rem;
    }
}

/* Utility Classes */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mt-20 {
    margin-top: 20px;
}

.mb-20 {
    margin-bottom: 20px;
}

.flex {
    display: flex;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.gap-10 {
    gap: 10px;
}

/* Loading Spinner */
.spinner {
    border: 3px solid var(--bg-light);
    border-top: 3px solid var(--primary-red);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Print Styles */
@media print {

    .sidebar,
    .top-bar .user-info,
    .btn,
    .filter-bar {
        display: none !important;
    }

    .main-content {
        margin-left: 0;
        width: 100%;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
        page-break-inside: avoid;
    }
}