/* =============================================
   ESTILOS CORPORATIVOS TARIFFAI (Unificados)
   ============================================= */

/* --- IMPORTACIÓN DE FUENTES --- */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;600;700;800&family=Open+Sans:wght@400;600&display=swap');

/* --- ACCESSIBILITY: skip link & screen-reader only --- */
.skip-link {
    position: absolute;
    top: -100%;
    left: 0;
    background: var(--theme-brand, #6366f1);
    color: #fff;
    padding: 8px 16px;
    z-index: 10000;
    font-size: 14px;
    border-radius: 0 0 8px 0;
    text-decoration: none;
}
.skip-link:focus {
    top: 0;
}
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* --- BREADCRUMBS --- */
.breadcrumb { display:flex; align-items:center; gap:6px; font-size:0.85rem; color:var(--theme-text-muted); margin-bottom:16px; }
.breadcrumb a { color:var(--theme-brand); text-decoration:none; }
.breadcrumb a:hover { text-decoration:underline; }
.bc-sep { opacity:.4; }
.bc-current { font-weight:600; color:var(--theme-title); }

/* --- EMPTY STATES --- */
.empty-state { text-align:center; padding:60px 20px; background:var(--theme-surface); border-radius:16px; box-shadow:var(--theme-surface-shadow); }
.empty-state i { font-size:3rem; color:var(--theme-brand); opacity:.3; margin-bottom:16px; display:block; }
.empty-state h3 { margin:0 0 8px; font-size:1.1rem; color:var(--theme-title); }
.empty-state p { color:var(--theme-text-muted); margin:0 0 20px; font-size:0.9rem; }

/* --- TOOLTIPS --- */
.tooltip-help { color:var(--theme-text-muted); cursor:help; margin-left:4px; font-size:0.8rem; }
.tooltip-help:hover { color:var(--theme-brand); }

/* --- VARIABLES DE MARCA --- */
:root {
    --theme-bg: #f8fafc;
    --theme-surface: #ffffff;
    --theme-surface-muted: #f8fafc;
    --theme-surface-border: #e2e8f0;
    --theme-surface-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
    --theme-text: #0f172a;
    --theme-text-muted: #64748b;
    --theme-title: #0f172a;
    --theme-brand: #6366f1;
    --theme-brand-soft: rgba(99, 102, 241, 0.12);
    --theme-amber: #f59e0b;
    --theme-input-bg: #ffffff;
    --theme-input-border: #e2e8f0;
    --theme-input-text: #0f172a;
    --theme-sidebar-bg: #ffffff;
    --theme-sidebar-text: #0f172a;
    --theme-sidebar-muted: #64748b;
    --theme-sidebar-border: #e2e8f0;
    --theme-sidebar-active-bg: rgba(99, 102, 241, 0.12);
    --theme-sidebar-promo-bg: #f8fafc;
    --theme-toggle-bg: #f1f5f9;
    --theme-toggle-border: #e2e8f0;
    --theme-toggle-active-bg: rgba(99, 102, 241, 0.2);
    --theme-topbar-bg: #ffffff;
    --theme-topbar-border: #e2e8f0;
    --theme-hero-gradient: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
    --theme-card-blur: none;
    --theme-card-bg: #ffffff;
    --theme-border: #e2e8f0;
    --row-power-bg: #e3f2fd;
    --row-power-text: #0d47a1;
    --row-days-bg: #e8f5e9;
    --row-days-text: #1b5e20;
    --row-energy-bg: #fff8e1;
    --row-energy-text: #e65100;
    --row-fixed-bg: #f3f4f6;
    --row-fixed-text: #374151;
    --row-tax-bg: #f3e5f5;
    --row-tax-text: #4a148c;

    --opt-dark-purple: var(--theme-brand);
    --opt-medium-purple: #818cf8;
    --opt-light-gray: var(--theme-surface-muted);
    --opt-text-dark: var(--theme-text);
    --opt-white: #ffffff;
    --opt-success: #25d366;
    --opt-error: #d32f2f;
    --app-bg: var(--theme-bg);
    --sidebar-bg: var(--theme-sidebar-bg);
    --sidebar-accent: var(--theme-brand);
    --card-shadow: var(--theme-surface-shadow);

    /* ✅ Alias para compatibilidad (por si algo antiguo usa --opt-dark) */
    --opt-dark: var(--opt-dark-purple);

    /* Degradado corporativo (Usado en Login y Dashboard) */
    --opt-gradient: linear-gradient(135deg, rgba(79, 70, 229, 0.95) 0%, rgba(129, 140, 248, 0.9) 100%);
    --auth-bg: var(--opt-gradient),
        url('https://images.unsplash.com/photo-1497366811353-6870744d04b2?auto=format&fit=crop&w=1350&q=80') center/cover;
     --hero-card-bg:
        radial-gradient(900px 600px at 20% 15%, rgba(99, 102, 241, 0.18), transparent 55%),
        radial-gradient(700px 500px at 80% 70%, rgba(245, 158, 11, 0.10), transparent 60%),
        linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);

    --font-heading: 'Montserrat', sans-serif;
    --font-body: 'Open Sans', sans-serif;
    --border-radius-pill: 50px;
    --border-radius-card: 20px;
    --box-shadow-soft: 0 15px 35px rgba(15, 23, 42, 0.1);
}

:root[data-theme="dark"],
body[data-theme="dark"] {
    --theme-bg: #0f172a;
    --app-bg: #0f172a;
    --theme-surface: rgba(15, 23, 42, 0.92);
    --theme-surface-muted: rgba(2, 6, 23, 0.96);
    --theme-surface-border: rgba(255, 255, 255, 0.1);
    --theme-surface-shadow: 0 20px 60px rgba(2, 6, 23, 0.65);
    --card-shadow: var(--theme-surface-shadow);
    --theme-text: #e2e8f0;
    --theme-text-muted: #94a3b8;
    --theme-title: #ffffff;
    --theme-brand: #6366f1;
    --theme-brand-soft: rgba(99, 102, 241, 0.25);
    --theme-amber: #f59e0b;
    --theme-input-bg: #020617;
    --theme-input-border: rgba(255, 255, 255, 0.18);
    --theme-input-text: #e2e8f0;
    --theme-sidebar-bg: #0b1222;
    --sidebar-bg: #0b1222;
    --sidebar-accent: #6366f1;
    --theme-sidebar-text: #e2e8f0;
    --theme-sidebar-muted: #94a3b8;
    --theme-sidebar-border: rgba(255, 255, 255, 0.08);
    --theme-sidebar-active-bg: rgba(99, 102, 241, 0.32);
    --theme-sidebar-promo-bg: rgba(15, 23, 42, 0.7);
    --theme-toggle-bg: rgba(2, 6, 23, 0.75);
    --theme-toggle-border: rgba(255, 255, 255, 0.15);
    --theme-toggle-active-bg: rgba(99, 102, 241, 0.5);
    --theme-topbar-bg: rgba(2, 6, 23, 0.9);
    --theme-topbar-border: rgba(255, 255, 255, 0.08);
    --theme-hero-gradient: linear-gradient(135deg, #0b1222 0%, #1e1b4b 100%);
    --theme-card-blur: blur(28px);
    --theme-card-bg: #1e293b;
    --theme-border: rgba(255, 255, 255, 0.12);
    --box-shadow-soft: 0 18px 50px rgba(2, 6, 23, 0.6);
    --hero-card-bg:
        radial-gradient(900px 600px at 20% 15%, rgba(99, 102, 241, 0.26), transparent 55%),
        radial-gradient(700px 500px at 80% 70%, rgba(245, 158, 11, 0.16), transparent 60%),
        linear-gradient(135deg, #0b1222 0%, #1e1b4b 100%);

    --auth-bg: linear-gradient(135deg, rgba(10, 15, 33, 0.94) 0%, rgba(24, 24, 52, 0.92) 100%),
        url('https://images.unsplash.com/photo-1497366811353-6870744d04b2?auto=format&fit=crop&w=1350&q=80') center/cover;
    --row-power-bg: rgba(59, 130, 246, 0.18);
    --row-power-text: #93c5fd;
    --row-days-bg: rgba(34, 197, 94, 0.18);
    --row-days-text: #86efac;
    --row-energy-bg: rgba(245, 158, 11, 0.18);
    --row-energy-text: #fcd34d;
    --row-fixed-bg: rgba(148, 163, 184, 0.18);
    --row-fixed-text: #e2e8f0;
    --row-tax-bg: rgba(168, 85, 247, 0.18);
    --row-tax-text: #d8b4fe;
    color-scheme: dark;
}

/* --- RESET BÁSICO --- */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: var(--font-body);
    color: var(--opt-text-dark);
    background-color: var(--app-bg);
    line-height: 1.6;
    transition: background-color 0.5s ease, color 0.5s ease;
}
.container { width: 90%; max-width: 1200px; margin: 0 auto; }
a { text-decoration: none; transition: 0.3s; }
ul { list-style: none; }
h1, h2, h3, h4 { font-family: var(--font-heading); }

/* =============================================
   COMPONENTES UI (Botones e Inputs)
   ============================================= */

/* Botones */
.btn-opt {
    display: inline-block;
    padding: 12px 35px;
    border-radius: var(--border-radius-pill);
    font-family: var(--font-heading);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    font-size: 0.9rem;
}

.btn-opt-gradient {
    background: linear-gradient(to right, var(--theme-brand), #818cf8);
    color: var(--opt-white);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}
.btn-opt-gradient:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

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

/* Inputs */
.input-group { position: relative; margin-bottom: 20px; }
.input-group > i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--opt-medium-purple);
    z-index: 1;
    pointer-events: none;
}
.input-styled {
    width: 100%;
    padding: 15px 15px 15px 45px; /* Espacio para el icono */
    border: 1px solid var(--theme-input-border);
    border-radius: var(--border-radius-pill);
    font-size: 1rem;
    background: var(--theme-input-bg);
    color: var(--theme-input-text);
    font-family: var(--font-body);
    transition: 0.3s;
}
.input-styled:focus {
    outline: none;
    border-color: var(--theme-brand);
    background: var(--theme-input-bg);
    box-shadow: 0 0 0 3px var(--theme-brand-soft);
}

/* Alertas */
.alert {
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    animation: alertFadeOut 0.6s ease 4s forwards;
}
@keyframes alertFadeOut {
    0%   { opacity: 1; max-height: 80px; margin-bottom: 20px; }
    60%  { opacity: 0; max-height: 80px; margin-bottom: 20px; }
    100% { opacity: 0; max-height: 0; padding-top: 0; padding-bottom: 0; margin-bottom: 0; overflow: hidden; }
}
.alert i { margin-right: 10px; font-size: 1.2rem; }
.alert.error { background-color: #fdecea; color: var(--opt-error); border-left: 4px solid var(--opt-error); animation: none; }
.alert.success { background-color: #e8f5e9; color: var(--opt-success); border-left: 4px solid var(--opt-success); }

/* =============================================
   LOGIN Y REGISTRO (Estilo idéntico al Dashboard)
   ============================================= */
.auth-layout {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;

    /* Nuevo fondo (sin imagen) */
    background:
        radial-gradient(900px 600px at 20% 15%, rgba(99, 102, 241, 0.35), transparent 55%),
        radial-gradient(700px 500px at 80% 70%, rgba(245, 158, 11, 0.22), transparent 60%),
        linear-gradient(135deg, #0b1222 0%, #1e1b4b 100%);
}

.auth-card {
    background: var(--theme-surface);
    padding: 50px 40px;
    border-radius: var(--border-radius-card);
    width: 100%;
    max-width: 420px;
    text-align: center;
    box-shadow: var(--box-shadow-soft);
    border: 1px solid var(--theme-surface-border);
    color: var(--theme-text);
    animation: fadeIn 0.5s ease-out;
}

.auth-logo { height: 60px; margin-bottom: 10px; }
.auth-brand { display: flex; flex-direction: column; margin-bottom: 30px; }
.brand-name {
    color: var(--opt-dark-purple);
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 1.5rem;
    letter-spacing: 2px;
    line-height: 1;
}
.brand-sub {
    color: var(--opt-medium-purple);
    font-size: 0.75rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    font-weight: 600;
}

.auth-title { color: var(--opt-text-dark); margin-bottom: 25px; font-size: 1.3rem; }
.auth-hint { color: var(--theme-text-muted); font-size: 0.95rem; margin: -8px 0 18px; text-align: center; }
.auth-value-list {
    display: grid;
    gap: 10px;
    margin: -4px 0 18px;
    text-align: left;
}
.auth-value-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    border-radius: 14px;
    border: 1px solid var(--theme-surface-border);
    background: var(--theme-surface-muted);
    color: var(--theme-text);
    font-size: 0.9rem;
    font-weight: 600;
}
.auth-value-item i {
    width: 26px;
    height: 26px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: var(--theme-brand-soft);
    color: var(--theme-brand);
    flex-shrink: 0;
}
.auth-qr { display: flex; justify-content: center; margin: 0 0 16px; }
.auth-qr img { width: 170px; height: 170px; padding: 8px; border-radius: 14px; background: #ffffff; box-shadow: 0 12px 24px rgba(15, 18, 35, 0.18); }
.auth-secret { background: var(--theme-surface); border: 1px solid var(--theme-surface-border); border-radius: 12px; padding: 10px 14px; font-size: 0.95rem; text-align: center; margin-bottom: 18px; color: var(--theme-text); }
.auth-secret span { font-weight: 700; letter-spacing: 0.5px; }
.auth-footer { margin-top: 30px; padding-top: 20px; border-top: 1px solid var(--theme-surface-border); font-size: 0.9rem; color: var(--theme-text-muted); }
.auth-footer a { color: var(--theme-brand); font-weight: 700; }

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

/* =============================================
   DASHBOARD (Versión "Good")
   ============================================= */
.dash-header { background: var(--theme-surface); padding: 15px 0; border-bottom: 1px solid var(--theme-surface-border); box-shadow: var(--theme-surface-shadow); }
.dash-nav { display: flex; justify-content: space-between; align-items: center; }
.user-menu { font-weight: 600; color: var(--theme-text); display: flex; align-items: center; gap: 15px; }
.sub-badge {
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.5px;
}
.sub-badge-pro { background: #dcfce7; color: #166534; }
.sub-badge-free { background: #e2e8f0; color: #334155; }
.sub-link { color: var(--theme-brand); font-weight: 700; }
.sub-link:hover { color: #4338ca; }
.sub-manage-btn {
    border: 1px solid #cbd5f5;
    background: #eef2ff;
    color: #332e8c;
    border-radius: 999px;
    padding: 6px 12px;
    font-weight: 700;
    cursor: pointer;
    font-size: 0.8rem;
}
.sub-manage-btn:hover { background: #e0e7ff; }
.btn-logout { font-size: 0.85rem; color: var(--theme-text-muted); display: flex; align-items: center; }
.btn-logout:hover { color: var(--opt-error); }

.dash-hero {
    position: relative;
    background: url('https://images.unsplash.com/photo-1460925895917-afdab827c52f?auto=format&fit=crop&w=1350&q=80') center/cover;
    padding: 80px 0 120px; /* Padding extra inferior para el solape */
    text-align: center;
    color: var(--opt-white);
}
.dash-hero-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: var(--opt-gradient); /* MISMO DEGRADADO QUE EL LOGIN */
}
.hero-content { position: relative; z-index: 2; }
.hero-content h1 { font-size: 2.8rem; font-weight: 800; text-transform: uppercase; margin-bottom: 10px; }
.hero-content p { font-size: 1.1rem; opacity: 0.9; max-width: 600px; margin: 0 auto; }

/* Tarjeta flotante de subida */
.analysis-card-container { margin-top: -80px; position: relative; z-index: 10; margin-bottom: 60px; }
.analysis-card {
    background: var(--theme-surface);
    padding: 40px;
    border-radius: var(--border-radius-card);
    border: 1px solid var(--theme-surface-border);
    box-shadow: var(--box-shadow-soft);
    backdrop-filter: var(--theme-card-blur);
    text-align: center;
    transition: background-color 0.5s ease, border-color 0.5s ease, box-shadow 0.5s ease;
}
.analysis-card h3 { color: var(--theme-title); margin-bottom: 30px; font-size: 1.3rem; }

/* =============================================
   REVISIÓN DE EXTRACCIÓN
   ============================================= */
.review-container { margin-top: 40px; margin-bottom: 60px; }
.review-container .analysis-card { text-align: left; }
.review-sub { color: var(--theme-text-muted); margin-bottom: 20px; }
.review-section { margin-top: 26px; text-align: left; }
.review-section h4 { color: var(--theme-title); margin-bottom: 12px; }

/* =========================================================
   Tarjeta resumen (datos de anclaje en la revisión)
   ========================================================= */
.review-summary-card {
    margin: 14px 0 16px 0;
    padding: 16px 18px;
    border-radius: 14px;
    border: 1px solid var(--theme-surface-border);
    background: linear-gradient(135deg, var(--theme-surface-muted) 0%, var(--theme-surface) 100%);
}
.review-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px 20px;
}
.review-summary-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}
.review-summary-item-wide {
    grid-column: span 2;
}
.review-summary-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--theme-text-muted);
    font-weight: 700;
}
.review-summary-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--theme-title);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.review-summary-mono {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.82rem;
}
.review-summary-item-highlight .review-summary-value {
    color: var(--theme-brand);
    font-size: 1.2rem;
    font-weight: 800;
}

@media (max-width: 768px) {
    .review-summary-item-wide { grid-column: auto; }
    .review-summary-value { white-space: normal; }
}

/* =========================================================
   Banner de calidad (reemplaza al panel antiguo)
   ========================================================= */
.quality-banner {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    border-radius: 12px;
    border: 1px solid var(--theme-surface-border);
    background: var(--theme-surface-muted);
    margin-bottom: 14px;
    text-align: left;
}
.quality-banner-icon {
    font-size: 1.8rem;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(148, 163, 184, 0.15);
}
.quality-banner-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.quality-banner-text strong {
    font-size: 0.98rem;
    color: var(--theme-title);
}
.quality-banner-text small {
    font-size: 0.8rem;
    color: var(--theme-text-muted);
}
.quality-banner-score {
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--theme-text-muted);
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--theme-surface);
    border: 1px solid var(--theme-surface-border);
    flex-shrink: 0;
}
.quality-banner-toggle {
    background: var(--theme-surface);
    border: 1px solid var(--theme-surface-border);
    color: var(--theme-text);
    font-size: 0.82rem;
    font-weight: 600;
    padding: 7px 13px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    transition: all 0.2s ease;
}
.quality-banner-toggle:hover {
    background: var(--theme-brand-soft);
    border-color: var(--theme-brand);
}
.quality-banner-info {
    background: var(--theme-surface);
    border: 1px solid var(--theme-surface-border);
    color: var(--theme-text-muted);
    font-size: 1rem;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
}
.quality-banner-info:hover {
    background: var(--theme-brand-soft);
    border-color: var(--theme-brand);
    color: var(--theme-brand);
}

/* =========================================================
   Leyenda de semáforo desplegable
   ========================================================= */
.quality-legend {
    margin-bottom: 16px;
    padding: 18px 20px;
    border-radius: 14px;
    border: 1px solid var(--theme-surface-border);
    background: var(--theme-surface-muted);
    text-align: left;
    animation: quality-legend-in 0.25s ease;
}
@keyframes quality-legend-in {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.quality-legend-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}
.quality-legend-header h5 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    color: var(--theme-title);
}
.quality-legend-header h5 i {
    color: var(--theme-brand);
}
.quality-legend-close {
    background: transparent;
    border: none;
    color: var(--theme-text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    transition: all 0.15s ease;
}
.quality-legend-close:hover {
    background: var(--theme-surface);
    color: var(--theme-title);
}
.quality-legend-intro {
    font-size: 0.86rem;
    color: var(--theme-text-muted);
    line-height: 1.5;
    margin-bottom: 14px;
}
.quality-legend-intro strong {
    color: var(--theme-title);
}
.quality-legend-table {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 14px;
}
.quality-legend-row {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 16px;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--theme-surface-border);
    background: var(--theme-surface);
    align-items: flex-start;
}
.quality-legend-row-good {
    border-color: rgba(34, 197, 94, 0.35);
    background: rgba(34, 197, 94, 0.06);
}
.quality-legend-row-warn {
    border-color: rgba(245, 158, 11, 0.35);
    background: rgba(245, 158, 11, 0.06);
}
.quality-legend-row-bad {
    border-color: rgba(239, 68, 68, 0.35);
    background: rgba(239, 68, 68, 0.06);
}
.quality-legend-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--theme-title);
    padding-top: 2px;
}
.quality-legend-desc {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.85rem;
    line-height: 1.45;
    color: var(--theme-text);
    min-width: 0;
}
.quality-legend-desc strong {
    color: var(--theme-title);
    font-size: 0.9rem;
}
.quality-legend-desc small {
    font-size: 0.8rem;
    color: var(--theme-text-muted);
}
.quality-legend-desc em {
    font-size: 0.78rem;
    font-style: italic;
    color: var(--theme-text-muted);
    background: var(--theme-surface);
    padding: 4px 8px;
    border-radius: 6px;
    border-left: 2px solid var(--theme-brand);
    margin-top: 2px;
}
.quality-legend-footer {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-top: 14px;
    border-top: 1px dashed var(--theme-surface-border);
}
.quality-legend-note {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    font-size: 0.82rem;
    color: var(--theme-text-muted);
    line-height: 1.45;
}
.quality-legend-note > i {
    color: var(--theme-brand);
    margin-top: 2px;
    flex-shrink: 0;
    width: 16px;
    text-align: center;
}
.quality-legend-note strong {
    color: var(--theme-title);
}

@media (max-width: 768px) {
    .quality-legend { padding: 14px 14px; }
    .quality-legend-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }
}
.quality-banner-good {
    border-color: rgba(34, 197, 94, 0.45);
    background: rgba(34, 197, 94, 0.08);
}
.quality-banner-good .quality-banner-icon {
    background: rgba(34, 197, 94, 0.18);
    color: #16a34a;
}
.quality-banner-warn {
    border-color: rgba(245, 158, 11, 0.45);
    background: rgba(245, 158, 11, 0.08);
}
.quality-banner-warn .quality-banner-icon {
    background: rgba(245, 158, 11, 0.18);
    color: #d97706;
}
.quality-banner-bad {
    border-color: rgba(239, 68, 68, 0.45);
    background: rgba(239, 68, 68, 0.08);
}
.quality-banner-bad .quality-banner-icon {
    background: rgba(239, 68, 68, 0.18);
    color: #dc2626;
}

@media (max-width: 768px) {
    .quality-banner { flex-wrap: wrap; }
    .quality-banner-text { flex-basis: 100%; order: 3; }
    .quality-banner-score { order: 2; }
    .quality-banner-toggle { order: 4; flex-basis: 100%; justify-content: center; }
}

/* =========================================================
   Secciones colapsables (auto-expand en issues)
   ========================================================= */
.review-section-collapsible {
    border: 1px solid var(--theme-surface-border);
    border-radius: 14px;
    background: var(--theme-surface-muted);
    overflow: hidden;
    margin-top: 14px;
    transition: border-color 0.2s ease;
}
.review-section-collapsible.section-warn {
    border-color: rgba(245, 158, 11, 0.5);
    background: rgba(245, 158, 11, 0.05);
}
.review-section-collapsible.section-bad {
    border-color: rgba(239, 68, 68, 0.5);
    background: rgba(239, 68, 68, 0.06);
}
.review-section-collapsible .review-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 18px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s ease;
}
.review-section-collapsible .review-section-header:hover {
    background: rgba(148, 163, 184, 0.08);
}
.review-section-collapsible h4 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.95rem;
    color: var(--theme-title);
    flex-shrink: 0;
}
.review-section-collapsible h4 > i {
    color: var(--theme-brand);
    font-size: 0.9rem;
}
.section-status-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 0.7rem;
    color: #fff;
    flex-shrink: 0;
}
.section-status-good { background: #22c55e; }
.section-status-warn { background: #f59e0b; }
.section-status-bad  { background: #ef4444; }

.review-section-preview {
    flex: 1;
    text-align: right;
    font-size: 0.82rem;
    color: var(--theme-text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    padding-right: 10px;
}
.review-section-toggle {
    color: var(--theme-text-muted);
    transition: transform 0.3s ease;
    font-size: 0.75rem;
    flex-shrink: 0;
}
.review-section-collapsible.open .review-section-toggle {
    transform: rotate(180deg);
}
.review-section-body {
    max-height: 0;
    overflow: hidden;
    padding: 0 18px;
    transition: max-height 0.35s ease, padding 0.35s ease;
}
.review-section-collapsible.open .review-section-body {
    max-height: 2500px;
    padding: 4px 18px 18px 18px;
}
.review-section-collapsible .review-section-body .review-grid {
    margin-top: 0;
}
.review-section-issues {
    margin: 4px 0 14px 0;
    padding-left: 20px;
    font-size: 0.85rem;
    color: #b45309;
    background: rgba(245, 158, 11, 0.1);
    padding: 10px 18px 10px 32px;
    border-radius: 10px;
    border-left: 3px solid #f59e0b;
    list-style-position: outside;
}
.review-section-collapsible.section-bad .review-section-issues {
    color: #b91c1c;
    background: rgba(239, 68, 68, 0.08);
    border-left-color: #ef4444;
}

@media (max-width: 768px) {
    .review-section-collapsible .review-section-header {
        flex-wrap: wrap;
        gap: 8px;
    }
    .review-section-preview {
        flex-basis: 100%;
        text-align: left;
        padding-right: 0;
        white-space: normal;
    }
}
.review-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.review-field label { display: block; font-size: 0.8rem; color: var(--theme-text-muted); margin-bottom: 6px; font-weight: 600; }
.review-field input,
.review-field select {
    width: 100%;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--theme-input-border);
    background: var(--theme-input-bg);
    color: var(--theme-input-text);
    font-size: 0.9rem;
    font-family: var(--font-body);
}
.review-field input:focus,
.review-field select:focus {
    outline: none;
    border-color: var(--theme-brand);
    background: var(--theme-input-bg);
    box-shadow: 0 0 0 3px var(--theme-brand-soft);
}
.review-subsection { margin-top: 18px; }
.review-subsection-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--theme-text-muted);
    margin-bottom: 10px;
    letter-spacing: 0.2px;
}
.review-field-total { grid-column: 1 / -1; }
.review-field-total label {
    color: var(--theme-title);
    font-weight: 800;
    font-size: 0.95rem;
}
.review-field-total input {
    font-size: 0.9rem;
    font-weight: 700;
    padding: 10px 12px;
    border-radius: 12px;
    border: 2px solid var(--theme-brand);
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.16), var(--theme-input-bg));
}
.review-field-total input:focus {
    box-shadow: 0 0 0 3px var(--theme-brand-soft);
}
.review-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 30px; }

/* Sección colapsable de precios unitarios */
.review-collapsible {
    margin-top: 18px;
    border: 1px solid var(--theme-surface-border);
    border-radius: 14px;
    overflow: hidden;
    background: var(--theme-surface-muted);
}
.review-collapsible-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    cursor: pointer;
    background: transparent;
    transition: background 0.2s ease;
    user-select: none;
}
.review-collapsible-header:hover {
    background: var(--theme-brand-soft);
}
.review-collapsible-header h5 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--theme-text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}
.review-collapsible-header h5 i {
    color: var(--theme-brand);
    font-size: 0.85rem;
}
.review-collapsible-toggle {
    font-size: 0.75rem;
    color: var(--theme-brand);
    transition: transform 0.3s ease;
}
.review-collapsible.open .review-collapsible-toggle {
    transform: rotate(180deg);
}
.review-collapsible-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease, padding 0.35s ease;
    padding: 0 18px;
}
.review-collapsible.open .review-collapsible-content {
    max-height: 600px;
    padding: 0 18px 18px 18px;
}
.review-collapsible .review-grid {
    margin-top: 10px;
}
.review-collapsible .review-field label {
    font-size: 0.75rem;
}
.review-collapsible .review-field input {
    font-size: 0.85rem;
    padding: 8px 10px;
}
.unit-price-hint {
    font-size: 0.7rem;
    color: var(--theme-text-muted);
    margin-top: 4px;
    font-style: italic;
}

.quality-panel {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px 24px;
    border-radius: 14px;
    border: 2px solid var(--theme-surface-border);
    background: var(--theme-surface-muted);
    margin-bottom: 16px;
    text-align: left;
}
.quality-score {
    display: flex; align-items: center; justify-content: center;
    min-width: 72px; height: 72px; border-radius: 50%;
    font-size: 1.5rem; font-weight: 800; color: #fff;
    background: var(--theme-brand);
    flex-shrink: 0;
}
.quality-label { font-size: 0.85rem; color: var(--theme-text-muted); font-weight: 600; }
.quality-state { font-size: 1.1rem; font-weight: 700; color: var(--theme-text); }
.quality-panel.quality-good { border-color: rgba(34, 197, 94, 0.5); background: rgba(34, 197, 94, 0.08); }
.quality-panel.quality-good .quality-score { background: #22c55e; }
.quality-panel.quality-warn { border-color: rgba(245, 158, 11, 0.5); background: rgba(245, 158, 11, 0.08); }
.quality-panel.quality-warn .quality-score { background: #f59e0b; }
.quality-panel.quality-bad { border-color: rgba(239, 68, 68, 0.5); background: rgba(239, 68, 68, 0.08); }
.quality-panel.quality-bad .quality-score { background: #ef4444; }
.quality-messages ul { margin-left: 16px; color: var(--theme-text); font-size: 0.9rem; text-align: left; }
.quality-ok { color: var(--theme-amber); font-weight: 600; text-align: left; }

.quality-block {
    margin-top: 12px;
    margin-bottom: 14px;
}

.quality-block-title {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--theme-text-muted);
    font-weight: 700;
    margin-bottom: 8px;
}

.quality-field-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
}

.quality-field-item {
    border: 1px solid var(--theme-surface-border);
    border-radius: 12px;
    padding: 10px 12px;
    background: var(--theme-surface-muted);
}

.quality-field-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
}

.quality-field-name {
    font-size: 0.83rem;
    font-weight: 700;
    color: var(--theme-title);
}

.quality-field-score {
    font-size: 0.78rem;
    font-weight: 800;
    color: var(--theme-brand);
}

.quality-field-detail {
    font-size: 0.78rem;
    color: var(--theme-text-muted);
}

.quality-field-good {
    border-color: rgba(34, 197, 94, 0.35);
    background: rgba(34, 197, 94, 0.08);
}

.quality-field-warn {
    border-color: rgba(245, 158, 11, 0.35);
    background: rgba(245, 158, 11, 0.08);
}

.quality-field-bad {
    border-color: rgba(239, 68, 68, 0.35);
    background: rgba(239, 68, 68, 0.08);
}

.quality-check-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.quality-check {
    border-radius: 12px;
    border: 1px solid var(--theme-surface-border);
    background: var(--theme-surface-muted);
    padding: 10px 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 10px;
    justify-content: space-between;
    align-items: center;
}

.quality-check-label {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--theme-title);
}

.quality-check-detail {
    font-size: 0.78rem;
    color: var(--theme-text-muted);
}

.quality-check-pass {
    border-color: rgba(34, 197, 94, 0.35);
}

.quality-check-warn {
    border-color: rgba(245, 158, 11, 0.35);
}

.quality-check-fail {
    border-color: rgba(239, 68, 68, 0.35);
}

.alert.warn { background-color: rgba(245, 158, 11, 0.15); color: var(--theme-amber); border-left: 4px solid var(--theme-amber); }

/* Recordatorios */
.reminder-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 15px;
}

.reminder-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border: 1px solid var(--theme-surface-border);
    border-radius: 12px;
    background: var(--theme-surface-muted);
}

.reminder-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    color: var(--theme-text);
}

.reminder-title.done {
    text-decoration: line-through;
    color: var(--theme-text-muted);
}

.reminder-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--theme-text-muted);
    font-size: 0.85rem;
}

.reminder-ics {
    text-decoration: none;
    font-weight: 700;
    color: var(--theme-brand);
}

/* Formulario Horizontal del Dashboard */
.flex-form { display: flex; gap: 15px; align-items: center; justify-content: center; flex-wrap: wrap; }
.flex-form .input-group { margin-bottom: 0; flex: 1; min-width: 250px; }

/* Botón de archivo personalizado */
.file-upload-label {
    display: flex; align-items: center; justify-content: center;
    height: 52px; /* Altura igual a los inputs */
    padding: 0 20px;
    background: var(--theme-surface-muted);
    color: var(--theme-text-muted);
    border: 2px dashed var(--theme-input-border);
    border-radius: var(--border-radius-pill);
    cursor: pointer;
    font-weight: 600;
    transition: 0.3s;
    width: 100%;
}
.file-upload-label:hover { border-color: var(--theme-brand); color: var(--theme-brand); background: var(--theme-brand-soft); }
.file-upload-label i { margin-right: 8px; color: var(--opt-medium-purple); }

/* Progreso de subida/analisis */
.upload-progress {
    display: none;
    flex: 1 1 100%;
    margin-top: 12px;
    text-align: left;
}
.upload-progress.active { display: block; }
.upload-progress-track {
    width: 100%;
    height: 12px;
    background: var(--theme-surface-muted);
    border-radius: 999px;
    overflow: hidden;
    border: 1px solid var(--theme-surface-border);
}
.upload-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--theme-brand), #818cf8);
    transition: width 0.2s ease;
}
.upload-progress-text {
    margin-top: 6px;
    font-size: 0.85rem;
    color: var(--theme-text-muted);
    font-weight: 600;
}
.upload-progress-fill.error {
    background: linear-gradient(90deg, #ef4444, #f87171);
}
.upload-progress-fill.extracting-pulse {
    background: linear-gradient(90deg, var(--theme-brand), #818cf8, var(--theme-brand));
    background-size: 200% 100%;
    animation: progress-pulse 1.5s ease-in-out infinite;
}
@keyframes progress-pulse {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Batch progress (bulk import) */
.bulk-progress-container {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 8px;
    background: var(--theme-surface-muted);
    border: 1px solid var(--theme-surface-border);
}
.batch-summary {
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--theme-text);
}
.batch-summary.batch-done {
    color: var(--theme-brand);
}
.batch-failed-count {
    color: #ef4444;
}
.batch-jobs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.batch-job-item {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    background: var(--theme-surface);
    border: 1px solid var(--theme-surface-border);
}
.batch-job-done { color: #16a34a; }
.batch-job-failed { color: #ef4444; }
.batch-job-active { color: var(--theme-brand); }

/* Formulario manual en dashboard */
.analysis-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 25px 0 15px;
    color: var(--theme-text-muted);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 1px;
}
.analysis-divider::before,
.analysis-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--theme-surface-border);
}
.analysis-divider span { padding: 0 6px; }

.manual-details { text-align: left; }
.manual-details summary {
    cursor: pointer;
    font-weight: 700;
    color: var(--theme-title);
    list-style: none;
}
.manual-details summary::-webkit-details-marker { display: none; }
.manual-details summary::after {
    content: "+";
    float: right;
    color: var(--opt-medium-purple);
    font-weight: 800;
}
.manual-details[open] summary::after { content: "-"; }

.manual-hint {
    margin: 10px 0 20px;
    font-size: 0.85rem;
    color: var(--theme-text-muted);
}
.manual-form { margin-top: 10px; }
.manual-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}
.manual-field label {
    display: block;
    font-size: 0.72rem;
    letter-spacing: 0.3px;
    color: var(--theme-text-muted);
    font-weight: 700;
    margin-bottom: 6px;
    text-transform: uppercase;
}
.manual-field input,
.manual-field select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--theme-input-border);
    border-radius: 14px;
    font-size: 0.95rem;
    background: var(--theme-input-bg);
    color: var(--theme-input-text);
    font-family: var(--font-body);
    transition: 0.3s;
}
.manual-field input:focus,
.manual-field select:focus {
    outline: none;
    border-color: var(--theme-brand);
    background: var(--theme-input-bg);
    box-shadow: 0 0 0 3px var(--theme-brand-soft);
}
.manual-subtitle {
    margin: 18px 0 10px;
    font-weight: 700;
    color: var(--theme-title);
    font-size: 0.9rem;
}
.manual-actions { margin-top: 18px; text-align: center; }

/* Tabla de Clientes */
.section-header { display: flex; align-items: center; margin-bottom: 25px; }
.section-header i { font-size: 1.8rem; color: var(--theme-brand); margin-right: 15px; }
.section-header h2 { color: var(--theme-title); font-size: 1.8rem; }

.branded-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--theme-surface);
    border-radius: 15px;
    overflow: hidden;
    border: 1px solid var(--theme-surface-border);
    box-shadow: var(--theme-surface-shadow);
}
.branded-table th {
    background: var(--opt-dark-purple);
    color: white;
    padding: 18px;
    text-align: left;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.branded-table td { padding: 18px; border-bottom: 1px solid var(--theme-surface-border); color: var(--theme-text); }
.client-name { font-weight: 700; color: var(--opt-dark-purple); }
.savings-pos { color: var(--opt-success); font-weight: 800; }

.table-scroll {
    overflow-x: auto;
}

.tariff-prices-table th,
.tariff-prices-table td {
    vertical-align: top;
}

.tariff-prices-table .price-cell {
    min-width: 130px;
}

.tariff-prices-table .price-input {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tariff-prices-table input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--theme-input-border);
    border-radius: 10px;
    font-size: 0.9rem;
    background: var(--theme-input-bg);
    color: var(--theme-input-text);
    font-family: var(--font-body);
    transition: 0.3s;
}

.tariff-prices-table input:focus {
    outline: none;
    border-color: var(--theme-brand);
    background: var(--theme-input-bg);
    box-shadow: 0 0 0 3px var(--theme-brand-soft);
}

.tariff-prices-table .price-default {
    font-size: 0.72rem;
    color: var(--theme-text-muted);
}

.field-default {
    font-size: 0.72rem;
    color: var(--theme-text-muted);
    margin-top: 6px;
    display: block;
}

.tariff-prices-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 18px;
}

.inline-form {
    display: inline-flex;
}

/* =============================================
   TABLA DE RESULTADOS (ESTILO TARIFFAI)
   ============================================= */

.audit-container {
    background: var(--theme-surface);
    padding: 40px;
    border-radius: 20px;
    border: 1px solid var(--theme-surface-border);
    box-shadow: var(--theme-surface-shadow);
    margin-top: -60px; /* Efecto flotante sobre el header */
    position: relative;
    z-index: 10;
}

.optimizze-table {
    width: 100%;
    border-collapse: separate; /* Necesario para bordes redondeados */
    border-spacing: 0;
    font-family: 'Open Sans', sans-serif;
    font-size: 0.95rem;
    color: var(--theme-text);
}

/* --- CABECERA (Compañías) --- */
.optimizze-table thead tr {
    background: var(--opt-dark-purple);
    color: white;
}

.optimizze-table thead th {
    padding: 20px 15px;
    text-align: center;
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 4px solid var(--opt-medium-purple);
}

/* Bordes redondeados superiores */
.optimizze-table thead th:first-child { border-top-left-radius: 15px; }
.optimizze-table thead th:last-child { border-top-right-radius: 15px; }

/* --- CUERPO (Conceptos) --- */
.optimizze-table tbody th {
    /* La primera columna (Conceptos) */
    background-color: var(--theme-surface-muted);
    color: var(--theme-title);
    text-align: left;
    padding: 12px 20px;
    font-weight: 700;
    border-bottom: 1px solid var(--theme-surface-border);
    min-width: 200px;
}

.optimizze-table tbody td {
    /* Las celdas de datos */
    text-align: center;
    padding: 12px 15px;
    border-bottom: 1px solid var(--theme-surface-border);
    color: var(--theme-text);
    transition: background 0.2s;
}

/* Efecto Hover en filas */
.optimizze-table tbody tr:hover td {
    background-color: var(--theme-surface-muted);
}

/* --- FILA DE TOTALES (La última fila) --- */
.optimizze-table tbody tr:last-child th,
.optimizze-table tbody tr:last-child td {
    background-color: var(--theme-brand);
    color: white;
    font-weight: 800;
    font-size: 1.1rem;
    padding: 20px;
    border-top: 2px solid var(--opt-medium-purple);
}

.optimizze-table tbody tr:last-child th {
    border-bottom-left-radius: 15px;
    text-transform: uppercase;
}

.optimizze-table tbody tr:last-child td:last-child {
    border-bottom-right-radius: 15px;
}

/* --- RESALTAR FACTURA REAL (Opcional, si es la última columna) --- */
.optimizze-table tbody td:last-child {
    background-color: var(--theme-surface-muted);
    font-weight: 600;
    color: var(--theme-text-muted);
    border-left: 1px dashed var(--theme-surface-border);
}

/* =============================================
   TABLA TÉCNICA (DESGLOSE) — COLORES RESTAURADOS
   ============================================= */

.tech-table-wrap{
    width: 100%;
    overflow: auto;
    max-height: 70vh;
    border-radius: 16px;
    border: 1px solid var(--theme-surface-border);
    box-shadow: var(--theme-surface-shadow);
    background: var(--theme-surface);
    backdrop-filter: var(--theme-card-blur);
}

.tech-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.88rem;
    font-family: var(--font-body);
}

/* ✅ Fix principal: usar --opt-dark-purple (y dejamos alias --opt-dark arriba por si acaso) */
.tech-table thead tr{
    background: var(--opt-dark-purple);
    color: var(--opt-white);
}

.tech-table thead th{
    position: sticky;
    top: 0;
    z-index: 6;
    background: var(--opt-dark-purple);
    color: var(--opt-white);
    padding: 16px 14px;
    font-family: var(--font-heading);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    border-bottom: 3px solid var(--opt-medium-purple);
    text-align: center;
}

.tech-table thead th:first-child{
    text-align: left;
}

.tech-table tbody th{
    position: sticky;
    left: 0;
    z-index: 5;
    text-align: left;
    padding: 12px 14px;
    font-weight: 800;
    color: var(--theme-title);
    background: var(--theme-surface-muted);
    border-bottom: 1px solid var(--theme-surface-border);
    min-width: 220px;
}

.tech-table tbody td{
    text-align: center;
    padding: 12px 12px;
    border-bottom: 1px solid var(--theme-surface-border);
    color: var(--theme-text);
    background: var(--theme-surface);
}

.tech-table tbody tr:hover td{
    filter: brightness(0.98);
}

.tech-table tbody td:last-child{
    background: var(--theme-surface-muted);
    font-weight: 800;
    color: var(--theme-title);
    border-left: 2px dashed var(--theme-surface-border);
}

/* --- Secciones por fila (si las usas por clases) ---
   Nota: si ahora generas el HTML con Pandas Styler (inline styles),
   esto sirve como fallback o para tablas antiguas. */
.tech-table tbody tr.row-days th,
.tech-table tbody tr.row-days td{
    background: var(--row-days-bg) !important;
    color: var(--row-days-text) !important;
    font-weight: 900;
}

.tech-table tbody tr.row-power th,
.tech-table tbody tr.row-power td{
    background: var(--row-power-bg) !important;
    color: var(--row-power-text) !important;
    font-weight: 800;
}

.tech-table tbody tr.row-energy th,
.tech-table tbody tr.row-energy td{
    background: var(--row-energy-bg) !important;
    color: var(--row-energy-text) !important;
    font-weight: 800;
}

.tech-table tbody tr.row-fixed th,
.tech-table tbody tr.row-fixed td{
    background: var(--row-fixed-bg) !important;
    color: var(--row-fixed-text) !important;
    font-weight: 800;
}

.tech-table tbody tr.row-tax th,
.tech-table tbody tr.row-tax td{
    background: var(--row-tax-bg) !important;
    color: var(--row-tax-text) !important;
    font-weight: 800;
}

.tech-table tbody tr.row-taxes th,
.tech-table tbody tr.row-taxes td{
    background: var(--row-tax-bg) !important;
    color: var(--row-tax-text) !important;
    font-weight: 800;
}

.tech-table tbody tr.row-total th,
.tech-table tbody tr.row-total td{
    background: var(--theme-brand) !important;
    color: #ffffff !important;
    font-weight: 900;
    font-size: 1.05rem;
    padding-top: 16px;
    padding-bottom: 16px;
    border-top: 2px solid var(--opt-medium-purple);
    border-bottom: none;
}

.tech-table tbody tr.row-total td:last-child{
    background: var(--theme-brand) !important;
    color: #ffffff !important;
    border-left: 2px solid rgba(255,255,255,0.15);
}

/* =============================================
   RESPONSIVE (mínimo)
   ============================================= */
@media (max-width: 768px){
    .auth-card { padding: 40px 26px; }
    .hero-content h1 { font-size: 2.1rem; }
    .analysis-card { padding: 26px; }
    .optimizze-table thead th { padding: 16px 10px; font-size: 0.78rem; }
    .optimizze-table tbody th { min-width: 160px; }
    .tech-table tbody th { min-width: 180px; }
}

/* =============================================
   APP SHELL + NUEVO DASHBOARD
   ============================================= */
.app-shell {
    display: flex;
    min-height: 100vh;
    background: var(--app-bg);
    transition: background-color 0.5s ease, color 0.5s ease;
}

.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    color: var(--theme-sidebar-text);
    padding: 28px 20px;
    display: flex;
    flex-direction: column;
    gap: 22px;
    border-right: 1px solid var(--theme-sidebar-border);
    box-shadow: 12px 0 30px rgba(15, 23, 42, 0.12);
    transition: background-color 0.5s ease, color 0.5s ease, border-color 0.5s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: var(--font-heading);
    font-weight: 800;
    letter-spacing: 1px;
    font-size: 1.2rem;
}

.sidebar-brand img {
    height: 38px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sidebar-theme {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sidebar-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1.4px;
    color: var(--theme-sidebar-muted);
    font-weight: 700;
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px;
    border-radius: 999px;
    background: var(--theme-toggle-bg);
    border: 1px solid var(--theme-toggle-border);
    transition: background-color 0.5s ease, border-color 0.5s ease;
}

.theme-btn {
    width: 36px;
    height: 36px;
    border-radius: 999px;
    border: none;
    background: transparent;
    color: var(--theme-sidebar-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    font-size: 15px;
    opacity: 0.75;
}

.theme-btn i,
.theme-btn svg {
    font-size: 15px;
    line-height: 1;
    pointer-events: none;
}

.theme-btn:hover {
    color: var(--theme-sidebar-text);
    opacity: 1;
}

.theme-btn.active {
    background: var(--theme-toggle-active-bg);
    color: var(--theme-sidebar-text);
    box-shadow: 0 0 0 1px var(--theme-toggle-border);
    opacity: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 999px;
    color: var(--theme-sidebar-muted);
    font-weight: 600;
    transition: all 0.2s ease;
}

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

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

/* ─── Nav Group (collapsible sub-menu) ─── */
.nav-group { display: flex; flex-direction: column; }
.nav-group-toggle {
    cursor: pointer; border: none; background: none; width: 100%;
    text-align: left; font-family: inherit; font-size: inherit;
    position: relative;
}
.nav-group-toggle .nav-group-arrow {
    margin-left: auto; font-size: 0.6rem; transition: transform 0.25s ease;
}
.nav-group.open .nav-group-toggle .nav-group-arrow { transform: rotate(180deg); }
.nav-group-items {
    display: none; flex-direction: column; padding-left: 16px;
    overflow: hidden;
}
.nav-group.open .nav-group-items { display: flex; }
.nav-sub-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 14px; border-radius: 999px;
    color: var(--theme-sidebar-muted); font-weight: 500;
    font-size: 0.85rem; transition: all 0.2s ease;
    text-decoration: none;
}
.nav-sub-item i { width: 16px; text-align: center; font-size: 0.78rem; }
.nav-sub-item:hover,
.nav-sub-item.active {
    background: var(--theme-sidebar-active-bg);
    color: var(--theme-sidebar-text);
}
:root[data-theme="dark"] .nav-sub-item,
body[data-theme="dark"] .nav-sub-item { color: #94a3b8; }
:root[data-theme="dark"] .nav-sub-item:hover,
:root[data-theme="dark"] .nav-sub-item.active,
body[data-theme="dark"] .nav-sub-item:hover,
body[data-theme="dark"] .nav-sub-item.active {
    background: rgba(99, 102, 241, 0.32); color: #ffffff;
}

.sidebar-promo {
    margin-top: auto;
    padding: 18px;
    border-radius: 18px;
    border: 1px solid var(--theme-sidebar-border);
    background: var(--theme-sidebar-promo-bg);
    transition: background-color 0.5s ease, border-color 0.5s ease;
}

.sidebar-promo h4 {
    text-transform: uppercase;
    letter-spacing: 1.4px;
    font-size: 0.75rem;
    margin-bottom: 6px;
}

.sidebar-promo p {
    font-size: 0.82rem;
    color: var(--theme-sidebar-muted);
    margin-bottom: 12px;
    line-height: 1.4;
}

.promo-btn {
    width: 100%;
    text-align: center;
    font-size: 0.75rem;
    padding: 10px 12px;
}

:root[data-theme="dark"] .sidebar,
body[data-theme="dark"] .sidebar {
    background: #0b1222;
    color: #e2e8f0;
    border-right-color: rgba(255, 255, 255, 0.08);
    box-shadow: 12px 0 30px rgba(2, 6, 23, 0.6);
}

:root[data-theme="dark"] .sidebar-brand span,
body[data-theme="dark"] .sidebar-brand span {
    color: #e2e8f0;
}

:root[data-theme="dark"] .nav-item,
body[data-theme="dark"] .nav-item {
    color: #94a3b8;
}

:root[data-theme="dark"] .nav-item:hover,
:root[data-theme="dark"] .nav-item.active,
body[data-theme="dark"] .nav-item:hover,
body[data-theme="dark"] .nav-item.active {
    background: rgba(99, 102, 241, 0.32);
    color: #ffffff;
}

:root[data-theme="dark"] .sidebar-label,
body[data-theme="dark"] .sidebar-label {
    color: #94a3b8;
}

:root[data-theme="dark"] .sidebar-promo,
body[data-theme="dark"] .sidebar-promo {
    background: rgba(15, 23, 42, 0.7);
    border-color: rgba(255, 255, 255, 0.08);
}

:root[data-theme="dark"] .sidebar-promo h4,
body[data-theme="dark"] .sidebar-promo h4 {
    color: #e2e8f0;
}

:root[data-theme="dark"] .sidebar-promo p,
body[data-theme="dark"] .sidebar-promo p {
    color: #94a3b8;
}

.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--app-bg);
    transition: background-color 0.5s ease, color 0.5s ease;
}

.topbar {
    background: var(--theme-topbar-bg);
    border-bottom: 1px solid var(--theme-topbar-border);
    padding: 16px 28px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    transition: background-color 0.5s ease, border-color 0.5s ease;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.top-link {
    color: var(--theme-text-muted);
    font-size: 0.85rem;
    font-weight: 600;
}

.top-link:hover {
    color: var(--theme-brand);
}

.pill {
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.6px;
    text-transform: uppercase;
}

.pill.pro {
    background: #dcfce7;
    color: #166534;
}

.pill.free {
    background: #e2e8f0;
    color: #334155;
}

.pill.stats-pill {
    background: var(--theme-brand-soft);
    color: var(--theme-brand);
}

.avatar {
    width: 38px;
    height: 38px;
    border-radius: 999px;
    background: var(--theme-brand);
    color: #ffffff;
    font-weight: 800;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── User menu dropdown ── */
.topbar-user-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 4px 8px 4px 4px;
    cursor: pointer;
    transition: background .15s, border-color .15s;
    color: var(--theme-text);
}
.topbar-user-btn:hover {
    background: var(--theme-surface-muted);
    border-color: var(--theme-border);
}
.topbar-user-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--theme-surface);
    border: 1px solid var(--theme-border);
    border-radius: 12px;
    box-shadow: 0 16px 48px rgba(0,0,0,.2);
    min-width: 220px;
    z-index: 9999;
    padding: 4px 0;
}
.topbar-user-menu.open .topbar-user-dropdown { display: block; }
.topbar-user-dropdown a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--theme-text);
    text-decoration: none;
    transition: background .15s;
}
.topbar-user-dropdown a:hover { background: var(--theme-surface-muted); }
.topbar-user-dropdown a i { width: 16px; text-align: center; opacity: .6; }

.app-content {
    padding: 28px 32px 48px;
    transition: background-color 0.5s ease, color 0.5s ease;
}

.page-wrap {
    max-width: 1200px;
    margin: 0 auto;
    overflow-x: hidden;
}

.white-card {
    background: var(--theme-surface);
    border-radius: 22px;
    padding: 24px;
    border: 1px solid var(--theme-surface-border);
    box-shadow: var(--card-shadow);
    backdrop-filter: var(--theme-card-blur);
    margin-bottom: 24px;
    transition: background-color 0.5s ease, color 0.5s ease, border-color 0.5s ease, box-shadow 0.5s ease;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 18px;
    font-family: var(--font-heading);
}

.card-header h3 {
    font-size: 1.1rem;
    color: var(--theme-title);
}

.card-header i {
    color: var(--theme-brand);
}

.card-header.row-between {
    justify-content: space-between;
}

.card-subtitle {
    font-size: 0.85rem;
    color: var(--theme-text-muted);
    font-weight: 600;
}

.link-muted {
    color: var(--theme-text-muted);
    font-weight: 600;
    font-size: 0.85rem;
}

.link-muted:hover {
    color: var(--theme-brand);
}

.hero {
    margin-bottom: 26px;
}

.hero-card {
    background: var(--hero-card-bg);
    border-radius: 32px;
    padding: 40px;
    color: #ffffff;
    position: relative;
    overflow: hidden;
    transition: background 0.5s ease;
}

.hero-card::before {
    content: "";
    position: absolute;
    top: -70px;
    right: -50px;
    width: 190px;
    height: 190px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
}

.hero-card::after {
    content: "";
    position: absolute;
    bottom: -90px;
    left: -60px;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
}

.hero-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 26px;
}

.hero-text h1 {
    font-size: 2.2rem;
    font-weight: 800;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.hero-text p {
    font-size: 1rem;
    opacity: 0.85;
    max-width: 640px;
    margin: 0 auto;
}

.hero-kicker {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1.6px;
    color: rgba(255, 255, 255, 0.75);
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
}

.analysis-inline-card {
    background: var(--theme-surface);
    color: var(--theme-text);
    border-radius: 22px;
    padding: 28px;
    width: min(920px, 100%);
    text-align: left;
    border: 1px solid var(--theme-surface-border);
    box-shadow: 0 18px 40px rgba(23, 26, 70, 0.18);
    backdrop-filter: var(--theme-card-blur);
    transition: background-color 0.5s ease, color 0.5s ease, border-color 0.5s ease, box-shadow 0.5s ease;
}

.analysis-inline-card h3 {
    color: var(--theme-title);
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.analysis-inline-card h3 i {
    color: var(--theme-brand);
}

.analysis-inline-card .flex-form {
    justify-content: flex-start;
}

.file-group {
    flex: 1;
    min-width: 240px;
}

.file-name {
    display: block;
    margin-top: 6px;
    color: var(--theme-brand);
    font-weight: 700;
    font-size: 0.85rem;
}

.file-hint {
    display: block;
    margin-top: 4px;
    color: var(--theme-text-muted);
    font-size: 0.8rem;
}

/* ====================================================================
   DRAG-AND-DROP ZONE
   ==================================================================== */
.dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 120px;
    padding: 24px 16px;
    border: 2px dashed var(--theme-input-border);
    border-radius: var(--border-radius);
    background: var(--theme-surface-muted);
    cursor: pointer;
    transition: border-color 0.25s, background 0.25s, box-shadow 0.25s;
}
.dropzone:hover {
    border-color: var(--theme-brand);
    background: var(--theme-brand-soft);
}
.dropzone-active {
    border-color: var(--theme-brand);
    background: var(--theme-brand-soft);
    box-shadow: 0 0 0 3px rgba(var(--theme-brand-rgb, 123, 97, 255), 0.18);
}
.dropzone-has-files .dropzone-prompt span,
.dropzone-has-files .dropzone-prompt small {
    display: none;
}
.dropzone-has-files .dropzone-prompt i {
    font-size: 1rem;
    margin-bottom: 0;
}
.dropzone-has-files {
    min-height: auto;
    padding: 12px;
}

.dropzone-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-align: center;
}
.dropzone-prompt i {
    font-size: 2rem;
    color: var(--opt-medium-purple);
    margin-bottom: 4px;
}
.dropzone-prompt span {
    font-weight: 600;
    color: var(--theme-text-muted);
    font-size: 0.95rem;
}
.dropzone-prompt small {
    color: var(--theme-text-muted);
    font-size: 0.8rem;
    opacity: 0.8;
}

/* File previews */
.file-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    width: 100%;
    margin-top: 8px;
}
.file-preview:empty { margin-top: 0; }

.file-preview-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--theme-card-bg);
    border: 1px solid var(--theme-input-border);
    border-radius: 8px;
    padding: 6px 10px;
    max-width: 220px;
    position: relative;
}

.file-preview-thumb {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--theme-surface-muted);
}
.file-preview-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.file-preview-pdf {
    color: #e74c3c;
    font-size: 1.4rem;
}

.file-preview-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.file-preview-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--theme-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.file-preview-size {
    font-size: 0.72rem;
    color: var(--theme-text-muted);
}

.file-preview-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: none;
    background: var(--theme-text-muted);
    color: var(--theme-card-bg);
    font-size: 0.6rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}
.file-preview-item:hover .file-preview-remove {
    opacity: 1;
}
.file-preview-remove:hover {
    background: #e74c3c;
}

/* ====================================================================
   DASHBOARD — KPI CARDS
   ==================================================================== */
/* ── Onboarding banner ── */
.onboarding-banner {
    padding: 20px 24px;
    margin-bottom: 20px;
    border-left: 4px solid var(--theme-brand, #4e6ef2);
}
.onboarding-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
}
.onboarding-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--theme-brand-soft, rgba(78,110,242,0.1));
    color: var(--theme-brand, #4e6ef2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}
.onboarding-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--theme-title);
}
.onboarding-sub {
    font-size: 0.82rem;
    color: var(--theme-text-muted);
    margin-top: 2px;
}
.onboarding-dismiss {
    margin-left: auto;
    opacity: 0.4;
}
.onboarding-dismiss:hover {
    opacity: 1;
}
.onboarding-steps {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}
.onboarding-step {
    display: flex;
    gap: 12px;
    padding: 14px;
    border-radius: 10px;
    background: var(--theme-surface, #f8f9fa);
}
.ob-step-muted {
    opacity: 0.5;
}
.ob-step-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--theme-brand, #4e6ef2);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.ob-step-muted .ob-step-num {
    background: var(--theme-text-muted, #9ca3af);
}
.ob-step-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--theme-title);
}
.ob-step-desc {
    font-size: 0.78rem;
    color: var(--theme-text-muted);
    margin-top: 3px;
    line-height: 1.4;
}

.dash-kpis {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
    margin-bottom: 22px;
}
@media (max-width: 1200px) {
    .dash-kpis { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 600px) {
    .dash-kpis { grid-template-columns: repeat(2, 1fr); }
}

.dash-kpi-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
}

.dash-kpi-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--theme-brand-soft);
    color: var(--theme-brand);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.dash-kpi-icon.accent {
    background: rgba(245, 158, 11, 0.12);
    color: var(--theme-amber, #f59e0b);
}

.dash-kpi-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.dash-kpi-value {
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1.2;
    color: var(--theme-brand);
}

.dash-kpi-value.accent {
    color: var(--theme-amber, #f59e0b);
}

.dash-kpi-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--theme-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dash-kpi-sub {
    font-size: 0.7rem;
    color: var(--theme-text-muted);
    opacity: 0.8;
    margin-top: 1px;
}

.dash-kpi-icon-green {
    background: rgba(34, 197, 94, 0.12);
    color: #16a34a;
}

/* ====================================================================
   DASHBOARD — UPLOAD SECTION
   ==================================================================== */
.dash-upload-section {
    margin-bottom: 24px;
}

.dash-upload-card {
    background: var(--theme-surface);
    border-radius: 24px;
    padding: 32px;
    border: 1px solid var(--theme-surface-border);
    box-shadow: 0 12px 36px rgba(23, 26, 70, 0.10);
    backdrop-filter: var(--theme-card-blur);
    transition: background-color 0.5s ease, border-color 0.5s ease, box-shadow 0.5s ease;
}

.dash-upload-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.dash-upload-icon-wrap {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--theme-brand), #818cf8);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.dash-upload-title {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--theme-title);
    margin: 0;
}

.dash-upload-subtitle {
    font-size: 0.88rem;
    color: var(--theme-text-muted);
    margin: 2px 0 0;
}

.dash-upload-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.dash-upload-form .input-group {
    margin-bottom: 0;
}

.dash-dropzone {
    min-height: 150px;
    border-radius: 18px;
    border-width: 2px;
}

.dash-dropzone .dropzone-prompt {
    gap: 10px;
    padding: 8px 0;
}

.dash-dropzone-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--theme-brand-soft);
    color: var(--theme-brand);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 4px;
}

.dash-dropzone .dropzone-prompt span {
    font-size: 0.95rem;
}

.dash-dropzone .dropzone-prompt span strong {
    color: var(--theme-brand);
}

.dash-submit-btn {
    width: 100%;
    padding: 16px 30px;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

/* Mode toggle (single ↔ bulk) */
.dash-mode-toggle {
    display: flex;
    background: var(--theme-bg);
    border-radius: 14px;
    padding: 4px;
    gap: 4px;
    margin-bottom: 20px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.dash-mode-toggle::-webkit-scrollbar { display: none; }

.dash-mode-btn {
    flex: 1 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 16px;
    border: none;
    border-radius: 11px;
    background: transparent;
    color: var(--theme-text-muted);
    font-size: 0.9rem;
    font-weight: 700;
    font-family: var(--font-heading);
    cursor: pointer;
    transition: all 0.25s ease;
    white-space: nowrap;
}

.dash-mode-btn:hover {
    color: var(--theme-text);
}

.dash-mode-btn.active {
    background: var(--theme-brand);
    color: #fff;
    box-shadow: 0 4px 12px rgba(123, 97, 255, 0.35);
}

.dash-mode-btn i {
    font-size: 0.85rem;
}

@media (max-width: 600px) {
    .dash-mode-btn {
        padding: 10px 12px;
        font-size: 0.78rem;
        gap: 5px;
    }
    .dash-mode-btn i { font-size: 0.75rem; }
}

.dash-mode-hint {
    font-size: 0.88rem;
    color: var(--theme-text-muted);
    margin: 0 0 16px;
}

.dash-direct-compare {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding: 12px;
    border: 1px dashed var(--theme-surface-border);
    border-radius: 12px;
    background: var(--theme-bg);
}

.dash-direct-compare .btn-opt {
    text-decoration: none;
}

.dash-direct-compare small {
    color: var(--theme-text-muted);
    font-size: 0.82rem;
}

/* Legacy feature-grid (kept for other pages) */
.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

.feature-card {
    background: var(--theme-surface);
    border-radius: 20px;
    padding: 22px;
    border: 1px solid var(--theme-surface-border);
    box-shadow: var(--card-shadow);
    backdrop-filter: var(--theme-card-blur);
    transition: background-color 0.5s ease, color 0.5s ease, border-color 0.5s ease, box-shadow 0.5s ease;
}

.feature-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--theme-brand-soft);
    color: var(--theme-brand);
    margin-bottom: 12px;
    font-size: 1.1rem;
}

.feature-card h4 {
    color: var(--theme-title);
    font-size: 1rem;
    margin-bottom: 6px;
}

.feature-card p {
    color: var(--theme-text-muted);
    font-size: 0.9rem;
}

.progress-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--theme-text-muted);
    margin-bottom: 8px;
}

.upload-progress {
    display: none;
    flex: 1 1 100%;
    margin-top: 14px;
}

.upload-progress.active {
    display: block;
}

.upload-progress-track {
    width: 100%;
    height: 12px;
    background: var(--theme-surface-muted);
    border-radius: 999px;
    overflow: hidden;
    border: 1px solid var(--theme-surface-border);
}

.upload-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--theme-brand), #818cf8);
    transition: width 0.2s ease;
}

.btn-small {
    padding: 8px 14px;
    font-size: 0.75rem;
    border-radius: 10px;
}

.btn-opt-secondary {
    background: transparent;
    border: 1px solid var(--theme-surface-border);
    color: var(--theme-text-muted);
}

.btn-opt-secondary:hover {
    border-color: var(--theme-brand);
    color: var(--theme-brand);
    background: var(--theme-brand-soft);
}

.input-opt {
    width: 100%;
    height: 44px;
    padding: 0 14px;
    border-radius: 12px;
    border: 1px solid var(--theme-input-border);
    background: var(--theme-input-bg);
    color: var(--theme-input-text);
    font-size: 0.92rem;
    font-family: var(--font-body);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.input-opt::placeholder {
    color: var(--theme-text-muted);
}

.input-opt:focus {
    outline: none;
    border-color: var(--theme-brand);
    box-shadow: 0 0 0 3px var(--theme-brand-soft);
}

select.input-opt {
    cursor: pointer;
}

.input-opt-textarea {
    min-height: 120px;
    height: auto;
    padding: 12px 14px;
    resize: vertical;
    line-height: 1.5;
}

.crm-filters-card {
    margin-bottom: 14px;
    text-align: left;
    position: relative;
    overflow: hidden;
}

.crm-filters-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 2px;
    background: linear-gradient(90deg, transparent 0%, var(--theme-brand) 25%, #818cf8 75%, transparent 100%);
    opacity: 0.7;
}

.crm-filters-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 14px;
    align-items: end;
}

.crm-filter-field {
    min-width: 0;
}

.crm-filter-field-wide {
    grid-column: span 2;
}

.crm-filter-label {
    display: block;
    margin-bottom: 6px;
    color: var(--theme-text-muted);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.crm-filter-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    grid-column: 1 / -1;
}

.crm-filter-actions .btn-opt {
    padding: 8px 18px;
    font-size: 0.78rem;
}

.crm-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 8px 0 14px;
}

.crm-preset-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid var(--theme-surface-border);
    background: var(--theme-surface);
    color: var(--theme-text-muted);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.crm-preset-chip:hover {
    border-color: var(--theme-brand);
    color: var(--theme-brand);
}

.crm-preset-chip.active {
    border-color: transparent;
    background: linear-gradient(90deg, var(--theme-brand), #818cf8);
    color: #fff;
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.22);
}

.crm-bulk-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    padding: 10px 12px;
    border: 1px solid var(--theme-surface-border);
    border-radius: 12px;
    background: var(--theme-surface);
}

.crm-check-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--theme-text);
    font-weight: 700;
    font-size: 0.82rem;
}

.crm-check-label input[type="checkbox"],
.crm-row-selector input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--theme-brand);
}

.crm-selected-count {
    color: var(--theme-text-muted);
    font-size: 0.82rem;
    font-weight: 700;
    min-width: 108px;
}

.crm-bulk-select {
    width: auto;
    min-width: 170px;
}

.crm-row-selector {
    align-self: stretch;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    margin-right: -4px;
}

.crm-divider {
    margin: 14px 0;
    border: 0;
    border-top: 1px solid var(--theme-surface-border);
    opacity: 0.7;
}

.customer-page-header {
    gap: 12px;
    flex-wrap: wrap;
}

.customer-header-meta {
    margin-top: 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px 14px;
}

.customer-header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

/* ── Customer Detail: KPI Strip ── */
.cd-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.cd-kpi-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
}

.cd-kpi-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--theme-brand-soft);
    color: var(--theme-brand);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.cd-kpi-icon-green {
    background: rgba(34, 197, 94, 0.12);
    color: #16a34a;
}

.cd-kpi-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cd-kpi-value {
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1.2;
    color: var(--theme-title);
    font-family: var(--font-heading);
}

.cd-kpi-green {
    color: #16a34a;
}

.cd-kpi-muted {
    opacity: 0.4;
}

.cd-kpi-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--theme-text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.cd-kpi-status-card {
    min-width: 140px;
}

.cd-kpi-status-select {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--theme-title);
    background: var(--theme-surface-muted);
    border: 1px solid var(--theme-surface-border);
    border-radius: 8px;
    padding: 4px 8px;
    cursor: pointer;
    font-family: var(--font-heading);
}

/* ── Customer Detail: Main Grid ── */
.cd-main-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 18px;
}

.cd-card {
    padding: 22px 24px;
}

.cd-supply-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 16px;
}

.cd-supply-bordered {
    margin-bottom: 14px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--theme-surface-border);
}

.cd-supply-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--theme-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 2px;
}

.cd-supply-value {
    font-weight: 600;
    color: var(--theme-title);
    word-break: break-all;
}

/* ── Contract section ── */
.cd-contract-badge {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.cd-contract-success { background: rgba(34,197,94,0.15); color: #16a34a; }
.cd-contract-warning { background: rgba(245,158,11,0.15); color: #d97706; }
.cd-contract-danger { background: rgba(239,68,68,0.15); color: #dc2626; }
.cd-contract-muted { background: var(--theme-surface-muted); color: var(--theme-text-muted); }

.cd-contract-details { margin-top: 10px; }
.cd-contract-summary {
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--theme-brand);
    padding: 6px 0;
    display: flex;
    align-items: center;
    gap: 6px;
}
.cd-contract-summary:hover { opacity: 0.8; }

.cd-contract-form { margin-top: 12px; }
.cd-contract-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 16px;
}
.cd-contract-field label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--theme-text-muted);
    display: block;
    margin-bottom: 3px;
}
.cd-contract-field .input-opt {
    width: 100%;
    box-sizing: border-box;
}

/* ── Notifications ── */
.notif-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: #fff;
    font-size: 0.6rem;
    font-weight: 800;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    line-height: 1;
}

.notif-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    width: 320px;
    max-height: 400px;
    overflow-y: auto;
    background: var(--theme-surface);
    border: 1px solid var(--theme-surface-border);
    border-radius: 12px;
    box-shadow: var(--theme-surface-shadow);
    z-index: 1000;
    padding: 8px 0;
}
.notif-dd-item {
    display: flex;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--theme-surface-border);
    align-items: flex-start;
}
.notif-dd-item:last-of-type { border-bottom: none; }
.notif-dd-unread { background: var(--theme-brand-soft); }
.notif-dd-icon { font-size: 1rem; margin-top: 2px; }
.notif-dd-icon-warning { color: #f59e0b; }
.notif-dd-icon-alert { color: #ef4444; }
.notif-dd-icon-success { color: #22c55e; }
.notif-dd-icon-info { color: var(--theme-brand); }
.notif-dd-text { flex: 1; min-width: 0; }
.notif-dd-title { font-weight: 600; font-size: 0.8rem; color: var(--theme-title); }
.notif-dd-body { font-size: 0.75rem; color: var(--theme-text-muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notif-dd-empty { padding: 20px; text-align: center; color: var(--theme-text-muted); font-size: 0.85rem; }
.notif-dd-all { display: block; text-align: center; padding: 10px; font-weight: 600; font-size: 0.8rem; color: var(--theme-brand); text-decoration: none; border-top: 1px solid var(--theme-surface-border); }
.notif-dd-all:hover { opacity: 0.8; }

/* Search dropdown */
.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--theme-surface);
    border: 1px solid var(--theme-surface-border);
    border-radius: 12px;
    box-shadow: var(--theme-surface-shadow);
    z-index: 1001;
    max-height: 380px;
    overflow-y: auto;
    margin-top: 4px;
}
.search-group { padding: 4px 0; }
.search-group + .search-group { border-top: 1px solid var(--theme-surface-border); }
.search-group-title {
    padding: 6px 14px 4px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--theme-text-muted);
}
.search-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    text-decoration: none;
    color: var(--theme-title);
    font-size: 0.85rem;
    transition: background 0.15s;
}
.search-item:hover { background: var(--theme-brand-soft); }
.search-item i { width: 16px; text-align: center; color: var(--theme-brand); font-size: 0.8rem; }
.search-item span:first-of-type { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-meta { font-size: 0.75rem; color: var(--theme-text-muted); }
.search-empty { padding: 20px; text-align: center; color: var(--theme-text-muted); font-size: 0.85rem; }

/* Notification page */
.notif-list { display: flex; flex-direction: column; gap: 8px; }
.notif-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 18px;
    cursor: pointer;
    transition: background 0.2s;
}
.notif-item:hover { background: var(--theme-surface-muted); }
.notif-unread { border-left: 3px solid var(--theme-brand); }
.notif-icon { font-size: 1.2rem; margin-top: 2px; }
.notif-icon-warning { color: #f59e0b; }
.notif-icon-alert { color: #ef4444; }
.notif-icon-success { color: #22c55e; }
.notif-icon-info { color: var(--theme-brand); }
.notif-content { flex: 1; min-width: 0; }
.notif-title { font-weight: 700; font-size: 0.9rem; color: var(--theme-title); }
.notif-body { font-size: 0.82rem; color: var(--theme-text-muted); margin-top: 3px; }
.notif-meta { display: flex; gap: 12px; margin-top: 6px; font-size: 0.72rem; color: var(--theme-text-muted); }
.notif-category { text-transform: uppercase; font-weight: 700; letter-spacing: 0.5px; }
.notif-link { color: var(--theme-brand); font-size: 1rem; padding: 4px; align-self: center; }

.cd-sp-count {
    background: var(--theme-brand-soft);
    color: var(--theme-brand);
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: auto;
}

.cd-recommendation {
    margin-top: 14px;
    padding: 10px 14px;
    background: rgba(34, 197, 94, 0.08);
    border: 1px solid rgba(34, 197, 94, 0.2);
    border-radius: 10px;
    font-size: 0.85rem;
    color: #15803d;
}

.cd-recommendation i {
    margin-right: 6px;
    color: #16a34a;
}

/* ── Customer Detail: CRM Section ── */
.cd-crm-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    margin-bottom: 14px;
}

.cd-crm-field {
    flex: 1;
}

.cd-field-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--theme-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 6px;
}

.cd-select-compact {
    width: 100%;
    font-size: 0.85rem;
    padding: 8px 10px;
}

.cd-btn-compact {
    padding: 8px 14px;
    font-size: 0.8rem;
}

.cd-crm-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.cd-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--theme-surface-border);
}

.cd-notes-area {
    width: 100%;
    font-size: 0.85rem;
    resize: vertical;
    min-height: 60px;
}

.cd-btn-save {
    margin-top: 8px;
}

/* ── Customer Detail: Tasks ── */
.cd-task-form {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 10px;
}

.cd-task-input {
    flex: 1;
    min-width: 140px;
    font-size: 0.85rem;
    padding: 8px 10px;
}

.cd-tasks-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cd-task-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 8px;
    background: var(--theme-surface-muted);
}

.cd-task-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.cd-task-title {
    font-weight: 600;
    font-size: 0.85rem;
}

.cd-task-title.is-done {
    text-decoration: line-through;
    opacity: 0.55;
}

.cd-empty-text {
    opacity: 0.5;
    font-size: 0.85rem;
    padding: 8px 0;
}

/* ── Customer Detail: Timeline Card ── */
.cd-timeline-card {
    margin-top: 0;
}

.cd-table-wrap {
    overflow-x: auto;
}

.cd-col-actions {
    white-space: nowrap;
    text-align: right;
}

.cd-col-actions a {
    margin-left: 4px;
}

.btn-icon {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: var(--theme-brand-soft);
    color: var(--theme-brand);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    border: none;
    transition: background-color 0.5s ease, color 0.5s ease;
}

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

.btn-icon.danger {
    background: rgba(220, 38, 38, 0.12);
    color: #ef4444;
}

.btn-icon.danger:hover {
    background: rgba(220, 38, 38, 0.22);
}

.portfolio-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.portfolio-row {
    background: var(--theme-surface);
    border-radius: 20px;
    padding: 18px 22px;
    display: flex;
    align-items: center;
    gap: 18px;
    border: 1px solid var(--theme-surface-border);
    box-shadow: var(--card-shadow);
    backdrop-filter: var(--theme-card-blur);
    transition: background-color 0.5s ease, color 0.5s ease, border-color 0.5s ease, box-shadow 0.5s ease;
}

.portfolio-list.compact .portfolio-row {
    box-shadow: none;
    border: 1px solid var(--theme-surface-border);
}

.portfolio-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--theme-brand-soft);
    color: var(--theme-brand);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.portfolio-main {
    flex: 1;
}

.portfolio-main-wide {
    min-width: 260px;
}

.portfolio-name {
    font-weight: 700;
    color: var(--theme-title);
}

/* Expiry badges */
.expiry-badge {
    display: inline-block;
    font-size: 0.62rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 5px;
    margin-left: 6px;
    vertical-align: middle;
    letter-spacing: 0.5px;
}
.expiry-expired {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fca5a5;
}
.expiry-critical {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fca5a5;
    animation: pulse-badge 1.2s ease-in-out infinite;
}
.expiry-warning {
    background: #fffbeb;
    color: #d97706;
    border: 1px solid #fcd34d;
}
.expiry-soon {
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #86efac;
}
@keyframes pulse-badge {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.55; }
}

.portfolio-meta {
    font-size: 0.85rem;
    color: var(--theme-text-muted);
    margin-top: 4px;
}

.portfolio-savings {
    text-align: center;
    width: 130px;
    flex-shrink: 0;
}

.portfolio-label {
    display: block;
    font-size: 0.68rem;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--theme-text-muted);
    font-weight: 700;
}

.portfolio-value {
    font-weight: 800;
    color: var(--theme-amber);
    font-size: 1rem;
}

.portfolio-status {
    display: inline-flex;
    align-items: center;
    margin-top: 4px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--theme-brand-soft);
    color: var(--theme-title);
    font-size: 0.82rem;
}

.portfolio-status[data-status="Pendiente"] {
    background: rgba(245, 158, 11, 0.16);
    color: #d97706;
}

.portfolio-status[data-status="Contactado"] {
    background: rgba(59, 130, 246, 0.16);
    color: #2563eb;
}

.portfolio-status[data-status="En gestión"] {
    background: rgba(99, 102, 241, 0.16);
    color: #4f46e5;
}

.portfolio-status[data-status="Cerrado"] {
    background: rgba(34, 197, 94, 0.16);
    color: #16a34a;
}

.portfolio-status[data-status="Perdido"] {
    background: rgba(239, 68, 68, 0.16);
    color: #dc2626;
}

.portfolio-savings-value {
    color: var(--theme-amber);
}

.portfolio-value.muted {
    color: var(--theme-text-muted);
}

.portfolio-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-title {
    font-family: var(--font-heading);
    font-weight: 800;
    text-transform: uppercase;
    color: var(--theme-title);
    letter-spacing: 1px;
}

.empty-card {
    background: var(--theme-surface);
    border-radius: 20px;
    padding: 40px;
    text-align: center;
    color: var(--theme-text-muted);
    border: 1px solid var(--theme-surface-border);
    box-shadow: var(--card-shadow);
    backdrop-filter: var(--theme-card-blur);
    transition: background-color 0.5s ease, color 0.5s ease, border-color 0.5s ease, box-shadow 0.5s ease;
}

.empty-card i {
    font-size: 2.6rem;
    margin-bottom: 12px;
    color: var(--theme-text-muted);
}

/* ── Pagination ── */
.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 24px;
    padding: 16px 20px;
    background: var(--theme-surface);
    border-radius: 16px;
    border: 1px solid var(--theme-surface-border);
    box-shadow: var(--card-shadow);
    backdrop-filter: var(--theme-card-blur);
    gap: 12px;
    flex-wrap: wrap;
    transition: background-color 0.5s ease, color 0.5s ease, border-color 0.5s ease;
}

.pagination-info {
    font-size: 0.85rem;
    color: var(--theme-text-muted);
    font-weight: 600;
    white-space: nowrap;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.pagination-btn {
    min-width: 36px;
    text-align: center;
    padding: 6px 12px !important;
    font-size: 0.82rem !important;
    border-radius: 10px !important;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pagination-btn.disabled {
    opacity: 0.4;
    pointer-events: none;
    cursor: default;
}

.pagination-current {
    cursor: default;
    font-weight: 700;
}

.pagination-ellipsis {
    color: var(--theme-text-muted);
    font-size: 0.85rem;
    padding: 0 4px;
    user-select: none;
}

@media (max-width: 600px) {
    .pagination-bar {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }
    .pagination-controls {
        justify-content: center;
    }
}

:root[data-theme="dark"] .pill.free,
body[data-theme="dark"] .pill.free {
    background: rgba(148, 163, 184, 0.16);
    color: #e2e8f0;
}

:root[data-theme="dark"] .pill.pro,
body[data-theme="dark"] .pill.pro {
    background: rgba(34, 197, 94, 0.18);
    color: #86efac;
}

:root[data-theme="dark"] .sub-badge-free,
body[data-theme="dark"] .sub-badge-free {
    background: rgba(148, 163, 184, 0.2);
    color: #e2e8f0;
}

:root[data-theme="dark"] .sub-badge-pro,
body[data-theme="dark"] .sub-badge-pro {
    background: rgba(34, 197, 94, 0.2);
    color: #86efac;
}

:root[data-theme="dark"] .sub-manage-btn,
body[data-theme="dark"] .sub-manage-btn {
    border-color: rgba(99, 102, 241, 0.4);
    background: rgba(99, 102, 241, 0.16);
    color: #c7d2fe;
}

@media (max-width: 1024px) {
    .app-shell {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        border-radius: 0 0 24px 24px;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .sidebar-nav {
        flex-direction: row;
        gap: 8px;
        flex-wrap: wrap;
    }

    .sidebar-theme {
        flex-direction: row;
        align-items: center;
    }

    .sidebar-label {
        display: none;
    }

    .sidebar-promo {
        display: none;
    }

    /* Nav group in horizontal layout */
    .nav-group { position: relative; flex-direction: row; align-items: center; }
    .nav-group-items {
        position: absolute; top: 100%; left: 0; z-index: 1000;
        background: var(--theme-sidebar-bg, var(--theme-surface));
        border: 1px solid var(--theme-sidebar-border);
        border-radius: 12px; padding: 8px; min-width: 180px;
        box-shadow: 0 8px 24px rgba(0,0,0,.15);
        padding-left: 0;
    }
    .nav-group-toggle .nav-group-arrow { margin-left: 4px; }
}

@media (max-width: 768px) {
    .app-content {
        padding: 24px 16px 88px;
    }

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

    .crm-filter-field-wide {
        grid-column: span 1;
    }

    .crm-filter-actions {
        width: 100%;
    }

    .crm-filter-actions .btn-opt {
        flex: 1;
        padding-left: 14px;
        padding-right: 14px;
    }

    .crm-presets {
        margin-top: 4px;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 6px;
        padding-bottom: 4px;
    }
    .crm-presets::-webkit-scrollbar { display: none; }
    .crm-preset-chip { flex-shrink: 0; padding: 6px 10px; font-size: 0.7rem; }
    .hide-mobile { display: none !important; }

    .crm-bulk-bar {
        padding: 10px;
    }

    .crm-bulk-select {
        min-width: 100%;
    }

    .hero-card {
        padding: 28px 22px;
    }

    .analysis-inline-card {
        padding: 22px;
    }

    .dash-upload-card {
        padding: 22px 18px;
    }

    .dash-upload-header {
        gap: 12px;
    }

    .dash-upload-icon-wrap {
        width: 42px;
        height: 42px;
        border-radius: 12px;
        font-size: 1.1rem;
    }

    .dash-upload-title {
        font-size: 1.1rem;
    }

    .portfolio-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .portfolio-savings {
        text-align: left;
        min-width: auto;
    }

    .portfolio-actions {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .customer-header-actions {
        width: 100%;
    }

    .customer-header-actions .btn-opt {
        flex: 1 1 120px;
    }

    .cd-kpis {
        grid-template-columns: repeat(2, 1fr);
    }

    .cd-main-grid {
        grid-template-columns: 1fr;
    }

    .cd-supply-grid {
        grid-template-columns: 1fr;
    }

    .cd-kpi-value {
        font-size: 1.2rem;
    }
}


/* =============================================
   HISTORICAL VIEW - KPI GRID
   ============================================= */

.historical-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-top: 14px;
}

.historical-kpi {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 20px;
}

.historical-kpi .kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--theme-brand-soft, rgba(99, 102, 241, 0.12));
    color: var(--theme-brand, #6366f1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.historical-kpi .kpi-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.historical-kpi .kpi-value {
    font-size: 20px;
    font-weight: 800;
    line-height: 1.2;
    color: var(--theme-text, #0f172a);
}

.historical-kpi .kpi-label {
    font-size: 12px;
    color: var(--theme-text-muted, #64748b);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

@media (max-width: 900px) {
    .historical-kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 500px) {
    .historical-kpi-grid {
        grid-template-columns: 1fr;
    }
}


/* =============================================
   TOAST NOTIFICATIONS
   ============================================= */

#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
    pointer-events: auto;
    opacity: 0;
    transform: translateX(60px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    min-width: 260px;
    max-width: 420px;
}

.toast-show {
    animation: toastIn 0.35s ease forwards;
}

.toast-out {
    animation: toastOut 0.3s ease forwards;
}

@keyframes toastIn {
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    to { opacity: 0; transform: translateX(60px); }
}

.toast-success { background: #22c55e; }
.toast-error   { background: #ef4444; }
.toast-info    { background: #6366f1; }
.toast-warning { background: #f59e0b; color: #0f172a; }

.toast-close {
    margin-left: auto;
    background: none;
    border: none;
    color: inherit;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0.7;
    padding: 0 4px;
}

.toast-close:hover { opacity: 1; }

.toast-msg { flex: 1; }


/* =============================================
   SKELETON LOADERS
   ============================================= */

.skeleton-container {
    padding: 40px 20px;
    max-width: 700px;
    margin: 0 auto;
}

.skeleton-title {
    height: 28px;
    width: 60%;
    border-radius: 8px;
    margin-bottom: 24px;
}

.skeleton-bar {
    height: 18px;
    border-radius: 6px;
    margin-bottom: 14px;
}

.skeleton-bar:nth-child(2) { width: 90%; }
.skeleton-bar:nth-child(3) { width: 75%; }
.skeleton-bar:nth-child(4) { width: 85%; }
.skeleton-bar:nth-child(5) { width: 60%; }

.skeleton-title,
.skeleton-bar {
    background: linear-gradient(90deg,
        var(--theme-surface-border) 25%,
        var(--theme-surface-muted) 50%,
        var(--theme-surface-border) 75%
    );
    background-size: 200% 100%;
    animation: skeletonPulse 1.5s ease-in-out infinite;
}

@keyframes skeletonPulse {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}


/* =============================================
   ENTRY ANIMATIONS
   ============================================= */

.fade-in {
    opacity: 0;
    transform: translateY(16px);
    animation: fadeInUp 0.5s ease forwards;
}

.fade-in:nth-child(2) { animation-delay: 0.08s; }
.fade-in:nth-child(3) { animation-delay: 0.16s; }
.fade-in:nth-child(4) { animation-delay: 0.24s; }
.fade-in:nth-child(5) { animation-delay: 0.32s; }

@keyframes fadeInUp {
    to { opacity: 1; transform: translateY(0); }
}


/* =============================================
   RESPONSIVE IMPROVEMENTS
   ============================================= */

@media (max-width: 768px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .actions-grid { grid-template-columns: 1fr; }
    .winner-card { flex-direction: column; text-align: center; gap: 20px; }
    .winner-price-box { text-align: center; }
    .big-price { font-size: 2.5rem; }
    .whatif-grid, .whatif-results-grid { grid-template-columns: 1fr 1fr; }

    /* Customer detail: stack columns */
    .cd-main-grid { grid-template-columns: 1fr !important; }

    /* Timeline: cards instead of table rows */
    .timeline-table { display: block; }
    .timeline-table thead { display: none; }
    .timeline-table tbody tr {
        display: block;
        background: var(--theme-surface);
        border: 1px solid var(--theme-surface-border);
        border-radius: 12px;
        padding: 14px;
        margin-bottom: 12px;
    }
    .timeline-table tbody td {
        display: flex;
        justify-content: space-between;
        padding: 4px 0;
        border: none;
    }
    .timeline-table tbody td::before {
        content: attr(data-label);
        font-weight: 700;
        color: var(--theme-text-muted);
        font-size: 0.8rem;
        text-transform: uppercase;
    }
}

@media (max-width: 480px) {
    .whatif-grid, .whatif-results-grid { grid-template-columns: 1fr; }
    .header { flex-direction: column; gap: 12px; text-align: center; }
    .meta-info { text-align: center; }
}


/* =============================================
   ONBOARDING WIZARD
   ============================================= */

.ob-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: ob-fadein 0.3s ease;
}

@keyframes ob-fadein {
    from { opacity: 0; }
    to { opacity: 1; }
}

.ob-card {
    background: var(--theme-surface, #fff);
    border-radius: 16px;
    padding: 40px 36px 32px;
    max-width: 440px;
    width: 90%;
    text-align: center;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: ob-slidein 0.35s ease;
}

@keyframes ob-slidein {
    from { opacity: 0; transform: translateY(20px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.ob-skip {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 22px;
    color: var(--theme-text-muted, #888);
    cursor: pointer;
    line-height: 1;
    padding: 4px;
}

.ob-skip:hover { color: var(--theme-text, #333); }

.ob-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent, #6366f1), var(--accent-hover, #4f46e5));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 26px;
}

.ob-title {
    font-size: 20px;
    font-weight: 800;
    margin: 0 0 10px;
    color: var(--theme-text, #1a1a1a);
}

.ob-text {
    font-size: 14px;
    line-height: 1.6;
    color: var(--theme-text-muted, #555);
    margin: 0 0 20px;
}

.ob-dots {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 20px;
}

.ob-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--theme-surface-border, #ccc);
    transition: background 0.2s, transform 0.2s;
}

.ob-dot.active {
    background: var(--accent, #6366f1);
    transform: scale(1.3);
}

.ob-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.ob-btn {
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: background 0.2s, transform 0.1s;
}

.ob-btn:active { transform: scale(0.97); }

.ob-btn-primary {
    background: linear-gradient(135deg, var(--accent, #6366f1), var(--accent-hover, #4f46e5));
    color: #fff;
}

.ob-btn-primary:hover { filter: brightness(1.1); }

.ob-btn-secondary {
    background: var(--theme-surface-hover, #f0f0f0);
    color: var(--theme-text, #333);
}

.ob-btn-secondary:hover { background: var(--theme-surface-border, #ddd); }

@media (max-width: 480px) {
    .ob-card { padding: 28px 20px 24px; }
    .ob-title { font-size: 18px; }
}

/* --- MOBILE HAMBURGER MENU --- */
.hamburger-btn { display:none; background:none; border:none; font-size:1.3rem; color:var(--theme-text); cursor:pointer; padding:8px; margin-right:8px; }
.sidebar-overlay { display:none; position:fixed; inset:0; background:rgba(0,0,0,.4); z-index:998; }

@media (max-width: 768px) {
    .hamburger-btn { display:flex; align-items:center; }
    .sidebar { position:fixed; left:-260px; top:0; bottom:0; z-index:999; transition:left .3s ease; width:240px; flex-direction:column; align-items:stretch; justify-content:flex-start; border-radius:0; overflow-y:auto; }
    .sidebar.open { left:0; }
    .sidebar-overlay.active { display:block; }
    .app-main { margin-left:0 !important; }
    .sidebar-nav { flex-direction:column; flex-wrap:nowrap; }

    /* Nav group vertical inside hamburger sidebar */
    .nav-group { flex-direction: column; position: static; }
    .nav-group-items { position: static; background: none; border: none; box-shadow: none; padding: 0; padding-left: 16px; min-width: 0; }
    .nav-group-toggle .nav-group-arrow { margin-left: auto; }

    /* Topbar compacta en móvil */
    .topbar {
        padding: 10px 14px;
        gap: 8px;
    }
    .topbar-search {
        display: none !important;
    }
    .top-link {
        display: none;
    }
    .topbar-actions .pill {
        display: none;
    }
    .topbar-actions {
        gap: 8px;
    }
    .mobile-search-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        margin-right: auto;
    }
}

/* --- SPARKLINES --- */
.portfolio-sparkline { display:flex; align-items:center; min-width:80px; }
.sparkline-svg { width:80px; height:24px; }

/* --- FOCUS VISIBLE --- */
:focus-visible { outline: 2px solid var(--theme-brand); outline-offset: 2px; border-radius: 4px; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--theme-brand); outline-offset: 2px; }
.nav-item:focus-visible { outline-offset: -2px; }

/* --- KEYBOARD SHORTCUTS OVERLAY --- */
.shortcuts-overlay { position:fixed; inset:0; background:rgba(0,0,0,.5); z-index:10000; display:flex; align-items:center; justify-content:center; }
.shortcuts-card { background:var(--theme-surface); border-radius:16px; padding:24px 32px; min-width:280px; box-shadow:0 8px 32px rgba(0,0,0,.2); }
.shortcuts-card h3 { margin:0 0 16px; font-size:1rem; color:var(--theme-title); }
.shortcut-row { display:flex; align-items:center; gap:12px; padding:6px 0; font-size:0.9rem; color:var(--theme-text); }
.shortcut-row kbd { background:var(--theme-surface-muted); border:1px solid var(--theme-surface-border); border-radius:4px; padding:2px 8px; font-family:monospace; font-size:0.85rem; min-width:28px; text-align:center; }

/* ==================== MOBILE BOTTOM NAV ==================== */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: var(--theme-surface);
    border-top: 1px solid var(--theme-surface-border);
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

@media (max-width: 768px) {
    .bottom-nav {
        display: flex;
        justify-content: space-around;
        align-items: center;
    }

    .main-content {
        padding-bottom: 80px !important;
    }

    /* Hide sidebar completely on mobile - bottom nav replaces it */
    .hamburger-btn { display: none !important; }
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 8px 4px;
    color: var(--theme-text-muted);
    text-decoration: none;
    font-size: 0.65rem;
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    transition: color 0.2s;
    -webkit-tap-highlight-color: transparent;
    position: relative;
}

.bottom-nav-item i {
    font-size: 1.2rem;
    margin-bottom: 3px;
    transition: transform 0.2s;
}

.bottom-nav-item.active {
    color: var(--theme-brand);
}

.bottom-nav-item.active i {
    transform: scale(1.15);
}

.bottom-nav-item:active i {
    transform: scale(0.9);
}

/* "More" menu that slides up */
.bottom-nav-more-menu {
    display: none;
    position: fixed;
    bottom: 64px;
    left: 0;
    right: 0;
    background: var(--theme-surface);
    border-top: 1px solid var(--theme-surface-border);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.12);
    padding: 16px;
    z-index: 999;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    max-height: 60vh;
    overflow-y: auto;
    padding-bottom: env(safe-area-inset-bottom, 16px);
}

.bottom-nav-more-menu.open {
    display: block;
    transform: translateY(0);
}

.bottom-nav-more-menu a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    color: var(--theme-text);
    text-decoration: none;
    font-size: 0.95rem;
    border-radius: 12px;
    transition: background 0.15s;
}

.bottom-nav-more-menu a:active,
.bottom-nav-more-menu a:hover {
    background: var(--theme-surface-muted);
}

.bottom-nav-more-menu a i {
    width: 24px;
    text-align: center;
    color: var(--theme-brand);
    font-size: 1.1rem;
}

.bottom-nav-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 998;
}

.bottom-nav-overlay.active {
    display: block;
}

/* ==================== MOBILE CARDS ==================== */
@media (max-width: 768px) {
    /* Transform tables to card layout on mobile */
    .branded-table.mobile-cards {
        display: block;
    }
    .branded-table.mobile-cards thead { display: none; }
    .branded-table.mobile-cards tbody { display: flex; flex-direction: column; gap: 12px; }
    .branded-table.mobile-cards tr {
        display: flex;
        flex-wrap: wrap;
        padding: 16px;
        background: var(--theme-surface);
        border-radius: 12px;
        border: 1px solid var(--theme-surface-border);
        gap: 8px;
        position: relative;
    }
    .branded-table.mobile-cards td {
        border: none;
        padding: 4px 0;
        font-size: 0.85rem;
    }
    .branded-table.mobile-cards td:first-child {
        width: 100%;
        font-weight: 700;
        font-size: 1rem;
        padding-bottom: 8px;
        border-bottom: 1px solid var(--theme-surface-border);
        margin-bottom: 4px;
    }
    .branded-table.mobile-cards td::before {
        content: attr(data-label);
        display: block;
        font-size: 0.7rem;
        color: var(--theme-text-muted);
        text-transform: uppercase;
        letter-spacing: 0.5px;
        font-weight: 600;
        margin-bottom: 2px;
    }

    /* Mobile-optimized KPI cards */
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }

    .kpi-card {
        padding: 12px !important;
    }

    .kpi-card .kpi-value {
        font-size: 1.4rem !important;
    }

    /* Full-width buttons on mobile */
    .btn-opt {
        width: 100%;
        text-align: center;
    }

    .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    .page-header > div {
        display: flex;
        justify-content: center;
        flex-wrap: nowrap;
        gap: 6px;
    }

    /* Floating action button */
    .fab {
        position: fixed;
        bottom: 80px;
        right: 16px;
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: var(--theme-brand);
        color: white;
        border: none;
        font-size: 1.5rem;
        display: none;
        align-items: center;
        justify-content: center;
        box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
        z-index: 100;
        cursor: pointer;
        transition: transform 0.2s, box-shadow 0.2s;
    }

    .fab:active {
        transform: scale(0.92);
    }
}

/* FAB: hidden on desktop, visible only on mobile */
.fab { display: none !important; }
@media (max-width: 768px) {
    .fab { display: flex !important; }
}

/* CLAUDE.md compliance: KPI grids must fit 2 columns on 375px mobile */
@media (max-width: 480px) {
    [style*="minmax(210px"], [style*="minmax(220px"],
    [style*="minmax(180px"], [style*="minmax(170px"],
    [style*="minmax(160px"], [style*="minmax(280px"] {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)) !important;
    }
    .review-grid,
    .cd-kpis,
    .dash-kpis,
    .kpi-grid,
    .cd-intel-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)) !important;
    }
}

/* ==================== PULL TO REFRESH ==================== */
.pull-refresh-indicator {
    position: fixed;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--theme-surface);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    transition: transform 0.2s, opacity 0.2s;
    color: var(--theme-brand);
}
.pull-refresh-indicator.ready { color: var(--theme-brand); }
.pull-refresh-indicator.ready i { animation: none; }
.pull-refresh-indicator.refreshing i { animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ==================== TOUCH IMPROVEMENTS ==================== */
@media (max-width: 768px) {
    /* Larger touch targets */
    .sidebar-link, .bottom-nav-item {
        min-height: 48px;
    }

    /* Smooth scrolling */
    .main-content {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
        overflow-x: hidden;
    }

    /* Hide scrollbars on mobile */
    .main-content::-webkit-scrollbar { display: none; }
    .main-content { -ms-overflow-style: none; scrollbar-width: none; }

    /* Larger form inputs on mobile */
    .input-styled, .input-opt, select, textarea {
        font-size: 16px !important;
        padding: 14px 16px !important;
        min-height: 48px;
    }
    /* Preserve left padding for inputs with icons */
    .input-group .input-styled {
        padding-left: 48px !important;
    }

    /* Swipeable horizontal scroll containers */
    .horizontal-scroll {
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
        gap: 12px;
        padding: 4px;
    }

    .horizontal-scroll > * {
        scroll-snap-align: start;
        flex: 0 0 auto;
    }

    /* Improve modal on mobile - full screen */
    .modal-content {
        width: 100% !important;
        max-width: 100% !important;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0 !important;
        margin: 0;
    }

    /* Stack action buttons vertically */
    .action-buttons {
        flex-direction: column;
    }

    .action-buttons .btn-opt {
        width: 100%;
    }
}

/* ==================== COMMAND PALETTE ==================== */
.cmd-palette-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 10000;
    justify-content: center;
    padding-top: 15vh;
}

.cmd-palette-overlay.open {
    display: flex;
}

.cmd-palette {
    width: 560px;
    max-width: 92vw;
    max-height: 70vh;
    background: var(--theme-surface);
    border-radius: 16px;
    box-shadow: 0 16px 70px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--theme-border);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: cmd-palette-in 0.15s ease-out;
}

@keyframes cmd-palette-in {
    from { transform: scale(0.96) translateY(-8px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

.cmd-palette-input-wrap {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--theme-border);
    gap: 12px;
}

.cmd-palette-input-wrap i {
    color: var(--theme-text-muted);
    font-size: 1rem;
}

.cmd-palette-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 1rem;
    background: transparent;
    color: var(--theme-text);
    font-family: 'Open Sans', sans-serif;
}

.cmd-palette-input-wrap kbd {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--theme-surface-muted);
    border: 1px solid var(--theme-border);
    color: var(--theme-text-muted);
    font-family: monospace;
}

.cmd-palette-results {
    overflow-y: auto;
    max-height: 50vh;
    padding: 8px;
}

.cmd-palette-group {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--theme-text-muted);
    padding: 8px 12px 4px;
}

.cmd-palette-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--theme-text);
    font-size: 0.9rem;
    transition: background 0.1s;
}

.cmd-palette-item:hover,
.cmd-palette-item.selected {
    background: var(--theme-surface-muted);
}

.cmd-palette-item i {
    width: 20px;
    text-align: center;
    color: var(--theme-text-muted);
    font-size: 0.85rem;
}

.cmd-palette-item.selected i {
    color: var(--theme-brand);
}

.cmd-palette-empty {
    text-align: center;
    padding: 24px;
    color: var(--theme-text-muted);
    font-size: 0.9rem;
}

.cmd-palette-footer {
    display: flex;
    gap: 16px;
    padding: 10px 20px;
    border-top: 1px solid var(--theme-border);
    font-size: 0.72rem;
    color: var(--theme-text-muted);
}

.cmd-palette-footer kbd {
    font-size: 0.65rem;
    padding: 1px 4px;
    border-radius: 3px;
    background: var(--theme-surface-muted);
    border: 1px solid var(--theme-border);
    font-family: monospace;
    margin-right: 4px;
}

@media (max-width: 768px) {
    .cmd-palette-overlay { padding-top: 5vh; }
    .cmd-palette { max-height: 85vh; border-radius: 12px; margin: 0 8px; }
}

/* ==================== BREADCRUMBS (enhanced) ==================== */
.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--theme-text-muted);
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.breadcrumbs a {
    color: var(--theme-text-muted);
    text-decoration: none;
    transition: color 0.15s;
}

.breadcrumbs a:hover {
    color: var(--theme-brand);
}

.breadcrumbs .separator {
    font-size: 0.65rem;
}

.breadcrumbs .current {
    color: var(--theme-text);
    font-weight: 600;
}

/* ==================== EXECUTIVE SUMMARY ==================== */
.executive-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding: 24px 28px;
    background: linear-gradient(135deg, var(--theme-brand) 0%, #818cf8 100%);
    border-radius: 16px;
    color: white;
}

.greeting-text {
    font-size: 1.6rem;
    font-weight: 700;
    margin: 0;
    font-family: 'Montserrat', sans-serif;
}

.greeting-subtitle {
    margin: 4px 0 0;
    opacity: 0.85;
    font-size: 0.9rem;
}

.quick-actions {
    display: flex;
    gap: 8px;
}

.quick-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: rgba(255,255,255,0.15);
    border-radius: 12px;
    color: white;
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 600;
    backdrop-filter: blur(4px);
    transition: background 0.2s;
}

.quick-action-btn:hover {
    background: rgba(255,255,255,0.25);
}

.quick-action-btn i {
    font-size: 1.2rem;
}

@media (max-width: 768px) {
    .executive-summary {
        flex-direction: column;
        text-align: center;
        gap: 12px;
        padding: 16px 14px;
    }
    .greeting-text {
        font-size: 1.1rem;
        word-break: break-word;
        overflow-wrap: break-word;
    }
    .quick-actions {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    .quick-action-btn {
        padding: 10px 8px;
        font-size: 0.7rem;
        min-width: 0;
    }
    .quick-action-btn i {
        font-size: 1rem;
    }
}

/* ==================== DASHBOARD GRID LAYOUT ==================== */
.dashboard-grid {
    display: block;
    margin-top: 24px;
}

.dashboard-main {
    min-width: 0;
}

/* ==================== ACTIVITY FEED ==================== */
.card-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.card-header-flex h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.text-link {
    font-size: 0.8rem;
    color: var(--theme-brand);
    text-decoration: none;
    font-weight: 600;
}

.text-link:hover {
    text-decoration: underline;
}

.activity-list {
    display: flex;
    flex-direction: column;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--theme-border);
}

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

.activity-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.activity-icon.report { background: #ede9fe; color: #7c3aed; }
.activity-icon.customer { background: #dbeafe; color: #2563eb; }
.activity-icon.invoice { background: #d1fae5; color: #059669; }
.activity-icon.info { background: #f1f5f9; color: #64748b; }

body[data-theme="dark"] .activity-icon.report { background: rgba(124,58,237,0.2); }
body[data-theme="dark"] .activity-icon.customer { background: rgba(37,99,235,0.2); }
body[data-theme="dark"] .activity-icon.invoice { background: rgba(5,150,105,0.2); }
body[data-theme="dark"] .activity-icon.info { background: rgba(100,116,139,0.2); }

.activity-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.activity-text {
    font-size: 0.85rem;
    color: var(--theme-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.activity-time {
    font-size: 0.7rem;
    color: var(--theme-text-muted);
    margin-top: 2px;
}

/* ==================== PENDING ACTIONS ==================== */
.pending-actions h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 16px;
}

.pending-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pending-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--theme-surface-muted);
    border-radius: 12px;
    text-decoration: none;
    color: var(--theme-text);
    transition: background 0.15s;
}

.pending-item:hover {
    background: var(--theme-border);
}

.pending-badge {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.pending-badge.warning { background: #fef3c7; color: #92400e; }
.pending-badge.info { background: #dbeafe; color: #1e40af; }
.pending-badge.danger { background: #fee2e2; color: #991b1b; }

body[data-theme="dark"] .pending-badge.warning { background: rgba(254,243,199,0.15); color: #fbbf24; }
body[data-theme="dark"] .pending-badge.info { background: rgba(37,99,235,0.2); color: #60a5fa; }
body[data-theme="dark"] .pending-badge.danger { background: rgba(239,68,68,0.2); color: #f87171; }

.pending-text {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.pending-text strong { font-size: 0.85rem; }
.pending-text span { font-size: 0.75rem; color: var(--theme-text-muted); }

.pending-item i.fa-chevron-right {
    color: var(--theme-text-muted);
    font-size: 0.75rem;
}

/* ==================== COLLAPSIBLE FILTER BAR ==================== */
.filter-bar {
    background: var(--theme-surface);
    border: 1px solid var(--theme-border);
    border-radius: 12px;
    margin-bottom: 12px;
    overflow: hidden;
}

.filter-bar-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--theme-text);
    user-select: none;
}

.filter-bar-toggle .toggle-arrow {
    margin-left: auto;
    transition: transform 0.2s;
    font-size: 0.75rem;
    color: var(--theme-text-muted);
}

.filter-bar.expanded .toggle-arrow {
    transform: rotate(180deg);
}

.filter-bar-content {
    display: none;
    padding: 0 16px 16px;
}

.filter-bar.expanded .filter-bar-content {
    display: block;
}

.filter-bar-form {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 140px;
}

.filter-group label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--theme-text-muted);
}

.filter-count {
    font-size: 0.75rem;
    color: var(--theme-brand);
    font-weight: 700;
    display: none;
}

.filter-bar-actions {
    display: flex;
    gap: 6px;
    align-items: flex-end;
    flex-wrap: wrap;
}

/* ── Quick filter bar ── */
.quick-filter-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    position: relative;
}

.quick-filter-icon {
    position: absolute;
    left: 12px;
    color: var(--theme-text-muted);
    font-size: 0.8rem;
    pointer-events: none;
}

.quick-filter-input {
    padding-left: 34px !important;
    height: 38px;
    font-size: 0.85rem;
    width: 100%;
    max-width: 400px;
}

.quick-filter-count {
    font-size: 0.78rem;
    color: var(--theme-text-muted);
    font-weight: 600;
    white-space: nowrap;
    display: none;
}

/* ==================== FLOATING BULK ACTIONS BAR ==================== */
.bulk-actions-bar {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: var(--theme-text);
    color: var(--theme-surface);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.25);
    z-index: 100;
    animation: bulk-slide-up 0.2s ease-out;
}

@keyframes bulk-slide-up {
    from { transform: translateX(-50%) translateY(20px); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

.bulk-count {
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
}

.bulk-buttons {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.bulk-action-select {
    background: rgba(255,255,255,0.15) !important;
    color: white !important;
    border-color: rgba(255,255,255,0.3) !important;
    font-size: 0.78rem !important;
    padding: 4px 8px !important;
    min-width: 90px;
}

.bulk-action-select option {
    background: var(--theme-surface);
    color: var(--theme-text);
}

.bulk-actions-bar .btn-opt-primary {
    background: var(--theme-brand) !important;
}

@media (max-width: 768px) {
    .bulk-actions-bar {
        bottom: 80px;
        left: 16px;
        right: 16px;
        transform: none;
        flex-wrap: wrap;
        justify-content: center;
    }

    .filter-bar-form {
        flex-direction: column;
    }

    .filter-group {
        min-width: 100%;
    }
}

/* ==================== INLINE EDIT ==================== */
[data-editable] {
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    transition: background 0.15s;
    position: relative;
}

[data-editable]:hover {
    background: var(--theme-surface-muted);
}

[data-editable]:hover::after {
    content: '\270E';
    position: absolute;
    right: -18px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.7rem;
    color: var(--theme-text-muted);
    opacity: 0.6;
}

.inline-edit-input {
    width: 100%;
    padding: 4px 8px;
    border: 2px solid var(--theme-brand);
    border-radius: 6px;
    font-size: inherit;
    font-family: inherit;
    background: var(--theme-surface);
    color: var(--theme-text);
    outline: none;
    min-width: 120px;
}

/* ==================== IMPROVED EMPTY STATES ==================== */
.empty-state {
    text-align: center;
    padding: 48px 24px;
}

.empty-state i {
    font-size: 3rem;
    color: var(--theme-text-muted);
    opacity: 0.3;
    margin-bottom: 16px;
    display: block;
}

.empty-state h3 {
    font-size: 1.1rem;
    color: var(--theme-text);
    margin: 0 0 8px;
}

.empty-state p {
    color: var(--theme-text-muted);
    font-size: 0.85rem;
    max-width: 320px;
    margin: 0 auto;
}

/* ==================== NOTIFICATIONS PAGE ENHANCED ==================== */
.notif-list-enhanced {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.notif-day-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 16px 0 8px;
}

.notif-day-header:first-child {
    margin-top: 0;
}

.notif-day-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--theme-text-muted);
    white-space: nowrap;
}

.notif-day-line {
    flex: 1;
    height: 1px;
    background: var(--theme-border);
}

.notif-card {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 16px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s;
    border: 1px solid transparent;
}

.notif-card:hover {
    background: var(--theme-surface-muted);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.notif-card-unread {
    border-left: 3px solid var(--theme-brand);
    background: var(--theme-brand-soft, rgba(78,110,242,0.04));
}

.notif-card-icon {
    font-size: 1.3rem;
    margin-top: 2px;
    flex-shrink: 0;
}

.notif-card-content {
    flex: 1;
    min-width: 0;
}

.notif-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.notif-card-title {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--theme-title);
}

.notif-unread-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--theme-brand);
    flex-shrink: 0;
}

.notif-card-body {
    font-size: 0.82rem;
    color: var(--theme-text-muted);
    margin-top: 4px;
    line-height: 1.45;
}

.notif-card-meta {
    display: flex;
    gap: 12px;
    margin-top: 6px;
    font-size: 0.72rem;
    color: var(--theme-text-muted);
}

.notif-card-category {
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.notif-card-actions {
    flex-shrink: 0;
    align-self: center;
}

.notif-card-actions .btn-icon {
    color: var(--theme-brand);
    font-size: 1rem;
}

/* Notification type filter buttons */
.notif-type-filters {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.notif-type-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    border: 1px solid var(--theme-border);
    border-radius: 20px;
    background: var(--theme-surface);
    color: var(--theme-text-muted);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.notif-type-btn:hover {
    border-color: var(--theme-brand);
    color: var(--theme-brand);
}

.notif-type-btn.active {
    background: var(--theme-brand);
    color: white;
    border-color: var(--theme-brand);
}

.notif-type-btn.active i {
    color: white !important;
}

@media (max-width: 768px) {
    .notif-type-filters {
        width: 100%;
        justify-content: flex-start;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ── Zona Fiscal Selector ── */
.zona-fiscal-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.zona-fiscal-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--theme-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.zona-fiscal-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.zona-option {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: 1.5px solid var(--theme-input-border);
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--theme-text);
    background: var(--theme-input-bg);
    transition: border-color 0.2s, background 0.2s;
}
.zona-option:hover {
    border-color: var(--theme-brand);
    background: var(--theme-brand-soft);
}
.zona-option input[type="radio"] {
    accent-color: var(--theme-brand);
    width: 14px;
    height: 14px;
    cursor: pointer;
}
.zona-option:has(input:checked) {
    border-color: var(--theme-brand);
    background: var(--theme-brand-soft);
    color: var(--theme-brand);
}
.zona-option small {
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--theme-text-muted);
}

/* =============================================
   CENTRO DE AYUDA
   ============================================= */

/* Article list grid */
.help-article-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
    padding: 16px;
}

/* Article card */
.help-article-card {
    display: block;
    padding: 16px;
    border-radius: 10px;
    border: 1px solid var(--theme-border);
    background: var(--theme-surface);
    text-decoration: none;
    color: var(--theme-text);
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
    position: relative;
}
.help-article-card:hover {
    border-color: var(--theme-brand);
    box-shadow: 0 2px 8px rgba(37,99,235,.12);
    transform: translateY(-1px);
}
.help-article-card h4 {
    margin: 0 0 6px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--theme-text);
}
.help-article-card p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--theme-text-muted);
    line-height: 1.4;
}
.help-article-arrow {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.3;
    font-size: 0.75rem;
    transition: opacity 0.15s;
}
.help-article-card:hover .help-article-arrow {
    opacity: 0.7;
}

/* Article body content */
.help-body {
    padding: 20px 24px;
    line-height: 1.7;
    font-size: 0.95rem;
    color: var(--theme-text);
}
.help-body h4 {
    margin: 24px 0 10px;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--theme-text);
}
.help-body h4:first-child {
    margin-top: 0;
}
.help-body p {
    margin: 0 0 12px;
}
.help-body ul, .help-body ol {
    margin: 0 0 14px;
    padding-left: 24px;
}
.help-body li {
    margin-bottom: 6px;
}

/* Formula blocks */
.help-formula {
    background: var(--theme-surface-muted);
    border: 1px solid var(--theme-border);
    border-left: 3px solid var(--theme-brand);
    border-radius: 8px;
    padding: 14px 18px;
    margin: 12px 0 16px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.8;
    overflow-x: auto;
}
.help-formula code {
    background: none;
    padding: 0;
    font-size: inherit;
    color: var(--theme-text);
}

/* Tip blocks */
.help-tip {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: var(--theme-brand-soft, rgba(37,99,235,.06));
    border: 1px solid var(--theme-brand);
    border-radius: 8px;
    padding: 12px 16px;
    margin: 14px 0;
    font-size: 0.9rem;
    line-height: 1.5;
}
.help-tip > i {
    color: var(--theme-brand);
    margin-top: 2px;
    flex-shrink: 0;
}

/* Help tables */
.help-table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0 16px;
    font-size: 0.9rem;
}
.help-table th, .help-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--theme-border);
}
.help-table th {
    background: var(--theme-surface-muted);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--theme-text-muted);
}
.help-table tr:last-child td {
    border-bottom: none;
}

/* Help permissions table */
.help-perms-table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0 16px;
    font-size: 0.88rem;
}
.help-perms-table td, .help-perms-table th {
    padding: 8px 12px;
    border-bottom: 1px solid var(--theme-border, #eee);
    text-align: left;
}
.help-perms-table td:last-child, .help-perms-table th:not(:first-child) {
    text-align: center;
    width: 80px;
}
.help-perms-table thead th {
    background: var(--theme-surface-muted, #f8f9fa);
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--theme-text-muted);
}
.help-perms-table tr:last-child td {
    border-bottom: none;
}
.help-perms-full td:first-child {
    font-weight: 500;
}

/* Trigger — small "?" marker next to a field label */
.help-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-left: 6px;
    border-radius: 50%;
    border: 1px solid var(--theme-border);
    color: var(--theme-text-muted);
    background: transparent;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: help;
    user-select: none;
    line-height: 1;
    transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.help-icon:hover,
.help-icon:focus {
    background: var(--theme-brand, #2563eb);
    border-color: var(--theme-brand, #2563eb);
    color: #fff;
    outline: none;
}

/* Rich tooltip popup */
.help-tooltip-popup {
    background: var(--theme-surface);
    border: 1px solid var(--theme-border);
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0,0,0,.12);
    padding: 14px 18px;
    max-width: 320px;
    min-width: 200px;
    transform: translateX(-50%);
    animation: helpTooltipIn 0.15s ease-out;
}
.help-tooltip-title {
    display: block;
    font-size: 0.9rem;
    margin-bottom: 6px;
    color: var(--theme-text);
}
.help-tooltip-body {
    font-size: 0.82rem;
    color: var(--theme-text-muted);
    line-height: 1.4;
    margin: 0 0 8px;
}
.help-tooltip-link {
    font-size: 0.82rem;
    color: var(--theme-brand);
    text-decoration: none;
    font-weight: 500;
}
.help-tooltip-link:hover {
    text-decoration: underline;
}
@keyframes helpTooltipIn {
    from { opacity: 0; transform: translateX(-50%) translateY(4px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Responsive */
@media (max-width: 600px) {
    .help-article-list {
        grid-template-columns: 1fr;
        padding: 12px;
        gap: 8px;
    }
    .help-body {
        padding: 16px;
    }
    .help-formula {
        font-size: 0.8rem;
        padding: 10px 12px;
    }
}

/* =============================================
   LEAD SCORE BADGES & SOURCE TAGS
   ============================================= */
.score-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    margin-left: 6px;
    vertical-align: middle;
}
.score-hot {
    background: rgba(34, 197, 94, .15);
    color: #16a34a;
}
.score-warm {
    background: rgba(245, 158, 11, .15);
    color: #d97706;
}
.score-cold {
    background: rgba(148, 163, 184, .15);
    color: #64748b;
}
.source-tag {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 7px;
    border-radius: 8px;
    background: var(--theme-surface-muted);
    color: var(--theme-text-muted);
    margin-left: 6px;
    vertical-align: middle;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* ═══════════════════════════════════════════════════════════════
   Theme contrast overrides — asegurar visibilidad de botones-icono
   y dropdowns en modo oscuro/claro. Cubre patrones donde el
   fondo era transparente y el texto usaba --theme-text-muted,
   que en modo oscuro quedaban casi invisibles sobre la card.
   ═══════════════════════════════════════════════════════════════ */

/* Forzar mínimo de contraste en botones de 3 puntos/menú dentro de
   cards con fondo tenue. Cualquier botón icon-only sin fondo que
   esté dentro de una card (white-card, ph-card, etc.) obtiene un
   chip tenue visible en ambos modos. */
button.icon-ghost,
a.icon-ghost {
    width: 32px; height: 32px; border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--theme-surface-muted);
    border: 1px solid var(--theme-surface-border);
    color: var(--theme-text);
    cursor: pointer;
    transition: background .2s, border-color .2s, color .2s;
    text-decoration: none;
    font-size: 0.9rem;
}
button.icon-ghost:hover,
a.icon-ghost:hover {
    background: var(--theme-brand-soft);
    border-color: var(--theme-brand);
    color: var(--theme-brand);
}
button.icon-ghost.danger:hover,
a.icon-ghost.danger:hover {
    background: rgba(239, 68, 68, 0.18);
    border-color: #ef4444;
    color: #ef4444;
}

/* Paleta para modo claro: reforzar text-muted un tono más oscuro
   cuando aparece aislado (sin fondo) para cumplir contraste AA. */
:root:not([data-theme="dark"]) {
    --theme-text-muted-strong: #475569;
}
:root[data-theme="dark"],
body[data-theme="dark"] {
    --theme-text-muted-strong: #cbd5e1;
}

/* Chips/pills típicas en cards — asegurar que el texto no se pierda
   si la tarjeta usa fondo con transparencia. */
.ph-tariff-pill,
.pph-version-badge {
    color: var(--theme-brand);
}
:root[data-theme="dark"] .ph-tariff-pill,
body[data-theme="dark"] .ph-tariff-pill {
    background: rgba(99, 102, 241, 0.22);
    color: #c7d2fe;
}

/* Botones tipo "Excel"/"PDF" badge dentro de cards — asegurar
   contraste del texto verde sobre fondo tenue en modo oscuro. */
:root[data-theme="dark"] .ph-origin-excel,
body[data-theme="dark"] .ph-origin-excel {
    background: rgba(34, 197, 94, 0.22);
    color: #86efac;
}
:root[data-theme="dark"] .ph-origin-ref,
body[data-theme="dark"] .ph-origin-ref {
    background: rgba(99, 102, 241, 0.22);
    color: #c7d2fe;
}
:root[data-theme="dark"] .ph-origin-api,
body[data-theme="dark"] .ph-origin-api {
    background: rgba(234, 179, 8, 0.22);
    color: #fde68a;
}
