:root {
    --primary-color: #1e3a5f;
    --secondary-color: #00b894;
    --accent-color: #00cec9;
    --success-color: #00d68f;
    --danger-color: #ff4757;
    --warning-color: #ffa502;
    --info-color: #1e90ff;
    --light-color: #f1f2f6;
    --dark-color: #2f3640;
    --text-color: #2d3436;
    --text-muted: #636e72;
    --border-color: #dfe6e9;
    --card-bg: #ffffff;
    --input-bg: #ffffff;
    --shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);
    --gradient-primary: linear-gradient(135deg, #00b894 0%, #00cec9 100%);
    --gradient-sidebar: linear-gradient(180deg, #1e3a5f 0%, #2d5478 100%);
    --border-radius: 12px;
    --transition: all 0.3s ease;
    /* Aliases for pages using alternate variable names */
    --bg-card: var(--card-bg);
    --bg-input: var(--input-bg);
    --bg-code: #f4f6f8;
    --text-primary: var(--text-color);
    --text-secondary: var(--text-muted);
    --accent: var(--secondary-color);
    --border: var(--border-color);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Aptos', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e8eb 100%);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
}

/* Botones */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: var(--transition);
    text-align: center;
    white-space: nowrap;
}

.btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 15px rgba(0, 184, 148, 0.3);
}

.btn-primary:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(0, 184, 148, 0.4);
}

.btn-success {
    background: linear-gradient(135deg, #00d68f 0%, #00b894 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(0, 214, 143, 0.3);
}

.btn-success:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(0, 214, 143, 0.4);
}

.btn-danger {
    background: linear-gradient(135deg, #ff4757 0%, #ff3838 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(255, 71, 87, 0.3);
}

.btn-danger:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(255, 71, 87, 0.4);
}

.btn-warning {
    background: linear-gradient(135deg, #ffa502 0%, #ff9f1a 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(255, 165, 2, 0.3);
}

.btn-warning:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(255, 165, 2, 0.4);
}

.btn-secondary {
    background: linear-gradient(135deg, #a4b0be 0%, #95a5a6 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(149, 165, 166, 0.3);
}

.btn-secondary:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(149, 165, 166, 0.4);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
    border-radius: 8px;
}

.btn-lg {
    padding: 16px 32px;
    font-size: 16px;
}

/* Formularios */
.form-group {
    margin-bottom: 24px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-color);
    font-size: 14px;
}

.form-control {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-family: inherit;
    font-size: 14px;
    transition: var(--transition);
    background: white;
}

.form-control:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 4px rgba(0, 184, 148, 0.1);
}

.form-control:hover:not(:focus) {
    border-color: #b2bec3;
}

select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23636e72' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
}

/* Tablas */
.table {
    width: 100%;
    border-collapse: collapse;
    background-color: white;
    box-shadow: var(--shadow);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.table thead {
    background: var(--gradient-sidebar);
    color: white;
}

.table th,
.table td {
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.table th {
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table tbody tr {
    transition: var(--transition);
}

.table tbody tr:hover {
    background: linear-gradient(135deg, #f8f9fa 0%, #f1f2f6 100%);
}

.table tbody tr.selected {
    background: linear-gradient(135deg, rgba(0, 184, 148, 0.1) 0%, rgba(0, 206, 201, 0.1) 100%);
}

/* Cards */
.card {
    background-color: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 24px;
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-header {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--primary-color);
    border-bottom: 2px solid var(--secondary-color);
    padding-bottom: 12px;
}

.card-body {
    padding: 10px 0;
}

/* Alerts */
.alert {
    padding: 16px 20px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert-success {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
    border-left: 4px solid var(--success-color);
}

.alert-error {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    color: #721c24;
    border-left: 4px solid var(--danger-color);
}

.alert-warning {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    color: #856404;
    border-left: 4px solid var(--warning-color);
}

.alert-info {
    background: linear-gradient(135deg, #d1ecf1 0%, #bee5eb 100%);
    color: #0c5460;
    border-left: 4px solid var(--info-color);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex !important;
}

.modal-content {
    background-color: white;
    margin: auto;
    padding: 32px;
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 600px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--border-color);
}

.modal-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--primary-color);
}

.close {
    font-size: 28px;
    font-weight: bold;
    color: var(--text-muted);
    cursor: pointer;
    border: none;
    background: none;
    padding: 0 8px;
    transition: var(--transition);
    border-radius: 8px;
}

.close:hover {
    color: var(--danger-color);
    background: rgba(255, 71, 87, 0.1);
}

/* Utilidades */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mt-1 { margin-top: 10px; }
.mt-2 { margin-top: 20px; }
.mt-3 { margin-top: 30px; }

.mb-1 { margin-bottom: 10px; }
.mb-2 { margin-bottom: 20px; }
.mb-3 { margin-bottom: 30px; }

.ml-1 { margin-left: 10px; }
.mr-1 { margin-right: 10px; }

.d-flex {
    display: flex;
}

.justify-between {
    justify-content: space-between;
}

.align-center {
    align-items: center;
}

.gap-1 { gap: 10px; }
.gap-2 { gap: 20px; }

/* Loading */
.loading {
    display: none;
    text-align: center;
    padding: 20px;
}

.spinner {
    border: 4px solid var(--light-color);
    border-top: 4px solid var(--secondary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 20px;
}

.badge-primary {
    background: var(--gradient-sidebar);
    color: white;
}

.badge-success {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
}

.badge-danger {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    color: #721c24;
}

.badge-warning {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    color: #856404;
}

.badge-info {
    background: linear-gradient(135deg, #d1ecf1 0%, #bee5eb 100%);
    color: #0c5460;
}

.badge-secondary {
    background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
    color: #495057;
}

.badge-real {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
}

.badge-estimado {
    background: linear-gradient(135deg, #cce5ff 0%, #b8daff 100%);
    color: #004085;
}

/* Sidebar con submenús - Diseño Moderno */
.sidebar {
    width: 280px;
    height: 100vh;
    background: var(--gradient-sidebar);
    position: fixed;
    left: 0;
    top: 0;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    transition: width 0.25s ease;
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.sidebar-header {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: rgba(0, 0, 0, 0.15);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 12px;
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(10px);
}

.sidebar-brand {
    font-size: 20px;
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
    color: white;
    letter-spacing: 0.5px;
    font-family: 'Aptos', 'Segoe UI', sans-serif;
    margin: 0;
}

/* Hamburger toggle button inside sidebar */
.sidebar-toggle-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.85);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}
.sidebar-toggle-btn:hover { background: rgba(255,255,255,0.15); }

.sidebar-nav {
    padding: 16px 12px;
}

.nav-group {
    margin-bottom: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    transition: var(--transition);
    border-radius: 10px;
    margin: 4px 0;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    font-family: 'Aptos', 'Segoe UI', sans-serif;
}

.nav-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 4px;
    background: var(--gradient-primary);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.12);
    padding-left: 24px;
    color: white;
}
}

.nav-item:hover::before {
    transform: translateX(0);
}

.nav-item.active {
    background: rgba(255, 255, 255, 0.18);
    color: white;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.nav-item.active::before {
    transform: translateX(0);
}

.nav-item .icon {
    font-size: 20px;
    margin-right: 14px;
    min-width: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.9);
    flex-shrink: 0;
}

.nav-item .icon svg {
    display: block;
    stroke: currentColor;
}

.nav-item .arrow {
    margin-left: auto;
    font-size: 11px;
    transition: transform 0.3s ease;
    opacity: 0.8;
}

.nav-item:hover .arrow {
    opacity: 1;
}

.submenu {
    background: rgba(0, 0, 0, 0.15);
    margin: 4px 0 8px 0;
    padding: 8px 0;
    border-radius: 8px;
    transition: all 0.3s ease;
    overflow: hidden;
    max-height: 500px;
}

.submenu[style*="display: none"] {
    max-height: 0;
    padding: 0;
    margin: 0;
}

.submenu-item {
    display: block;
    padding: 12px 20px 12px 54px;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    transition: all 0.3s ease;
    font-size: 14px;
    border-left: 3px solid transparent;
    position: relative;
}

.submenu-item::before {
    content: '';
    position: absolute;
    left: 36px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    transition: all 0.3s ease;
}

.submenu-item:hover {
    background: rgba(255, 255, 255, 0.1);
    padding-left: 58px;
    color: white;
    border-left-color: rgba(0, 184, 148, 0.8);
}

.submenu-item:hover::before {
    background: var(--secondary-color);
    width: 8px;
    height: 8px;
    box-shadow: 0 0 8px var(--secondary-color);
}

.submenu-item.active {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    font-weight: 600;
    border-left-color: var(--secondary-color);
}

.submenu-item.active::before {
    background: var(--secondary-color);
    width: 8px;
    height: 8px;
    box-shadow: 0 0 10px var(--secondary-color);
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    position: sticky;
    bottom: 0;
    background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.2) 100%);
    backdrop-filter: blur(10px);
}

.btn-logout {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    background: rgba(231, 76, 60, 0.9);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 3px 10px rgba(231, 76, 60, 0.3);
}

.btn-logout:hover {
    background: rgba(192, 57, 43, 1);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(231, 76, 60, 0.5);
}

.btn-logout .icon {
    margin-right: 10px;
    font-size: 18px;
}

/* Dashboard Container */
.dashboard-container {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    margin-left: 280px;
    background: #f5f6fa;
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

/* ========== Responsive table wrapper ========== */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--border-radius);
}

/* ========== Responsive — tablet ========== */
@media (max-width: 768px) {
    .container { padding: 10px; }

    .modal-content {
        width: 95%;
        margin: 10% auto;
        padding: 20px;
    }

    .table { font-size: 12px; }
    .table th, .table td { padding: 8px; }

    .mobile-menu-btn { display: flex !important; }
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease, width 0.25s ease;
        width: 280px !important;
    }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0 !important; padding-top: 64px; }

    .search-toolbar { flex-direction: column; align-items: stretch; }
    .search-box { max-width: 100%; }
    .toolbar-actions { flex-wrap: wrap; }

    .form-grid { grid-template-columns: 1fr !important; }
}

/* ========== Responsive — small phones (<480px) ========== */
@media (max-width: 480px) {
    .container { padding: 6px; }

    .main-content { padding: 12px; }

    .btn { padding: 8px 12px; font-size: 13px; }
    .btn-sm { padding: 5px 10px; font-size: 12px; }

    .table { font-size: 11px; }
    .table th, .table td { padding: 6px 4px; }

    .modal-content { width: 100%; margin: 4% auto; padding: 16px; border-radius: 12px; }

    .card { padding: 16px; }

    .page-header, .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        padding: 12px;
    }

    .header-user { flex-direction: column; gap: 4px; }
}

/* ========== Responsive — tablet landscape ========== */
@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar { width: 220px; }
    .main-content { margin-left: 220px; }
}

/* Grid System */
.row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -15px;
    margin-left: -15px;
    gap: 10px;
}

.col-md-4 {
    flex: 0 0 calc(33.333% - 10px);
    max-width: calc(33.333% - 10px);
}

.col-md-6 {
    flex: 0 0 calc(50% - 10px);
    max-width: calc(50% - 10px);
}

.col-md-12 {
    flex: 0 0 calc(100% - 10px);
    max-width: calc(100% - 10px);
}

@media (max-width: 768px) {
    .col-md-4,
    .col-md-6,
    .col-md-12 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* Modal de confirmación de logout */
.confirmation-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}

.confirmation-modal.open {
    display: flex !important;
}

.confirmation-content {
    background: white;
    border-radius: 12px;
    padding: 30px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.confirmation-content h3 {
    margin: 0 0 15px 0;
    color: var(--primary-color);
    font-size: 24px;
}

.confirmation-content p {
    margin: 0 0 25px 0;
    color: var(--text-muted);
    font-size: 16px;
}

.confirmation-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.confirmation-actions button {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.confirmation-actions .btn-secondary {
    background: #95a5a6;
    color: white;
}

.confirmation-actions .btn-secondary:hover {
    background: #7f8c8d;
}

.confirmation-actions .btn-danger {
    background: var(--danger-color);
    color: white;
}

.confirmation-actions .btn-danger:hover {
    background: #e84118;
}

/* ========== Dark Mode ========== */
[data-theme="dark"] {
    --text-color: #e8eaf0;
    --text-muted: #9aa0ac;
    --border-color: #3d4148;
    --light-color: #2e3138;
    --card-bg: #252830;
    --input-bg: #252830;
    --bg-card: #252830;
    --bg-input: #252830;
    --bg-code: #1e2128;
    --bg-hover: #2e3138;
    --text-primary: #e8eaf0;
    --text-secondary: #9aa0ac;
    --shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.5);
    --loading-overlay-bg: rgba(26, 29, 35, 0.97);
}

[data-theme="dark"] body {
    background: linear-gradient(135deg, #1a1d23 0%, #1e2128 100%);
}

[data-theme="dark"] .main-content {
    background: #1a1d23;
}

[data-theme="dark"] .header,
[data-theme="dark"] .top-header,
[data-theme="dark"] .chart-card,
[data-theme="dark"] .search-toolbar,
[data-theme="dark"] .table-section {
    background: #252830;
}

/* Override inline background: white in page-local <style> blocks */
[data-theme="dark"] .table-section,
[data-theme="dark"] .card-perfil,
[data-theme="dark"] .panel-card { background: var(--card-bg) !important; color: var(--text-color) !important; }

/* Universal table dark mode — covers all page-specific table classes */
[data-theme="dark"] table { background: var(--card-bg); color: var(--text-color); }
[data-theme="dark"] table th { background: #1a2535; color: var(--text-color); border-bottom: 2px solid var(--border-color); }
[data-theme="dark"] table td { border-bottom: 1px solid var(--border-color); color: var(--text-color); }
[data-theme="dark"] table tbody tr:hover { background: #2e3138; }

[data-theme="dark"] .header-title,
[data-theme="dark"] .page-title,
[data-theme="dark"] .chart-title,
[data-theme="dark"] .card-header {
    color: #7ecfcb;
}

[data-theme="dark"] .user-name {
    color: #e8eaf0;
}

[data-theme="dark"] .card,
[data-theme="dark"] .modal-content,
[data-theme="dark"] .confirmation-content {
    background-color: #252830;
    color: var(--text-color);
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .search-input,
[data-theme="dark"] .modal-input {
    background: #2e3138;
    border-color: #3d4148;
    color: var(--text-color);
}

[data-theme="dark"] .modal-input:disabled {
    background: #252830;
}

[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .modal-input:focus {
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(0, 184, 148, 0.15);
}

[data-theme="dark"] .table {
    background-color: #252830;
    color: var(--text-color);
}

[data-theme="dark"] .table th,
[data-theme="dark"] .table td {
    border-bottom-color: #3d4148;
}

[data-theme="dark"] .table tbody tr:hover {
    background: #2e3138;
}

[data-theme="dark"] .table tbody tr.selected {
    background: rgba(0, 184, 148, 0.15);
}

[data-theme="dark"] .tabla-registros {
    background: #252830;
    color: var(--text-color);
}

[data-theme="dark"] .tabla-registros thead {
    background: #2e3138;
}

[data-theme="dark"] .tabla-registros th {
    color: var(--text-color);
    border-bottom-color: #3d4148;
}

[data-theme="dark"] .tabla-registros td {
    border-bottom-color: #3d4148;
}

[data-theme="dark"] .tabla-registros tbody tr:hover {
    background: #2e3138;
}

[data-theme="dark"] .filtros-container {
    background: #252830;
}

[data-theme="dark"] .filtro-grupo label {
    color: var(--text-color);
}

[data-theme="dark"] .filtro-grupo input,
[data-theme="dark"] .filtro-grupo select {
    background: #2e3138;
    border-color: #3d4148;
    color: var(--text-color);
}

[data-theme="dark"] .paginacion button {
    background: #2e3138;
    border-color: #3d4148;
    color: var(--text-color);
}

[data-theme="dark"] .paginacion button:hover,
[data-theme="dark"] .paginacion button.activa {
    background: var(--secondary-color);
    border-color: var(--secondary-color);
    color: white;
}

[data-theme="dark"] .info-paginacion,
[data-theme="dark"] .sin-resultados,
[data-theme="dark"] .estado-carga {
    color: var(--text-muted);
}

[data-theme="dark"] .table-salas {
    background: #252830;
    color: var(--text-color);
}

[data-theme="dark"] .table-salas tbody tr:hover {
    background: #2e3138;
}

[data-theme="dark"] .table-salas tbody tr.selected {
    background: rgba(0, 184, 148, 0.15);
}

[data-theme="dark"] .table-salas td {
    border-bottom-color: #3d4148;
}

[data-theme="dark"] .especial-item {
    background: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .modal-header {
    border-bottom-color: #3d4148;
}

[data-theme="dark"] .modal-title {
    color: #7ecfcb;
}

[data-theme="dark"] .close:hover {
    background: rgba(255, 71, 87, 0.2);
}

[data-theme="dark"] .alert-success {
    background: linear-gradient(135deg, #1a3a2a 0%, #1e3d2f 100%);
    color: #7ecfcb;
}

[data-theme="dark"] .alert-error {
    background: linear-gradient(135deg, #3a1a1a 0%, #3d1e1e 100%);
    color: #ff8080;
}

[data-theme="dark"] .alert-warning {
    background: linear-gradient(135deg, #3a2e00 0%, #3d3200 100%);
    color: #ffc107;
}

[data-theme="dark"] .alert-info {
    background: linear-gradient(135deg, #0a2a3a 0%, #0e2e3d 100%);
    color: #56c8e0;
}

/* Sidebar theme toggle */
.sidebar-theme {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    margin: 8px 12px 12px;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    border-radius: 10px;
    transition: var(--transition);
    font-size: 14px;
    font-weight: 500;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-theme:hover {
    background: rgba(255, 255, 255, 0.12);
    color: white;
}

/* ===== Collapsed sidebar — icon-only (desktop) ===== */
.sidebar.collapsed { width: 64px; }
.sidebar.collapsed .sidebar-brand { display: none; }
.sidebar.collapsed .sidebar-header { justify-content: center; padding: 14px 0; }
.sidebar.collapsed .nav-label { display: none; }
.sidebar.collapsed .arrow { display: none; }
.sidebar.collapsed .submenu { display: none !important; }
.sidebar.collapsed .nav-item { justify-content: center; padding-left: 0; padding-right: 0; }
.sidebar.collapsed .nav-item:hover { padding-left: 0; }
.sidebar.collapsed .icon { margin-right: 0; }
.sidebar.collapsed .sidebar-theme { justify-content: center; padding-left: 0; padding-right: 0; }
body.sidebar-collapsed .main-content { margin-left: 88px; }

/* ===== Sidebar overlay — mobile backdrop ===== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 999;
    backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* ===== Mobile hamburger button (fixed, floating) ===== */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 1100;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
    transition: background 0.2s;
}
.mobile-menu-btn:hover { background: var(--secondary-color); }

.theme-toggle-icon {
    font-size: 18px;
    min-width: 20px;
    display: flex;
    align-items: center;
    color: rgba(255, 255, 255, 0.9);
}

/* ========== Dark Mode Extensions ========== */

/* --- Page containers (white backgrounds in page-local styles) --- */
[data-theme="dark"] .form-container,
[data-theme="dark"] .settings-section,
[data-theme="dark"] .config-section,
[data-theme="dark"] .subpanel-container,
[data-theme="dark"] .familia-buttons,
[data-theme="dark"] .categoria-buttons,
[data-theme="dark"] .control-bar,
[data-theme="dark"] .password-modal-content {
    background: #252830;
    color: var(--text-color);
}

[data-theme="dark"] .grid-section {
    background: #2e3138;
}

/* --- Modal footer (using !important to override inline styles in configurar-salas) --- */
[data-theme="dark"] .modal-footer {
    background: #1e2128 !important;
    border-top-color: #3d4148 !important;
    border-radius: 0 0 12px 12px;
}

[data-theme="dark"] .modal-body {
    color: var(--text-color);
}

[data-theme="dark"] .modal-header {
    border-bottom-color: #3d4148;
}

/* --- Text labels --- */
[data-theme="dark"] .form-group label,
[data-theme="dark"] .form-row label,
[data-theme="dark"] .grid-title,
[data-theme="dark"] .section-title,
[data-theme="dark"] .form-section-title,
[data-theme="dark"] .config-title,
[data-theme="dark"] .control-bar label,
[data-theme="dark"] .modal-message,
[data-theme="dark"] .actions-bar h2,
[data-theme="dark"] .password-modal-title {
    color: var(--text-color);
}

[data-theme="dark"] .section-title {
    border-bottom-color: #3d4148;
}

/* --- Generic form inputs --- */
[data-theme="dark"] .form-group input,
[data-theme="dark"] .form-group select,
[data-theme="dark"] .form-group textarea,
[data-theme="dark"] .form-row input,
[data-theme="dark"] .control-bar select,
[data-theme="dark"] .search-box-modal input,
[data-theme="dark"] .password-modal-form input {
    background: #2e3138;
    border-color: #3d4148;
    color: var(--text-color);
}

[data-theme="dark"] .form-group input:disabled,
[data-theme="dark"] .form-group.readonly input {
    background: #252830;
    color: var(--text-muted);
}

[data-theme="dark"] .btn-show-password {
    background: #2e3138;
    border-color: #3d4148;
    color: var(--text-color);
}

[data-theme="dark"] .btn-show-password:hover {
    background: #3a3f4a;
}

[data-theme="dark"] .action-buttons {
    border-top-color: #3d4148;
}

/* --- Info / Warning / Locked messages --- */
[data-theme="dark"] .info-message {
    background: rgba(10, 42, 58, 0.6);
    border-color: #2196F3;
    color: #82c8f0;
}

[data-theme="dark"] .warning-message {
    background: rgba(58, 46, 0, 0.6);
    border-color: #FF9800;
    color: #ffc107;
}

[data-theme="dark"] .locked-message {
    background: rgba(58, 46, 0, 0.6);
    border-color: #ffc107;
    color: #ffc107;
}

/* --- Generar facturas: loading overlay --- */
[data-theme="dark"] .loading-overlay {
    background: rgba(26, 29, 35, 0.97) !important;
}

[data-theme="dark"] .loading-text {
    color: var(--text-color);
}

[data-theme="dark"] .loading-subtext {
    color: var(--text-muted);
}

/* --- Generar facturas: datos factura block --- */
[data-theme="dark"] .datos-factura {
    background: #2e3138;
}

[data-theme="dark"] .dato-label {
    color: var(--text-muted);
}

[data-theme="dark"] .dato-valor {
    color: var(--text-color);
}

/* --- Generar facturas: mode selector --- */
[data-theme="dark"] .mode-option {
    border-color: #3d4148;
    background: #252830;
    color: var(--text-color);
}

[data-theme="dark"] .mode-option:hover {
    border-color: var(--secondary-color);
    background: rgba(0, 184, 148, 0.08);
}

[data-theme="dark"] .mode-option.active {
    border-color: var(--secondary-color);
    background: rgba(0, 184, 148, 0.15);
}

[data-theme="dark"] .mode-title {
    color: var(--text-color);
}

[data-theme="dark"] .mode-desc {
    color: var(--text-muted);
}

[data-theme="dark"] .form-actions {
    border-top-color: #3d4148;
}

/* --- Generar facturas: result items --- */
[data-theme="dark"] .result-item.success {
    background: rgba(39, 174, 96, 0.2);
    color: #7ecfcb;
}

[data-theme="dark"] .result-item.error {
    background: rgba(231, 76, 60, 0.2);
    color: #ff8080;
}

[data-theme="dark"] .result-item.skipped {
    background: rgba(243, 156, 18, 0.2);
    color: #ffc107;
}

/* --- Generar facturas: facturas table --- */
[data-theme="dark"] .table-facturas {
    background: #252830;
    color: var(--text-color);
}

[data-theme="dark"] .table-facturas td {
    border-bottom-color: #3d4148;
    color: var(--text-color);
}

[data-theme="dark"] .table-facturas tbody tr:hover {
    background: #2e3138;
}

[data-theme="dark"] .badge-real {
    background: rgba(21, 87, 36, 0.4);
    color: #7ecfcb;
}

[data-theme="dark"] .badge-estimado {
    background: rgba(0, 64, 133, 0.4);
    color: #82c8f0;
}

/* --- Contratos: badges + slots tiers table --- */
[data-theme="dark"] .badge-success {
    background: rgba(21, 87, 36, 0.4);
    color: #7ecfcb;
}

[data-theme="dark"] .badge-danger {
    background: rgba(114, 28, 36, 0.4);
    color: #ff8080;
}

[data-theme="dark"] #seccionSlotsTiers thead tr {
    background: #2e3138 !important;
    color: var(--text-color) !important;
}

[data-theme="dark"] #seccionSlotsTiers td,
[data-theme="dark"] #seccionSlotsTiers th {
    border-color: #3d4148 !important;
    color: var(--text-color) !important;
}

[data-theme="dark"] #seccionSlotsTiers input {
    background: #252830 !important;
    border-color: #3d4148 !important;
    color: var(--text-color) !important;
}

/* --- Settings: backup drop zone --- */
[data-theme="dark"] #dropZone {
    border-color: #2196F3;
    background: #1e2128;
}

[data-theme="dark"] #dropZone p {
    color: #82c8f0;
}

[data-theme="dark"] #dropZone:hover,
[data-theme="dark"] #dropZone.dragover {
    background: rgba(33, 150, 243, 0.08);
}

/* --- Config centro: btn-cancel --- */
[data-theme="dark"] .btn-cancel {
    background: #2e3138;
    color: var(--text-color);
}

[data-theme="dark"] .btn-cancel:hover {
    background: #3a3f4a;
}

/* --- All data tables in pages (multiple pages) --- */
[data-theme="dark"] .table-clientes,
[data-theme="dark"] .table-contratos,
[data-theme="dark"] .table-proveedor,
[data-theme="dark"] .table-dispositivos-gen,
[data-theme="dark"] .table-dispositivos-salait,
[data-theme="dark"] .table-salas-cliente {
    background: #252830;
    color: var(--text-color);
}

[data-theme="dark"] .table-clientes td,
[data-theme="dark"] .table-contratos td,
[data-theme="dark"] .table-proveedor td,
[data-theme="dark"] .table-dispositivos-gen td,
[data-theme="dark"] .table-dispositivos-salait td,
[data-theme="dark"] .table-salas-cliente td {
    border-bottom-color: #3d4148;
    color: var(--text-color);
}

[data-theme="dark"] .table-clientes tbody tr:hover,
[data-theme="dark"] .table-contratos tbody tr:hover,
[data-theme="dark"] .table-proveedor tbody tr:hover,
[data-theme="dark"] .table-dispositivos-gen tbody tr:hover,
[data-theme="dark"] .table-dispositivos-salait tbody tr:hover,
[data-theme="dark"] .table-salas-cliente tbody tr:hover {
    background: #2e3138;
}

[data-theme="dark"] .table-clientes tbody tr.selected,
[data-theme="dark"] .table-contratos tbody tr.selected,
[data-theme="dark"] .table-proveedor tbody tr.selected,
[data-theme="dark"] .table-dispositivos-gen tbody tr.selected,
[data-theme="dark"] .table-dispositivos-salait tbody tr.selected,
[data-theme="dark"] .table-salas-cliente tbody tr.selected {
    background: rgba(0, 184, 148, 0.15);
}

[data-theme="dark"] .table-salas-cliente thead {
    background: #2e3138;
}

[data-theme="dark"] .table-salas-cliente th {
    color: var(--text-color);
    border-bottom-color: #3d4148;
}

/* --- btn-familia / btn-categoria (dispositivos-generales, configurar-salas) --- */
[data-theme="dark"] .btn-familia,
[data-theme="dark"] .btn-categoria {
    background: #252830;
    border-color: #3d4148;
    color: var(--text-color);
}

[data-theme="dark"] .btn-familia:hover,
[data-theme="dark"] .btn-categoria:hover {
    background: #2e3138;
}

/* --- Sidebar dark mode --- */
[data-theme="dark"] .sidebar {
    background: linear-gradient(180deg, #12151c 0%, #1a1e28 100%);
}

/* --- Modal editar dispositivo (configurar-salas) — inline styles override --- */
[data-theme="dark"] #modalEditarDispositivo .modal-footer {
    background: #1e2128 !important;
    border-top-color: #3d4148 !important;
}
[data-theme="dark"] #formEditarDispositivo input:disabled,
[data-theme="dark"] #formEditarDispositivo input[disabled] {
    background: #252830 !important;
    color: var(--text-muted) !important;
    border-color: #3d4148 !important;
}
[data-theme="dark"] #formEditarDispositivo select {
    background: #2e3138;
    border-color: #3d4148 !important;
    color: var(--text-color);
}
[data-theme="dark"] #formEditarDispositivo label {
    color: var(--text-color);
}
/* Also fix the asociar modal side select in configurar-salas */
[data-theme="dark"] #sideSelect {
    background: #2e3138;
    border-color: #3d4148 !important;
    color: var(--text-color);
}

/* ========== Utility — dark-mode-safe text helpers ========== */
.text-hint    { color: var(--text-muted); }
.text-hint-sm { color: var(--text-muted); font-size: 12px; }
.text-body    { color: var(--text-color); }
.text-success-accent { color: var(--success-color); }
.text-danger-accent  { color: var(--danger-color); }
.text-info-accent    { color: var(--info-color); }

/* Progress bar track (dark-mode safe) */
.progress-track {
    width: 100%;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    margin-top: 10px;
}

/* Section heading inside cards (replaces inline color: #2c3e50) */
.section-heading {
    color: var(--text-color);
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 15px;
}

/* ========== Search Toolbar (shared component) ========== */
.search-toolbar {
    display: flex;
    gap: 15px;
    align-items: center;
    padding: 20px;
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-box {
    flex: 1;
    min-width: 200px;
    max-width: 600px;
}

.search-input {
    width: 100%;
    padding: 12px 20px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    background: var(--input-bg);
    color: var(--text-color);
    transition: var(--transition);
}

.search-input:focus {
    outline: none;
    border-color: var(--info-color);
    box-shadow: 0 0 0 3px rgba(30, 144, 255, 0.1);
}

.search-input::placeholder {
    color: var(--text-muted);
}

.toolbar-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ── Notificaciones bell ───────────────────────────────────────────────────── */
.notif-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    margin-right: 8px;
}

.notif-btn {
    position: relative;
    background: none;
    border: none;
    color: rgba(255,255,255,0.75);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    transition: background 0.15s, color 0.15s;
}

.notif-btn:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.notif-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    background: #e53e3e;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    pointer-events: none;
}

.notif-dropdown {
    position: fixed;
    width: 320px;
    background: #1e293b;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    z-index: 9999;
    overflow: hidden;
}

.notif-header {
    padding: 12px 16px;
    font-weight: 700;
    font-size: 14px;
    color: #e2e8f0;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.notif-list {
    max-height: 360px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.2) transparent;
}
.notif-list::-webkit-scrollbar { width: 4px; }
.notif-list::-webkit-scrollbar-track { background: transparent; }
.notif-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 2px; }

.notif-empty {
    padding: 24px 16px;
    text-align: center;
    color: rgba(200,220,255,0.5);
    font-size: 13px;
}

.notif-item {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    transition: background 0.1s;
}

.notif-item:last-child { border-bottom: none; }

.notif-item:hover { background: rgba(255,255,255,0.05); }

.notif-item.leida { opacity: 0.45; }

.notif-msg {
    font-size: 13px;
    color: #cbd5e1;
    line-height: 1.45;
    margin-bottom: 6px;
}

.notif-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.notif-fecha {
    font-size: 11px;
    color: rgba(200,220,255,0.45);
}

.notif-actions { display: flex; gap: 8px; }

.notif-act-btn {
    background: none;
    border: none;
    font-size: 11px;
    cursor: pointer;
    color: #7dd3fc;
    padding: 2px 4px;
    border-radius: 4px;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.notif-act-btn:hover { opacity: 0.7; }
.notif-act-borrar { color: #e53e3e; }

/* Indicador fortaleza contraseña */
.pwd-strength {
    font-size: 12px;
    margin-top: 4px;
    font-weight: 600;
}
.pwd-strength.debil  { color: #e53e3e; }
.pwd-strength.media  { color: #d97706; }
.pwd-strength.fuerte { color: #38a169; }
