/* Reset y Variables */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 13px;
}

:root {
    --primary-color: #2563eb;
    --primary-dark: #1e40af;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --background: #f8fafc;
    --card-background: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    padding: 0;
    margin: 0;
    display: flex;
}

.container {
    width: 100% !important;
    max-width: none !important;
    min-height: calc(100vh - 80px);
    background: var(--card-background);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    margin: 0 !important;
}

/* Header */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 40px;
    text-align: center;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 700;
}

header p {
    font-size: 1.1rem;
    opacity: 0.95;
}

/* Filters Section */
.filters-section {
    padding: 40px;
    background: var(--background);
    border-bottom: 2px solid var(--border-color);
}

.filters-section h2 {
    margin-bottom: 24px;
    color: var(--text-primary);
    font-size: 1.5rem;
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.filter-group {
    display: flex;
    flex-direction: column;
}

.filter-group label {
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.filter-select {
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    background: white;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    box-sizing: border-box;
}

.filter-select:hover {
    border-color: var(--primary-color);
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.voltaje-radio-group {
    display: flex;
    gap: 12px;
}

.voltaje-radio-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    flex: 1;
    background: white;
}

.voltaje-radio-option:hover {
    border-color: var(--primary-color);
}

.voltaje-radio-option input[type="radio"] {
    display: none;
}

.voltaje-radio-circle {
    display: inline-block;
    width: 18px;
    min-width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid #cbd5e1;
    transition: all 0.2s;
    flex-shrink: 0;
    flex-grow: 0;
    box-sizing: border-box;
}

.voltaje-radio-option input[type="radio"]:checked ~ .voltaje-radio-circle {
    border-color: var(--primary-color);
    background: var(--primary-color);
    box-shadow: inset 0 0 0 3px white;
}

.voltaje-radio-option input[type="radio"]:checked ~ .voltaje-radio-label {
    color: var(--primary-color);
    font-weight: 600;
}

.voltaje-radio-option:has(input:checked) {
    border-color: var(--primary-color);
    background: rgba(37, 99, 235, 0.04);
}

/* Buttons */
.button-group {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 32px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow);
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: #475569;
    transform: translateY(-2px);
}

/* Loading Indicator */
.loading {
    text-align: center;
    padding: 60px;
}

.spinner {
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error Toast — S6 */
.pv-toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}
.pv-toast {
    background: #1e293b;
    border-left: 4px solid #ef4444;
    color: #f1f5f9;
    padding: 14px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    max-width: 420px;
    font-size: 14px;
    position: relative;
    pointer-events: auto;
    animation: pv-toast-in 0.3s ease;
}
.pv-toast.pv-toast-warning { border-left-color: #f59e0b; }
.pv-toast-title { font-weight: 600; margin-bottom: 4px; }
.pv-toast-msg { color: #94a3b8; font-size: 13px; word-break: break-word; }
.pv-toast-close {
    position: absolute;
    top: 8px;
    right: 12px;
    background: none;
    border: none;
    color: #64748b;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
}
.pv-toast-close:hover { color: #f1f5f9; }
@keyframes pv-toast-in {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Results Section */
.results-section {
    padding: 40px;
}

.results-section h2 {
    margin-bottom: 24px;
    color: var(--text-primary);
    font-size: 1.8rem;
}

.results-section h3 {
    margin-bottom: 16px;
    color: var(--text-primary);
    font-size: 1.3rem;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 24px;
    border-radius: 12px;
    text-align: center;
    color: white;
    box-shadow: var(--shadow);
}

.stat-label {
    font-size: 0.9rem;
    opacity: 0.95;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
}

/* Tariff Summary */
.tariff-summary {
    margin-bottom: 40px;
}

.tariff-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.tariff-card {
    background: var(--background);
    padding: 24px;
    border-radius: 12px;
    border-left: 4px solid var(--primary-color);
    box-shadow: var(--shadow);
}

.tariff-card h4 {
    color: var(--primary-color);
    margin-bottom: 16px;
    font-size: 1.2rem;
}

.tariff-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

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

.tariff-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.tariff-value {
    font-weight: 600;
    color: var(--text-primary);
}

/* Chart Container */
.chart-container {
    margin-bottom: 40px;
    background: var(--background);
    padding: 24px;
    border-radius: 12px;
}

/* Table */
.table-container {
    margin-bottom: 40px;
}

.table-scroll {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 600px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    position: relative;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

thead {
    background: var(--primary-color);
    color: white;
    position: sticky;
    top: 0;
    z-index: 10;
}

th {
    padding: 16px;
    text-align: left;
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    background: var(--primary-color);
}

td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

tbody tr:hover {
    background: var(--background);
}

tbody tr:last-child td {
    border-bottom: none;
}

/* No Results */
.no-results {
    text-align: center;
    padding: 60px;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Hidden Class */
.hidden {
    display: none !important;
}

/* Footer */
footer {
    background: var(--text-primary);
    color: white;
    text-align: center;
    padding: 20px;
    margin-top: 40px;
    margin-bottom: 20px;
}

/* Filter Steps */
.filter-step {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 24px;
    padding: 20px;
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary-color);
}

.step-number {
    min-width: 40px;
    height: 40px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.step-content {
    flex: 1;
}

.step-content label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.help-text {
    display: block;
    margin-top: 4px;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Radio Groups */
.radio-group {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--background);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.radio-label:hover {
    border-color: var(--primary-color);
    background: white;
}

.radio-label input[type="radio"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.radio-label input[type="radio"]:checked + span {
    color: var(--primary-color);
    font-weight: 600;
}

/* Info Card */
.info-card {
    margin: 24px 40px;
    padding: 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
}

.info-card h3 {
    margin-bottom: 16px;
    font-size: 1.3rem;
}

#clienteInfoContent {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

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

.info-item-label {
    font-size: 0.85rem;
    opacity: 0.9;
    margin-bottom: 4px;
}

.info-item-value {
    font-size: 1.1rem;
    font-weight: 600;
}

/* Result Cards */
.result-card {
    background: white;
    padding: 24px;
    margin-bottom: 24px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary-color);
}

.result-card h3 {
    margin-bottom: 16px;
    color: var(--text-primary);
}

.summary-card {
    border-left-color: var(--success-color);
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
}

/* Tariff Details */
.tariff-details {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.tariff-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--background);
    border-radius: 8px;
}

.tariff-row.highlight {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    font-weight: 600;
    border-left: 3px solid var(--primary-color);
}

.tariff-label {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.tariff-value {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1.05rem;
}

.tariff-row.highlight .tariff-value {
    color: var(--primary-color);
    font-size: 1.2rem;
}

/* Tariff Summary Grid */
.tariff-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
}

.summary-item {
    padding: 16px;
    background: white;
    border-radius: 8px;
    border-left: 3px solid var(--success-color);
}

.summary-item-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.summary-item-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--success-color);
}

/* Info Box */
.info-box {
    margin-top: 24px;
    padding: 20px;
    background: var(--background);
    border-radius: 12px;
    border-left: 4px solid #10b981;
}

.info-box h4 {
    color: var(--text-primary);
    margin-bottom: 12px;
}

.info-box ul {
    list-style: none;
    padding: 0;
}

.info-box li {
    padding: 8px 0;
    color: var(--text-secondary);
    line-height: 1.6;
}

.info-box strong {
    color: var(--text-primary);
}

/* Responsive */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    header h1 {
        font-size: 1.8rem;
    }

    .filters-section,
    .results-section {
        padding: 20px;
    }

    .filters-grid {
        grid-template-columns: 1fr;
    }

    .button-group {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

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

    th, td {
        padding: 10px;
        font-size: 0.85rem;
    }

    .filter-step {
        flex-direction: column;
    }

    .radio-group {
        flex-direction: column;
    }

    .radio-label {
        width: 100%;
    }

    .info-card {
        margin: 24px 20px;
    }
}

/* Sidebar Styles */
.sidebar {
    width: 280px;
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    transition: transform 0.3s ease;
}

.sidebar.collapsed {
    transform: translateX(-280px);
}

#sidebar-open {
    position: fixed;
    top: 12px;
    left: 10px;
    z-index: 1001;
    background: #1e293b;
    color: #cbd5e1;
    border: none;
    border-radius: 6px;
    width: 32px;
    height: 32px;
    font-size: 1.2rem;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

#sidebar-open:hover {
    background: #334155;
}

.sidebar.collapsed ~ #sidebar-open {
    display: flex;
}

.sidebar.collapsed ~ .main-content {
    margin-left: 0;
}

.sidebar-header {
    padding: 30px 20px;
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
}

.sidebar-header h2 {
    color: #ffffff;
    font-size: 1.4rem;
    font-weight: 600;
    margin: 0;
    text-align: center;
}

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

.nav-item {
    display: flex;
    align-items: center;
    padding: 8px 24px;
    color: #cbd5e1;
    text-decoration: none;
    transition: all 0.3s ease;
    border-left: 4px solid transparent;
    margin: 1px 0;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    border-left-color: #667eea;
}

.nav-item.active {
    background: rgba(102, 126, 234, 0.15);
    color: #ffffff;
    border-left-color: #667eea;
    font-weight: 700;
}

.nav-icon {
    font-size: 1.5rem;
    margin-right: 12px;
    min-width: 32px;
    text-align: center;
}

.nav-text {
    font-size: 0.95rem;
}

/* Main Content Area */
.main-content {
    margin-left: 280px;
    flex: 1;
    min-height: 100vh;
    padding: 0;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
}

.page-content {
    display: none;
}

.page-content.active {
    display: block;
    padding: 20px;
    flex: 1;
    width: 100%;
    box-sizing: border-box;
}

/* Content Placeholder */
.content-placeholder {
    text-align: center;
    padding: 100px 40px;
    color: var(--text-secondary);
}

.placeholder-icon {
    font-size: 5rem;
    margin-bottom: 20px;
    opacity: 0.3;
}

.content-placeholder h3 {
    font-size: 1.8rem;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.content-placeholder p {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

/* Responsive Sidebar */
@media (max-width: 768px) {
    .sidebar {
        width: 70px;
    }

    .sidebar-header h2 {
        font-size: 1.5rem;
        writing-mode: vertical-rl;
        text-orientation: mixed;
    }

    .nav-text {
        display: none;
    }

    .nav-item {
        justify-content: center;
        padding: 16px 12px;
    }

    .nav-icon {
        margin-right: 0;
        font-size: 1.8rem;
    }

    .main-content {
        margin-left: 70px;
        width: calc(100% - 70px);
        padding: 20px;
    }
}

/* Estilos para MPC */
.mpc-stats {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 24px;
    text-align: center;
    font-size: 1.2rem;
    font-weight: 600;
}

.mpc-listado {
    max-height: 600px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.mpc-cliente-item {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    transition: background-color 0.2s ease;
}

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

.mpc-cliente-item:hover {
    background-color: #f8fafc;
}

.mpc-cliente-numero {
    background: var(--primary-color);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    margin-right: 16px;
    flex-shrink: 0;
}

.mpc-cliente-nombre {
    font-size: 1rem;
    color: var(--text-primary);
    flex: 1;
}

.mpc-cliente-badge {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.mpc-badge-aplica {
    background-color: #d1fae5;
    color: #065f46;
}

.mpc-badge-no-aplica {
    background-color: #fee2e2;
    color: #991b1b;
}

/* Estilo unificado para cajas de título de subplataformas */
.results-card {
    width: 100%;
    box-sizing: border-box;
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    background: #f8fafc;
}

.card-header h3 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--text-primary);
}

.card-body {
    padding: 24px;
}

/* === Parámetros Autoconsumo === */
.params-section {
    margin-bottom: 28px;
    padding: 24px;
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.params-section h3 {
    margin-bottom: 20px;
    font-size: 1.15rem;
    color: var(--text-primary);
    padding-bottom: 12px;
    border-bottom: 2px solid #e2e8f0;
}

.params-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.param-group {
    display: flex;
    flex-direction: column;
}

.param-group label {
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.param-group .param-input {
    padding: 10px 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    width: 100%;
    box-sizing: border-box;
    transition: all 0.3s ease;
}

.param-group .param-input:hover {
    border-color: var(--primary-color);
}

.param-group .param-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.param-group .param-unit {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

#autoconsumoMap {
    height: 450px;
    border-radius: 12px;
    border: 2px solid var(--border-color);
    z-index: 1;
}

#autoconsumoParametrosSection {
    margin-top: 24px;
}

/* === Irradiancia Solar PVGIS === */
.irradiance-card {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.irradiance-header {
    padding: 16px 20px;
    border-bottom: 2px solid #e2e8f0;
}

.irradiance-header h4 {
    margin: 0 0 4px 0;
    font-size: 1.05rem;
    color: var(--text-primary);
}

.irradiance-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    padding: 16px 20px;
    background: #f0f9ff;
    border-bottom: 1px solid #e2e8f0;
}

.irradiance-stat {
    text-align: center;
}

.irradiance-stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.irradiance-stat-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary-color);
}

#pvgisTable tfoot td {
    font-weight: 700;
    background: #f8fafc;
    border-top: 2px solid var(--primary-color);
}

/* === Inclinación / Azimut Controls === */
.param-checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 400;
    font-size: 0.85rem;
    cursor: pointer;
    margin-top: 6px;
    color: var(--text-secondary);
}

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

#paramInclinacion:disabled {
    background: #f1f5f9;
    color: var(--text-secondary);
    cursor: not-allowed;
    border-color: #e2e8f0;
}

/* === Botón Modelo Horario === */
.btn-calcular-horario {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.btn-calcular-horario:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4);
}

.btn-calcular-horario:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* === Progress Bar === */
.progress-bar-container {
    width: 100%;
    max-width: 400px;
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    margin: 0 auto;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #f59e0b, #d97706);
    border-radius: 3px;
    width: 0%;
    transition: width 0.5s ease;
}

/* === Botón Optimizador === */
.btn-optimizar {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 32px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-optimizar:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.btn-optimizar:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* === Resultados Optimizador === */
.opt-results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.opt-result-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    text-align: center;
}

.opt-result-card .opt-label {
    font-size: 0.85rem;
    color: #64748b;
    margin-bottom: 6px;
}

.opt-result-card .opt-value {
    font-size: 1.15rem;
    font-weight: 700;
}

.opt-result-card .opt-subvalue {
    font-size: 0.8rem;
    color: #94a3b8;
    margin-top: 4px;
}

.opt-result-card.opt-highlight {
    border-left: 4px solid #10b981;
}

/* === Tabla Flujo de Caja === */
.cashflow-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.cashflow-table th {
    padding: 10px 8px;
    border-bottom: 2px solid #e2e8f0;
    font-weight: 600;
}

.cashflow-table th:first-child {
    text-align: center;
}

.cashflow-table td {
    padding: 8px;
    text-align: center;
    border-bottom: 1px solid #f1f5f9;
}

.cashflow-table td:first-child {
    text-align: center;
    font-weight: 600;
}

.cashflow-table tr:hover {
    background: #f0f9ff;
}

.cashflow-table .positive { color: #059669; }
.cashflow-table .negative { color: #dc2626; }

/* ============================================================================
   AUTH OVERLAY — Login / Register / Pending Approval
   ============================================================================ */

#auth-overlay {
    display: flex;
    position: fixed;
    top: 0; left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 10000;
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 30%, #4338ca 60%, #6366f1 100%);
    align-items: center;
    justify-content: center;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

#auth-container {
    background: white;
    border-radius: 16px;
    padding: 40px;
    width: 440px;
    max-width: 90vw;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    text-align: center;
}

.auth-logo {
    font-size: 3rem;
    margin-bottom: 4px;
}

.auth-title {
    font-size: 1.8rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 4px 0;
}

.auth-subtitle {
    color: #1a2332;
    font-size: 1.1rem;
    margin: 0 0 28px 0;
    font-weight: 500;
}

.auth-input {
    display: block;
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 12px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 0.95rem;
    transition: border-color 0.2s;
    box-sizing: border-box;
    outline: none;
}

.auth-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.auth-btn {
    display: block;
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #4338ca, #6366f1);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
    margin-top: 4px;
}

.auth-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

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

.auth-btn:disabled,
.auth-btn-loading {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.auth-btn-register {
    background: linear-gradient(135deg, #059669, #10b981);
}

.auth-switch {
    margin-top: 16px;
    font-size: 0.85rem;
    color: #64748b;
}

.auth-switch a {
    color: #4338ca;
    text-decoration: none;
    font-weight: 600;
}

.auth-switch a:hover {
    text-decoration: underline;
}

.auth-pending-icon {
    font-size: 3rem;
    margin-bottom: 12px;
}

#auth-error {
    display: none;
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 10px 14px;
    margin-top: 12px;
    font-size: 0.85rem;
    text-align: center;
}

/* User info in sidebar */
#user-info {
    display: none;
    align-items: center;
    justify-content: center;
    margin-top: 8px;
    padding: 6px 0;
    gap: 6px;
}

#user-email {
    font-size: 0.75rem;
    color: #94a3b8;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 160px;
}

#auth-logout-btn {
    background: rgba(255,255,255,0.1);
    color: #94a3b8;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 0.65rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

#auth-logout-btn:hover {
    background: rgba(255,255,255,0.2);
    color: white;
}

/* ============================================================================
   ADMIN PANEL
   ============================================================================ */

.admin-nav-separator {
    border-top: 1px solid rgba(255,255,255,0.1);
    margin-top: 16px;
    padding-top: 8px;
}

.admin-stats {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
}

.admin-stat-card {
    flex: 1;
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
}

.admin-stat-number {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
}

.admin-stat-label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.admin-user-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.admin-user-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    transition: box-shadow 0.2s;
}

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

.admin-user-approved {
    border-left: 4px solid var(--success-color);
}

.admin-user-info {
    flex: 1;
    min-width: 0;
}

.admin-user-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1rem;
}

.admin-user-email {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 2px;
}

.admin-user-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.admin-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.admin-badge-verified {
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #bbf7d0;
}

.admin-badge-unverified {
    background: #fefce8;
    color: #ca8a04;
    border: 1px solid #fef08a;
}

.admin-badge-active {
    background: #eff6ff;
    color: #2563eb;
    border: 1px solid #bfdbfe;
}

.admin-user-actions {
    display: flex;
    gap: 8px;
    margin-left: 16px;
    flex-shrink: 0;
}

.admin-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
}

.admin-btn:hover {
    opacity: 0.85;
    transform: translateY(-1px);
}

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

.admin-btn-approve {
    background: linear-gradient(135deg, #059669, #10b981);
    color: white;
}

.admin-btn-reject {
    background: linear-gradient(135deg, #dc2626, #ef4444);
    color: white;
}

.admin-btn-revoke {
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #e2e8f0;
}

.admin-btn-revoke:hover {
    background: #fee2e2;
    color: #dc2626;
    border-color: #fecaca;
}
