/* =============================================
   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); }
.alert.persistent { animation: none !important; opacity: 1 !important; max-height: none !important; }

/* =============================================
   LOGIN Y REGISTRO (Estilo idéntico al Dashboard)
   ============================================= */
.auth-layout {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    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-card.auth-card-wide {
    max-width: 480px;
}

.auth-name-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 0;
}
@media (max-width: 480px) {
    .auth-name-grid {
        grid-template-columns: 1fr;
        gap: 0;
    }
}

/* Phone field: country prefix select + national number input */
.phone-group { display: flex; gap: 8px; align-items: stretch; }
.phone-group > i {
    /* El icono se queda a la izquierda del select; mantenemos posición
       absoluta sobre el contenedor flex. */
    left: 15px;
}
.phone-prefix {
    flex: 0 0 110px;
    padding: 15px 10px 15px 38px;
    border: 1px solid var(--theme-input-border);
    border-radius: var(--border-radius-pill);
    font-size: 0.95rem;
    background: var(--theme-input-bg);
    color: var(--theme-input-text);
    font-family: var(--font-body);
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%2364748b' d='M0 0l5 6 5-6z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    cursor: pointer;
    transition: 0.3s;
}
.phone-prefix:focus {
    outline: none;
    border-color: var(--theme-brand);
    box-shadow: 0 0 0 3px var(--theme-brand-soft);
}
.phone-input {
    flex: 1 1 auto;
    padding-left: 18px !important;
}
@media (max-width: 480px) {
    .phone-prefix { flex-basis: 96px; padding-left: 36px; font-size: 0.9rem; }
}

.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-line {
    margin: 12px 0 0;
    text-align: center;
    color: var(--theme-text-muted);
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0.02em;
}
.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; }

/* ─── Vista paralela: revisión + archivo original ─── */
/* Cuando el usuario activa "Ver original", la página entera se parte
   en 2 columnas con grid: form a la izquierda, PDF a la derecha. Cada
   columna tiene su propio scroll vertical dentro del área disponible.
   En pantallas <900px se apila vertical (responsivo). */
.review-source-panel {
    display: none;
    background: var(--theme-card-bg);
    border: 1px solid var(--theme-border);
    border-radius: 12px;
    overflow: hidden;
    flex-direction: column;
}
.review-container.with-source {
    max-width: none;
    padding: 0 24px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    gap: 16px;
    height: calc(100vh - 110px);
    margin-bottom: 20px;
}
.review-container.with-source > .breadcrumb {
    grid-column: 1 / -1;
    margin-bottom: 0;
}
.review-container.with-source .analysis-card {
    overflow-y: auto;
    margin: 0;
    height: 100%;
}
.review-container.with-source .review-source-panel {
    display: flex;
    height: 100%;
}
@media (max-width: 900px) {
    .review-container.with-source {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        height: auto;
    }
    .review-container.with-source .analysis-card { height: auto; max-height: none; }
    .review-container.with-source .review-source-panel { height: 70vh; }
}

.source-panel-head {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px;
    background: var(--theme-surface-muted);
    border-bottom: 1px solid var(--theme-border);
    font-size: 0.85rem; font-weight: 600;
    color: var(--theme-text);
    flex-shrink: 0;
}
.source-panel-head > span:first-child {
    flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    display: inline-flex; align-items: center; gap: 8px;
}
.source-panel-head i { color: var(--theme-brand); font-size: 0.95rem; }
.source-panel-select {
    font-size: 0.78rem; padding: 4px 8px; border-radius: 6px;
    border: 1px solid var(--theme-border);
    background: var(--theme-card-bg); color: var(--theme-text);
    max-width: 180px;
}
.source-panel-open,
.source-panel-close {
    color: var(--theme-text-muted); text-decoration: none;
    padding: 5px 7px; border-radius: 6px;
    background: none; border: none; cursor: pointer; font-size: 0.9rem;
    line-height: 1;
}
.source-panel-open:hover,
.source-panel-close:hover { background: var(--theme-border); color: var(--theme-text); }

.source-panel-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    background: #2d2d2d;
    padding: 12px;
    --source-zoom: 100%;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.3) transparent;
}
.source-panel-body[hidden],
.source-panel-text[hidden],
.source-panel-native[hidden] {
    display: none !important;
}
.source-panel-body::-webkit-scrollbar { width: 8px; height: 8px; }
.source-panel-body::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.25);
    border-radius: 4px;
}
.source-page-wrap {
    width: var(--source-zoom);
    margin: 0 auto 8px;
    position: relative;
    transition: width 0.15s ease;
}
.source-panel-page {
    width: 100%;
    max-width: none;
    height: auto;
    display: block;
    background: #fff;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
    border-radius: 4px;
}
/* Texto OCR superpuesto: invisible visualmente pero seleccionable.
   El usuario hace click-drag sobre la imagen y el browser selecciona
   los spans subyacentes igual que cualquier texto HTML. Ctrl+C copia
   el texto plano. */
.source-word {
    position: absolute;
    color: transparent;
    background: transparent;
    line-height: 1;
    font-size: 1px; /* irrelevante, se redimensiona via height/width */
    overflow: hidden;
    white-space: nowrap;
    cursor: text;
    user-select: text;
    -webkit-user-select: text;
    pointer-events: auto;
    /* ::selection muestra el highlight del navegador */
}
.source-word::selection { background: rgba(99, 102, 241, 0.35); color: transparent; }
.source-word::-moz-selection { background: rgba(99, 102, 241, 0.35); color: transparent; }

/* ─── Botón "Ver original" ─── */
.source-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid var(--theme-border);
    background: var(--theme-card-bg);
    color: var(--theme-text);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
    white-space: nowrap;
}
.source-toggle-btn i {
    color: var(--theme-brand);
    font-size: 0.95rem;
}
.source-toggle-btn:hover {
    background: var(--theme-brand-soft, var(--theme-surface-muted));
    border-color: var(--theme-brand);
    color: var(--theme-brand);
}
.source-toggle-btn:hover i { color: var(--theme-brand); }
.source-toggle-btn[aria-pressed="true"] {
    background: var(--theme-brand);
    border-color: var(--theme-brand);
    color: #fff;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.25);
}
.source-toggle-btn[aria-pressed="true"] i { color: #fff; }
.source-toggle-btn:active { transform: translateY(1px); }
.source-toggle-btn:focus-visible {
    outline: 2px solid var(--theme-brand);
    outline-offset: 2px;
}

/* ─── Controles de zoom ─── */
.source-zoom-group {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px;
    border-radius: 999px;
    background: var(--theme-card-bg);
    border: 1px solid var(--theme-border);
}
.source-zoom-btn {
    width: 26px;
    height: 26px;
    border-radius: 999px;
    border: none;
    background: transparent;
    color: var(--theme-text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    line-height: 1;
    transition: background 0.15s ease, color 0.15s ease;
}
.source-zoom-btn:hover:not(:disabled) {
    background: var(--theme-brand-soft, var(--theme-surface-muted));
    color: var(--theme-brand);
}
.source-zoom-btn:disabled {
    opacity: 0.35;
    cursor: default;
}
.source-zoom-level {
    min-width: 44px;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--theme-text-muted);
    font-variant-numeric: tabular-nums;
    padding: 0 4px;
}

/* ─── Toggle PDF/Imagen / Parser ─── */
.source-view-group {
    display: inline-flex;
    align-items: center;
    gap: 0;
    padding: 2px;
    border-radius: 999px;
    background: var(--theme-card-bg);
    border: 1px solid var(--theme-border);
}
.source-view-btn {
    min-width: 28px;
    height: 26px;
    padding: 0 9px;
    border-radius: 999px;
    border: none;
    background: transparent;
    color: var(--theme-text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    font-size: 0.8rem;
    font-weight: 600;
    transition: background 0.15s ease, color 0.15s ease;
}
.source-view-btn[hidden] {
    display: none !important;
}
.source-view-btn span {
    font-size: 0.74rem;
    line-height: 1;
}
.source-view-btn.is-active {
    background: var(--theme-brand);
    color: #fff;
}
.source-view-btn:not(.is-active):hover {
    background: var(--theme-brand-soft, var(--theme-surface-muted));
    color: var(--theme-brand);
}

.source-panel-text {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    margin: 0;
    padding: 16px 18px;
    background: var(--theme-card-bg);
    color: var(--theme-text);
    font-family: ui-monospace, SFMono-Regular, "Cascadia Code", Menlo, Consolas, monospace;
    font-size: 0.78rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    user-select: text;
    -webkit-user-select: text;
}
.source-panel-text:focus { outline: 2px solid var(--theme-brand); outline-offset: -2px; }

/* Modo "Original" — embed nativo del PDF (selección de texto) */
.source-panel-native {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    background: #2d2d2d;
    display: flex;
    flex-direction: column;
}
.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-field input,
    .review-field select {
        font-size: 16px;
    }
}
.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;
}

/* Mini info inline: el botón "i" se oculta. El label que contiene el
   botón se vuelve clickable y muestra/oculta el panel debajo. Mantenemos
   el botón en el DOM (no eliminado) para no romper otros listeners y
   conservar accesibilidad alternativa. */
.field-info {
    display: none !important;
}
/* Label clickable que tiene info asociada */
label.has-field-info {
    cursor: pointer;
    position: relative;
    user-select: none;
    transition: color .15s ease;
}
label.has-field-info:hover { color: var(--theme-brand); }
label.has-field-info::after {
    /* Chevron sutil que indica que se puede expandir */
    content: "▾";
    display: inline-block;
    margin-left: 6px;
    font-size: 0.7em;
    color: var(--theme-text-muted);
    opacity: .6;
    transition: transform .15s ease, opacity .15s ease, color .15s ease;
}
label.has-field-info[aria-expanded="true"]::after {
    transform: rotate(180deg);
    color: var(--theme-brand);
    opacity: 1;
}
label.has-field-info:focus { outline: none; }
label.has-field-info:focus-visible {
    outline: 2px solid var(--theme-brand);
    outline-offset: 2px;
    border-radius: 4px;
}
.field-info-panel {
    margin-top: 6px;
    padding: 10px 12px;
    background: var(--theme-surface-muted);
    border: 1px solid var(--theme-surface-border);
    border-left: 3px solid var(--theme-brand);
    border-radius: 8px;
    font-size: 0.78rem;
    color: var(--theme-text);
    line-height: 1.45;
}
.field-info-panel[hidden] { display: none; }
.field-info-panel p { margin: 0 0 4px 0; }
.field-info-panel p:last-child { margin-bottom: 0; }
.field-info-panel strong {
    color: var(--theme-text-muted);
    font-weight: 700;
    margin-right: 4px;
}
/* Campos que no aplican a la tarifa/compañía detectada (ej. Potencia P2 en
   Endesa 2.0TD, que usa convención P1+P3). Visualmente atenuados + badge
   para que el consultor no piense que tiene que rellenarlos a mano.
   El input sigue editable por si hay que corregir errores de extracción. */
.review-field-na input,
.review-field-na select {
    background: var(--theme-input-bg-muted, rgba(148, 163, 184, 0.08));
    color: var(--theme-text-muted);
    border-style: dashed;
}
.review-field-na label {
    color: var(--theme-text-muted);
    opacity: 0.85;
}
.badge-na {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--theme-text-muted);
    background: rgba(148, 163, 184, 0.18);
    padding: 1px 6px;
    border-radius: 8px;
    margin-left: 4px;
    vertical-align: middle;
}

.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;
}

.block-breakdown {
    margin-top: 14px;
    padding: 14px 16px;
    border-radius: 12px;
    background: var(--theme-surface-muted);
    border: 1px dashed var(--theme-surface-border);
}
.block-breakdown-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--theme-text-muted);
    font-weight: 700;
    margin-bottom: 10px;
}
.block-breakdown-period {
    margin-top: 14px;
}
.block-breakdown-period:first-of-type {
    margin-top: 0;
}
.block-breakdown-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--theme-brand);
    margin-bottom: 8px;
    letter-spacing: 0.3px;
}

/* Grid uniforme: cabeceras 1 vez en la primera fila + N filas de inputs.
   Power = 4 cols (kW, €/kW·día, días, coste); Energy = 3 cols (kWh,
   €/kWh, coste). Las cabeceras solo aparecen al inicio del grid. */
.block-grid {
    display: grid;
    gap: 8px 12px;
    align-items: center;
}
/* Power: 4 cols datos + 32px botón borrar fila */
.block-grid-power {
    grid-template-columns: repeat(4, minmax(0, 1fr)) 32px;
}
/* Energy: 3 cols datos + 32px botón borrar fila */
.block-grid-energy {
    grid-template-columns: repeat(3, minmax(0, 1fr)) 32px;
}
/* Botón borrar fila — visible solo en hover de la fila */
.block-row-delete {
    width: 32px;
    height: 38px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--theme-text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.block-row-delete:hover {
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.3);
}
/* Botón añadir fila — debajo del grid */
.block-row-add {
    margin-top: 8px;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px dashed var(--theme-border);
    background: transparent;
    color: var(--theme-text-muted);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.block-row-add:hover {
    background: var(--theme-brand-soft, rgba(99, 102, 241, 0.08));
    color: var(--theme-brand);
    border-color: var(--theme-brand);
    border-style: solid;
}
.block-grid-services {
    /* Concepto más ancho que las 3 columnas numéricas */
    grid-template-columns: minmax(0, 2fr) repeat(3, minmax(0, 1fr));
}
.block-grid-head {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--theme-text-muted);
    font-weight: 600;
}
.block-grid-input {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--theme-surface-border);
    background: var(--theme-surface);
    color: var(--theme-text);
    font-family: inherit;
    font-size: 0.9rem;
    font-variant-numeric: tabular-nums;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}
.block-grid-input:focus {
    outline: none;
    border-color: var(--theme-brand);
}
@media (max-width: 768px) {
    .block-grid-power, .block-grid-energy, .block-grid-services {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .block-grid-head {
        display: none;
    }
}

.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/análisis */
.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);
    position: relative;
    transition: width 0.25s ease, padding 0.25s ease,
                background-color 0.5s ease, color 0.5s ease, border-color 0.5s ease;
}

/* ─── Collapse / expand toggle (discreto) ─── */
.sidebar-collapse-toggle {
    position: absolute;
    top: 50%;
    right: -10px;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    border-radius: 999px;
    background: var(--theme-surface);
    border: 1px solid var(--theme-sidebar-border);
    color: var(--theme-sidebar-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 5;
    opacity: 0.5;
    box-shadow: none;
    transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
    padding: 0;
}
.sidebar-collapse-toggle:hover {
    opacity: 1;
    background: var(--theme-sidebar-active-bg);
    color: var(--theme-sidebar-text);
}
.sidebar-collapse-toggle i {
    font-size: 9px;
    line-height: 1;
    transition: transform 0.25s ease;
}
.sidebar.collapsed .sidebar-collapse-toggle i { transform: rotate(180deg); }

/* ─── Collapsed state ─── */
.sidebar.collapsed { width: 76px; padding: 28px 10px; gap: 16px; }
.sidebar.collapsed .sidebar-brand { display: none; }
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .nav-sub-item span,
.sidebar.collapsed .nav-group-arrow,
.sidebar.collapsed .sidebar-label,
.sidebar.collapsed .sidebar-promo,
.sidebar.collapsed .nav-group-items { display: none !important; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 12px 8px; gap: 0; }
.sidebar.collapsed .nav-item i { width: auto; font-size: 1.05rem; }
.sidebar.collapsed .sidebar-theme { align-items: center; }
.sidebar.collapsed .theme-toggle {
    flex-direction: column;
    padding: 3px;
    gap: 2px;
    border-radius: 999px;
}
.sidebar.collapsed .theme-btn { width: 30px; height: 30px; font-size: 14px; }
.sidebar.collapsed .theme-btn i,
.sidebar.collapsed .theme-btn svg { font-size: 14px; }
.sidebar.collapsed .sidebar-nav-bottom { padding-top: 12px; }

/* Reposition shrinks when content beside expands */
.app-main { transition: margin-left 0.25s ease; }

@media (max-width: 768px) {
    /* Mobile uses hamburger; hide collapse toggle and force full-width on open */
    .sidebar-collapse-toggle { display: none !important; }
    .sidebar.collapsed { width: 240px; padding: 28px 20px; gap: 22px; }
    .sidebar.collapsed .sidebar-brand { display: flex; justify-content: flex-start; gap: 12px; }
    .sidebar.collapsed .nav-item span,
    .sidebar.collapsed .nav-sub-item span,
    .sidebar.collapsed .nav-group-arrow,
    .sidebar.collapsed .sidebar-label,
    .sidebar.collapsed .sidebar-promo,
    .sidebar.collapsed .nav-group.open .nav-group-items { display: revert !important; }
    .sidebar.collapsed .nav-item { justify-content: flex-start; padding: 12px 14px; gap: 12px; }
}

.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;
    flex: 1;
    min-height: 0;
}

.sidebar-nav-bottom {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--theme-sidebar-border);
}

.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: 5px;
    padding: 5px;
    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: 38px;
    height: 38px;
    border-radius: 999px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--theme-sidebar-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    font-size: 17px;
    opacity: 1;
}

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

.theme-btn[data-theme-value="light"] {
    color: #d97706;
}

.theme-btn[data-theme-value="dark"] {
    color: #475569;
}

:root[data-theme="dark"] .theme-btn[data-theme-value="dark"],
body[data-theme="dark"] .theme-btn[data-theme-value="dark"] {
    color: #c4b5fd;
}

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

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

.theme-btn[data-theme-value="light"].active {
    color: #b45309;
}

.theme-btn[data-theme-value="dark"].active {
    color: #4338ca;
}

:root[data-theme="dark"] .theme-btn.active,
body[data-theme="dark"] .theme-btn.active {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.22);
}

:root[data-theme="dark"] .theme-btn[data-theme-value="dark"].active,
body[data-theme="dark"] .theme-btn[data-theme-value="dark"].active {
    color: #ddd6fe;
}

.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: 14px 28px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 16px;
    transition: background-color 0.5s ease, border-color 0.5s ease;
}

/* Logo corporativo dentro del cluster de la derecha. Click → dashboard.
   Tamaño compacto para integrarse con los iconos de campana/avatar. */
.topbar-brand {
    display: inline-flex;
    align-items: center;
    height: 32px;
    text-decoration: none;
    flex-shrink: 0;
    padding-right: 4px;
    border-right: 1px solid var(--theme-border);
    margin-right: 4px;
    transition: opacity 0.15s ease;
}
.topbar-brand:hover { opacity: 0.75; }
.topbar-brand img {
    height: 24px;
    width: auto;
    max-width: 120px;
    object-fit: contain;
    display: block;
}

/* Nombre del usuario al lado del avatar (dentro de topbar-actions) */
.topbar-greeting {
    display: inline-flex;
    align-items: center;
    min-width: 0;
}
.topbar-greeting-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--theme-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 200px;
    padding: 0 4px;
}

@media (max-width: 768px) {
    .topbar-brand { display: none; }
    .topbar-greeting { display: none; }
}

.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;
}

/* Select del manual form (compañía) — heredamos los estilos de
   .manual-field input para consistencia visual. */
.manual-field .manual-company-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--theme-input-border, var(--theme-surface-border));
    border-radius: 10px;
    background: var(--theme-input-bg, var(--theme-surface-muted));
    color: var(--theme-text);
    font-size: 14px;
    font-family: inherit;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2'%3e%3cpath d='M6 9l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 36px;
    cursor: pointer;
}
.manual-field .manual-company-select:focus {
    outline: none;
    border-color: var(--theme-brand);
    box-shadow: 0 0 0 3px var(--theme-brand-soft);
}

/* Tabs Express / Avanzado (datos manuales) */
.manual-mode-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 16px;
}
.manual-mode-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 12px 16px;
    border: 1px solid var(--theme-surface-border);
    border-radius: 12px;
    background: var(--theme-surface-muted);
    color: var(--theme-text-muted);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .12s, color .12s, border-color .12s, transform .1s;
}
.manual-mode-tab:hover { background: var(--theme-surface); }
.manual-mode-tab i { font-size: 1.1rem; }
.manual-mode-tab small {
    font-size: 0.7rem;
    font-weight: 400;
    opacity: 0.65;
}
.manual-mode-tab.active {
    background: var(--theme-brand-soft);
    color: var(--theme-brand);
    border-color: var(--theme-brand);
}
.manual-mode-tab.active i { color: var(--theme-brand); }

/* Visibilidad por modo */
.manual-form.mode-express .advanced-only { display: none !important; }
.manual-form.mode-advanced .express-only { display: none !important; }

/* Badge de validación inline (totales) */
.manual-total-validation {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1.4;
}
.manual-total-validation[hidden] { display: none; }
.manual-total-validation--ok {
    background: rgba(22, 163, 74, 0.12);
    color: #16a34a;
    border: 1px solid rgba(22, 163, 74, 0.3);
}
.manual-total-validation--warn {
    background: rgba(245, 158, 11, 0.12);
    color: #d97706;
    border: 1px solid rgba(245, 158, 11, 0.4);
}
.manual-total-validation i { font-size: 0.7rem; }

/* Toggle "Auto/Manual" para días facturados (datos manuales) */
.manual-days-toggle {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    background: var(--theme-brand-soft, rgba(99, 102, 241, 0.18));
    color: var(--theme-brand);
    border: 1px solid var(--theme-brand);
    cursor: pointer;
    user-select: none;
    transition: background .12s, color .12s, border-color .12s;
    line-height: 1.4;
}
.manual-days-toggle[aria-pressed="false"] {
    background: var(--theme-surface-muted);
    color: var(--theme-text-muted);
    border-color: var(--theme-surface-border);
}
.manual-days-toggle:hover { filter: brightness(1.1); }
.manual-days-toggle i { font-size: 0.7rem; }
input#manual-days[readonly] {
    opacity: 0.75;
    cursor: not-allowed;
    background: var(--theme-surface-muted);
}

/* Panel desplegable: compañías y tarifas con parser específico */
.parser-coverage {
    margin: 12px 0 18px;
    border: 1px solid var(--theme-surface-border);
    border-radius: 12px;
    background: var(--theme-surface-muted);
    overflow: hidden;
}
.parser-coverage > summary {
    list-style: none;
    cursor: pointer;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.88rem;
    color: var(--theme-text);
    user-select: none;
}
.parser-coverage > summary::-webkit-details-marker { display: none; }
.parser-coverage > summary > i { color: var(--theme-success, #16a34a); font-size: 1rem; }
.parser-coverage > summary > small {
    color: var(--theme-text-muted);
    font-weight: 400;
    margin-left: auto;
    font-size: 0.75rem;
}
.parser-coverage[open] > summary {
    border-bottom: 1px solid var(--theme-surface-border);
    background: var(--theme-surface);
}
.parser-coverage-body { padding: 14px 16px 16px; }
.parser-coverage-hint {
    font-size: 0.78rem;
    color: var(--theme-text-muted);
    margin: 0 0 12px;
    line-height: 1.5;
}
.parser-coverage-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
}
.parser-coverage-card {
    border: 1px solid var(--theme-surface-border);
    border-radius: 10px;
    padding: 10px 12px;
    background: var(--theme-surface);
}
.parser-coverage-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 8px;
    font-size: 0.82rem;
}
.parser-coverage-kw {
    font-size: 0.7rem;
    color: var(--theme-text-muted);
    background: var(--theme-surface-muted);
    border: 1px solid var(--theme-surface-border);
    border-radius: 999px;
    padding: 2px 8px;
    white-space: nowrap;
}
.parser-coverage-list {
    list-style: none;
    margin: 0;
    padding: 0;
    /* Grid auto-fill: las celdas tienen un mínimo (140px) y crecen
       hasta llenar la fila. En móvil se ajusta a 2 columnas (140px
       mínimo cabe 2x en ~320px). En desktop son 3-4 columnas. */
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 6px;
}
.parser-coverage-list li {
    font-size: 0.78rem;
    color: var(--theme-text);
    background: var(--theme-surface-muted);
    border: 1px solid var(--theme-surface-border);
    border-radius: 8px;
    padding: 0;
    list-style: none;
    overflow: hidden;
    min-height: 40px;
    display: flex;
}
.parser-coverage-list .parser-coverage-chip-static {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    color: var(--theme-text-muted);
    opacity: 0.65;
    width: 100%;
    line-height: 1.25;
}
.parser-coverage-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: transparent;
    border: 0;
    color: var(--theme-text);
    font-size: inherit;
    font-family: inherit;
    cursor: pointer;
    transition: color .12s, background .12s;
    border-radius: 8px;
    width: 100%;
    text-align: left;
    line-height: 1.25;
}
.parser-coverage-chip:hover {
    background: var(--theme-brand-soft, rgba(99, 102, 241, 0.15));
    color: var(--theme-brand);
}
.parser-coverage-chip > span:not(.parser-coverage-logo-fallback):not(.parser-coverage-logo-box),
.parser-coverage-chip-static > span:not(.parser-coverage-logo-fallback):not(.parser-coverage-logo-box) {
    flex: 1;
    /* Permitir wrap a 2 líneas para nombres largos. La altura mínima
       del <li> garantiza que las celdas mantengan el mismo aspecto. */
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    word-break: break-word;
}
/* Caja contenedora del logo: tamaño visual consistente para todos
   los aspect ratios (de cuadrado a 5:1). Logo se centra dentro y
   nunca excede la caja. Fondo blanco para que logos diseñados para
   fondo claro se vean bien en tema oscuro. */
.parser-coverage-logo-box,
.parser-coverage-logo-fallback {
    width: 36px;
    height: 22px;
    flex-shrink: 0;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.parser-coverage-logo-box {
    background: white;
    padding: 2px 3px;
    border: 1px solid rgba(0, 0, 0, 0.06);
}
.parser-coverage-logo {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}
.parser-coverage-logo-fallback {
    background: var(--theme-brand-soft, rgba(99, 102, 241, 0.2));
    color: var(--theme-brand);
    font-weight: 700;
    font-size: 0.8rem;
}

/* Modal: factura modelo. Layout sin flex en el body para evitar
   bugs conocidos de iOS Safari con flex + overflow + img grande. */
.sample-pdf-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
}
.sample-pdf-modal[hidden] { display: none; }
.sample-pdf-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
}
.sample-pdf-window {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(900px, 96vw);
    max-height: 92vh;
    background: var(--theme-surface);
    border-radius: 14px;
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
    display: grid;
    grid-template-rows: auto 1fr auto;
    overflow: hidden;
}
.sample-pdf-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--theme-surface-border);
    background: var(--theme-surface-muted);
    min-height: 0;
}
.sample-pdf-header strong {
    font-size: 0.92rem;
    color: var(--theme-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}
.sample-pdf-actions { display: flex; gap: 6px; flex-shrink: 0; }
.sample-pdf-actions a,
.sample-pdf-actions button {
    height: 34px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    justify-content: center;
    border-radius: 8px;
    background: transparent;
    border: 1px solid var(--theme-surface-border);
    color: var(--theme-text-muted);
    cursor: pointer;
    transition: background .12s, color .12s;
    text-decoration: none;
    font-size: 0.78rem;
    font-weight: 600;
}
.sample-pdf-actions a {
    background: var(--theme-brand);
    color: white;
    border-color: var(--theme-brand);
}
.sample-pdf-actions a:hover {
    background: var(--theme-brand-dark, #4338ca);
    color: white;
}
.sample-pdf-actions button:hover {
    background: var(--theme-brand-soft);
    color: var(--theme-brand);
    border-color: var(--theme-brand);
}
.sample-pdf-body {
    background: #525659;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    padding: 14px;
    text-align: center;
    min-height: 0;
}
.sample-pdf-body img.sample-pdf-page {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
    background: white;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
    border-radius: 4px;
}
.sample-pdf-body img.sample-pdf-page + .sample-pdf-page-label {
    margin: 6px auto 14px;
}
.sample-pdf-page-label {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.72rem;
    text-align: center;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    margin: 6px 0 14px;
}
.sample-pdf-body img.sample-pdf-page:last-child,
.sample-pdf-body img.sample-pdf-page + .sample-pdf-page-label:last-child {
    margin-bottom: 0;
}
.sample-pdf-footer {
    padding: 8px 14px;
    border-top: 1px solid var(--theme-surface-border);
    background: var(--theme-surface-muted);
    color: var(--theme-text-muted);
    font-size: 0.7rem;
    line-height: 1.4;
}
.sample-pdf-footer i { color: var(--theme-success, #16a34a); margin-right: 4px; }

@media (max-width: 768px) {
    .parser-coverage-grid { grid-template-columns: 1fr; }
    .parser-coverage > summary > small { display: none; }
    /* Móvil: 2 columnas garantizadas para aprovechar el ancho.
       En móviles muy estrechos (<340px) cae a 1 columna. */
    .parser-coverage-list {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }
    .parser-coverage-list li { min-height: 44px; }
    .parser-coverage-chip,
    .parser-coverage-chip-static {
        padding: 6px 8px;
        gap: 7px;
        font-size: 0.74rem;
    }
    .parser-coverage-logo-box,
    .parser-coverage-logo-fallback {
        width: 32px;
        height: 20px;
    }

    /* Móvil: modal a pantalla completa con dvh para iOS Safari
       (viewport dinámico que cambia al ocultar/mostrar barra). */
    .sample-pdf-window {
        top: 0;
        left: 0;
        transform: none;
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
    }
    .sample-pdf-header { padding: 10px 12px; }
    .sample-pdf-header strong { font-size: 0.85rem; }
    .sample-pdf-actions a span,
    .sample-pdf-actions button span { display: none; }
    .sample-pdf-actions a,
    .sample-pdf-actions button {
        width: 38px;
        padding: 0;
    }
    .sample-pdf-body { padding: 8px; }
    .sample-pdf-footer { padding: 6px 10px; font-size: 0.65rem; }
}

.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;
}

/* Presets del listado CRM. Redesign mayo 2026: chips más ligeros
   (sin uppercase, menor padding/letter-spacing) y agrupados en 2 filas
   (Comercial / Mantenimiento) con un sub-label discreto a la izquierda
   que da contexto sin gritar. */
.crm-presets-wrap {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 8px 0 14px;
}
.crm-presets-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.crm-presets-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--theme-text-muted);
    opacity: 0.55;
    min-width: 100px;
    flex-shrink: 0;
}
.crm-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex: 1;
    min-width: 0;
}

.crm-preset-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px 11px;
    border-radius: 999px;
    border: 1px solid var(--theme-surface-border);
    background: var(--theme-surface);
    color: var(--theme-text-muted);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
    transition: all .15s ease;
    text-decoration: none;
}

.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 4px 12px rgba(99, 102, 241, 0.18);
}

/* Mobile: el sub-label se posiciona arriba de los chips para ahorrar ancho. */
@media (max-width: 640px) {
    .crm-presets-label { min-width: 0; width: 100%; }
}

.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;
}

.cd-hero-panel {
    position: relative;
    margin-bottom: 20px;
    padding: 22px;
    border: 1px solid var(--theme-surface-border);
    border-radius: 22px;
    background:
        linear-gradient(135deg, rgba(99, 102, 241, .10), transparent 42%),
        var(--theme-surface);
    box-shadow: 0 18px 42px rgba(15, 23, 42, .08);
}

.cd-hero-top {
    align-items: flex-start;
    gap: 18px;
    margin-bottom: 18px;
}

.cd-hero-identity {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    min-width: min(100%, 520px);
}

.cd-hero-avatar {
    width: 58px;
    height: 58px;
    border-radius: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    color: #fff;
    background: linear-gradient(135deg, var(--theme-brand), #22c55e);
    box-shadow: 0 14px 30px rgba(99, 102, 241, .25);
    font-size: 1.35rem;
}

.cd-hero-content {
    min-width: 0;
}

.cd-hero-title {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    line-height: 1.1;
}

.cd-hero-title > span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.cd-hero-edit {
    margin-left: 0;
    flex: 0 0 auto;
}

.cd-hero-badges {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.cd-hero-badges .score-badge,
.cd-hero-badges .tax-id-badge,
.cd-hero-badges .completeness-badge {
    margin-left: 0;
    height: 24px;
    padding: 0 9px;
    border-radius: 999px;
    text-decoration: none;
}

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

.cd-hero-meta {
    gap: 8px;
    margin-top: 12px;
}

.cd-hero-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 30px;
    max-width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--theme-surface-border);
    border-radius: 999px;
    color: var(--theme-text-muted);
    background: var(--theme-surface);
    background: color-mix(in srgb, var(--theme-surface) 80%, transparent);
    font-size: .82rem;
    font-weight: 650;
    line-height: 1.2;
    text-decoration: none;
}

.cd-hero-chip span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cd-hero-chip i {
    color: var(--theme-brand);
    flex: 0 0 auto;
}

.cd-hero-chip-link {
    color: var(--theme-brand);
}

.cd-hero-chip:hover {
    border-color: var(--theme-brand);
    color: var(--theme-brand);
}

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

.cd-action-group {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.customer-header-actions .btn-opt {
    min-height: 38px;
    border-radius: 12px;
    padding: 9px 13px;
    letter-spacing: 0;
    text-transform: none;
    white-space: nowrap;
}

.cd-action-group-primary .btn-opt-gradient {
    box-shadow: 0 12px 26px rgba(99, 102, 241, .24);
}

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

.cd-kpis-visual {
    grid-template-columns: minmax(150px, .85fr) minmax(150px, .85fr) minmax(240px, 1.35fr) minmax(180px, .9fr);
    gap: 12px;
    margin-bottom: 0;
}

.cd-kpi-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    min-width: 0;
    border: 1px solid var(--theme-surface-border);
    border-radius: 18px;
    background: var(--theme-surface);
    background: color-mix(in srgb, var(--theme-surface) 88%, transparent);
    box-shadow: 0 10px 24px rgba(15, 23, 42, .06);
}

.cd-kpi-card-featured {
    border-color: rgba(34, 197, 94, .34);
    background:
        linear-gradient(135deg, rgba(34, 197, 94, .15), rgba(99, 102, 241, .06)),
        var(--theme-surface);
}

.cd-kpi-card-cost {
    background:
        linear-gradient(135deg, rgba(99, 102, 241, .08), transparent 55%),
        var(--theme-surface);
}

.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;
    min-width: 0;
}

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

.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-subline {
    color: var(--theme-text-muted);
    font-size: .76rem;
    font-weight: 650;
    margin-top: 2px;
}

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

@media (max-width: 1120px) {
    .cd-kpis-visual {
        grid-template-columns: repeat(2, minmax(180px, 1fr));
    }
}

@media (max-width: 768px) {
    .cd-hero-panel {
        padding: 16px;
        border-radius: 18px;
    }

    .cd-hero-top {
        flex-direction: column;
    }

    .cd-hero-identity {
        width: 100%;
        gap: 12px;
    }

    .cd-hero-avatar {
        width: 48px;
        height: 48px;
        border-radius: 14px;
        font-size: 1.05rem;
    }

    .customer-header-actions,
    .cd-action-group {
        width: 100%;
        justify-content: flex-start;
    }

    .customer-header-actions .btn-opt {
        flex: 1 1 140px;
        justify-content: center;
    }

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

.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);
    /* Evita que el <select> con texto largo (ej. "Comparativa generada")
       desborde la tarjeta KPI: max-width al ancho del padre. */
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    text-overflow: ellipsis;
}

/* ── Customer Detail: Main Grid ── */
.cd-main-grid {
    /* Mayo 2026: pasamos de 2 cols a 1 col. La ficha en 2 columnas
       hacía leer en zigzag (Punto suministro / Gestión / Acerca de /
       Tareas) y dejaba mucho espacio vacío a la derecha en monitores
       anchos. Una sola columna fluye de arriba a abajo y se lee como
       una historia natural del cliente. */
    display: grid;
    grid-template-columns: 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;
}
@media (max-width: 480px) {
    .cd-contract-grid {
        grid-template-columns: 1fr;
    }
}
.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;
}
@media (max-width: 480px) {
    .notif-dropdown {
        position: fixed;
        top: calc(56px + env(safe-area-inset-top, 0px));
        right: 8px;
        left: 8px;
        width: auto;
        max-height: calc(100vh - 80px);
    }
}
.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;
}
@media (max-width: 480px) {
    .search-dropdown {
        position: fixed;
        top: calc(56px + env(safe-area-inset-top, 0px));
        left: 8px;
        right: 8px;
        max-height: calc(100vh - 80px);
        margin-top: 0;
    }
}
.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-crm-cockpit {
    margin-bottom: 20px;
    display: grid;
    grid-template-columns: minmax(280px, 1.2fr) minmax(260px, 1fr);
    gap: 16px;
    align-items: stretch;
}

.cd-next-action-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    border-radius: 12px;
    border: 1px solid var(--theme-surface-border);
    background: var(--theme-surface);
}

.cd-next-action-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #fff;
    background: var(--theme-brand);
}

.cd-next-action-body {
    flex: 1;
    min-width: 0;
}

.cd-next-action-label {
    display: block;
    margin-bottom: 4px;
    color: var(--theme-text-muted);
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.cd-next-action-body strong {
    display: block;
    color: var(--theme-title);
    font-size: 1rem;
}

.cd-next-action-body p {
    margin: 3px 0 0;
    color: var(--theme-text-muted);
    font-size: 0.82rem;
}

.cd-next-action-hot .cd-next-action-icon,
.cd-next-action-danger .cd-next-action-icon {
    background: #ef4444;
}

.cd-next-action-warning .cd-next-action-icon {
    background: #f59e0b;
}

.cd-next-action-success .cd-next-action-icon {
    background: #22c55e;
}

.cd-crm-signal-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.cd-crm-signal {
    padding: 12px;
    border: 1px solid var(--theme-surface-border);
    border-radius: 10px;
    background: var(--theme-surface);
}

.cd-crm-signal span {
    display: block;
    margin-bottom: 4px;
    color: var(--theme-text-muted);
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.cd-crm-signal strong {
    color: var(--theme-title);
    font-size: 0.95rem;
}

@media (max-width: 768px) {
    /* En móvil el card "Siguiente mejor acción" tenía flex con icono +
       cuerpo + botón ABRIR en horizontal. El botón se solapaba sobre
       el texto del cuerpo. Pasamos a layout en grid: icono+cuerpo en
       fila superior, botón ABRIR en fila inferior a ancho completo. */
    .cd-next-action-card {
        display: grid;
        grid-template-columns: auto 1fr;
        grid-template-rows: auto auto;
        gap: 12px 14px;
        align-items: start;
    }
    .cd-next-action-icon { grid-row: 1; grid-column: 1; }
    .cd-next-action-body { grid-row: 1; grid-column: 2; }
    .cd-next-action-card > a.btn-opt {
        grid-row: 2;
        grid-column: 1 / -1;
        width: 100%;
        justify-content: center;
    }
    .cd-next-action-body strong {
        white-space: normal;
        word-break: break-word;
    }
    .cd-next-action-body p {
        white-space: normal;
        word-break: break-word;
        line-height: 1.4;
    }

    /* Tablas de "Comparativas guardadas" y "Simulaciones" con 5-6
       columnas: scroll horizontal en móvil para no romper el layout
       (CLAUDE.md regla obligatoria). El header pasa a flex-wrap así
       el botón "Nueva …" cae a línea propia y se ve completo. */
    .cd-comparisons-card .card-header,
    .cd-card .card-header {
        flex-wrap: wrap;
        row-gap: 10px;
    }
    .cd-comparisons-card .card-header > .btn-opt,
    .cd-card .card-header > .btn-opt {
        margin-left: 0 !important;
        flex-basis: 100%;
        justify-content: center;
        width: 100%;
    }
    .cd-comparisons-list {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .cd-comparisons-list table {
        min-width: 580px;
    }
    /* Las celdas de la tabla no deben envolverse en el móvil:
       que la columna entera se desplace al hacer scroll, no que
       cada celda apile su contenido en 5 líneas. */
    .cd-comparisons-list table td,
    .cd-comparisons-list table th {
        white-space: nowrap;
    }
    /* Excepción: la columna "Nombre" puede ser larga; permitimos
       wrap pero con max-width para que no estire toda la tabla. */
    .cd-comparisons-list table td:nth-child(2),
    .cd-comparisons-list table th:nth-child(2) {
        white-space: normal;
        max-width: 200px;
        word-break: break-word;
    }
}

@media (max-width: 860px) {
    .cd-crm-cockpit {
        grid-template-columns: 1fr;
    }
    .portfolio-next-action {
        width: 100%;
    }
    .next-action-detail {
        max-width: 100%;
    }
}

.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: 1rem;
    border: 1px solid var(--theme-brand);
    transition: background-color .2s ease, color .2s ease, transform .15s ease;
    text-decoration: none;
    cursor: pointer;
}

.btn-icon i { color: inherit; line-height: 1; }

.btn-icon:hover {
    background: var(--theme-brand);
    color: #fff;
    transform: translateY(-1px);
}

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

.btn-icon.danger:hover {
    background: #ef4444;
    color: #fff;
}

.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;
    flex-wrap: wrap;
    gap: 18px;
    row-gap: 12px;
    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="Factura recibida"] {
    background: rgba(14, 165, 233, 0.16);
    color: #0284c7;
}

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

.portfolio-status[data-status="Propuesta enviada"] {
    background: rgba(139, 92, 246, 0.16);
    color: #7c3aed;
}

.portfolio-status[data-status="Propuesta vista"],
.portfolio-status[data-status="Interesado"] {
    background: rgba(236, 72, 153, 0.16);
    color: #db2777;
}

.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-status[data-status="Seguimiento"] {
    background: rgba(249, 115, 22, 0.16);
    color: #ea580c;
}

.portfolio-next-action {
    width: 190px;
    flex-shrink: 0;
    text-align: left;
}

.next-action-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    max-width: 100%;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 800;
    text-decoration: none;
    border: 1px solid transparent;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.next-action-chip span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.next-action-hot {
    background: rgba(239, 68, 68, 0.12);
    color: #dc2626;
    border-color: rgba(239, 68, 68, 0.18);
}

.next-action-warning {
    background: rgba(245, 158, 11, 0.13);
    color: #d97706;
    border-color: rgba(245, 158, 11, 0.22);
}

.next-action-success {
    background: rgba(34, 197, 94, 0.13);
    color: #16a34a;
    border-color: rgba(34, 197, 94, 0.22);
}

.next-action-danger {
    background: rgba(239, 68, 68, 0.13);
    color: #b91c1c;
    border-color: rgba(239, 68, 68, 0.22);
}

.next-action-neutral {
    background: var(--theme-brand-soft);
    color: var(--theme-brand);
    border-color: var(--theme-surface-border);
}

.next-action-detail {
    display: block;
    margin-top: 3px;
    max-width: 180px;
    color: var(--theme-text-muted);
    font-size: 0.72rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

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

/* Acciones (Ver ficha + iconos) viven dentro de portfolio-main, debajo
   del nombre y meta. Ya no flotan a la derecha del row. */
.portfolio-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 10px;
}

.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-nav-bottom {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
        margin-top: 0;
        padding-top: 0;
        border-top: 0;
    }

    .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; }
    .sidebar-nav-bottom { flex-direction:column; flex-wrap:nowrap; gap:10px; margin-top:16px; padding-top:12px; border-top:1px solid var(--theme-sidebar-border); }

    /* 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;
    }
}


/* --- 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 TOP NAV (fusionada con topbar) ====================
   En móvil la barra de navegación principal vive arriba como segunda
   fila de la topbar, no abajo. Esto evita una doble barra (top + bottom)
   y deja toda la zona inferior libre para el contenido + barras de
   wizard/resultados del simulador. */

/* Topbar y nav fusionadas en UNA sola fila a 56px:
   - Izquierda: 5 items de nav (icon-only, label solo en activo)
   - Derecha: search-btn + bell + avatar
   Anchura aproximada del cluster derecho: ~155px en 375px. */
:root {
    --mobile-topbar-h: 64px;
    --mobile-topbar-actions-w: 130px;
    --mobile-topnav-h: var(--mobile-topbar-h);
}

.bottom-nav {
    display: none;  /* oculta en desktop — la sidebar ya tiene la nav */
    height: var(--mobile-topbar-h);
    background: var(--theme-surface);
    z-index: 1000;
}

@media (max-width: 768px) {
    /* Topbar entera oculta en móvil. La nav row ocupa toda la fila y
       contiene los 5 destinos principales. Búsqueda, notificaciones y
       perfil viven dentro del menú "Más" (ver bottom-nav-more-menu). */
    .topbar { display: none !important; }

    /* Nav row full-width, fija arriba, cubre safe-area. */
    .bottom-nav {
        display: flex;
        justify-content: space-around;
        align-items: center;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: calc(var(--mobile-topbar-h) + env(safe-area-inset-top, 0px));
        padding-top: env(safe-area-inset-top, 0px);
        background: var(--theme-topbar-bg);
        border-bottom: 1px solid var(--theme-surface-border);
        z-index: 1001;
        box-shadow: 0 2px 8px rgba(0,0,0,.18);
    }

    /* Espacio bajo la topnav fusionada para que el contenido no quede oculto. */
    .app-content, .main-content {
        padding-top: calc(var(--mobile-topbar-h) + env(safe-area-inset-top, 0px) + 8px) !important;
        padding-bottom: 24px !important;
    }
    .app-main { padding-top: 0 !important; }

    /* More-menu desliza desde justo debajo de la fila fusionada */
    .bottom-nav-more-menu {
        top: calc(var(--mobile-topbar-h) + env(safe-area-inset-top, 0px));
    }

    /* Items de nav: icono encima, label corto debajo. Con la fila a
       full-width hay sitio cómodo para 5 items con texto. */
    .bottom-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        /* Padding asimétrico fuerte: el icono se percibe alto cuando el
           label cuelga debajo. Compensamos con más padding-top. */
        padding: 18px 4px 4px;
        font-size: 0.62rem;
        font-weight: 600;
        min-width: 0;
        position: relative;
        background: transparent !important;
        border: 0;
        outline: none;
        cursor: pointer;
        height: 100%;
        color: var(--theme-text-muted);
        text-decoration: none;
        -webkit-tap-highlight-color: transparent;
    }
    .bottom-nav-item:focus { outline: none; }
    .bottom-nav-item i {
        font-size: 1.1rem;
        margin: 0;
        line-height: 1;
    }
    .bottom-nav-item span {
        display: block;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }
    .bottom-nav-item.active {
        color: var(--theme-brand);
    }
    .bottom-nav-item.active i { transform: none; }

    /* Compactar cluster derecho: PRO + chevron desaparecen en móvil
       (la dropdown sigue funcionando con el avatar como trigger). */
    .topbar-user-btn {
        padding: 0;
        gap: 0;
        border: 0;
    }
    .topbar-user-btn:hover { background: transparent; border: 0; }
    .topbar-user-btn .avatar {
        width: 30px !important;
        height: 30px !important;
        font-size: 11px !important;
    }
    .topbar-user-btn > span,         /* PRO badge */
    .topbar-user-btn > i.fa-chevron-down { display: none; }
    /* Iconos del cluster derecho: transparentes, sin borde, igualados a
       los iconos de la nav row para que toda la fila luzca uniforme. */
    .topbar .btn-icon,
    .mobile-search-btn,
    .notif-bell-wrap .btn-icon {
        width: 32px !important;
        height: 32px !important;
        background: transparent !important;
        border: 0 !important;
        border-radius: 8px !important;
        color: var(--theme-text-muted) !important;
        font-size: 1.05rem !important;
    }
    .topbar .btn-icon:hover,
    .mobile-search-btn:hover,
    .notif-bell-wrap .btn-icon:hover {
        background: var(--theme-surface-muted) !important;
        color: var(--theme-brand) !important;
    }
    .notif-bell-wrap { flex-shrink: 0; display: inline-flex; align-items: center; }
    .mobile-search-btn { margin-right: 0 !important; flex-shrink: 0; }
    /* Separador sutil vertical entre nav row y cluster derecho */
    .topbar::before {
        content: "";
        position: absolute;
        left: 0;
        top: calc(env(safe-area-inset-top, 0px) + 12px);
        bottom: 12px;
        width: 1px;
        background: var(--theme-surface-border);
        opacity: .6;
    }

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

    /* Mobile overflow safety: prevent any element from forcing horizontal scroll */
    html, body { overflow-x: hidden; }
    .app-content, .app-main { max-width: 100vw; overflow-x: hidden; }

    /* Form controls: force full-width + ellipsis so option labels never clip */
    select, input[type="text"], input[type="email"], input[type="tel"],
    input[type="number"], input[type="date"], input[type="password"], textarea {
        max-width: 100%;
        box-sizing: border-box;
    }
    select { text-overflow: ellipsis; }
}

.bottom-nav-item {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    flex: 1 !important;
    padding: 0 4px !important;     /* Sin padding vertical: dejamos que align-items center mande */
    color: var(--theme-text-muted);
    text-decoration: none;
    font-size: 0.62rem;
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    transition: color 0.2s;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    height: 100%;
    box-sizing: border-box;
    min-height: 0 !important;       /* anula el min-height: 48px que rompía el centrado */
}

.bottom-nav-item i {
    font-size: 1.15rem;
    margin: 0 0 3px 0 !important;
    line-height: 1;
    transition: transform 0.2s;
    display: block;
}
.bottom-nav-item span {
    line-height: 1;
}

.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 — desliza HACIA ABAJO desde la topnav fusionada (antes
   subía desde el bottom-nav, ahora baja desde el top-nav). */
.bottom-nav-more-menu {
    display: none;
    position: fixed;
    top: calc(var(--mobile-topnav-h) + env(safe-area-inset-top, 0px));
    left: 0;
    right: 0;
    background: var(--theme-surface);
    border-bottom: 1px solid var(--theme-surface-border);
    border-radius: 0 0 16px 16px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
    padding: 14px 12px 18px;
    z-index: 999;
    transform: translateY(-110%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    max-height: calc(100dvh - var(--mobile-topnav-h) - 40px);
    overflow-y: auto;
}

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

.bottom-nav-more-section {
    margin-bottom: 14px;
}
.bottom-nav-more-section:last-child {
    margin-bottom: 0;
}

.bottom-nav-more-heading {
    margin: 0 6px 8px;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--theme-text-muted);
    font-family: 'Montserrat', sans-serif;
}
.bottom-nav-more-heading-admin {
    color: #ef4444;
}

.bottom-nav-more-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.bottom-nav-more-menu a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 4px;
    color: var(--theme-text);
    text-decoration: none;
    font-size: 0.72rem;
    font-weight: 600;
    border-radius: 12px;
    background: var(--theme-surface-muted);
    transition: background 0.15s, transform 0.15s;
    text-align: center;
    min-height: 68px;
}

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

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

.bottom-nav-more-admin {
    color: #ef4444 !important;
}
.bottom-nav-more-admin i {
    color: #ef4444 !important;
}
/* Punto rojo en el botón "Más" cuando hay notificaciones sin leer.
   La cuenta exacta vive dentro del menú (en el item "Avisos"). */
@media (max-width: 768px) {
    .bottom-nav-item.has-notifications::after {
        content: "";
        position: absolute;
        top: calc(env(safe-area-inset-top, 0px) + 6px);
        right: 18px;
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: #ef4444;
        border: 2px solid var(--theme-topbar-bg);
    }
    /* Badge numérico del item "Avisos" dentro del menú Más */
    #bottom-nav-notif-link {
        position: relative;
    }
    .bottom-nav-notif-count {
        position: absolute;
        top: 6px;
        right: 6px;
        min-width: 18px;
        height: 18px;
        padding: 0 5px;
        border-radius: 9px;
        background: #ef4444;
        color: #fff;
        font-size: 10px;
        font-weight: 800;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        line-height: 1;
    }
}

@media (max-width: 360px) {
    .bottom-nav-more-grid { grid-template-columns: repeat(3, 1fr); }
}

.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: flex-start;
        flex-wrap: wrap;
        gap: 6px;
    }
    .page-header .btn-opt,
    .page-header button,
    .page-header a.btn,
    .page-header a.btn-opt {
        flex: 0 1 auto;
    }

    /* Floating action button */
    .fab {
        position: fixed;
        bottom: calc(80px + env(safe-area-inset-bottom, 0px));
        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;
        text-decoration: none;
    }

    .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; }
    /* Ocultar FAB en páginas de formulario para no tapar CTAs de guardar */
    body[data-hide-fab="true"] .fab { display: none !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;
    }
}

/* ==================== MOBILE GLOBAL FIXES (Fase 1) ==================== */

/* Wrapper utilitario para tablas anchas en móvil. Envolver <table> en <div class="table-scroll"> */
.table-scroll,
.pr-table-scroll {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.table-scroll > table,
.pr-table-scroll > table {
    min-width: max-content;
}

@media (max-width: 480px) {
    /* Colapsar grids de 2 columnas a 1 en móvil (modales, formularios inline) */
    [style*="grid-template-columns: 1fr 1fr"],
    [style*="grid-template-columns:1fr 1fr"],
    [style*="grid-template-columns: repeat(2,"],
    [style*="grid-template-columns:repeat(2,"] {
        grid-template-columns: 1fr !important;
    }
    /* Colapsar grids de 3 columnas a 1 en móvil */
    [style*="grid-template-columns: 1fr 1fr 1fr"],
    [style*="grid-template-columns:1fr 1fr 1fr"],
    [style*="grid-template-columns: repeat(3,"],
    [style*="grid-template-columns:repeat(3,"] {
        grid-template-columns: 1fr !important;
    }

    /* Modales: no exceder viewport */
    .modal,
    [class*="modal"][style*="max-width"] {
        max-width: calc(100vw - 24px) !important;
    }

    /* Filas de chips/filtros: permitir wrap siempre en móvil */
    .pr-filter-bar,
    .pr-filters,
    .chips-row,
    .filter-chips,
    [class*="filters-row"] {
        flex-wrap: wrap !important;
    }
    /* Fallback: chips demasiado numerosos se desplazan con scroll horizontal */
    .pr-filter-bar {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Inputs a 16px mínimo en móvil para evitar zoom automático en iOS */
@media (max-width: 768px) {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    input[type="search"],
    input[type="url"],
    input[type="date"],
    input[type="datetime-local"],
    input[type="month"],
    input[type="time"],
    input[type="week"],
    select,
    textarea {
        font-size: 16px !important;
    }
}

/* Padding inferior en contenido para no quedar tapado por bottom-nav + FAB */
@media (max-width: 768px) {
    .app-content {
        padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px)) !important;
    }
}

/* Kanban: scroll-snap horizontal en móvil para que las columnas se alineen */
@media (max-width: 768px) {
    .kanban-board {
        scroll-snap-type: x mandatory;
        scroll-padding: 14px;
    }
    .kanban-column {
        scroll-snap-align: start;
        min-width: 85vw !important;
        max-width: 85vw !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,
.help-fórmula {
    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,
.help-fórmula code {
    background: none;
    padding: 0;
    font-size: inherit;
    color: var(--theme-text);
}

.help-subpage-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
    margin: 12px 0 18px;
}
.help-subpage-card {
    position: relative;
    display: block;
    min-height: 118px;
    padding: 15px 40px 15px 16px;
    border: 1px solid var(--theme-border);
    border-radius: 10px;
    background: var(--theme-surface);
    color: var(--theme-text);
    text-decoration: none;
    transition: border-color .15s, box-shadow .15s, transform .12s;
}
.help-subpage-card:hover {
    border-color: var(--theme-brand);
    box-shadow: 0 4px 14px rgba(37,99,235,.12);
    transform: translateY(-1px);
}
.help-subpage-card strong {
    display: block;
    margin-bottom: 6px;
    font-size: 0.94rem;
    line-height: 1.3;
    color: var(--theme-title, var(--theme-text));
}
.help-subpage-card span {
    display: block;
    font-size: 0.82rem;
    line-height: 1.45;
    color: var(--theme-text-muted);
}
.help-subpage-card i {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--theme-brand);
    opacity: .45;
    font-size: .78rem;
}

/* 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;
}

/* Tabs por tipo de energía para el diagrama de anatomía de factura. */
.help-body .ia-tabs {
    display: flex;
    gap: 6px;
    margin: 18px 0 12px;
    flex-wrap: wrap;
    overflow-x: auto;
}
.help-body .ia-tab {
    flex: 1 1 auto;
    min-width: 140px;
    padding: 10px 14px;
    background: var(--theme-surface-muted, #f1f5f9);
    border: 1px solid var(--theme-border);
    border-radius: 10px;
    color: var(--theme-text-muted);
    font-size: 0.86rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    transition: background .15s, color .15s, border-color .15s, box-shadow .15s;
}
.help-body .ia-tab:hover {
    color: var(--theme-text);
    border-color: var(--theme-brand);
}
.help-body .ia-tab.is-active {
    background: var(--theme-surface, #fff);
    border-color: var(--theme-brand);
    color: var(--theme-brand);
    box-shadow: 0 0 0 3px var(--theme-brand-soft, rgba(99,102,241,.10));
}
.help-body .ia-tabpanel[hidden] { display: none; }
[data-theme="dark"] .help-body .ia-tab { background: rgba(2,6,23,.55); }
[data-theme="dark"] .help-body .ia-tab.is-active { background: rgba(15,23,42,.85); }
@media (max-width: 540px) {
    .help-body .ia-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: thin;
        -webkit-overflow-scrolling: touch;
        margin-left: -4px; margin-right: -4px;
        padding-left: 4px; padding-right: 4px;
    }
    .help-body .ia-tab {
        flex: 0 0 auto;
        min-width: 0;
        font-size: 0.78rem;
        padding: 8px 12px;
        white-space: nowrap;
    }
}

/* Invoice anatomy: rejilla de rectángulos desplegables (<details>).
   Carmen mayo 2026 — usado en /ayuda/estructura-factura. */
.help-body .invoice-anatomy {
    margin: 18px 0 24px;
    padding: 14px;
    background: linear-gradient(135deg, var(--theme-brand-soft, rgba(37,99,235,.06)), transparent);
    border: 1px solid var(--theme-border);
    border-radius: 14px;
    display: grid;
    gap: 8px;
}
.help-body .ia-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.help-body .ia-row-full {
    grid-template-columns: 1fr;
}
.help-body details.ia-block {
    background: var(--theme-surface, #fff);
    border: 1px solid var(--theme-border);
    border-radius: 10px;
    overflow: hidden;
    transition: border-color .15s, box-shadow .15s, transform .12s;
}
.help-body details.ia-block:hover {
    border-color: var(--theme-brand);
}
.help-body details.ia-block[open] {
    border-color: var(--theme-brand);
    box-shadow: 0 6px 18px rgba(37,99,235,.10);
    grid-column: 1 / -1;   /* al abrir ocupa ancho completo dentro de su .ia-row para que la tabla respire */
}
.help-body details.ia-block summary {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    cursor: pointer;
    list-style: none;
    user-select: none;
    transition: background .15s;
}
.help-body details.ia-block summary::-webkit-details-marker { display: none; }
.help-body details.ia-block summary::after {
    content: "\f078";
    font-family: "Font Awesome 6 Free", "FontAwesome";
    font-weight: 900;
    margin-left: auto;
    color: var(--theme-text-muted);
    font-size: 0.75rem;
    transition: transform .2s, color .15s;
    flex-shrink: 0;
}
.help-body details.ia-block[open] summary::after {
    transform: rotate(180deg);
    color: var(--theme-brand);
}
.help-body details.ia-block summary:hover {
    background: rgba(37,99,235,.04);
}
.help-body .ia-link-btn {
    margin-left: 6px;
    margin-right: 4px;
    background: transparent;
    border: 0;
    color: var(--theme-text-muted, #94a3b8);
    cursor: pointer;
    padding: 4px 6px;
    font-size: 0.78rem;
    border-radius: 6px;
    opacity: 0;
    transition: opacity .15s, color .15s, background .15s;
}
.help-body details.ia-block summary:hover .ia-link-btn,
.help-body details.ia-block[open] .ia-link-btn {
    opacity: 1;
}
.help-body .ia-link-btn:hover {
    color: var(--theme-brand, #6366f1);
    background: var(--theme-brand-soft, rgba(99,102,241,.10));
}
.help-body .ia-link-btn:focus-visible {
    opacity: 1;
    outline: 2px solid var(--theme-brand, #6366f1);
    outline-offset: 1px;
}
.help-body .ia-block summary > div { flex: 1; min-width: 0; }
.help-body .ia-block strong {
    display: block;
    font-size: 0.92rem;
    color: var(--theme-text);
    font-weight: 700;
    line-height: 1.2;
}
.help-body .ia-block small {
    display: block;
    font-size: 0.78rem;
    color: var(--theme-text-muted);
    line-height: 1.4;
    margin-top: 3px;
}
.help-body .ia-icon {
    font-size: 1.6rem;
    flex-shrink: 0;
    width: 40px;
    text-align: center;
}
.help-body .ia-detail {
    padding: 14px 18px 18px;
    border-top: 1px solid var(--theme-border);
    background: var(--theme-surface-muted, #fafafa);
    font-size: 0.9rem;
    line-height: 1.55;
}
.help-body .ia-detail p { margin: 0 0 10px; }
.help-body .ia-detail p:last-child { margin-bottom: 0; }
.help-body .ia-detail ul { margin: 0; padding-left: 22px; }
.help-body .ia-detail li { margin-bottom: 5px; font-size: 0.88rem; }
.help-body .ia-detail li:last-child { margin-bottom: 0; }

/* Tabla .ia-table — funciona DENTRO de .ia-detail (3 cols Campo/Desc/Ejemplo)
   y también FUERA (tablas comparativas en pestañas como diferencias-companias).
   Estilo limpio con zebra, hover y header tintado. */
.help-body .ia-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.86rem;
    margin: 12px 0;
    background: var(--theme-surface, #fff);
    border: 1px solid var(--theme-border);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .03);
}
.help-body .ia-table thead th {
    text-align: left;
    padding: 11px 14px;
    background: linear-gradient(180deg, var(--theme-surface-muted, #f1f5f9), var(--theme-surface, #fff));
    border-bottom: 2px solid var(--theme-border);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--theme-text-muted);
    font-weight: 700;
    position: sticky;
    top: 0;
    z-index: 1;
}
.help-body .ia-table thead th:first-child { padding-left: 16px; }
.help-body .ia-table tbody td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--theme-border);
    vertical-align: middle;
    line-height: 1.45;
    transition: background .12s;
}
.help-body .ia-table tbody tr:last-child td { border-bottom: 0; }
.help-body .ia-table tbody tr:nth-child(even) td {
    background: rgba(241, 245, 249, .35);
}
.help-body .ia-table tbody tr:hover td {
    background: var(--theme-brand-soft, rgba(99, 102, 241, .07));
}
.help-body .ia-table tbody td:first-child {
    font-weight: 600;
    color: var(--theme-text);
    padding-left: 16px;
}
.help-body .ia-table td.ia-ex {
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    color: var(--theme-text-muted);
    white-space: nowrap;
}

/* Variante: tabla dentro de un bloque expandido — sin top sticky ni shadow. */
.help-body .ia-detail .ia-table {
    margin: 0;
    box-shadow: none;
    font-size: 0.85rem;
}
.help-body .ia-detail .ia-table thead th { position: static; }
.help-body .ia-detail .ia-table tbody td:first-child {
    width: 24%;
    min-width: 130px;
}
.help-body .ia-detail .ia-table td.ia-ex {
    width: 32%;
    white-space: normal;
}

[data-theme="dark"] .help-body .ia-table {
    background: rgba(2, 6, 23, .50);
    box-shadow: 0 1px 2px rgba(0,0,0,.20);
}
[data-theme="dark"] .help-body .ia-table thead th {
    background: linear-gradient(180deg, rgba(15,23,42,.85), rgba(2,6,23,.50));
}
[data-theme="dark"] .help-body .ia-table tbody tr:nth-child(even) td {
    background: rgba(15, 23, 42, .35);
}
[data-theme="dark"] .help-body .ia-table tbody tr:hover td {
    background: rgba(99, 102, 241, .12);
}

@media (max-width: 540px) {
    .help-body .ia-table { font-size: 0.78rem; }
    .help-body .ia-table thead th,
    .help-body .ia-table tbody td { padding: 8px 10px; }
    .help-body .ia-table td.ia-ex { font-size: 0.72rem; }
}

/* Variantes por categoría (color de fondo en summary). */
.help-body details.ia-block.ia-header summary {
    background: var(--theme-brand-soft, rgba(37,99,235,.10));
}
.help-body details.ia-block.ia-header { border-color: var(--theme-brand); }
.help-body details.ia-block.ia-taxes summary {
    background: rgba(245,158,11,.10);
}
.help-body details.ia-block.ia-taxes { border-color: rgba(245,158,11,.40); }
.help-body details.ia-block.ia-total { border-color: #16a34a; }
.help-body details.ia-block.ia-total summary {
    background: linear-gradient(135deg, #16a34a, #22c55e);
    padding: 16px 18px;
}
.help-body details.ia-block.ia-total summary strong,
.help-body details.ia-block.ia-total summary small {
    color: #fff;
}
.help-body details.ia-block.ia-total summary strong { font-size: 1.05rem; letter-spacing: .04em; }
.help-body details.ia-block.ia-total summary::after { color: rgba(255,255,255,.85); }

[data-theme="dark"] .help-body details.ia-block { background: rgba(2,6,23,.55); }
[data-theme="dark"] .help-body details.ia-block.ia-header summary { background: rgba(37,99,235,.18); }
[data-theme="dark"] .help-body details.ia-block.ia-taxes summary { background: rgba(245,158,11,.18); }
[data-theme="dark"] .help-body .ia-detail { background: rgba(15,23,42,.55); }

@media (max-width: 540px) {
    .help-body .ia-row { grid-template-columns: 1fr; }
    .help-body .ia-icon { font-size: 1.3rem; width: 32px; }
}

/* ════════════════════════════════════════════════════════════════
   Visualizaciones reusables dentro de help articles:
   - .ia-timeline-24h   Tarifa de luz por hora (24 celdas coloreadas)
   - .ia-flow           Diagrama de pasos horizontal con flechas
   - .ia-chain          Fórmula concatenada (operadores entre cajas)
   Carmen mayo 2026 — usado en periodos-horarios, excedentes, descuentos.
   ════════════════════════════════════════════════════════════════ */

/* Timeline 24h: una fila de 24 celdas con color por periodo. */
.help-body .ia-timeline-24h {
    margin: 14px 0;
    border-radius: 8px;
    overflow: hidden;
    font-family: var(--font-heading);
}
.help-body .ia-timeline-24h-bar {
    display: grid;
    grid-template-columns: repeat(24, 1fr);
    gap: 1px;
}
.help-body .ia-timeline-24h-cell {
    padding: 10px 0 8px;
    font-size: 0.72rem;
    font-weight: 700;
    color: #fff;
    text-align: center;
    background: var(--theme-surface-muted);
}
.help-body .ia-timeline-24h-cell.p1 { background: #ef4444; }
.help-body .ia-timeline-24h-cell.p2 { background: #f59e0b; }
.help-body .ia-timeline-24h-cell.p3 { background: #22c55e; }
.help-body .ia-timeline-24h-cell.p4 { background: #84cc16; }
.help-body .ia-timeline-24h-cell.p5 { background: #06b6d4; }
.help-body .ia-timeline-24h-cell.p6 { background: #6366f1; }
.help-body .ia-timeline-24h-hours {
    display: grid;
    grid-template-columns: repeat(24, 1fr);
    margin-top: 4px;
    font-size: 0.62rem;
    color: var(--theme-text-muted);
    text-align: center;
    font-family: 'Courier New', monospace;
}
.help-body .ia-timeline-24h-hours span:nth-child(odd) { visibility: hidden; }
.help-body .ia-timeline-legend {
    display: flex; gap: 14px; flex-wrap: wrap;
    font-size: 0.78rem;
    margin: 8px 0 12px;
}
.help-body .ia-timeline-legend-item {
    display: inline-flex; align-items: center; gap: 6px;
    color: var(--theme-text);
}
.help-body .ia-timeline-legend-dot {
    width: 14px; height: 14px;
    border-radius: 3px;
    flex-shrink: 0;
}

/* Flow horizontal: pasos con flechas. */
.help-body .ia-flow {
    display: flex;
    align-items: stretch;
    gap: 8px;
    margin: 16px 0;
    flex-wrap: wrap;
}
.help-body .ia-flow-step {
    flex: 1 1 140px;
    min-width: 0;
    padding: 14px 14px;
    border: 1px solid var(--theme-border);
    border-radius: 12px;
    background: var(--theme-surface);
    text-align: center;
    display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.help-body .ia-flow-step-icon {
    font-size: 1.5rem;
}
.help-body .ia-flow-step-title {
    font-weight: 700;
    font-size: 0.86rem;
    color: var(--theme-text);
}
.help-body .ia-flow-step-sub {
    font-size: 0.74rem;
    color: var(--theme-text-muted);
    line-height: 1.35;
}
.help-body .ia-flow-arrow {
    align-self: center;
    color: var(--theme-brand);
    font-size: 1.1rem;
    flex: 0 0 auto;
}
.help-body .ia-flow-step.is-output {
    background: linear-gradient(135deg, rgba(34,197,94,.10), transparent);
    border-color: rgba(34,197,94,.30);
}
.help-body .ia-flow-step.is-cap {
    background: linear-gradient(135deg, rgba(245,158,11,.10), transparent);
    border-color: rgba(245,158,11,.30);
}
[data-theme="dark"] .help-body .ia-flow-step { background: rgba(2,6,23,.55); }

/* Diagrama bipartito: Compañías con parser → OptiMatch → Compañías con catálogo.
   Carmen mayo 2026 — usado en /ayuda/comparador-cobertura. */
.help-body .ia-bipartite {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 14px;
    margin: 18px 0;
    align-items: stretch;
}
.help-body .ia-bipartite-col {
    background: var(--theme-surface, #fff);
    border: 1px solid var(--theme-border);
    border-radius: 12px;
    padding: 14px 16px;
    display: flex; flex-direction: column;
    min-width: 0;
}
.help-body .ia-bipartite-col.is-input {
    border-color: rgba(59,130,246,.30);
    background: linear-gradient(135deg, rgba(59,130,246,.05), transparent 70%);
}
.help-body .ia-bipartite-col.is-output {
    border-color: rgba(34,197,94,.30);
    background: linear-gradient(135deg, rgba(34,197,94,.05), transparent 70%);
}
.help-body .ia-bipartite-head {
    font-family: var(--font-heading);
    font-size: 0.78rem;
    font-weight: 800;
    color: var(--theme-text);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 8px;
    display: flex; align-items: center; gap: 6px;
}
.help-body .ia-bipartite-sub {
    font-size: 0.74rem;
    color: var(--theme-text-muted);
    margin-bottom: 10px;
    line-height: 1.35;
}
.help-body .ia-bipartite-list {
    margin: 0; padding: 0;
    list-style: none;
    display: flex; flex-direction: column; gap: 4px;
    font-size: 0.84rem;
    flex: 1;
}
.help-body .ia-bipartite-list li {
    padding: 5px 9px;
    border-radius: 6px;
    background: rgba(241,245,249,.6);
    display: flex; align-items: center; gap: 7px;
    color: var(--theme-text);
}
.help-body .ia-bipartite-list li .dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.help-body .ia-bipartite-list li.is-strong {
    background: rgba(99,102,241,.10);
    font-weight: 600;
}
.help-body .ia-bipartite-list li.is-excluded {
    background: rgba(245,158,11,.10);
    border-left: 3px solid #f59e0b;
    padding-left: 9px;
}
.help-body .ia-bipartite-list li.is-excluded .excluded-flag {
    margin-left: auto;
    font-size: 0.7rem;
    color: #b45309;
    font-weight: 700;
    background: rgba(245,158,11,.18);
    padding: 2px 7px;
    border-radius: 4px;
    white-space: nowrap;
}
[data-theme="dark"] .help-body .ia-bipartite-list li.is-excluded {
    background: rgba(245,158,11,.16);
}
.help-body .ia-bipartite-bridge {
    display: flex; align-items: center; justify-content: center;
    flex-direction: column;
    color: var(--theme-brand, #6366f1);
    font-weight: 800;
    font-family: var(--font-heading);
    gap: 4px;
}
.help-body .ia-bipartite-bridge .arrow {
    font-size: 1.6rem;
    opacity: .7;
}
.help-body .ia-bipartite-bridge .label {
    font-size: 0.75rem;
    text-align: center;
    padding: 4px 8px;
    background: var(--theme-brand-soft, rgba(99,102,241,.10));
    border-radius: 6px;
    white-space: nowrap;
}
[data-theme="dark"] .help-body .ia-bipartite-col { background: rgba(2,6,23,.55); }
[data-theme="dark"] .help-body .ia-bipartite-list li { background: rgba(15,23,42,.55); }
[data-theme="dark"] .help-body .ia-bipartite-list li.is-strong { background: rgba(99,102,241,.18); }
@media (max-width: 640px) {
    .help-body .ia-bipartite {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    .help-body .ia-bipartite-bridge { flex-direction: row; padding: 4px 0; }
    .help-body .ia-bipartite-bridge .arrow { transform: rotate(90deg); }
}

/* Chain (fórmula encadenada con operadores entre cajas). */
.help-body .ia-chain {
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
    margin: 14px 0;
    padding: 14px;
    background: var(--theme-surface-muted, #f8fafc);
    border-radius: 12px;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
}
.help-body .ia-chain-box {
    padding: 6px 10px;
    border-radius: 6px;
    background: var(--theme-surface);
    border: 1px solid var(--theme-border);
    color: var(--theme-text);
    font-weight: 600;
}
.help-body .ia-chain-box.is-discount {
    background: rgba(34,197,94,.14);
    border-color: rgba(34,197,94,.40);
    color: #15803d;
}
.help-body .ia-chain-op {
    color: var(--theme-text-muted);
    font-weight: 700;
}
.help-body .ia-chain-result {
    margin-left: auto;
    padding: 6px 12px;
    background: linear-gradient(135deg, #16a34a, #22c55e);
    color: #fff;
    border-radius: 6px;
    font-weight: 700;
}
[data-theme="dark"] .help-body .ia-chain { background: rgba(15,23,42,.45); }
[data-theme="dark"] .help-body .ia-chain-box { background: rgba(2,6,23,.65); }

@media (max-width: 540px) {
    .help-body .ia-timeline-24h-cell { font-size: 0.6rem; padding: 6px 0 4px; }
    .help-body .ia-flow { gap: 4px; }
    .help-body .ia-flow-arrow { display: none; }
}

/* Help proposal document preview */
.help-body .proposal-doc-demo {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(240px, .9fr);
    gap: 16px;
    align-items: start;
    margin: 16px 0;
}
.help-body .proposal-doc-sheet {
    background: var(--theme-surface, #fff);
    border: 1px solid var(--theme-border);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 10px 28px rgba(15, 23, 42, .08);
}
.help-body .proposal-doc-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--theme-border);
}
.help-body .proposal-doc-logo {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    color: var(--theme-text);
}
.help-body .proposal-doc-logo-mark {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--theme-brand, #6366f1), #22c55e);
    box-shadow: 0 6px 16px rgba(99, 102, 241, .25);
}
.help-body .proposal-doc-meta {
    text-align: right;
    color: var(--theme-text-muted);
    font-size: .78rem;
    line-height: 1.45;
}
.help-body .proposal-doc-field {
    border: 1px dashed rgba(99, 102, 241, .38);
    background: var(--theme-brand-soft, rgba(99, 102, 241, .07));
    border-radius: 10px;
    padding: 10px 12px;
    margin-top: 12px;
}
.help-body .proposal-doc-field.is-winner {
    border-color: rgba(34, 197, 94, .55);
    background: rgba(34, 197, 94, .10);
}
.help-body .proposal-doc-field.is-warning {
    border-color: rgba(245, 158, 11, .55);
    background: rgba(245, 158, 11, .10);
}
.help-body .proposal-doc-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .72rem;
    text-transform: uppercase;
    font-weight: 800;
    color: var(--theme-text-muted);
    margin-bottom: 5px;
}
.help-body .proposal-doc-marker {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--theme-brand, #6366f1);
    color: #fff;
    font-size: .72rem;
    font-weight: 800;
    flex: 0 0 auto;
}
.help-body .proposal-doc-value {
    color: var(--theme-text);
    font-weight: 700;
    line-height: 1.35;
}
.help-body .proposal-doc-sub {
    color: var(--theme-text-muted);
    font-size: .8rem;
    line-height: 1.45;
    margin-top: 3px;
}
.help-body .proposal-doc-kpis {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 12px;
}
.help-body .proposal-doc-kpi {
    border: 1px solid var(--theme-border);
    border-radius: 10px;
    padding: 9px 10px;
    background: var(--theme-surface-muted, #f8fafc);
}
.help-body .proposal-doc-kpi strong {
    display: block;
    color: var(--theme-text);
    font-size: 1rem;
}
.help-body .proposal-doc-kpi span {
    display: block;
    color: var(--theme-text-muted);
    font-size: .72rem;
    margin-top: 2px;
}
.help-body .proposal-doc-mini-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
    font-size: .78rem;
}
.help-body .proposal-doc-mini-table th,
.help-body .proposal-doc-mini-table td {
    padding: 7px 6px;
    border-bottom: 1px solid var(--theme-border);
    text-align: left;
}
.help-body .proposal-doc-mini-table th {
    color: var(--theme-text-muted);
    font-weight: 700;
}
.help-body .proposal-field-map {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 8px;
}
.help-body .proposal-field-map li {
    display: grid;
    grid-template-columns: 28px 1fr;
    gap: 8px;
    align-items: start;
    padding: 9px 10px;
    border: 1px solid var(--theme-border);
    border-radius: 10px;
    background: var(--theme-surface, #fff);
}
.help-body .proposal-field-map strong {
    display: block;
    color: var(--theme-text);
    font-size: .86rem;
}
.help-body .proposal-field-map span {
    display: block;
    color: var(--theme-text-muted);
    font-size: .78rem;
    line-height: 1.4;
    margin-top: 2px;
}
[data-theme="dark"] .help-body .proposal-doc-sheet,
[data-theme="dark"] .help-body .proposal-field-map li {
    background: rgba(2, 6, 23, .55);
}
[data-theme="dark"] .help-body .proposal-doc-kpi {
    background: rgba(15, 23, 42, .55);
}
@media (max-width: 760px) {
    .help-body .proposal-doc-demo { grid-template-columns: 1fr; }
    .help-body .proposal-doc-kpis { grid-template-columns: 1fr; }
    .help-body .proposal-doc-header { flex-direction: column; }
    .help-body .proposal-doc-meta { text-align: left; }
}

/* 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;
}

/* Help mobile tweaks */
@media (max-width: 640px) {
    .help-article-list {
        grid-template-columns: 1fr;
        padding: 12px;
        gap: 10px;
    }
    .help-body {
        padding: 14px 16px;
        font-size: 0.9rem;
    }
    .help-body h4 { font-size: 1rem; margin-top: 18px; }
    .help-table { font-size: 0.82rem; }
    .help-table th, .help-table td { padding: 8px 10px; }

    /* Category pills: horizontal scroll when they overflow */
    .help-category-filters {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
        scrollbar-width: none;
    }
    .help-category-filters::-webkit-scrollbar { display: none; }
    .help-cat-pill { white-space: nowrap; flex-shrink: 0; }
}

/* Subtle pulse for "Contactar soporte" when a user said the article wasn't useful */
@keyframes btn-pulse-kf {
    0%, 100% { box-shadow: 0 0 0 0 rgba(99,102,241,0.5); }
    50% { box-shadow: 0 0 0 6px rgba(99,102,241,0); }
}
.btn-pulse { animation: btn-pulse-kf 1.6s ease-in-out 2; }

/* Floating contextual help button — lives bottom-left to avoid colliding with the FAB */
.contextual-help-fab {
    position: fixed;
    bottom: 24px;
    left: 24px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--theme-surface);
    color: var(--theme-brand);
    border: 1.5px solid var(--theme-brand);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 1rem;
    font-weight: 700;
    box-shadow: 0 3px 10px rgba(0,0,0,0.08);
    z-index: 90;
    transition: transform 0.15s, box-shadow 0.15s;
}
.contextual-help-fab:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(99,102,241,.25);
}
@media (max-width: 768px) {
    .contextual-help-fab {
        bottom: calc(76px + env(safe-area-inset-bottom, 0px));
        left: 16px;
        width: 40px;
        height: 40px;
    }
}

/* 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;
}
/* Tax ID type badges (NIF/CIF/NIE) — distinguen persona física vs jurídica
   en la lista de clientes. Mismo formato que score-badge para consistencia. */
.tax-id-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 20px;
    padding: 0 7px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .04em;
    margin-left: 6px;
    vertical-align: middle;
    text-transform: uppercase;
}
.tax-id-cif {
    background: rgba(59, 130, 246, .15);
    color: #2563eb;
    border: 1px solid rgba(59, 130, 246, .3);
}
.tax-id-nif {
    background: rgba(34, 197, 94, .15);
    color: #16a34a;
    border: 1px solid rgba(34, 197, 94, .3);
}
.tax-id-nie {
    background: rgba(139, 92, 246, .15);
    color: #7c3aed;
    border: 1px solid rgba(139, 92, 246, .3);
}
.tax-id-otro {
    background: var(--theme-surface-muted);
    color: var(--theme-text-muted);
    border: 1px solid var(--theme-border);
}
/* CRM Modelo A — casuística del cliente. Mismo formato base que tax-id-*. */
.ctype-particular {
    background: rgba(34, 197, 94, .15);
    color: #16a34a;
    border: 1px solid rgba(34, 197, 94, .3);
}
.ctype-autonomo {
    background: rgba(245, 158, 11, .15);
    color: #d97706;
    border: 1px solid rgba(245, 158, 11, .3);
}
.ctype-empresa {
    background: rgba(59, 130, 246, .15);
    color: #2563eb;
    border: 1px solid rgba(59, 130, 246, .3);
}
.ctype-comunidad_otros {
    background: rgba(139, 92, 246, .15);
    color: #7c3aed;
    border: 1px solid rgba(139, 92, 246, .3);
}
.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;
}

/* Botones de canal externo (WhatsApp / Telegram / SMS / Llamada) en la
   ficha del cliente. Tinte por marca para distinguirse del botón
   genérico, sin romper la rejilla de cd-action-buttons.
   El icono lleva su color de marca; el resto del botón mantiene el
   chrome del btn-opt-secondary. */
.cd-btn-whatsapp i { color: #25D366; }
.cd-btn-telegram i { color: #229ED9; }
.cd-btn-sms i      { color: #6366F1; }
.cd-btn-call i     { color: #f59e0b; }
.cd-btn-whatsapp:hover { border-color: #25D366; }
.cd-btn-telegram:hover { border-color: #229ED9; }
.cd-btn-sms:hover      { border-color: #6366F1; }
.cd-btn-call:hover     { border-color: #f59e0b; }

/* Badge de "último contacto" en cards del CRM. 3 tonos según frescura:
   verde <30d, ámbar 30-60d, rojo >=60d o nunca. Aparece junto al
   consultor asignado en .portfolio-meta. */
.contact-badge {
    display: inline-block;
    font-size: 10.5px;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 8px;
    vertical-align: middle;
    letter-spacing: 0.2px;
    white-space: nowrap;
}
.contact-fresh { background: rgba(34,197,94,.12); color: #15803d; }
.contact-warm  { background: rgba(245,158,11,.14); color: #b45309; }
.contact-stale { background: rgba(239,68,68,.12); color: #b91c1c; }

/* Badge de completitud de ficha del cliente. Verde >=70 (todo OK),
   ámbar 40-69 (faltan algunos), rojo <40 (ficha mínima). El tooltip
   detalla qué campos faltan exactamente. */
.completeness-badge { display:inline-flex; align-items:center; gap:4px; }
.completeness-good   { background: rgba(34,197,94,.12); color: #15803d; }
.completeness-medium { background: rgba(245,158,11,.14); color: #b45309; }
.completeness-low    { background: rgba(239,68,68,.12); color: #b91c1c; }

/* ═══════════════════════════════════════════════════════════════
   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;
}

/* ═══════════════════════════════════════════════════════════════
   Home CRM — Panel "Qué hago hoy"
   ═══════════════════════════════════════════════════════════════ */
.today-panel {
    background: var(--theme-card-bg);
    border: 1px solid var(--theme-surface-border);
    border-radius: 16px;
    padding: 18px 20px;
    margin-bottom: 18px;
    box-shadow: var(--card-shadow);
}
.today-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.today-panel-header h3 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--theme-title);
    margin: 0;
}
.today-panel-header p {
    margin: 4px 0 0;
    font-size: 0.78rem;
    color: var(--theme-text-muted);
}
.today-panel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 12px;
}
.today-card {
    background: var(--theme-surface);
    border: 1px solid var(--theme-surface-border);
    border-radius: 14px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.today-card-savings   { border-top: 3px solid #16a34a; }
.today-card-expiring  { border-top: 3px solid #f59e0b; }
.today-card-tasks     { border-top: 3px solid var(--theme-brand); }
.today-card-proposals { border-top: 3px solid #8b5cf6; }
.today-card-priority  { border-top: 3px solid #ef4444; }
.today-card-head {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--theme-text-muted);
}
.today-card-head i { font-size: 0.95rem; color: var(--theme-brand); }
.today-card-savings   .today-card-head i { color: #16a34a; }
.today-card-expiring  .today-card-head i { color: #f59e0b; }
.today-card-proposals .today-card-head i { color: #8b5cf6; }
.today-card-priority  .today-card-head i { color: #ef4444; }
.today-card-count {
    margin-left: auto;
    background: var(--theme-surface-muted);
    color: var(--theme-text);
    font-size: 0.72rem;
    padding: 2px 10px;
    border-radius: 999px;
    font-weight: 700;
}
.today-card-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.today-card-list li { margin: 0; }
.today-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--theme-text);
    transition: background .15s ease;
}
.today-row:hover { background: var(--theme-brand-soft); }
.today-row-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.today-row-name {
    font-weight: 600;
    font-size: 0.86rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.today-row-sub {
    font-size: 0.72rem;
    color: var(--theme-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.today-row-badge {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 999px;
    white-space: nowrap;
}
.today-row-badge.savings {
    background: rgba(22, 163, 74, 0.15);
    color: #16a34a;
}
.today-row-badge.expiring {
    background: rgba(245, 158, 11, 0.15);
    color: #d97706;
}
.today-row-badge.overdue {
    background: rgba(239, 68, 68, 0.15);
    color: #dc2626;
}
.today-row-badge.priority {
    background: rgba(239, 68, 68, 0.14);
    color: #dc2626;
}
.today-card-empty {
    font-size: 0.78rem;
    color: var(--theme-text-muted);
    font-style: italic;
    padding: 12px 4px;
    text-align: center;
}

/* ═══════════════════════════════════════════════════════════════
   Customer detail — Feed cronológico unificado
   ═══════════════════════════════════════════════════════════════ */
.cd-activity-feed {
    max-height: 480px;
    overflow-y: auto;
    padding: 6px 2px;
}
.cd-feed-list {
    list-style: none;
    margin: 0;
    padding: 0;
    position: relative;
}
.cd-feed-list::before {
    content: "";
    position: absolute;
    left: 17px;
    top: 10px;
    bottom: 10px;
    width: 2px;
    background: var(--theme-surface-border);
}
.cd-feed-item {
    position: relative;
    display: flex;
    gap: 14px;
    padding: 10px 0 10px 0;
    align-items: flex-start;
}
.cd-feed-bullet {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 14px;
    position: relative;
    z-index: 1;
    box-shadow: 0 2px 6px rgba(0,0,0,.08);
}
.cd-feed-body {
    flex: 1;
    min-width: 0;
}
.cd-feed-row {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
}
.cd-feed-title {
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--theme-text);
    text-decoration: none;
}
a.cd-feed-title:hover { color: var(--theme-brand); text-decoration: underline; }
.cd-feed-when {
    font-size: 0.72rem;
    color: var(--theme-text-muted);
    margin-left: auto;
    white-space: nowrap;
}
.cd-feed-sub {
    font-size: 0.78rem;
    color: var(--theme-text-muted);
    margin-top: 2px;
    line-height: 1.4;
}
.cd-feed-author {
    font-size: 0.7rem;
    color: var(--theme-text-muted);
    margin-top: 2px;
    opacity: .85;
}

/* ════════════════════════════════════════════════════════════
   APP DIALOG (showAlert / showConfirm)
   Reemplaza alert()/confirm() nativos por un modal centrado
   coherente con el resto de la UI. JS en static/js/dialog.js.
   ════════════════════════════════════════════════════════════ */
.app-dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 22, 0.72);
  backdrop-filter: blur(3px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.16s ease;
}
.app-dialog-overlay--show { opacity: 1; }
.app-dialog-overlay--out { opacity: 0; }
.app-dialog {
  background: var(--theme-surface, #fff);
  color: var(--theme-text, #1f2937);
  border: 1px solid var(--theme-surface-border, rgba(0,0,0,.08));
  border-radius: 14px;
  width: 100%;
  max-width: 480px;
  min-width: 280px;
  box-shadow: 0 24px 60px rgba(0,0,0,.45);
  transform: translateY(8px) scale(0.98);
  transition: transform 0.18s ease;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.app-dialog-overlay--show .app-dialog { transform: translateY(0) scale(1); }
.app-dialog-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--theme-surface-border, rgba(0,0,0,.08));
}
.app-dialog-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  font-size: 1.05rem;
  flex-shrink: 0;
}
.app-dialog-overlay--info .app-dialog-icon    { background: rgba(99,102,241,.18); color: #818cf8; }
.app-dialog-overlay--warning .app-dialog-icon { background: rgba(245,158,11,.20); color: #fbbf24; }
.app-dialog-overlay--danger .app-dialog-icon  { background: rgba(239,68,68,.20);  color: #f87171; }
.app-dialog-overlay--success .app-dialog-icon { background: rgba(34,197,94,.20);  color: #4ade80; }
.app-dialog-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.3;
  flex: 1;
  color: var(--theme-text, #1f2937);
}
.app-dialog-close {
  background: transparent;
  border: 1px solid transparent;
  color: var(--theme-text-muted, #6b7280);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  flex-shrink: 0;
}
.app-dialog-close:hover {
  background: rgba(239,68,68,.12);
  border-color: rgba(239,68,68,.30);
  color: #ef4444;
}
.app-dialog-body {
  padding: 18px 20px 20px;
  font-size: 0.94rem;
  line-height: 1.55;
  color: var(--theme-text, #1f2937);
  max-height: 56vh;
  overflow-y: auto;
  white-space: normal;
}
.app-dialog-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px 18px;
  border-top: 1px solid var(--theme-surface-border, rgba(0,0,0,.06));
  background: rgba(0,0,0,.04);
  flex-wrap: wrap;
}
.app-dialog-btn {
  border: 1.5px solid transparent;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform .08s ease, background .12s ease, border-color .12s ease, box-shadow .12s ease;
  font-family: inherit;
  min-width: 100px;
}
.app-dialog-btn:active { transform: translateY(1px); }
.app-dialog-btn:focus-visible {
  outline: 2px solid var(--theme-brand, #6366f1);
  outline-offset: 2px;
}
.app-dialog-btn--ghost {
  background: var(--theme-surface-muted, rgba(255,255,255,.04));
  border-color: var(--theme-surface-border, rgba(255,255,255,.18));
  color: var(--theme-text, #e5e7eb);
}
.app-dialog-btn--ghost:hover {
  background: var(--theme-surface, rgba(255,255,255,.08));
  border-color: var(--theme-text-muted, rgba(255,255,255,.30));
}
.app-dialog-btn--info,
.app-dialog-btn--success {
  background: linear-gradient(135deg, var(--theme-brand, #6366f1), #818cf8);
  color: #fff;
  box-shadow: 0 2px 8px rgba(99,102,241,.30);
}
.app-dialog-btn--info:hover,
.app-dialog-btn--success:hover {
  filter: brightness(1.08);
  box-shadow: 0 4px 14px rgba(99,102,241,.45);
}
.app-dialog-btn--warning {
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
  color: #fff;
  box-shadow: 0 2px 8px rgba(245,158,11,.30);
}
.app-dialog-btn--warning:hover {
  filter: brightness(1.05);
  box-shadow: 0 4px 14px rgba(245,158,11,.45);
}
.app-dialog-btn--danger {
  background: linear-gradient(135deg, #ef4444, #f87171);
  color: #fff;
  box-shadow: 0 2px 8px rgba(239,68,68,.30);
}
.app-dialog-btn--danger:hover {
  filter: brightness(1.05);
  box-shadow: 0 4px 14px rgba(239,68,68,.45);
}

@media (max-width: 480px) {
  .app-dialog { max-width: 100%; }
  .app-dialog-head { padding: 14px 14px; }
  .app-dialog-body { padding: 14px 14px 16px; font-size: 0.88rem; }
  .app-dialog-foot { padding: 10px 14px 14px; }
  .app-dialog-btn { padding: 9px 14px; font-size: 0.85rem; }
}

/* ─── Pestañas (Desglose / Ranking / Visual) ───
   Compartido entre la pantalla de comparativa (pricing_compare_result.html)
   y el simulador (whatif.html). Si añades una tercera vista con pestañas,
   reutiliza estas clases en lugar de duplicar el CSS. */
.pr-results-tabs { padding: 0; }
.pr-tabs-nav {
  display: flex; gap: 4px; flex-wrap: wrap;
  padding: 10px 16px 0;
  border-bottom: 1px solid var(--theme-border, #e5e7eb);
  background: var(--theme-bg-subtle, #fafafa);
  border-radius: 12px 12px 0 0;
}
.pr-tab {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; border: 0;
  padding: 10px 14px; cursor: pointer;
  font-family: var(--font-heading); font-size: 0.85rem; font-weight: 600;
  color: var(--theme-text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s, border-color .15s, background .15s;
}
.pr-tab i { color: var(--theme-text-muted); }
.pr-tab:hover:not([disabled]) {
  color: var(--theme-title);
  background: rgba(0,0,0,.025);
}
.pr-tab.is-active {
  color: var(--theme-brand);
  border-bottom-color: var(--theme-brand);
  background: var(--theme-bg, #fff);
}
.pr-tab.is-active i { color: var(--theme-brand); }
.pr-tab[disabled] { opacity: .4; cursor: not-allowed; }
.pr-tab-pane { display: none; padding: 18px; }
.pr-tab-pane.is-active { display: block; }
@media (max-width: 600px) {
  .pr-tabs-nav { padding: 6px 8px 0; }
  .pr-tab { padding: 8px 10px; font-size: 0.78rem; }
  .pr-tab-pane { padding: 14px 12px; }
}

/* ─── Tablas Ranking/Detail/Bars (compartidas comparativa + simulador) ───
   Movidas desde pricing_compare_result.html para que el simulador
   (whatif.html) pueda reusar el mismo look-and-feel. Si modificas algo
   aquí, ambas vistas se actualizan a la vez. */
.pr-table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.pr-table-scroll > table { min-width: max-content; }

.pr-ranking { width: 100%; border-collapse: collapse; }
.pr-ranking th {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.5px;
  font-weight: 700; color: var(--theme-text-muted); padding: 10px 10px;
  border-bottom: 2px solid var(--theme-surface-border);
  background: var(--theme-surface);
  text-align: left;
}
.pr-th-center { text-align: center; }
.pr-th-right { text-align: right; }
.pr-ranking td {
  padding: 10px 10px; border-bottom: 1px solid var(--theme-surface-border);
  font-size: 0.85rem; white-space: nowrap;
}
.pr-rank { text-align: center; font-weight: 800; color: var(--theme-text-muted); font-size: 0.82rem; }
.pr-plan-name { font-weight: 500; max-width: 300px; overflow: hidden; text-overflow: ellipsis; }
.pr-mono { font-family: 'SF Mono', 'Consolas', monospace; text-align: right; font-size: 0.82rem; }
.pr-total { font-weight: 700; }
.pr-annual { color: var(--theme-text-muted); font-size: 0.78rem; }
.pr-diff-best { color: #16a34a; font-weight: 700; }
.pr-diff-worse { color: #dc2626; font-size: 0.8rem; }
.pr-row-best {
  background: linear-gradient(90deg, rgba(34,197,94,.06), transparent) !important;
}
.pr-row-best .pr-rank { color: #16a34a; font-size: 1rem; }
.pr-row-current {
  background: var(--theme-brand-soft, rgba(99,102,241,.06)) !important;
}
.ranking-row:hover { background: var(--theme-brand-soft); }
.ranking-row.hidden { display: none; }

/* Bars */
.pr-bars { display: flex; flex-direction: column; gap: 8px; }
.pr-bar-row { display: flex; align-items: center; gap: 10px; }
.pr-bar-row.hidden { display: none; }
.pr-bar-label {
  min-width: 220px; display: flex; align-items: center; gap: 8px;
  font-size: 0.82rem; color: var(--theme-text);
}
.pr-bar-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pr-bar-track {
  flex: 1; background: var(--theme-surface-muted);
  border-radius: 8px; height: 30px; overflow: hidden;
  border: 1px solid var(--theme-surface-border);
}
.pr-bar-fill {
  height: 100%; border-radius: 7px; display: flex; align-items: center;
  padding: 0 12px; min-width: fit-content; transition: width .6s ease;
}
.pr-bar-value { font-size: 0.75rem; font-weight: 700; color: #fff; white-space: nowrap; }
.pr-bar-best { box-shadow: 0 0 0 2px rgba(0,0,0,.1); }

/* Detail table multi-column */
.pr-detail { width: 100%; border-collapse: collapse; }
.pr-detail th, .pr-detail td {
  padding: 7px 8px; font-size: 0.82rem; white-space: nowrap;
  border-bottom: 1px solid var(--theme-surface-border);
}
.pr-detail-concept { min-width: 180px; font-weight: 500; }
.pr-detail-plan { display: block; font-size: 0.72rem; font-weight: 400; margin-top: 3px; color: var(--theme-text-muted); }
.pr-detail-plan-head { min-width: 180px; text-align: center; padding: 12px 8px; }
.pr-detail-current-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  background: #fef3c7;
  color: #92400e;
  margin-bottom: 4px;
  letter-spacing: 0.3px;
}
.pr-detail-best-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  background: rgba(34,197,94,.18);
  color: #16a34a;
  margin-bottom: 4px;
  letter-spacing: 0.3px;
}
.pr-detail-company-name {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 0.78rem;
  font-weight: 700;
  background: var(--theme-brand-soft);
  color: var(--theme-brand);
}
.pr-detail-picker {
  position: relative;
  width: min(100%, 310px);
  margin: 8px auto 0;
}
.pr-detail-plan-select-native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  pointer-events: none !important;
}
.pr-detail-picker-button {
  width: 100%;
  min-height: 42px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid var(--theme-surface-border);
  border-radius: 10px;
  background: var(--theme-surface);
  color: var(--theme-text);
  cursor: pointer;
  text-align: left;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.02);
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease, transform .15s ease;
}
.pr-detail-picker-button:hover,
.pr-detail-picker.open .pr-detail-picker-button {
  border-color: var(--theme-brand);
  background: var(--theme-brand-soft);
  box-shadow: 0 8px 22px rgba(99, 102, 241, .14);
}
.pr-detail-picker-button:focus-visible {
  outline: 2px solid var(--theme-brand);
  outline-offset: 2px;
}
.pr-detail-picker-icon {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(99, 102, 241, .12);
  color: var(--theme-brand);
  font-size: .72rem;
}
.pr-detail-picker-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.pr-detail-picker-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .74rem;
  font-weight: 800;
  color: var(--theme-title);
  line-height: 1.15;
}
.pr-detail-picker-sub {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  font-size: .66rem;
  color: var(--theme-text-muted);
}
.pr-detail-picker-price {
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: .72rem;
  font-weight: 900;
  color: #16a34a;
  white-space: nowrap;
}
.pr-detail-picker-caret {
  color: var(--theme-text-muted);
  font-size: .72rem;
  transition: transform .15s ease;
}
.pr-detail-picker.open .pr-detail-picker-caret { transform: rotate(180deg); }
.pr-detail-picker-menu {
  position: fixed;
  z-index: 5000;
  display: none;
  flex-direction: column;
  max-height: min(460px, calc(100vh - 24px));
  overflow: hidden;
  border: 1px solid var(--theme-surface-border);
  border-radius: 14px;
  background: var(--theme-card-bg, var(--theme-surface));
  color: var(--theme-text);
  box-shadow: 0 22px 60px rgba(15, 23, 42, .22);
}
.pr-detail-picker-menu.open { display: flex; }
.pr-detail-picker-search {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border-bottom: 1px solid var(--theme-surface-border);
  background: var(--theme-card-bg, var(--theme-surface));
}
.pr-detail-picker-search i {
  color: var(--theme-text-muted);
  font-size: .78rem;
}
.pr-detail-picker-search input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--theme-text);
  font-size: .82rem;
}
.pr-detail-picker-list {
  overflow: auto;
  padding: 6px;
}
.pr-detail-picker-group {
  padding: 6px 4px 4px;
}
.pr-detail-picker-group[hidden],
.pr-detail-picker-option[hidden] {
  display: none !important;
}
.pr-detail-picker-group-label {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 8px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--theme-brand-soft) 70%, var(--theme-card-bg, #fff));
  color: var(--theme-brand);
  font-size: .68rem;
  font-weight: 900;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.pr-detail-picker-count {
  margin-left: auto;
  color: var(--theme-text-muted);
  font-size: .64rem;
}
.pr-detail-picker-option {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  margin-top: 5px;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--theme-text);
  cursor: pointer;
  text-align: left;
}
.pr-detail-picker-option:hover,
.pr-detail-picker-option:focus-visible {
  outline: none;
  border-color: var(--theme-brand);
  background: var(--theme-brand-soft);
}
.pr-detail-picker-option.is-selected {
  border-color: rgba(99, 102, 241, .35);
  background: linear-gradient(90deg, rgba(99, 102, 241, .16), rgba(99, 102, 241, .06));
}
.pr-detail-picker-option-name {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .82rem;
  font-weight: 750;
  color: var(--theme-title);
}
.pr-detail-picker-option-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 5px;
}
.pr-detail-picker-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(100, 116, 139, .10);
  color: var(--theme-text-muted);
  font-size: .62rem;
  font-weight: 800;
  line-height: 1.2;
}
.pr-detail-picker-chip.is-current {
  background: #fef3c7;
  color: #92400e;
}
.pr-detail-picker-chip.is-service {
  background: rgba(99, 102, 241, .13);
  color: var(--theme-brand);
}
.pr-detail-picker-chip.is-solar {
  background: rgba(245, 158, 11, .16);
  color: #b45309;
}
.pr-detail-picker-option-total {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  white-space: nowrap;
}
.pr-detail-picker-button > .pr-detail-picker-option-total {
  flex-direction: row;
  align-items: center;
  gap: 7px;
}
.pr-detail-picker-option-total strong {
  font-family: 'SF Mono', 'Consolas', monospace;
  color: #16a34a;
  font-size: .84rem;
}
.pr-detail-picker-option-total small {
  color: var(--theme-text-muted);
  font-size: .62rem;
  font-weight: 700;
}
.pr-detail-picker-empty {
  padding: 16px 12px;
  color: var(--theme-text-muted);
  font-size: .82rem;
  text-align: center;
}
@media (max-width: 640px) {
  .pr-detail-picker { width: min(100%, 260px); }
  .pr-detail-picker-menu {
    left: 8px !important;
    right: 8px !important;
    width: auto !important;
  }
}
.pr-detail-subhead th {
  font-size: 0.62rem; text-transform: uppercase; letter-spacing: .5px;
  font-weight: 700; color: var(--theme-text-muted);
  background: var(--theme-surface-muted);
  text-align: right;
}
.pr-detail-subhead th:first-child { text-align: left; }
.pr-detail-label { font-weight: 500; color: var(--theme-text); }
.pr-mono-sm { font-family: 'SF Mono', 'Consolas', monospace; text-align: right; font-size: 0.78rem; }
.pr-na { color: var(--theme-text-muted); opacity: 0.75; }
.pr-detail-section td {
  background: var(--theme-brand-soft); font-weight: 700; font-size: 0.78rem;
  padding: 8px 10px; color: var(--theme-brand); letter-spacing: .5px;
}
.pr-detail-section i { margin-right: 6px; }
.pr-detail-subtotal td { background: var(--theme-surface-muted); font-size: 0.82rem; }
.pr-detail-grand-total td {
  background: linear-gradient(90deg, var(--theme-brand-soft), transparent);
  font-size: 1rem; padding: 12px 8px; font-weight: 800;
}
.pr-detail-annual td {
  background: rgba(34,197,94,.06); font-size: 0.88rem; padding: 8px 8px;
  color: #16a34a; font-weight: 700;
}

/* Recommendation badges */
.pr-rec-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 6px;
  font-size: 0.65rem; font-weight: 700; letter-spacing: .2px;
  margin: 1px 2px; white-space: nowrap;
}
.pr-rec-cheapest { background: rgba(34,197,94,.12); color: #16a34a; }
.pr-rec-value { background: rgba(59,130,246,.12); color: #2563eb; }

:root[data-theme="dark"] .pr-bar-fill,
body[data-theme="dark"] .pr-bar-fill { opacity: .9; }

/* ========================================================
   Mobile input zoom guard — CLAUDE.md exige font-size >= 16px
   en inputs móvil para evitar el auto-zoom de iOS al enfocar.
   Estos selectores antes usaban 0.9rem / 13px y disparaban el
   zoom en el wizard manual y en la tabla de tarifas.
   ======================================================== */
@media (max-width: 768px) {
    .block-grid-input,
    .manual-field input,
    .manual-field select,
    .manual-field textarea,
    .tariff-prices-table input,
    .tariff-prices-table select,
    input[type="text"].compact,
    input[type="number"].compact,
    input[type="email"].compact {
        font-size: 16px !important;
    }
}

/* ── Onboarding tour (M-10) ─────────────────────────────────────── */
.tour-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    z-index: 9999;
    overflow: hidden;
}
.tour-cutout {
    position: absolute;
    border-radius: 10px;
    box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.55);
    pointer-events: none;
    transition: all 0.25s ease-out;
}
.tour-panel {
    position: absolute;
    background: var(--theme-surface, #fff);
    color: var(--theme-text, #1e293b);
    border: 1px solid var(--theme-surface-border, #e2e8f0);
    border-radius: 12px;
    padding: 18px 20px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.25);
    max-width: 360px;
    min-width: 260px;
    z-index: 10000;
    transition: top 0.2s ease-out, left 0.2s ease-out;
}
.tour-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}
.tour-step-counter {
    font-size: 0.74rem;
    color: var(--theme-text-muted, #64748b);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}
.tour-close {
    background: transparent;
    border: 0;
    color: var(--theme-text-muted, #64748b);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}
.tour-close:hover { color: var(--theme-text); }
.tour-title {
    margin: 4px 0 8px;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--theme-brand, #6366f1);
}
.tour-body {
    font-size: 0.88rem;
    line-height: 1.5;
    color: var(--theme-text, #334155);
}
.tour-nav {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 14px;
}
.tour-btn {
    border: 0;
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, transform 0.05s;
}
.tour-btn-primary {
    background: var(--theme-brand, #6366f1);
    color: #fff;
}
.tour-btn-primary:hover { filter: brightness(1.1); }
.tour-btn-secondary {
    background: var(--theme-surface-alt, #f1f5f9);
    color: var(--theme-text, #334155);
}
.tour-btn-secondary:hover { background: var(--theme-surface-border, #e2e8f0); }
.tour-target-highlight {
    position: relative;
    z-index: 9998;
}
@media (max-width: 600px) {
    .tour-panel {
        max-width: calc(100vw - 32px);
        left: 16px !important;
        right: 16px;
    }
}
