@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    /* Fonts */
    --font-main: 'Inter', sans-serif;
    --font-heading: 'Outfit', sans-serif;

    /* Theme colors: Light Mode */
    --bg-dark: #f1f5f9;
    --bg-card: #ffffff;
    --bg-sidebar: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    --text-main: #0f172a;
    --text-muted: #475569;
    --border: #cbd5e1;
    --border-hover: #94a3b8;
    
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --primary-focus: rgba(99, 102, 241, 0.15);
    
    --secondary: #10b981;
    --secondary-dark: #059669;
    --secondary-focus: rgba(16, 185, 129, 0.15);
    
    --danger: #ef4444;
    --danger-dark: #dc2626;
    
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(255, 255, 255, 0.5);
    
    --shadow: 0 4px 20px rgba(15, 23, 42, 0.05), 0 8px 30px rgba(15, 23, 42, 0.05);
    --shadow-hover: 0 12px 35px rgba(15, 23, 42, 0.1);
    
    --radius: 16px;
    --radius-sm: 8px;
    --radius-md: 12px;
    
    --input-bg: #f8fafc;
}

[data-theme="dark"] {
    /* Theme colors: Dark Mode (Antigravity Space Dark style) */
    --bg-dark: #07090e;
    --bg-card: rgba(13, 17, 28, 0.7); /* Matte transparent glass */
    --bg-sidebar: #090b11; /* Flat matte space sidebar */
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(99, 102, 241, 0.35);
    
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --primary-focus: rgba(99, 102, 241, 0.25);
    
    --secondary: #00f5ff; /* Glowing Cyber Cyan */
    --secondary-dark: #00d8e2;
    --secondary-focus: rgba(0, 245, 255, 0.25);
    
    --danger: #ff4b60;
    --danger-dark: #e11d48;
    
    --glass-bg: rgba(13, 17, 28, 0.85);
    --glass-border: rgba(255, 255, 255, 0.06);
    
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    --shadow-hover: 0 15px 40px rgba(99, 102, 241, 0.18), 0 5px 15px rgba(0, 0, 0, 0.5);
    
    --input-bg: #111625;
}

/* Modo Web: ocultar la barra de título de escritorio (Electron) */
body.web-mode .app-titlebar { display: none; }
body.web-mode .app-container { margin-top: 0; height: 100vh; }
body.web-mode .auth-overlay { top: 0; height: 100vh; }

/* Custom Titlebar */
.app-titlebar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 36px;
    background: #e2e8f0;
    border-bottom: 1px solid var(--border);
    color: var(--text-main);
    user-select: none;
    -webkit-app-region: drag;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 9999;
    padding-left: 15px;
    box-sizing: border-box;
    font-family: var(--font-heading);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .app-titlebar {
    background: #05070a;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}

.titlebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.titlebar-logo {
    width: 22px;
    height: 22px;
    object-fit: contain;
    border-radius: 4px;
    background: white;
    padding: 2px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.titlebar-title {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: var(--text-main);
}

.titlebar-controls {
    display: flex;
    height: 100%;
    -webkit-app-region: no-drag;
}

.titlebar-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    width: 48px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 13px;
    transition: background-color 0.25s, color 0.25s;
}

.titlebar-btn:hover {
    background-color: rgba(0, 0, 0, 0.06);
    color: var(--text-main);
}

[data-theme="dark"] .titlebar-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.titlebar-btn.close:hover {
    background-color: #ff4b60 !important;
    color: white !important;
}

.form-card {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden;
    font-family: var(--font-main);
    transition: background-color 0.3s ease, color 0.3s ease;
}

.app-container {
    display: flex;
    height: calc(100vh - 36px);
    margin-top: 36px;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    color: white;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 25px rgba(0, 0, 0, 0.15);
    z-index: 10;
    border-right: 1px solid var(--border);
    overflow-y: hidden;
}

.sidebar-header {
    padding: 30px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
    font-family: var(--font-heading);
    font-weight: 700;
    letter-spacing: 0.5px;
}

.logo-icon {
    font-size: 28px;
    background: rgba(255, 255, 255, 0.1);
    padding: 10px;
    border-radius: 50%;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    gap: 4px;
    overflow-y: auto;
    flex-grow: 1;
}

.nav-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.65);
    padding: 14px 22px;
    text-align: left;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    gap: 12px;
    border-left: 3px solid transparent;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin-right: 15px;
}

.nav-btn i {
    font-size: 16px;
    width: 20px;
    text-align: center;
    transition: transform 0.25s ease;
}

.nav-btn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.05);
}

.nav-btn:hover i {
    transform: translateX(2px);
}

.nav-btn.active {
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.15) 0%, rgba(99, 102, 241, 0.02) 100%);
    color: var(--primary-light);
    border-left-color: var(--primary-light);
    font-weight: 600;
}

[data-theme="dark"] .nav-btn.active {
    color: #818cf8;
    border-left-color: #818cf8;
}

/* Main Content */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
    position: relative;
    background-color: var(--bg-dark);
}

.view-section {
    display: none;
    animation: fadeIn 0.45s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

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

.header-glass {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    padding: 22px 28px;
    border-radius: var(--radius);
    margin-bottom: 25px;
    box-shadow: var(--shadow);
}

.header-glass h1 {
    font-family: var(--font-heading);
    font-size: 28px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 4px;
    letter-spacing: -0.5px;
}

.header-glass p {
    color: var(--text-muted);
    font-size: 14px;
}

/* Forms & Cards */
.form-grid,
.config-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
}

.span-2 {
    grid-column: span 2;
}

.card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
    border-color: var(--border-hover);
}

.card h3 {
    margin-bottom: 20px;
    color: var(--text-main);
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 18px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card h3 i {
    color: var(--primary-light);
}

.input-group {
    margin-bottom: 18px;
    display: flex;
    flex-direction: column;
    position: relative;
}

.input-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.input-row.align-bottom {
    align-items: flex-end;
}

label {
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--text-main);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

label i {
    margin-right: 4px;
    color: var(--text-muted);
}

input,
select,
textarea {
    padding: 11px 15px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 15px;
    color: var(--text-main);
    transition: all 0.25s ease;
    background: var(--input-bg);
    font-family: var(--font-main);
}

input::placeholder,
select::placeholder {
    color: var(--text-muted);
    opacity: 0.5;
}

/* Custom select: quitamos la flecha nativa y ponemos una propia */
select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    /* deja espacio a la derecha para que el texto no choque con la flecha */
    padding-right: 40px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 16px;
    cursor: pointer;
}

select::-ms-expand {
    display: none;
}

/* Las opciones del desplegable nativo */
select option {
    background: var(--bg-card);
    color: var(--text-main);
    padding: 10px 12px;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px var(--primary-focus);
    background-color: var(--bg-card);
}

input:disabled,
select:disabled,
textarea:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--border);
}

/* Buttons */
.btn {
    padding: 11px 22px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 600;
    font-family: var(--font-heading);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
}

.btn:hover {
    transform: translateY(-2px);
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.2);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.35);
}

.btn-secondary {
    background: linear-gradient(135deg, var(--secondary) 0%, var(--secondary-dark) 100%);
    color: #07090e;
    box-shadow: 0 4px 15px rgba(0, 245, 255, 0.15);
}

[data-theme="dark"] .btn-secondary {
    color: #07090e;
    box-shadow: 0 4px 15px rgba(0, 245, 255, 0.3);
}

.btn-secondary:hover {
    background: linear-gradient(135deg, var(--secondary-dark) 0%, var(--secondary) 100%);
    box-shadow: 0 6px 20px rgba(0, 245, 255, 0.4);
}

.btn-neutral {
    background: var(--border);
    color: var(--text-main);
}

.btn-neutral:hover {
    background: var(--border-hover);
    box-shadow: 0 4px 12px rgba(120, 120, 120, 0.1);
}

.btn-danger {
    background: var(--danger);
    color: white;
    padding: 10px 18px;
    font-size: 14px;
}

.btn-danger:hover {
    background: var(--danger-dark);
    box-shadow: 0 4px 12px rgba(255, 75, 96, 0.25);
}

.btn-icon {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 15px;
    color: var(--primary-light);
    padding: 8px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: rgba(99, 102, 241, 0.1);
}

.btn-icon.delete {
    color: var(--danger);
}

.btn-icon.delete:hover {
    background: rgba(255, 75, 96, 0.15);
}

/* Utilities */
.mt-2 {
    margin-top: 15px;
}

.mt-3 {
    margin-top: 25px;
}

.action-bar {
    margin-top: 25px;
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    background: transparent;
}

/* Search results */
.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    max-height: 220px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: var(--shadow-hover);
    display: none;
    margin-top: 5px;
}

.search-item {
    padding: 12px 18px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    color: var(--text-main);
    font-size: 15px;
    transition: background-color 0.2s ease;
}

.search-item:hover {
    background: var(--input-bg);
}

.search-item:last-child {
    border-bottom: none;
}

/* Lists */
.item-list {
    list-style: none;
}

.item-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 18px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
    color: var(--text-main);
}

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

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

.modern-table th,
.modern-table td {
    padding: 16px 20px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    color: var(--text-main);
}

.modern-table th {
    background: var(--input-bg);
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 13px;
    letter-spacing: 0.8px;
}

.modern-table td {
    font-size: 15px;
}

.modern-table tbody tr {
    transition: background-color 0.2s ease;
}

.modern-table tbody tr:hover {
    background: rgba(120, 120, 120, 0.03);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 36px;
    left: 0;
    width: 100%;
    height: calc(100vh - 36px);
    background: rgba(0, 0, 0, 0.45);
    z-index: 1000;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--glass-bg);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-radius: var(--radius);
    padding: 35px;
    width: 90%;
    max-width: 650px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--shadow-hover);
    border: 1px solid var(--glass-border);
    animation: modalSlideUp 0.45s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

[data-theme="dark"] .modal-content {
    background: rgba(15, 20, 32, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(99, 102, 241, 0.15);
}

.modal-body {
    max-height: 70vh;
    overflow-y: auto;
    overflow-x: hidden;
    width: 100%;
    padding: 10px;
    margin-top: 15px;
    box-sizing: border-box;
}

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

.modal-content.large {
    max-width: 950px;
    height: 80vh;
    display: flex;
    flex-direction: column;
}

.close-modal {
    position: absolute;
    top: 25px;
    right: 25px;
    font-size: 26px;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.2s ease;
}

.close-modal:hover {
    color: var(--text-main);
}

.preview-container {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin: 20px 0;
    overflow: hidden;
    background: #333336;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 4px 12px rgba(0, 0, 0, 0.15);
}

.preview-container iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: white;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 35px;
    right: 35px;
    background: var(--text-main);
    color: var(--bg-card);
    padding: 14px 28px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-hover);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 10000;
    font-weight: 500;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Checkbox List */
.checkbox-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 160px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 18px;
    background: var(--input-bg);
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-size: 15px;
    color: var(--text-main);
}

.checkbox-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary);
}

/* Receipt Button */
.btn-receipt {
    background: linear-gradient(135deg, #eab308 0%, #ca8a04 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(234, 179, 8, 0.25);
}

.btn-receipt:hover {
    background: linear-gradient(135deg, #facc15 0%, #a16207 100%);
    box-shadow: 0 6px 20px rgba(234, 179, 8, 0.4);
}

/* Receipt Modal - data table */
.recibo-data-table {
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.recibo-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border-bottom: 1px solid var(--border);
}

.recibo-row:last-child {
    border-bottom: none;
}

.recibo-cell {
    padding: 12px 18px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    border-right: 1px solid var(--border);
}

.recibo-cell:last-child {
    border-right: none;
}

.recibo-cell-full {
    grid-column: span 1;
}

.recibo-cell-folio {
    align-items: flex-start;
}

.recibo-label {
    font-size: 9.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
}

.recibo-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.4;
}

.recibo-folio-badge {
    background: linear-gradient(135deg, #7c3aed, #5b21b6);
    color: white !important;
    padding: 2px 12px;
    border-radius: 20px;
    font-size: 12px;
    display: inline-block;
    margin-top: 3px;
    font-weight: 700;
}

.monto-card {
    background: rgba(124, 58, 237, 0.04);
    border: 1px dashed rgba(124, 58, 237, 0.3);
    border-radius: var(--radius);
    padding: 25px 20px;
    text-align: center;
    width: 100%;
}

.monto-icon {
    font-size: 32px;
    color: #7c3aed;
    margin-bottom: 10px;
    display: block;
}

.monto-label {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.monto-input-wrapper {
    display: flex;
    align-items: center;
    border: 2px solid #7c3aed80;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-card);
    margin-bottom: 10px;
    box-shadow: var(--shadow-inset);
    transition: border-color 0.2s ease;
}

.monto-input-wrapper:focus-within {
    border-color: #7c3aed;
}

.monto-prefix {
    padding: 12px 16px;
    background: #7c3aed;
    color: white;
    font-size: 20px;
    font-weight: 700;
}

.monto-input {
    border: none !important;
    border-radius: 0 !important;
    font-size: 22px !important;
    font-weight: 700 !important;
    color: var(--text-main) !important;
    text-align: right;
    flex: 1;
    padding: 12px 16px !important;
    background: transparent !important;
}

.monto-input:focus {
    box-shadow: none !important;
}

.monto-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0;
}

/* Table card */
.table-card {
    padding: 0;
    overflow: hidden;
}

.table-card .table-responsive {
    padding: 0;
}

.table-card .modern-table th:first-child {
    padding-left: 30px;
}

.table-card .modern-table td:first-child {
    padding-left: 30px;
}

/* Authentication Overlay */
.auth-overlay {
    position: fixed;
    top: 36px;
    left: 0;
    width: 100vw;
    height: calc(100vh - 36px);
    background:
        radial-gradient(circle at 20% 20%, rgba(99, 102, 241, 0.25) 0%, transparent 45%),
        radial-gradient(circle at 80% 80%, rgba(16, 185, 129, 0.20) 0%, transparent 45%),
        linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--radius);
    padding: 45px;
    width: 450px;
    max-width: 90%;
    box-shadow: var(--shadow-hover);
    animation: authFadeIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    color: var(--text-main);
}

.auth-error-alert {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #f87171;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-bottom: 25px;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    line-height: 1.4;
    animation: authFadeIn 0.3s ease;
}

@keyframes authFadeIn {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(15px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.auth-brand {
    text-align: center;
    margin-bottom: 30px;
}

.auth-logo {
    width: 80px;
    height: 80px;
    object-fit: contain;
    border-radius: var(--radius-md);
    margin-bottom: 15px;
    box-shadow: var(--shadow);
}

.auth-brand h2 {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 6px;
    font-family: var(--font-heading);
}

.auth-brand p {
    color: var(--text-muted);
    font-size: 14px;
}

.auth-card .input-group label {
    color: var(--text-main);
    font-size: 13px;
}

.auth-card input,
.auth-card select {
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--text-main);
    font-size: 16px;
    padding: 12px 16px;
}

.auth-card input::placeholder {
    color: var(--text-muted);
    opacity: 0.5;
}

.auth-card input:focus {
    background: var(--bg-card);
    border-color: var(--primary);
    color: var(--text-main);
}

.auth-card .btn-primary {
    background: var(--primary);
    width: 100%;
}

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

.w-100 {
    width: 100%;
}

/* Service Calendar */
.cal-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    margin: 16px 0;
    font-size: 13px;
    color: var(--text-muted);
}

.cal-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.cal-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.cal-dot-upcoming { background: var(--primary); }
.cal-dot-overdue { background: var(--danger); }
.cal-dot-done { background: #16a34a; }

.cal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.cal-nav-btn {
    padding: 8px 14px;
}

/* Month list */
.month-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.month-item {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    background: var(--bg-card);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    transition: transform 0.12s ease, border-color 0.12s ease;
    color: var(--text-main);
}

.month-item:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
}

.month-item.month-selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary) inset;
    background: rgba(37, 99, 235, 0.08);
}

.month-name {
    font-weight: 700;
    font-size: 14px;
}

.month-badges {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.month-badge {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.mb-upcoming { background: var(--primary); }
.mb-overdue { background: var(--danger); }
.mb-done { background: #16a34a; }
.month-empty { color: var(--text-muted); font-size: 13px; }

.cal-service-item {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    background: var(--bg-hover);
    flex-wrap: wrap;
}

.cal-service-item.is-overdue { border-left: 4px solid var(--danger); }
.cal-service-item.is-upcoming { border-left: 4px solid var(--primary); }
.cal-service-item.is-done { border-left: 4px solid #16a34a; opacity: 0.85; }

/* Password field with show/hide toggle */
.password-field {
    position: relative;
    display: flex;
    align-items: center;
}

.password-field input {
    width: 100%;
    padding-right: 44px !important;
}

.toggle-password {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px 8px;
    font-size: 15px;
    line-height: 1;
    border-radius: 6px;
    transition: color 0.15s ease, background 0.15s ease;
}

.toggle-password:hover {
    color: var(--primary);
    background: rgba(0, 0, 0, 0.05);
}

/* Auth helper links (forgot password, back, etc.) */
.auth-link-row {
    text-align: right;
    margin-top: 8px;
}

.auth-link {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-size: 13px;
    padding: 4px 2px;
    text-decoration: none;
}

.auth-link:hover {
    text-decoration: underline;
    color: var(--primary-light);
}

/* Sidebar user section at bottom */
.sidebar-footer {
    margin-top: auto;
    border-top: 1px solid var(--border);
    padding: 15px 0 15px 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: rgba(0, 0, 0, 0.05);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 25px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--secondary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.2);
    font-family: var(--font-heading);
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    font-size: 15px;
    color: white;
}

.nav-btn-footer {
    padding: 12px 25px;
    font-size: 15px;
    color: rgba(255, 255, 255, 0.7) !important;
}

.nav-btn-footer:hover {
    color: white !important;
}

/* Theme toggle capsule switch styling */
.theme-switch {
    width: 50px;
    height: 28px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 100px;
    position: relative;
    cursor: pointer;
    transition: background-color 0.3s, border-color 0.3s;
    display: flex;
    align-items: center;
    padding: 2px;
}

.theme-switch-thumb {
    width: 22px;
    height: 22px;
    background: white;
    border-radius: 50%;
    position: absolute;
    left: 2px;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.25s;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.theme-switch-thumb i {
    font-size: 12px;
    color: #1e1b4b; /* deep indigo */
    transition: color 0.25s, transform 0.25s;
}

/* Dark mode switch styling */
[data-theme="dark"] .theme-switch {
    background: rgba(0, 0, 0, 0.4);
    border-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .theme-switch-thumb {
    transform: translateX(22px);
    background: #0f172a;
}

[data-theme="dark"] .theme-switch-thumb i {
    color: #00f5ff;
    transform: rotate(180deg);
}

/* Clickable back indicator disabled - logo remains static */
.sidebar-header .sidebar-back-indicator {
    display: none !important;
}

@keyframes pulseLeft {
    from { transform: translateX(0); }
    to { transform: translateX(-4px); }
}

/* Configuration layout with tabs */
.config-sub-view {
    animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.sidebar-nav-title {
    font-size: 11px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 1.2px;
    padding: 10px 25px;
    text-transform: uppercase;
}

/* Shake animation for password inputs */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}

.shake {
    animation: shake 0.4s ease;
    border-color: var(--danger) !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2) !important;
}

/* Password error label */
.error-msg {
    color: var(--danger);
    font-size: 13px;
    font-weight: 500;
    margin-top: 5px;
    display: block;
}

/* Auto backup form adjustments */
.backup-section-layout {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.switch-group {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.switch-group input[type="checkbox"] {
    width: 22px;
    height: 22px;
    cursor: pointer;
    accent-color: var(--primary);
}

/* Highlighted Search Bars */
.search-card {
    background: var(--bg-card) !important;
    border: 2px solid var(--border) !important;
    border-radius: var(--radius-md) !important;
    padding: 15px 25px !important;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease !important;
    margin-bottom: 25px !important;
    box-shadow: var(--shadow) !important;
}
.search-card:focus-within {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 4px var(--primary-focus), var(--shadow) !important;
    transform: translateY(-1px) !important;
}

/* Dashboard Bento Grid Layout */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 24px;
    margin-bottom: 30px;
}
.bento-stats {
    grid-column: span 8;
}
.bento-quick-actions {
    grid-column: span 4;
    grid-row: span 2;
    display: flex;
    flex-direction: column;
}
.bento-chart {
    grid-column: span 8;
}

.stats-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    height: calc(100% - 60px);
}
.stat-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.stat-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}
.stat-icon-wrapper {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}
.stat-icon-wrapper.blue {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
}
.stat-icon-wrapper.green {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}
.stat-icon-wrapper.purple {
    background: rgba(139, 92, 246, 0.15);
    color: #8b5cf6;
}
.stat-icon-wrapper.orange {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.stat-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.stat-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-main);
    font-family: var(--font-heading);
}

/* Progress List for Products chart */
.progress-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.progress-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.progress-header {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    font-weight: 500;
}
.progress-name {
    color: var(--text-main);
}
.progress-percentage {
    color: var(--text-muted);
    font-weight: 600;
}
.progress-bar-container {
    height: 8px;
    background: var(--input-bg);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border);
}
.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: 10px;
    width: 0;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Quick Actions Tile Grid */
.bento-quick-actions h3 {
    margin-bottom: 20px;
}
.quick-actions-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1;
    justify-content: center;
}
.action-tile {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px 24px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    text-align: left;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-main);
}
.action-tile i {
    font-size: 20px;
    color: var(--primary);
    transition: transform 0.2s ease;
}
.action-tile span {
    font-size: 16px;
    font-weight: 600;
    font-family: var(--font-heading);
}
.action-tile:hover {
    background: var(--bg-card);
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}
.action-tile:hover i {
    transform: scale(1.15);
}
.action-tile:active {
    transform: translateY(0);
}

@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    .bento-stats, .bento-quick-actions, .bento-chart {
        grid-column: span 1;
        grid-row: auto;
    }
    .stats-container {
        grid-template-columns: 1fr;
    }
}

/* Custom Redesign Follow-ups */

/* 1. Control De alignment grid */
.add-option-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 15px;
    align-items: flex-end;
}

/* 2. Custom File Upload Container */
.custom-file-upload {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 6px;
    transition: all 0.25s ease;
}

.custom-file-upload:focus-within {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px var(--primary-focus);
}

.file-name-span {
    color: var(--text-muted);
    font-size: 13.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 250px;
    font-weight: 500;
}

/* 3. Theme Toggle Rotation transition */
.theme-switch-thumb i {
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), color 0.3s ease;
}

/* 4. Custom Confirm Modal borders */
#custom-confirm-modal .modal-content {
    border: 1px solid var(--border-hover);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

/* 5. Document Preview Container Iframe */
#preview-container iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
}
/* Locked data chips inside the contract template editor */
.tpl-chip {
    display: inline-block;
    background: var(--primary, #2563eb);
    color: #fff;
    font-weight: 600;
    font-size: 0.78em;
    letter-spacing: 0.3px;
    padding: 1px 9px;
    margin: 0 2px;
    border-radius: 11px;
    white-space: nowrap;
    user-select: none;
    cursor: default;
    vertical-align: baseline;
}

/* ============================================================
   ===== TEMA PREMIUM UNIFICADO (look del panel de debug) =====
   Iguala toda la app al diseño oscuro de vidrio del Debug Console.
   Paleta base: #11141c, bordes rgba(255,255,255,.12), radio 12px.
   ============================================================ */

/* Paleta afinada para que coincida con el panel de debug */
[data-theme="dark"] {
    --bg-dark: #0b0e14;
    --bg-card: rgba(23, 27, 36, 0.72);
    --bg-sidebar: rgba(17, 20, 28, 0.96);
    --text-main: #e6e9ef;
    --text-muted: #9aa0aa;
    --border: rgba(255, 255, 255, 0.12);
    --border-hover: rgba(255, 255, 255, 0.22);
    --glass-bg: rgba(17, 20, 28, 0.88);
    --glass-border: rgba(255, 255, 255, 0.10);
    --shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
    --shadow-hover: 0 18px 50px rgba(0, 0, 0, 0.55);
    --radius: 12px;
    --radius-md: 10px;
    --radius-sm: 8px;
    --input-bg: rgba(255, 255, 255, 0.04);
}

/* Fondo general: degradado oscuro premium (igual que la pantalla de login) */
[data-theme="dark"] body {
    background:
        radial-gradient(circle at 18% 12%, rgba(99, 102, 241, 0.14) 0%, transparent 42%),
        radial-gradient(circle at 85% 88%, rgba(16, 185, 129, 0.10) 0%, transparent 45%),
        linear-gradient(135deg, #0b0e14 0%, #11141c 60%, #0d1018 100%);
}
[data-theme="dark"] .main-content { background: transparent; }
[data-theme="dark"] .app-container { background: transparent; }

/* Tarjetas y paneles: vidrio translúcido con blur */
[data-theme="dark"] .card,
[data-theme="dark"] .header-glass,
[data-theme="dark"] .modal-content,
[data-theme="dark"] .search-card,
[data-theme="dark"] .table-card,
[data-theme="dark"] .stat-item,
[data-theme="dark"] .action-tile,
[data-theme="dark"] .monto-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow);
}
[data-theme="dark"] .card:hover,
[data-theme="dark"] .stat-item:hover,
[data-theme="dark"] .action-tile:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-hover);
}

/* Encabezado de sección como la barra de header del debug */
[data-theme="dark"] .header-glass {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
}

/* Sidebar: panel sólido oscuro con borde sutil */
[data-theme="dark"] .sidebar {
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    box-shadow: none;
}
[data-theme="dark"] .sidebar-header,
[data-theme="dark"] .sidebar-footer { border-color: var(--border); }

/* Item de menú activo/hover con acento verde como el punto del debug */
[data-theme="dark"] .nav-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}
[data-theme="dark"] .nav-btn.active {
    background: rgba(105, 219, 124, 0.10);
    color: #fff;
    border-left-color: #69db7c;
}
[data-theme="dark"] .nav-btn.active i { color: #69db7c; }

/* Inputs / selects / textareas: campos de vidrio */
[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-main);
}
[data-theme="dark"] input:focus,
[data-theme="dark"] textarea:focus {
    border-color: rgba(255, 255, 255, 0.28);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.06);
    background: rgba(255, 255, 255, 0.06);
}

/* Flecha clara para el tema oscuro */
[data-theme="dark"] select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 16px;
}
/* mantener la flecha al enfocar (el background cambia en :focus) */
[data-theme="dark"] select:focus {
    border-color: rgba(255, 255, 255, 0.28);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.06);
    background-color: rgba(255, 255, 255, 0.06);
}
[data-theme="dark"] select option {
    background: #111625;
    color: var(--text-main);
}

/* Botones secundarios/neutros: estilo "vidrio" idéntico a los del debug */
[data-theme="dark"] .btn-neutral,
[data-theme="dark"] .btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border);
    color: var(--text-main);
    box-shadow: none;
    background-image: none;
}
[data-theme="dark"] .btn-neutral:hover,
[data-theme="dark"] .btn-secondary:hover {
    background: rgba(255, 255, 255, 0.16);
    border-color: var(--border-hover);
    box-shadow: none;
    background-image: none;
}

/* Botón primario: mantiene acento índigo pero más plano y elegante */
[data-theme="dark"] .btn-primary {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    border: 1px solid rgba(129, 140, 248, 0.4);
    box-shadow: 0 6px 18px rgba(99, 102, 241, 0.25);
}

/* Botones de icono */
[data-theme="dark"] .btn-icon {
    color: #b197fc;
    border-radius: var(--radius-sm);
}
[data-theme="dark"] .btn-icon:hover { background: rgba(255, 255, 255, 0.08); }

/* Tablas: encabezado translúcido y filas con separadores sutiles */
[data-theme="dark"] .modern-table th {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}
[data-theme="dark"] .modern-table td { border-bottom: 1px solid var(--border); }
[data-theme="dark"] .modern-table tbody tr:hover { background: rgba(255, 255, 255, 0.04); }

/* Modal: sombra y borde como el panel del debug */
[data-theme="dark"] .modal-content {
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6);
    border: 1px solid var(--border);
}
[data-theme="dark"] .modal { background: rgba(0, 0, 0, 0.55); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }

/* Barras de progreso con acento */
[data-theme="dark"] .progress-bar-container { background: rgba(255, 255, 255, 0.08); }
[data-theme="dark"] .progress-bar-fill { background: linear-gradient(90deg, #69db7c, #4dd4ac); }

/* Scrollbars finas estilo consola */
[data-theme="dark"] ::-webkit-scrollbar { width: 10px; height: 10px; }
[data-theme="dark"] ::-webkit-scrollbar-track { background: transparent; }
[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    border: 2px solid transparent;
    background-clip: padding-box;
}
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.22); background-clip: padding-box; }

/* ===== Sidebar flotante de vidrio (coherente con las tarjetas) ===== */
[data-theme="dark"] .sidebar {
    margin: 14px 0 14px 14px;
    border-radius: 18px;
    background: rgba(23, 27, 36, 0.60);
    border: 1px solid var(--border);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow);
    overflow: hidden;
}

/* Encabezado y pie de la sidebar: separadores sutiles */
[data-theme="dark"] .sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border);
}
[data-theme="dark"] .sidebar-footer {
    border-top: 1px solid var(--border);
}

/* Botones de navegación: redondeados, con margen, sin barra cuadrada */
[data-theme="dark"] .nav-btn,
[data-theme="dark"] .nav-btn-footer {
    margin: 4px 12px;
    padding: 12px 16px;
    border-left: 0;
    border-radius: 12px;
    width: auto;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(255, 255, 255, 0.015);
    transition: all 0.2s ease;
}
[data-theme="dark"] .nav-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.15);
    border-left: 0;
    transform: translateX(2px);
}
[data-theme="dark"] .nav-btn.active {
    background: rgba(105, 219, 124, 0.10);
    border-color: rgba(105, 219, 124, 0.35);
    border-left: 0;
    box-shadow: inset 0 0 0 1px rgba(105, 219, 124, 0.15);
}
[data-theme="dark"] .nav-btn.active i { color: #69db7c; }

/* Logo de la sidebar más suave */
[data-theme="dark"] .logo-icon {
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.06);
}

/* ============================================================
   ===== TEMA CLARO: mismo lenguaje premium (suave/redondeado) =====
   ============================================================ */
[data-theme="light"] {
    --bg-dark: #eef2f7;
    --border: #d8dee8;
    --border-hover: #b8c2d4;
    --radius: 14px;
    --radius-md: 12px;
    --radius-sm: 10px;
    --shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
    --shadow-hover: 0 16px 44px rgba(15, 23, 42, 0.14);
}

/* Fondo general claro con degradado sutil */
[data-theme="light"] body {
    background:
        radial-gradient(circle at 18% 12%, rgba(99, 102, 241, 0.06) 0%, transparent 42%),
        radial-gradient(circle at 85% 88%, rgba(16, 185, 129, 0.06) 0%, transparent 45%),
        linear-gradient(135deg, #eef2f7 0%, #e6ebf3 100%);
}
[data-theme="light"] .main-content { background: transparent; }
[data-theme="light"] .app-container { background: transparent; }

/* Tarjetas y paneles: radios y sombras consistentes */
[data-theme="light"] .card,
[data-theme="light"] .header-glass,
[data-theme="light"] .modal-content,
[data-theme="light"] .search-card,
[data-theme="light"] .table-card,
[data-theme="light"] .stat-item,
[data-theme="light"] .action-tile,
[data-theme="light"] .monto-card {
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}
[data-theme="light"] .card:hover,
[data-theme="light"] .stat-item:hover,
[data-theme="light"] .action-tile:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-hover);
}

/* Sidebar flotante (mantiene el azul profundo pero suave y separada) */
[data-theme="light"] .sidebar {
    margin: 14px 0 14px 14px;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.16);
    overflow: hidden;
}
[data-theme="light"] .sidebar-header { padding: 24px 20px; }

/* Botones de navegación: redondeados, con margen, sin barra cuadrada */
[data-theme="light"] .nav-btn,
[data-theme="light"] .nav-btn-footer {
    margin: 4px 12px;
    padding: 12px 16px;
    border-left: 0;
    border-radius: 12px;
    width: auto;
    border: 1px solid rgba(0, 0, 0, 0.05);
    background: rgba(0, 0, 0, 0.015);
    transition: all 0.2s ease;
}
[data-theme="light"] .nav-btn:hover {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.1);
    border-left: 0;
    transform: translateX(2px);
}
[data-theme="light"] .nav-btn.active {
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.15) 0%, rgba(99, 102, 241, 0.02) 100%);
    color: var(--primary-light);
    border-color: rgba(99, 102, 241, 0.25);
    border-left: 0;
    box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.1);
}
[data-theme="light"] .nav-btn.active i { color: var(--primary-light); }

/* Logo de la sidebar más suave */
[data-theme="light"] .logo-icon {
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.12);
}

/* Inputs con radio consistente */
[data-theme="light"] input,
[data-theme="light"] select,
[data-theme="light"] textarea {
    border-radius: var(--radius-sm);
}

/* Scrollbars suaves en claro */
[data-theme="light"] ::-webkit-scrollbar { width: 10px; height: 10px; }
[data-theme="light"] ::-webkit-scrollbar-track { background: transparent; }
[data-theme="light"] ::-webkit-scrollbar-thumb {
    background: rgba(15, 23, 42, 0.18);
    border-radius: 8px;
    border: 2px solid transparent;
    background-clip: padding-box;
}
[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: rgba(15, 23, 42, 0.30); background-clip: padding-box; }

/* ============================================================
   ================= VERSIÓN MÓVIL (responsive) ===============
   ============================================================ */

/* Elementos móviles ocultos en escritorio */
.mobile-topbar { display: none; }
.sidebar-overlay { display: none; }

@media (max-width: 768px) {
    /* ---- Barra superior con hamburguesa ---- */
    .mobile-topbar {
        display: flex;
        align-items: center;
        gap: 14px;
        position: fixed;
        top: 0; left: 0; right: 0;
        height: 58px;
        padding: 0 16px;
        z-index: 1500;
        background: rgba(17, 20, 28, 0.92);
        -webkit-backdrop-filter: blur(12px);
        backdrop-filter: blur(12px);
        border-bottom: 1px solid var(--border);
    }
    [data-theme="light"] .mobile-topbar {
        background: rgba(255, 255, 255, 0.92);
    }
    .mobile-menu-btn {
        background: rgba(255, 255, 255, 0.08);
        border: 1px solid var(--border);
        color: var(--text-main);
        width: 42px; height: 42px;
        border-radius: 12px;
        font-size: 18px;
        display: flex; align-items: center; justify-content: center;
        cursor: pointer;
        flex: 0 0 auto;
    }
    [data-theme="light"] .mobile-menu-btn { background: rgba(15, 23, 42, 0.06); }
    .mobile-menu-btn:active { transform: scale(0.94); }
    .mobile-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
    .mobile-brand img { width: 30px; height: 30px; object-fit: contain; border-radius: 7px; }
    .mobile-brand span {
        font-family: var(--font-heading);
        font-weight: 700; font-size: 17px; color: var(--text-main);
        white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }

    /* ---- Sidebar como cajón deslizable ---- */
    .sidebar {
        position: fixed !important;
        top: 0; left: 0;
        height: 100dvh !important;
        width: 82vw; max-width: 320px;
        margin: 0 !important;
        border-radius: 0 20px 20px 0 !important;
        transform: translateX(-110%);
        transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
        z-index: 1600;
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
        overflow-y: hidden !important;
    }
    .sidebar-footer {
        padding-bottom: env(safe-area-inset-bottom, 30px) !important;
    }
    body.sidebar-open .sidebar { transform: translateX(0); }

    /* Fondo oscuro del cajón */
    .sidebar-overlay {
        display: block;
        position: fixed; inset: 0;
        background: rgba(0, 0, 0, 0.55);
        z-index: 1550;
        opacity: 0; pointer-events: none;
        transition: opacity 0.3s ease;
    }
    body.sidebar-open .sidebar-overlay { opacity: 1; pointer-events: auto; }

    /* ---- Contenido principal a pantalla completa ---- */
    .main-content {
        padding: 74px 14px 96px !important;
    }

    /* ---- Grids a una sola columna ---- */
    .form-grid,
    .config-grid,
    .input-row,
    .stats-container,
    .quick-actions-grid,
    .dashboard-grid,
    .add-option-row {
        grid-template-columns: 1fr !important;
    }
    .span-2 { grid-column: span 1 !important; }

    /* ---- Encabezados y tarjetas más compactos ---- */
    .header-glass { padding: 16px 18px; margin-bottom: 18px; }
    .header-glass h1 { font-size: 22px; }
    .header-glass p { font-size: 13px; }
    .card { padding: 18px; }

    /* ---- Tablas con scroll horizontal ---- */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .modern-table { min-width: 560px; }

    /* ---- Modales casi a pantalla completa ---- */
    .modal {
        top: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        height: 100dvh !important;
        z-index: 2000 !important;
    }
    .modal-content {
        width: 96vw !important;
        max-width: 96vw !important;
        max-height: 94vh !important;
        padding: 20px 14px !important;
        overflow-y: auto;
    }
    .modal-body {
        max-height: 72vh !important;
        padding: 4px !important;
        margin-top: 10px !important;
    }
    .modal-actions { flex-direction: column-reverse; }
    .modal-actions .btn { width: 100%; }

    /* ---- Barra de acciones apilada ---- */
    .action-bar { flex-direction: column; }
    .action-bar .btn { width: 100%; }

    /* ---- Login adaptado ---- */
    .auth-card { width: 92vw !important; max-width: 400px; padding: 26px 22px !important; }
}

/* Teléfonos muy pequeños */
@media (max-width: 400px) {
    .main-content { padding: 70px 10px 96px !important; }
    .card { padding: 15px; }
    .header-glass h1 { font-size: 20px; }
    .mobile-brand span { font-size: 16px; }
}

/* ============================================================
   PANEL DE ADMINISTRACIÓN (usuarios, bases, auditoría)
   ============================================================ */
.admin-subtabs {
    display: flex;
    gap: 8px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}
.admin-subtab {
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 9px 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font-main);
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 7px;
}
.admin-subtab:hover { color: var(--text-main); }
.admin-subtab.active {
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
    color: #fff;
    border-color: transparent;
}
.admin-panel { display: none; }
.admin-panel.active { display: block; }
.admin-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.admin-panel-head h3 { margin: 0; }

/* Badge de rol */
.role-badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    background: rgba(148, 163, 184, 0.2);
    color: var(--text-muted);
}
.role-badge.role-root  { background: rgba(239, 68, 68, 0.15);  color: #f87171; }
.role-badge.role-admin { background: rgba(99, 102, 241, 0.16); color: #818cf8; }
.role-badge.role-user  { background: rgba(34, 197, 94, 0.15);  color: #4ade80; }

.user-info { display: flex; flex-direction: column; gap: 3px; }

/* Estado activo/inactivo */
.status-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-right: 6px;
    background: var(--text-muted);
}
.status-dot.on  { background: #22c55e; }
.status-dot.off { background: #ef4444; }

.muted-tag { color: var(--text-muted); font-size: 12px; }

.row-actions { display: inline-flex; gap: 2px; }
.btn-icon-danger { color: var(--danger); }
.btn-icon-danger:hover { background: rgba(239, 68, 68, 0.12); }

/* Indicador de base activa en el sidebar */
.active-db-indicator {
    margin: 6px 14px 0;
    padding: 10px 12px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}
.active-db-indicator label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.active-db-indicator select { width: 100%; padding: 8px 30px 8px 10px; font-size: 13px; }

/* Caja de permisos en el modal de usuario */
.permissions-box {
    margin-top: 8px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--input-bg);
}
.permissions-box h4 { margin: 0 0 4px; }
.perm-section { margin-top: 14px; }
.perm-section > strong { display: block; margin-bottom: 8px; font-size: 13px; }
.perm-tabs { display: flex; flex-wrap: wrap; gap: 10px 16px; }
.perm-chk {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    text-transform: capitalize;
    cursor: pointer;
}
.perm-chk input, .perm-table input { width: auto; cursor: pointer; }
.perm-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.perm-table th, .perm-table td {
    padding: 7px 8px;
    text-align: center;
    border-bottom: 1px solid var(--border);
}
.perm-table th:first-child, .perm-table td:first-child { text-align: left; }

/* Rejillas y acciones reutilizadas por el modal de usuario */
.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
.form-actions { display: flex; gap: 10px; justify-content: flex-end; }
.password-wrapper { position: relative; display: flex; align-items: center; }
.password-wrapper input { width: 100%; padding-right: 40px; }
.password-wrapper .toggle-password { position: absolute; right: 6px; }

@media (max-width: 640px) {
    .form-grid-2 { grid-template-columns: 1fr; }
}

/* Config del logo de login (sección Marca) */
.login-logo-config {
    display: flex;
    gap: 24px;
    align-items: center;
    flex-wrap: wrap;
}
.login-logo-config #login-logo-preview {
    width: 96px;
    height: 96px;
    object-fit: contain;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--input-bg);
    padding: 8px;
}

/* ============================================================
   PAGINADOR DE TABLAS
   ============================================================ */
.table-pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 16px;
    flex-wrap: wrap;
}
.pager-info { color: var(--text-muted); font-size: 13px; }
.pager-controls { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.pager-size-label {
    display: flex; align-items: center; gap: 8px;
    font-size: 13px; color: var(--text-muted);
}
.pager-size { width: auto; padding: 7px 30px 7px 11px; font-size: 13px; }
.pager-nav { display: flex; align-items: center; gap: 8px; }
.pager-btn {
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--text-main);
    width: 34px; height: 34px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    transition: all 0.2s ease;
}
.pager-btn:hover:not(:disabled) { border-color: var(--primary-light); color: var(--primary-light); }
.pager-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.pager-pages { font-size: 13px; color: var(--text-main); min-width: 52px; text-align: center; font-weight: 600; }

@media (max-width: 768px) {
    .table-pager { justify-content: center; }
    .pager-info { width: 100%; text-align: center; }
    .pager-controls { width: 100%; justify-content: space-between; }
}

/* ============================================================
   TABLAS COMO TARJETAS-LISTA EN MÓVIL
   (solo tablas de listado en vistas; no las editables de modales)
   ============================================================ */
@media (max-width: 768px) {
    /* La fila ya no necesita scroll horizontal: cada fila es una tarjeta */
    .view-section .table-responsive { overflow-x: visible; }

    .view-section .modern-table,
    .view-section .modern-table tbody { display: block; width: 100%; min-width: 0; }

    .view-section .modern-table thead { display: none; }

    .view-section .modern-table tr {
        display: block;
        background: var(--bg-card);
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        padding: 4px 14px;
        margin-bottom: 12px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    }

    .view-section .modern-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 14px;
        text-align: right;
        padding: 10px 0;
        border: none;
        border-bottom: 1px solid var(--border);
        min-height: 0;
        white-space: normal;
        word-break: break-word;
    }
    .view-section .modern-table tr td:last-child { border-bottom: none; }

    /* Etiqueta (cabecera) a la izquierda de cada valor */
    .view-section .modern-table td[data-label]::before {
        content: attr(data-label);
        text-align: left;
        font-weight: 700;
        color: var(--text-muted);
        text-transform: uppercase;
        font-size: 11px;
        letter-spacing: 0.4px;
        flex: 0 0 38%;
    }

    /* Fila de "sin datos" (colspan): centrada y sin etiqueta */
    .view-section .modern-table td[colspan] {
        justify-content: center;
        text-align: center;
        color: var(--text-muted);
    }

    /* La celda de acciones: botones alineados a la derecha */
    .view-section .modern-table td .row-actions,
    .view-section .modern-table td .btn-icon { margin-left: auto; }
}

/* Estilo para botón rojo de Cerrar sesión */
#sidebar-logout-btn {
    color: #ef4444 !important;
}
#sidebar-logout-btn:hover {
    color: #f87171 !important;
    background: rgba(239, 68, 68, 0.1) !important;
}
