/* ============================================================
   RADAR IA — PREMIUM COHESIVE DARK THEME (Design System v3)
   Unifica el Escritorio Principal e Inteligencia de Monitoreo
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Archivo:wght@500;700;800;900&family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans:wght@400;500;600;700&display=swap');

:root {
    /* Paleta oscura semántica — alineada al design system del CRM (Cemprende IA) */
    --bg:           #0B0B0D;
    --surface:      #18181C;
    --surface-2:    #1F2024;
    --surface-3:    #232327;

    /* Bordes y textos */
    --border:       #2A2A30;
    --border-md:    #2A2A30;
    --border-muted: #1F2024;
    --text:         #EDEDEF;
    --text-primary: #EDEDEF;
    --text-secondary: #9A9AA2;
    --text-tertiary: #6E6E76;
    --text-muted:   #9A9AA2;
    --text-dim:     #6E6E76;

    /* Colores acento y semánticos */
    --accent:       #f97316;
    --accent-dark:  #ea580c;
    color-scheme: dark;

    --c-validado:   #2EA043;
    --c-validar:    #D29922;
    --c-pendiente:  #388BFD;
    --c-ignorado:   #DA3633;
    --c-analisis:   #A371F7;
    --c-gemini:     #7C3AED;
    --c-sintesis:   #0EA5E9;

    /* Fuentes y canales */
    --c-wa:         #25D366;
    --c-mail:       #F59E0B;
    --c-serper:     #3B82F6;
    --c-maps:       #10B981;
    --c-gemini-src: #8B5CF6;

    /* Sizing y transiciones */
    --radius:    4px;
    --radius-sm: 4px;
    --radius-md: 10px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --shadow:    0 2px 8px rgba(0,0,0,.4);
    --shadow-lg: 0 8px 24px rgba(0,0,0,.5);
    --transition: 180ms ease;
    
    /* Compatibilidad heredada */
    --green: #2EA043;
    --green-bg: rgba(46, 160, 67, 0.15);
    --green-text: #58A6FF;
    --amber: #D29922;
    --amber-bg: rgba(210, 153, 34, 0.15);
    --amber-text: #E3B341;
    --purple: #A371F7;
    --purple-bg: rgba(163, 113, 247, 0.15);
    --purple-text: #DDD6FE;
    --card-bg: #18181C;

    --header-h: 56px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

/* Tema claro — mismos nombres de variable, mismos valores que crm-theme.css
   del CRM (Cemprende IA). Los colores de estado/canal (--c-*, --green/--amber/
   --purple) se dejan iguales en los dos temas a propósito: son significado
   (validado/pendiente/ignorado, marca de WhatsApp/Gmail/Gemini), no identidad
   visual, y ya tienen buen contraste sobre fondo claro u oscuro. */
:root[data-theme="light"] {
    --bg:           #F5F3EF;
    --surface:      #FDFCFA;
    --surface-2:    #F0EEE8;
    --surface-3:    #E7E4DC;

    --border:       #E7E4DC;
    --border-md:    #E7E4DC;
    --border-muted: #F0EEE8;
    --text:         #33312C;
    --text-primary: #33312C;
    --text-secondary: #767268;
    --text-tertiary: #9A968A;
    --text-muted:   #767268;
    --text-dim:     #9A968A;

    --card-bg: #FDFCFA;
    color-scheme: light;
}

/* ── BASE & GENERAL ────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* Alto de header responsive, igual que el CRM (h-14 -> md:h-16) */
@media (min-width: 768px) {
    :root { --header-h: 64px; }
}

body.radar-body {
    font-family: 'IBM Plex Sans', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ── HEADER STICKY (index & monitoreo) ─────────────────── */
.radar-topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: color-mix(in srgb, var(--bg) 95%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(249, 115, 22, 0.2);
    padding: 0 24px;
    min-height: var(--header-h);
}

.radar-topbar-inner {
    width: 100%;
    max-width: 1800px;
    margin: 0 auto;
    height: 100%;
    min-height: var(--header-h);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: nowrap;
}

.radar-header {
    display: flex;
    align-items: center;
    gap: 20px;
    flex: 1 1 auto;
    min-width: 0;
    height: var(--header-h);
    padding: 0;
    margin: 0;
    border: none;
    background: transparent;
}

/* Nav principal (Dashboard / Monitoreo) — igual al header del CRM */
.radar-mainnav {
    display: flex;
    align-items: center;
    gap: 24px;
    margin-left: auto;
}

.radar-mainnav a {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    text-decoration: none;
    padding-bottom: 4px;
    border-bottom: 2px solid transparent;
    transition: var(--transition);
}

.radar-mainnav a:hover {
    color: var(--text);
}

.radar-mainnav a.is-active {
    color: var(--accent);
    font-weight: 600;
    border-bottom-color: var(--accent);
}

@media (max-width: 768px) {
    .radar-mainnav {
        display: none;
    }
}

.radar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'Archivo', sans-serif;
    font-weight: 900;
    font-size: 18px;
    color: var(--text);
    text-decoration: none;
    flex-shrink: 0;
    letter-spacing: -0.025em;
}
@media (min-width: 640px) {
    .radar-logo { font-size: 24px; }
}
.radar-logo-accent {
    color: var(--accent);
}
.radar-logo-sub {
    color: var(--text-muted);
    font-family: 'IBM Plex Sans', sans-serif;
    font-weight: 600;
    font-size: 16px;
    margin-left: 4px;
}
@media (min-width: 640px) {
    .radar-logo-sub { font-size: 18px; }
}

.radar-logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--c-gemini) 0%, var(--c-pendiente) 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    animation: radar-pulse 3s ease-in-out infinite;
}

@keyframes radar-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(124, 58, 237, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(124, 58, 237, 0); }
}

.radar-live-badge {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 600;
    color: var(--c-validado);
    text-transform: uppercase;
    letter-spacing: .06em;
}

.radar-live-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--c-validado);
    animation: blink 2s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: .2; }
}

.radar-nav {
    display: none;
    gap: 6px;
    margin-left: auto;
    align-items: center;
}

/* ── BOTONES DE ACCIÓN ─────────────────────────────────── */
.btn-canal {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: var(--radius);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all var(--transition);
    white-space: nowrap;
    text-decoration: none;
}

.btn-canal:focus-visible { outline: 2px solid var(--c-pendiente); outline-offset: 2px; }

.btn-canal-web      { background: rgba(59, 130, 246, 0.12); border-color: rgba(59, 130, 246, 0.3); color: #93C5FD; }
.btn-canal-mail     { background: rgba(245, 158, 11, 0.12); border-color: rgba(245, 158, 11, 0.3); color: #FCD34D; }
.btn-canal-wa       { background: rgba(37, 211, 102, 0.12); border-color: rgba(37, 211, 102, 0.3); color: #86EFAC; }
.btn-canal-analisis { background: rgba(168, 139, 250, 0.12); border-color: rgba(168, 139, 250, 0.3); color: #C4B5FD; }
.btn-canal-gemini   { background: rgba(124, 58, 237, 0.15); border-color: rgba(124, 58, 237, 0.4); color: #DDD6FE; }

.btn-canal:hover { filter: brightness(1.15); transform: translateY(-1px); }
.btn-canal:active { transform: translateY(0); filter: brightness(.95); }
.btn-canal.running { animation: btn-glow 1.5s ease-in-out infinite; }

@keyframes btn-glow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(56, 139, 253, 0.3); }
    50% { box-shadow: 0 0 12px 3px rgba(56, 139, 253, 0.25); }
}

.btn-canal .btn-spinner {
    width: 12px;
    height: 12px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── PESTAÑAS (monitoreo) ──────────────────────────────── */
.radar-tabs {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 24px 0;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    max-width: 1800px;
    margin: 0 auto;
}

.radar-tabs-spacer {
    flex: 1 1 auto;
}

.radar-tab {
    background: transparent;
    border: 1px solid transparent;
    border-bottom: none;
    color: var(--text-muted);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 8px 16px;
    border-radius: var(--radius) var(--radius) 0 0;
    cursor: pointer;
    white-space: nowrap;
}

.radar-tab:hover { color: var(--text); }

.radar-tab.is-active {
    color: var(--accent);
    font-weight: 600;
    background: var(--surface);
    border-color: var(--border);
    border-bottom: 1px solid var(--surface);
    margin-bottom: -1px;
}

.radar-tab-panel {
    display: none;
}

.radar-tab-panel.is-active {
    display: block;
}

.radar-nav-log {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 14px;
}

/* ── LAYOUT PRINCIPAL (monitoreo) ──────────────────────── */
.radar-workspace {
    width: 100%;
    max-width: 1800px;
    margin: 0 auto;
    height: calc(100dvh - var(--header-h) - 40px);
    overflow-y: auto;
}

.radar-main {
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-height: 0;
    min-width: 0;
    max-width: 100%;
}

#tab-tablero,
#tab-clientes,
#tab-consumo,
#tab-log {
    padding: 20px 24px;
}

#section-cola {
    margin-bottom: 4px;
}

.radar-aside {
    border-left: none;
    background: var(--surface);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.radar-aside--tab {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    height: 70dvh;
    overflow: hidden;
}

.radar-aside > .aside-header,
.radar-aside > div:not(.aside-content) {
    flex-shrink: 0;
}

/* ── MÉTRICAS CARDS (monitoreo) ────────────────────────── */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.metric-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px 18px;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.metric-card:hover {
    border-color: rgba(255, 255, 255, 0.12);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.metric-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.metric-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    transition: all .3s ease;
}

/* ── COLA DE DECISIONES (monitoreo) ────────────────────── */
.cola-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    padding: 4px 0 12px;
    border-bottom: 1px solid var(--border-muted);
    margin-bottom: 12px;
}

.cola-section-title .cnt {
    background: var(--surface-3);
    color: var(--text-muted);
    border-radius: 20px;
    padding: 1px 8px;
    font-size: 11px;
    margin-left: auto;
}

/* Lista de fichas por bloque de cola (una debajo de la otra, no en grilla) */
.cola-cards-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 22px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

/* Tarjetas de hallazgos */
.hallazgo-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    margin-bottom: 0;
    transition: all var(--transition);
    position: relative;
    min-height: 0;
    min-width: 0;
    max-width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.hallazgo-card:hover {
    border-color: rgba(255, 255, 255, 0.15);
    border-left-color: inherit;
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

/* Colores de bordes por fuente */
.hallazgo-card.fuente-whatsapp,
.hallazgo-card.fuente-whatsapp_sync { border-left-color: var(--c-wa); }
.hallazgo-card.fuente-gmail_sync { border-left-color: var(--c-mail); }
.hallazgo-card.fuente-serper,
.hallazgo-card.fuente-search_organico,
.hallazgo-card.fuente-maps { border-left-color: var(--c-serper); }
.hallazgo-card.fuente-gemini_analysis,
.hallazgo-card.fuente-sintesis_ia { border-left-color: var(--c-gemini-src); }
.hallazgo-card.standby { border-left-color: var(--c-validar); }

.hallazgo-header {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 10px;
}

.hallazgo-source-icon {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.hallazgo-source-icon.wa    { background: rgba(37, 211, 102, 0.15); }
.hallazgo-source-icon.mail  { background: rgba(245, 158, 11, 0.15); }
.hallazgo-source-icon.web   { background: rgba(59, 130, 246, 0.15); }
.hallazgo-source-icon.gemini{ background: rgba(124, 58, 237, 0.15); }
.hallazgo-source-icon.default{ background: var(--surface-3); }

.hallazgo-meta {
    flex: 1;
    min-width: 0;
}

.hallazgo-empresa {
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text);
}

.hallazgo-subtitulo {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.hallazgo-tiempo {
    font-size: 11px;
    color: var(--text-dim);
    flex-shrink: 0;
    white-space: nowrap;
}

.hallazgo-campo {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--surface-3);
    border-radius: 4px;
    padding: 2px 7px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.hallazgo-dato {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    color: var(--text);
    background: var(--surface-2);
    border-radius: var(--radius);
    padding: 6px 10px;
    word-break: break-all;
    margin-bottom: 8px;
    border: 1px solid var(--border-muted);
}

.hallazgo-meta-line {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 8px;
    padding: 6px 10px;
    background: var(--surface-2);
    border-radius: var(--radius);
    border: 1px solid var(--border-muted);
    line-height: 1.4;
}

.evidencia-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 6px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--surface-2);
    border: 1px solid var(--border-muted);
    border-radius: var(--radius);
    cursor: pointer;
}

.evidencia-toggle:hover {
    color: var(--text);
    border-color: rgba(255, 255, 255, 0.12);
}

.evidencia-content {
    display: none;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 8px;
    padding: 8px 10px;
    background: var(--surface-2);
    border-radius: var(--radius);
    border: 1px solid var(--border-muted);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 200px;
    overflow: auto;
}

.evidencia-content.open {
    display: block;
}

.confianza-bar-wrap {
    margin-bottom: 10px;
}

.confianza-bar-label {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.confianza-bar-label .pct {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.confianza-bar {
    height: 5px;
    background: var(--surface-3);
    border-radius: 99px;
    overflow: hidden;
}

.confianza-fill {
    height: 100%;
    border-radius: 99px;
    transition: width .6s cubic-bezier(.34, 1.56, .64, 1);
}

.confianza-fill.alto   { background: linear-gradient(90deg, var(--c-validado), #4ADE80); }
.confianza-fill.medio  { background: linear-gradient(90deg, var(--c-validar), #FCD34D); }
.confianza-fill.bajo   { background: linear-gradient(90deg, var(--c-ignorado), #F87171); }
.confianza-fill.ia     { background: linear-gradient(90deg, var(--c-pendiente), #93C5FD); }

.estado-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border-radius: 20px;
    padding: 2px 9px;
    font-size: 11px;
    font-weight: 600;
    border: 1px solid transparent;
}

.estado-badge.validado   { background: rgba(46, 160, 67, 0.15); border-color: rgba(46, 160, 67, 0.3); color: #3FB950; }
.estado-badge.validar    { background: rgba(210, 153, 34, 0.15); border-color: rgba(210, 153, 34, 0.3); color: #E3B341; }
.estado-badge.pendiente  { background: rgba(56, 139, 253, 0.15); border-color: rgba(56, 139, 253, 0.3); color: #79C0FF; }
.estado-badge.analisis   { background: rgba(163, 113, 247, 0.15); border-color: rgba(163, 113, 247, 0.3); color: #C8A9FA; }
.estado-badge.ignorado   { background: rgba(218, 54, 51, 0.15); border-color: rgba(218, 54, 51, 0.3); color: #FF7B72; }
.estado-badge.analisisIA { background: rgba(124, 58, 237, 0.15); border-color: rgba(124, 58, 237, 0.3); color: #DDD6FE; }
.estado-badge.pendienteIA{ background: rgba(56, 139, 253, 0.12); border-color: rgba(56, 139, 253, 0.25); color: #93C5FD; }
.estado-badge.ia-badge-nuevo {
    background: rgba(251, 191, 36, 0.18);
    border: 1px solid rgba(251, 191, 36, 0.45);
    color: #FCD34D;
    font-weight: 700;
    letter-spacing: 0.04em;
    margin-left: 6px;
    vertical-align: middle;
}
.mh-title .ia-badge-nuevo { font-size: 11px; }

.hallazgo-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    padding-top: 10px;
    border-top: 1px solid var(--border-muted);
    margin-top: auto;
}

.btn-action {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-muted);
    transition: all var(--transition);
}

.btn-action:hover { background: var(--surface-3); color: var(--text); border-color: rgba(255, 255, 255, 0.15); }
.btn-action.primary   { background: rgba(56, 139, 253, 0.15); border-color: rgba(56, 139, 253, 0.4); color: #79C0FF; }
.btn-action.primary:hover { background: rgba(56, 139, 253, 0.25); color: #93C5FD; }
.btn-action.success   { background: rgba(46, 160, 67, 0.12); border-color: rgba(46, 160, 67, 0.35); color: #3FB950; }
.btn-action.success:hover { background: rgba(46, 160, 67, 0.22); }
.btn-action.danger    { background: rgba(218, 54, 51, 0.12); border-color: rgba(218, 54, 51, 0.35); color: #FF7B72; }
.btn-action.danger:hover { background: rgba(218, 54, 51, 0.22); }

/* ── ASIDE TERMINAL LOG (monitoreo) ───────────────────── */
.aside-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.aside-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    flex: 1;
}

.aside-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    padding: 0 16px;
}

.aside-tab {
    padding: 8px 14px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border: none;
    border-bottom: 2px solid transparent;
    background: none;
    transition: all var(--transition);
}

.aside-tab:hover { color: var(--text); }
.aside-tab.active { color: var(--text); border-bottom-color: var(--c-pendiente); }

.aside-content {
    flex: 1;
    min-height: 0;
    overflow-x: auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    overscroll-behavior: contain;
    position: relative;
}

.terminal-log {
    display: block;
    height: auto;
    min-height: 0;
    overflow: visible;
    background: #010409;
    padding: 12px;
    font-family: 'IBM Plex Mono', 'Fira Code', monospace;
    font-size: 11.5px;
    line-height: 1.65;
    color: #8B949E;
    scroll-behavior: smooth;
    max-width: 100%;
}

.log-line {
    display: block;
    white-space: pre-wrap;
    word-break: break-all;
    overflow-wrap: anywhere;
}
.log-line.ok      { color: #3FB950; }
.log-line.error   { color: #FF7B72; }
.log-line.warn    { color: #E3B341; }
.log-line.info    { color: #79C0FF; }
.log-line.section { color: #DDD6FE; font-weight: 600; }
.log-line.dim     { color: #484F58; }

/* Log viewer estructurado (monitoreo #op-log) */
.log-view .log-line {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px 8px;
    padding: 2px 0;
    white-space: pre-wrap;
}
.log-view .log-line--spacer {
    height: 6px;
    padding: 0;
}
.log-view .log-line--indent {
    padding-left: 14px;
    border-left: 2px solid #21262d;
    margin-left: 4px;
}
.log-view .log-line--ts {
    gap: 10px;
    padding: 4px 0;
    border-bottom: 1px solid #161b22;
}
.log-view .log-ts {
    flex: 0 0 auto;
    font-size: 10.5px;
    color: #6e7681;
    background: #161b22;
    padding: 1px 6px;
    border-radius: 4px;
    white-space: nowrap;
}
.log-view .log-ts-body {
    flex: 1 1 200px;
    min-width: 0;
    word-break: break-word;
}
.log-view .log-block {
    margin: 8px 0 4px;
    padding: 6px 10px;
    border-radius: 6px;
    line-height: 1.5;
}
.log-view .log-block--section {
    color: #c9d1d9;
    background: #161b22;
    border-left: 3px solid #8957e5;
    font-weight: 600;
    font-size: 11px;
}
.log-view .log-block--empresa {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    background: linear-gradient(90deg, #0d2818 0%, #010409 100%);
    border-left: 3px solid #3fb950;
}
.log-view .log-empresa-id {
    font-size: 10px;
    font-weight: 700;
    color: #3fb950;
    background: #033a16;
    padding: 2px 7px;
    border-radius: 999px;
}
.log-view .log-empresa-nom {
    color: #e6edf3;
    font-weight: 600;
}
.log-view .log-block--footer {
    margin-top: 10px;
    background: #0d2818;
    border: 1px solid #238636;
    font-weight: 600;
}
.log-view .log-line--resumen {
    padding-left: 14px;
    border-left: 2px solid #30363d;
    margin-left: 4px;
}
.log-view .log-resumen-lbl {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6e7681;
    margin-right: 4px;
}
.log-view .log-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 999px;
    background: #21262d;
    color: #8b949e;
    white-space: nowrap;
}
.log-view .log-pill b {
    color: #e6edf3;
    font-weight: 700;
}
.log-view .log-pill--aprobado,
.log-view .log-pill--validado   { background: #033a16; color: #3fb950; }
.log-view .log-pill--validar    { background: #2a1f00; color: #e3b341; }
.log-view .log-pill--ignorado   { background: #2d0a0a; color: #ff7b72; }
.log-view .log-pill--procesadosIA { background: #1a2332; color: #8b949e; }
.log-view .log-pill--pendienteIA,
.log-view .log-pill--pendiente  { background: #0c2d6b; color: #79c0ff; }
.log-view .log-pill--analisis,
.log-view .log-pill--analisisIA { background: #1c1f35; color: #a5b4fc; }
.log-view .log-pill--sintesis   { background: #1c2a3a; color: #7ee787; }

/* analisis_ia: prompt colapsado + tabla por registro */
.log-view--analisis-ia .log-ia-run-header {
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #21262d;
}
.log-view--analisis-ia .log-ia-empresa {
    margin: 16px 0 20px;
    padding: 0 0 16px;
    border-bottom: 1px solid #30363d;
}
.log-view--analisis-ia .log-ia-prompts {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 8px 0 10px;
}
.log-view--analisis-ia .log-ia-prompt {
    border: 1px solid #30363d;
    border-radius: 6px;
    background: #0d1117;
}
.log-view--analisis-ia .log-ia-prompt-sum {
    cursor: pointer;
    padding: 6px 10px;
    font-size: 11px;
    color: #8b949e;
    list-style: none;
}
.log-view--analisis-ia .log-ia-prompt-sum::-webkit-details-marker { display: none; }
.log-view--analisis-ia .log-ia-prompt[open] .log-ia-prompt-sum {
    color: #c9d1d9;
    border-bottom: 1px solid #21262d;
}
.log-view--analisis-ia .log-ia-prompt-body {
    margin: 0;
    padding: 8px 10px;
    max-height: 320px;
    overflow: auto;
    font-size: 10px;
    line-height: 1.45;
    color: #8b949e;
    white-space: pre-wrap;
    word-break: break-word;
}
.log-view--analisis-ia .log-ia-fase {
    margin: 10px 0;
}
.log-view--analisis-ia .log-ia-fase-title {
    margin: 0 0 6px;
    font-size: 11px;
    font-weight: 600;
    color: #79c0ff;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.log-view--analisis-ia .log-ia-tabla {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    line-height: 1.4;
}
.log-view--analisis-ia .log-ia-tabla th {
    text-align: left;
    padding: 5px 8px;
    background: #161b22;
    color: #8b949e;
    font-weight: 600;
    border-bottom: 1px solid #30363d;
}
.log-view--analisis-ia .log-ia-tabla td {
    padding: 5px 8px;
    border-bottom: 1px solid #21262d;
    vertical-align: top;
}
.log-view--analisis-ia .log-ia-tabla tr:hover td {
    background: #161b22;
}
.log-view--analisis-ia .log-ia-id {
    font-family: ui-monospace, monospace;
    color: #a5b4fc;
    white-space: nowrap;
}
.log-view--analisis-ia .log-ia-valor {
    max-width: 200px;
    word-break: break-word;
    color: #c9d1d9;
}
.log-view--analisis-ia .log-ia-nota {
    color: #8b949e;
    max-width: 280px;
}
.log-view--analisis-ia .log-ia-sindato {
    margin-top: 6px;
    font-size: 11px;
    color: #8b949e;
}
.log-view--analisis-ia .log-ia-sindato-lbl {
    margin-right: 6px;
    color: #6e7681;
}
.log-view--analisis-ia .log-ia-tag {
    display: inline-block;
    margin: 2px 4px 2px 0;
    padding: 1px 6px;
    border-radius: 4px;
    background: #21262d;
    color: #c9d1d9;
    font-size: 10px;
}
.log-view--analisis-ia .log-ia-motivo {
    margin-top: 6px;
    padding: 6px 10px;
    background: #161b22;
    border-left: 3px solid #388bfd;
    font-size: 11px;
    line-height: 1.45;
}
.log-view--analisis-ia .log-ia-motivo-lbl {
    display: block;
    font-size: 10px;
    font-weight: 600;
    color: #6e7681;
    text-transform: uppercase;
    margin-bottom: 2px;
}
.log-view--analisis-ia .log-ia-perfiles {
    margin: 0;
    padding-left: 18px;
    font-size: 11px;
    color: #c9d1d9;
}
.log-view--analisis-ia .log-ia-perfiles li {
    margin-bottom: 4px;
}
.log-view--analisis-ia .log-ia-empty {
    margin: 0;
    font-size: 11px;
}
.log-view .log-line--mail {
    display: grid;
    grid-template-columns: auto 1fr auto 1fr;
    gap: 6px 8px;
    align-items: start;
    padding: 3px 0 3px 8px;
    border-left: 2px solid #1f6feb33;
}
.log-view--mail .log-line--mail-row {
    display: grid;
    grid-template-columns: minmax(140px, 34%) minmax(100px, 22%) minmax(120px, 28%) minmax(0, 1fr);
    gap: 6px 10px;
    align-items: start;
    padding: 6px 8px;
    margin: 2px 0;
    border-left: 2px solid #1f6feb44;
    border-radius: 0 4px 4px 0;
    background: rgba(31, 111, 235, 0.04);
}
.log-view--mail .log-mail-email {
    font-weight: 600;
    color: #e6edf3;
    word-break: break-all;
    font-size: 11px;
}
.log-view--mail .log-mail-cliente {
    font-size: 10.5px;
    color: #79c0ff;
    word-break: break-word;
}
.log-view--mail .log-mail-cliente--vacio {
    color: #484f58;
}
.log-view--mail .log-mail-cliente--ok {
    color: #7ee787;
}
.log-view--mail .log-mail-subj {
    color: #8b949e;
    font-size: 10.5px;
    word-break: break-word;
    grid-column: 1 / -1;
    padding-left: 4px;
}
.log-view .log-mail-subj {
    color: #c9d1d9;
    word-break: break-word;
}
.log-view .log-mail-arr {
    color: #484f58;
}
.log-view .log-mail-act {
    color: #8b949e;
    font-size: 11px;
    word-break: break-word;
}
.log-view .log-mail-act--ok    { color: #3fb950; }
.log-view .log-mail-act--error { color: #ff7b72; }
.log-view .log-mail-act--dim   { color: #484f58; }
.log-view .log-line--kv .log-k { color: #79c0ff; }
.log-view .log-line--kv .log-v { color: #e6edf3; }
.log-view .log-json {
    margin: 6px 0;
    border: 1px solid #30363d;
    border-radius: 6px;
    background: #0d1117;
}
.log-view .log-json-sum {
    cursor: pointer;
    padding: 6px 10px;
    font-size: 10.5px;
    color: #8b949e;
    list-style: none;
    user-select: none;
}
.log-view .log-json-sum::-webkit-details-marker { display: none; }
.log-view .log-json[open] .log-json-sum {
    border-bottom: 1px solid #21262d;
    color: #c9d1d9;
}
.log-view .log-json-body {
    margin: 0;
    padding: 10px 12px;
    max-height: 320px;
    overflow: auto;
    font-size: 10.5px;
    line-height: 1.55;
    color: #a5d6ff;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Preview analisis en aside: mismas tablas que simulador */
.log-view--analisis-preview {
    display: flex;
    flex-direction: column;
    gap: 12px;
    font-family: 'IBM Plex Sans', system-ui, sans-serif;
}
.log-view--analisis-preview .log-preview-run-header,
.log-view--analisis-preview .log-preview-run-footer {
    flex-shrink: 0;
    font-family: 'IBM Plex Mono', 'Fira Code', monospace;
    font-size: 11px;
}
.log-view--analisis-preview .log-preview-empresas {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}
.monitoreo-page #op-log .analisis-lote-card--log {
    margin: 0;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid #30363d;
    background: #0d1117;
}
.monitoreo-page #op-log .analisis-lote-card--log .analisis-lote-empresa {
    font-size: 13px;
}
.monitoreo-page #op-log .analisis-lote-table {
    font-size: 10.5px;
}
.monitoreo-page #op-log .analisis-lote-table-wrap {
    overflow-x: auto;
}

/* ── INDEX.PHP ESCRITORIO (Estilos unificados a Dark Mode) ─ */
.content {
    padding: 20px 24px;
    max-width: 1400px;
    margin: 0 auto;
}

.grid-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
    margin-bottom: 16px;
}

.grid-toolbar-text {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1 1 auto;
    min-width: 0;
}

.grid-toolbar-text .search-input {
    flex: 1 1 0;
    min-width: 100px;
    width: auto;
    max-width: 280px;
}

.grid-toolbar-sorts {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    margin-left: auto;
}

.empresa-card.oculta,
.index-crm-row.oculta {
    display: none !important;
}

.search-input {
    font-family: 'IBM Plex Sans', system-ui, sans-serif;
    font-size: 13px;
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
    color: var(--text);
    width: 220px;
    outline: none;
    transition: border-color .15s;
}
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--text-tertiary); }

.sort-select {
    font-family: 'IBM Plex Sans', system-ui, sans-serif;
    font-size: 13px;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
    color: var(--text-secondary);
    outline: none;
    cursor: pointer;
}

.stat-pill {
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 5px 12px;
    white-space: nowrap;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0 14px;
    border-bottom: 1px solid var(--border-muted);
    margin-bottom: 16px;
}

.section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
}

/* Dashboard KPIs Cobertura */
.index-dashboard {
    margin-bottom: 8px;
    padding-bottom: 22px;
    border-bottom: 2px solid var(--border-muted);
}

/* Index: una pantalla (30% franja KPIs tipo métricas monitoreo / 70% lista con scroll) */
.index-workspace {
    height: calc(100dvh - var(--header-h));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 16px 24px 18px;
    max-width: 100%;
}

.index-kpi-strip {
    flex: 0 0 30%;
    min-height: 0;
    overflow: hidden;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-muted);
}

.index-kpi-strip-inner {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    height: 100%;
    min-height: 0;
}

.index-kpi-col {
    min-height: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.index-kpi-col--span2 {
    grid-column: span 2;
}

.index-kpi-summary-card--strip,
.index-kpi-card--strip,
.index-kpi-empty-card--strip {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.index-kpi-empty-card--strip {
    padding: 14px 16px;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 13px;
    color: var(--text-secondary);
}

.index-kpi-summary-card--strip .index-kpi-summary-head {
    flex-shrink: 0;
}

.index-kpi-summary-body--stack {
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.index-kpi-summary-body--stack .index-kpi-stat-pill {
    flex: 0 0 auto;
    width: 100%;
}

.index-kpi-card--strip .index-kpi-card-head {
    flex-shrink: 0;
}

.index-kpi-card--strip .index-kpi-card-body {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.index-clientes-panel {
    flex: 1 1 70%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-top: 4px;
}

.index-clientes-panel .grid-toolbar {
    flex-shrink: 0;
    margin-bottom: 10px;
}

@media (max-width: 720px) {
    .index-clientes-panel .grid-toolbar {
        flex-wrap: wrap;
    }
    .grid-toolbar-sorts {
        margin-left: 0;
        width: 100%;
        justify-content: flex-end;
    }
}

.index-clientes-panel .section-header {
    flex-shrink: 0;
    margin-bottom: 10px;
}

.index-empresa-grid-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 2px;
}

/* Index toolbar v2: búsqueda · filtros estado · orden */
.index-toolbar-v2 {
    display: grid;
    grid-template-columns: minmax(200px, 1fr) minmax(0, 2fr) auto;
    align-items: center;
    gap: 10px 14px;
}

.grid-toolbar-search {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.grid-toolbar-search .search-input {
    flex: 1 1 140px;
    min-width: 100px;
    max-width: 220px;
}

.index-concepto-select {
    flex: 1 1 160px;
    min-width: 120px;
    max-width: 280px;
}

.index-estado-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 0;
}

.index-est-btn {
    font-family: 'IBM Plex Sans', system-ui, sans-serif;
    font-size: 11px;
    font-weight: 500;
    padding: 5px 10px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    transition: background .12s, border-color .12s, color .12s;
}

.index-est-btn:hover {
    border-color: rgba(255, 255, 255, 0.18);
    color: var(--text-primary);
}

.index-est-btn.is-active {
    background: var(--purple-bg);
    border-color: rgba(124, 58, 237, 0.45);
    color: var(--purple-text);
}

.index-toolbar-v2 .grid-toolbar-sorts {
    margin-left: 0;
}

@media (max-width: 1100px) {
    .index-toolbar-v2 {
        grid-template-columns: 1fr 1fr;
    }
    .index-estado-filters {
        grid-column: 1 / -1;
        justify-content: center;
    }
    .index-toolbar-v2 .grid-toolbar-sorts {
        justify-self: end;
    }
}

@media (max-width: 640px) {
    .index-toolbar-v2 {
        grid-template-columns: 1fr;
    }
    .index-toolbar-v2 .grid-toolbar-sorts {
        justify-self: stretch;
    }
    .index-toolbar-v2 .grid-toolbar-sorts .sort-select {
        width: 100%;
    }
}

/* Index tabla 15 campos CRM */
.index-crm-table-wrap {
    min-width: 100%;
}

.index-crm-table {
    width: max-content;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 12px;
}

.index-crm-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    padding: 8px 10px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-tertiary);
    text-align: left;
    white-space: nowrap;
}

.index-crm-th-empresa,
.index-crm-td-empresa {
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--card-bg);
    min-width: 160px;
    max-width: 220px;
    border-right: 1px solid var(--border-muted);
}

.index-crm-table thead .index-crm-th-empresa {
    z-index: 3;
    background: var(--surface-2);
}

.index-crm-td-campo {
    padding: 7px 10px;
    border-bottom: 1px solid var(--border-muted);
    max-width: 130px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: top;
    color: var(--text-secondary);
}

.index-crm-row {
    cursor: pointer;
    transition: background .1s;
}

.index-crm-row:hover td {
    background: rgba(255, 255, 255, 0.03);
}

.index-crm-row:hover .index-crm-td-empresa {
    background: var(--surface-2);
}

.index-crm-row--conflicto .index-crm-td-empresa {
    box-shadow: inset 3px 0 0 var(--amber);
}

.index-crm-empresa-nombre {
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}

.index-crm-empresa-loc {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.index-crm-pill {
    display: inline-block;
    margin-top: 5px;
    font-size: 10px;
    padding: 2px 7px;
    border-radius: 10px;
    background: var(--surface-3);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.index-crm-pill--ok {
    background: rgba(46, 160, 67, 0.12);
    color: #7ee787;
    border-color: rgba(46, 160, 67, 0.35);
}

.index-crm-pill--warn {
    background: var(--amber-bg);
    color: var(--amber-text);
    border-color: var(--amber);
}

.index-crm-td-campo.valor {
    color: var(--text-primary);
    font-weight: 500;
}

.index-crm-td-campo.valor--aprobado {
    color: #7ee787;
}

.index-crm-td-campo.valor--validado {
    color: #c4b5fd;
}

.index-crm-td-campo.analisis {
    color: var(--text-tertiary);
    font-style: italic;
    font-size: 11px;
}

.index-crm-td-campo.vacio {
    color: transparent;
}

/* KPIs compactos en la franja superior */
.index-kpi-strip .index-kpi-summary-title {
    font-size: 14px;
}

.index-kpi-strip .index-kpi-summary-sub {
    font-size: 11px;
}

.index-kpi-strip .index-kpi-stat-num {
    font-size: 18px;
}

.index-kpi-strip .index-kpi-card-head {
    padding: 10px 12px 8px;
}

.index-kpi-strip .index-kpi-card-body {
    padding: 10px 12px 12px;
    gap: 8px;
}

.index-kpi-strip .index-kpi-hero-label {
    font-size: 9px;
    margin-bottom: 4px;
}

.index-kpi-strip .index-kpi-hero-bar {
    height: 10px;
    flex-shrink: 0;
}

.index-kpi-strip .index-kpi-metrics {
    gap: 3px;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--border-muted);
    flex: 1;
    min-height: 0;
}

.index-kpi-strip .index-kpi-metric--inline {
    padding: 3px 4px;
}

@media (max-width: 1024px) {
    .index-kpi-strip-inner {
        grid-template-columns: 1fr;
    }

    .index-kpi-col--span2 {
        grid-column: span 1;
    }

    .index-kpi-strip {
        flex: 0 0 auto;
        max-height: min(52vh, 420px);
        overflow-y: auto;
    }
}

.index-kpi-wrap {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.index-kpi-summary-card,
.index-kpi-card,
.index-kpi-empty-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    cursor: default;
    box-shadow: var(--shadow);
}

.index-kpi-summary-head {
    align-items: center;
}

.index-kpi-summary-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 2px;
}

.index-kpi-summary-sub {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 0;
}

.index-kpi-summary-body {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 0 14px 14px;
}

.index-kpi-stat-pill {
    flex: 1 1 140px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--surface-2);
}

.index-kpi-stat-pill--muted { border-left: 4px solid var(--text-tertiary); }
.index-kpi-stat-pill--info { border-left: 4px solid var(--purple); background: var(--purple-bg); }

.index-kpi-stat-num {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
}

.index-kpi-stat-lbl {
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.index-kpi-stat-pct {
    font-size: 12px;
    color: var(--text-muted);
}

.index-kpi-cards-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}


.index-kpi-card-head {
    padding: 12px 14px 10px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-muted);
}

.index-kpi-card-title { font-weight: 600; color: var(--text-primary); }
.index-kpi-card-hint { font-size: 12px; color: var(--text-secondary); }

.index-kpi-badge-ok {
    background: var(--green-bg);
    color: var(--green-text);
    border: 1px solid rgba(46, 160, 67, 0.35);
}

.index-kpi-card-body {
    padding: 12px 14px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.index-kpi-hero-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-tertiary);
}

.index-kpi-hero-bar {
    display: flex;
    height: 18px;
    border-radius: 9px;
    overflow: hidden;
    background: var(--surface-3);
    border: 1px solid var(--border);
}

.index-kpi-hero-seg {
    display: block;
    height: 100%;
}

.index-kpi-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
}

.index-kpi-legend-chip {
    font-size: 10px;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    background: var(--surface-2);
    border-radius: 20px;
    border: 1px solid var(--border);
}

.index-kpi-legend-chip .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.index-kpi-metrics {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 4px;
    padding-top: 8px;
    border-top: 1px solid var(--border-muted);
}

.index-kpi-metric {
    padding: 6px 8px;
    background: var(--surface-2);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

/* Una línea: % · definición · barra corta · cantidad */
.index-kpi-metric--inline {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
}

.index-kpi-metric--inline .index-kpi-metric-label {
    flex: 0 0 auto;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 2.4rem;
}

.index-kpi-metric--inline .index-kpi-metric-desc {
    flex: 0 1 auto;
    max-width: 6.5rem;
    min-width: 0;
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.index-kpi-metric--inline .index-kpi-metric-bar {
    flex: 1 1 11rem;
    min-width: 11rem;
    width: auto;
    max-width: none;
    height: 6px;
    border-radius: 3px;
    background: var(--surface-3);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.05);
    margin: 0;
}

.index-kpi-metric--inline .index-kpi-metric-values {
    flex: 0 0 auto;
    margin-left: auto;
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.index-kpi-metric--inline .index-kpi-metric-values strong {
    color: var(--text-primary);
    margin-right: 4px;
    font-weight: 600;
}

.index-kpi-metric--inline .index-kpi-metric-values em {
    font-style: normal;
    opacity: 0.85;
    font-size: 10px;
}

.index-kpi-metric-fill {
    display: block;
    height: 100%;
    border-radius: 3px;
    min-width: 2px;
}

/* Colores de segmentos */
.index-kpi-card--aprob .seg--completo, .index-kpi-card--aprob .dot.seg--completo { background: #1a6b2e; }
.index-kpi-card--aprob .seg--gt70, .index-kpi-card--aprob .dot.seg--gt70 { background: var(--green); }
.index-kpi-card--aprob .seg--gt30, .index-kpi-card--aprob .dot.seg--gt30 { background: #88c788; }
.index-kpi-card--aprob .seg--nada, .index-kpi-card--aprob .dot.seg--nada { background: #b8e0b9; }

.index-kpi-card--val .seg--completo, .index-kpi-card--val .dot.seg--completo { background: var(--accent-dark); }
.index-kpi-card--val .seg--gt70, .index-kpi-card--val .dot.seg--gt70 { background: var(--purple); }
.index-kpi-card--val .seg--gt30, .index-kpi-card--val .dot.seg--gt30 { background: #c4b5fd; }
.index-kpi-card--val .seg--nada, .index-kpi-card--val .dot.seg--nada { background: #ddd6fe; }

/* GRID DE EMPRESAS Y TARJETAS (index) */
.empresa-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(520px, 1fr));
    gap: 12px;
}

.card-stats-split {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 6px 12px;
}

.card-stats-izq .card-stat-aprob strong {
    color: #7ee787;
}

.card-stats-der {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
    justify-content: flex-end;
}

.campos-grid--crm15 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.campos-grid--crm15 .campo-cell {
    border-right: 1px solid var(--border-muted);
}

.campos-grid--crm15 .campo-cell:nth-child(3n) {
    border-right: none;
}

.campos-grid--crm15 .campo-cell:nth-child(even) {
    border-right: 1px solid var(--border-muted);
}

.campo-valor.valor,
.campo-valor.valor--aprobado,
.campo-valor.valor--validado {
    font-weight: 500;
}

.campo-valor.valor--aprobado { color: #7ee787; }
.campo-valor.valor--validado { color: #c4b5fd; }
.campo-valor.analisis { color: var(--text-tertiary); font-style: italic; }

.campo-cell--filtro-oculta {
    display: none !important;
}

.empresa-card--filtro-estado .campos-grid--crm15 {
    align-content: start;
}

.empresa-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    cursor: pointer;
    transition: border-color .15s, transform .1s;
    display: flex;
    flex-direction: column;
}

.empresa-card:hover {
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
}

.card-head {
    padding: 12px 14px 10px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.card-nombre { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.card-loc { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

.badge-count {
    font-size: 11px;
    font-weight: 500;
    padding: 3px 8px;
    border-radius: 20px;
    white-space: nowrap;
}
.badge-count.muchas { background: var(--amber-bg); color: var(--amber-text); }
.badge-count.pocas  { background: var(--surface-3); color: var(--text-secondary); border: 1px solid var(--border); }
.badge-count.analisis-badge { background: var(--purple-bg); color: var(--purple-text); }

.badge-conflicto-empresa {
    display: inline-block;
    margin-top: 6px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    padding: 4px 8px;
    border-radius: 6px;
    background: var(--amber-bg);
    color: var(--amber-text);
    border: 1px solid var(--amber);
}

.card-redes-icons {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 0 14px 8px;
}

.card-redes-icons span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.card-stats {
    font-size: 11px;
    color: var(--text-secondary);
    padding: 0 14px 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
}

.campos-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border-top: 1px solid var(--border-muted);
    border-bottom: 1px solid var(--border-muted);
    background: rgba(0, 0, 0, 0.1);
}

.campo-cell {
    padding: 8px 14px;
    border-right: 1px solid var(--border-muted);
    min-width: 0;
}
.campo-cell:nth-child(even) { border-right: none; }

.campo-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-tertiary);
    margin-bottom: 3px;
}

.campo-valor {
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.campo-valor.tiene   { color: var(--text-primary); }
.campo-valor.sugiere { color: var(--green); font-weight: 500; }
.campo-valor.vacio   { color: var(--text-tertiary); font-style: italic; }

.sug-dot {
    display: inline-block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--green);
    margin-right: 4px;
    vertical-align: middle;
}

.card-foot {
    padding: 9px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0,0,0,0.08);
}

.fuentes { display: flex; gap: 4px; }
.fuente-tag {
    font-size: 10px;
    padding: 2px 7px;
    border-radius: 4px;
    background: var(--surface-2);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-revisar {
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: var(--radius-md);
    background: var(--accent);
    color: #fff;
    border: none;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: background var(--transition);
}
.btn-revisar:hover { background: var(--accent-dark); }

/* ── MODALES COMPARTIDOS (index & monitoreo) ───────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    backdrop-filter: blur(4px);
    z-index: 500;
    align-items: flex-start;
    justify-content: center;
    padding: 24px 16px;
    overflow-y: auto;
}
.modal-overlay.visible { display: flex; }

/* Modales CRM (detalle cola / wizard — clase `visible` desde JS) */
.crm-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 600;
    align-items: flex-start;
    justify-content: center;
    padding: 24px 16px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(6px);
}

.crm-modal-overlay.visible {
    display: flex;
}

.crm-modal {
    width: 100%;
    max-width: 920px;
    max-height: 92vh;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.error-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    flex-shrink: 0;
}

.error-modal-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.error-modal-body {
    padding: 14px 16px 18px;
    overflow: auto;
    flex: 1;
    min-height: 0;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.45;
}

.error-modal-body p {
    color: var(--text-secondary);
}

.modal {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 1320px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.modal-ficha-shell {
    height: calc(100dvh - 48px);
    max-width: min(96vw, 1720px);
    width: 100%;
    display: flex;
    flex-direction: column;
}

#modal-ficha-overlay .modal-ficha-shell {
    max-width: min(96vw, 1720px);
}

.modal-ficha-head {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--card-bg);
}

.modal-ficha-open-full,
.modal-ficha-close {
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 12px;
    text-decoration: none;
    cursor: pointer;
}
.modal-ficha-open-full:hover,
.modal-ficha-close:hover {
    background: var(--surface-3);
}


.analisis-lote-modal {
    max-width: 1080px;
}

.analisis-lote-log {
    margin: 10px 0 0;
    padding: 10px 12px;
    max-height: 220px;
    overflow: auto;
    font-size: 11px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text);
}

.analisis-lote-summary {
    margin-bottom: 10px;
}

.analisis-lote-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 62vh;
    overflow: auto;
    padding-right: 4px;
}

.analisis-lote-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-2);
    padding: 10px 12px;
}

.analisis-lote-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.analisis-lote-empresa {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.25;
}

.analisis-lote-meta {
    font-size: 11px;
    color: var(--text-muted);
}

.analisis-lote-registrar {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.analisis-lote-registrar-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.analisis-lote-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.analisis-lote-switch {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.analisis-lote-toggle-opt {
    font-size: 12px;
    font-weight: 600;
    min-width: 1.4rem;
    text-align: center;
    color: var(--text-muted);
    transition: color 0.15s;
}

.analisis-lote-toggle-opt--off {
    color: var(--text-secondary);
}

.analisis-lote-toggle-opt--on {
    color: var(--text-muted);
}

.analisis-lote-toggle-track {
    position: relative;
    width: 40px;
    height: 22px;
    border-radius: 999px;
    background: var(--surface-3);
    border: 1px solid var(--border);
    transition: background 0.15s, border-color 0.15s;
}

.analisis-lote-toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: transform 0.15s, background 0.15s;
}

.analisis-lote-switch:not(:checked) ~ .analisis-lote-toggle-track {
    background: rgba(239, 68, 68, 0.22);
    border-color: #ef4444;
}

.analisis-lote-switch:not(:checked) ~ .analisis-lote-toggle-track .analisis-lote-toggle-thumb {
    transform: translateX(0);
    background: #ef4444;
}

.analisis-lote-switch:not(:checked) ~ .analisis-lote-toggle-opt--off {
    color: #ef4444;
}

.analisis-lote-switch:checked ~ .analisis-lote-toggle-track {
    background: rgba(34, 197, 94, 0.25);
    border-color: var(--c-validado);
}

.analisis-lote-switch:checked ~ .analisis-lote-toggle-track .analisis-lote-toggle-thumb {
    transform: translateX(18px);
    background: var(--c-validado);
}

.analisis-lote-switch:checked ~ .analisis-lote-toggle-opt--on {
    color: var(--c-validado);
}

.analisis-lote-etapa {
    margin: 0 0 8px;
    border: 1px solid var(--border-muted);
    border-radius: var(--radius-sm);
    background: var(--surface-1);
}

.analisis-lote-etapa--final {
    border-color: var(--c-validado);
    background: rgba(34, 197, 94, 0.06);
}

.analisis-lote-cambios-final {
    margin-top: 8px;
}

.analisis-lote-table--compacta .analisis-lote-dato {
    max-width: 180px;
    color: var(--text);
    word-break: break-word;
}

.analisis-lote-etapa--tecnico {
    margin-top: 10px;
    opacity: 0.85;
}

.analisis-lote-etapa--tecnico > .analisis-lote-etapa-head {
    font-size: 11px;
    color: var(--text-muted);
}

.analisis-lote-etapa-head {
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    padding: 8px 10px;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--text);
}

.analisis-lote-etapa-head::-webkit-details-marker {
    display: none;
}

.analisis-lote-etapa-count {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--surface-3);
    padding: 2px 8px;
    border-radius: 999px;
}

.analisis-lote-etapa-vacia {
    font-size: 11px;
    color: var(--text-muted);
    margin: 0;
    padding: 8px 10px 12px;
}

.analisis-lote-table--etapa {
    font-size: 11px;
}

.analisis-lote-pipeline {
    font-size: 11px;
    color: var(--text-muted);
    margin: 0 0 10px;
    padding: 8px 10px;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-muted);
}

.analisis-lote-row-procesado td {
    opacity: 0.85;
    font-style: italic;
}

.analisis-lote-row-cruce td {
    background: rgba(59, 130, 246, 0.08);
}

.analisis-lote-motivo {
    max-width: 140px;
    font-size: 10px;
    line-height: 1.35;
}

.analisis-lote-cambio {
    color: #ef4444;
    font-weight: 700;
}

.analisis-lote-row-sin-cambio td {
    opacity: 0.5;
}

.analisis-lote-row-cambio-bd td {
    opacity: 1;
}

.analisis-lote-etapa--final .analisis-lote-row-cambio-bd {
    background: rgba(239, 68, 68, 0.06);
}

.analisis-lote-table-wrap {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: auto;
}

.analisis-lote-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}

.analisis-lote-table th,
.analisis-lote-table td {
    text-align: left;
    padding: 7px 8px;
    border-bottom: 1px solid var(--border-muted);
    color: var(--text-secondary);
    vertical-align: top;
}

.analisis-lote-table th {
    background: var(--surface-3);
    color: var(--text-tertiary);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.analisis-lote-table .analisis-lote-concepto {
    max-width: 220px;
    color: var(--text);
    font-size: 11px;
}

.analisis-lote-empty {
    padding: 9px 10px;
    font-size: 12px;
    color: var(--text-muted);
}

.analisis-lote-footer {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

/* Consultor macro — tarjetas más legibles que el resto del dark theme */
.consultor-modal {
    max-height: 96vh;
}

.consultor-modal .analisis-lote-list {
    max-height: 72vh;
}

.consultor-modal .analisis-lote-summary {
    font-size: 14px;
    color: var(--text);
    line-height: 1.5;
}

.consultor-card {
    background: #2d333b;
    border: 1px solid #768390;
    border-left: 4px solid var(--accent);
    padding: 16px 18px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.consultor-card-head {
    margin-bottom: 10px;
}

.consultor-card .analisis-lote-empresa {
    font-size: 17px;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 4px;
}

.consultor-card .analisis-lote-meta {
    font-size: 13px;
    color: #c9d1d9;
}

.consultor-pregunta {
    font-size: 15px;
    line-height: 1.55;
    color: #f0f6fc;
    margin: 0 0 6px;
    font-weight: 500;
}

.consultor-nota {
    font-size: 12px;
    color: #8b949e;
    margin: 0 0 12px;
}

.consultor-resumen {
    list-style: none;
    margin: 0 0 12px;
    padding: 10px 12px;
    background: #0d1117;
    border: 1px solid #484f58;
    border-radius: var(--radius-sm);
}

.consultor-resumen li {
    font-size: 13px;
    line-height: 1.5;
    padding: 4px 0;
    border-bottom: 1px solid #30363d;
}

.consultor-resumen li:last-child {
    border-bottom: none;
}

.consultor-campo {
    display: inline-block;
    min-width: 5.5rem;
    font-weight: 600;
    color: #a371f7;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.03em;
}

.consultor-dato {
    color: #e6edf3;
    word-break: break-word;
}

.consultor-mas {
    color: #8b949e;
    font-style: italic;
}

.consultor-links {
    margin-bottom: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
}

.consultor-link {
    font-size: 13px;
    font-weight: 600;
    color: #c4b5fd !important;
    text-decoration: underline;
}

.consultor-opciones {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.consultor-opciones .consultor-opcion {
    font-size: 13px;
    padding: 8px 12px;
}

.consultor-opcion--recomendada {
    border-color: #7c3aed !important;
    color: #5b21b6 !important;
    background: #f5f3ff !important;
    font-weight: 600;
}

.consultor-tipo-tag {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 6px;
    border-radius: 4px;
    background: #ede9fe;
    color: #5b21b6;
    margin-right: 6px;
    vertical-align: middle;
}

.consultor-rec-motivo {
    font-size: 12px;
    color: #5b21b6;
    margin: 0 0 8px;
}

.consultor-pregunta--claro {
    white-space: normal;
    line-height: 1.45;
}

.consultor-cli {
    color: #94a3b8;
    font-size: 11px;
    margin-right: 4px;
}

.consultor-ft {
    color: #64748b;
    font-size: 10px;
}

.consultor-origen {
    color: #b45309;
    font-size: 10px;
}

.consultor-origen-dom,
.consultor-regla-propuesta {
    font-size: 12px;
    line-height: 1.45;
    margin: 6px 0 0;
    padding: 8px 10px;
    border-radius: 6px;
    background: rgba(180, 83, 9, 0.08);
    border: 1px solid rgba(180, 83, 9, 0.25);
}

.consultor-regla-propuesta--panel {
    margin-bottom: 8px;
}

.consultor-links-nota {
    font-size: 11px;
    color: #64748b;
    margin: 0 0 4px;
}

.consultor-modal-overlay .error-modal-body {
    background: var(--surface);
}

.modal-ficha-frame {
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    width: 100%;
    border: 0;
    background: var(--bg);
}

/* iframe modal_decision.php (Detalle desde index / ficha) */
.modal-decision-host {
    z-index: 650;
}
.modal-decision-iframe-wrap {
    width: min(920px, 96vw);
    max-height: 94vh;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    overflow: hidden;
}
.modal-decision-frame {
    display: block;
    width: 100%;
    height: min(88vh, 900px);
    border: 0;
    background: transparent;
}

/* Ficha dentro del iframe de index: el modal de decisión cubre la ficha */
.ficha-page.embed-mode .modal-decision-host {
    z-index: 800;
}
.ficha-page.embed-mode .modal-decision-iframe-wrap {
    width: min(900px, 98vw);
    max-height: 96vh;
}
.ficha-page.embed-mode .modal-decision-frame {
    height: min(92vh, 880px);
}

/* ── FICHA CLIENTE (ficha_cliente.php + iframe modal) ─── */
/* Una pantalla: 50% perfil+chequear / 50% cuatro columnas; scroll solo dentro de cada zona. */
html.ficha-html-embed {
    height: 100%;
    overflow: hidden;
}

body.ficha-page {
    font-family: 'IBM Plex Sans', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

body.ficha-page.radar-body {
    min-height: 0;
}

body.ficha-page.embed-mode {
    height: 100%;
    min-height: 0;
}

.ficha-page .topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 56px;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(249, 115, 22, 0.2);
}

.ficha-page .topbar .logo {
    font-weight: 700;
    font-size: 16px;
    color: var(--text);
}

.ficha-page .topbar .logo span { color: var(--accent); }

.ficha-page .topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ficha-page .run-btn {
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}

.ficha-page .run-btn:hover {
    background: var(--surface-3);
    color: var(--text);
}

.ficha-page .user-info {
    font-size: 12px;
    color: var(--text-muted);
}

.ficha-wrap {
    padding-top: 0;
    max-width: min(96vw, 1720px);
    width: 100%;
    margin: 0 auto;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.ficha-page.embed-mode { background: transparent; }

body.ficha-page.embed-mode .ficha-wrap,
body.ficha-page.embed-mode .content.ficha-wrap {
    max-width: 100%;
    margin: 0;
}

.ficha-page .content.ficha-wrap {
    padding: 0;
    max-width: none;
    margin: 0;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-hallazgos-root {
    font-family: 'IBM Plex Sans', system-ui, sans-serif;
    color: var(--text);
    max-width: 100%;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

body.ficha-page .modal-hallazgos-root {
    flex: 1;
    min-height: 0;
    height: auto;
}

.mh-top {
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.mh-title { font-size: 18px; font-weight: 600; color: var(--text-primary); }

.mh-sub { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

.mh-close {
    border: 1px solid var(--border);
    background: var(--surface-2);
    padding: 6px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 13px;
    text-decoration: none;
    color: var(--text);
    display: inline-block;
    transition: background var(--transition);
}

.mh-close:hover,
.mh-close-link:hover { background: var(--surface-3); }

.mh-layout {
    padding: 14px 18px 18px;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow: hidden;
}

/* Ficha escritorio: sidebar 1/3 + columna de bloques 2/3 */
.mh-layout--split {
    display: grid;
    grid-template-columns: minmax(0, 30%) minmax(0, 70%);
    gap: 14px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.mh-sidebar {
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.12) 0%, rgba(46, 160, 67, 0.08) 100%);
    border-color: rgba(124, 58, 237, 0.35);
}

.mh-sidebar-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 4px;
}

.mh-perfil-block {
    margin-bottom: 14px;
    padding: 10px 12px 12px;
    border: 1px solid rgba(124, 58, 237, 0.25);
    border-radius: var(--radius-md);
}

.mh-perfil-block.mh-comp-aprobado {
    background: rgba(46, 160, 67, 0.1);
    border-color: rgba(46, 160, 67, 0.32);
}

.mh-resumen-block--comp {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px dashed rgba(210, 153, 34, 0.35);
}

.mh-resumen-row.mh-comp-aprobado,
.mh-card.mh-comp-aprobado {
    background: rgba(46, 160, 67, 0.1);
    border-color: rgba(46, 160, 67, 0.32);
}

.mh-resumen-row.mh-comp-validar,
.mh-card.mh-comp-validar,
.mh-reubicados-inline.mh-comp-validar-block {
    background: rgba(210, 153, 34, 0.1);
    border-color: rgba(210, 153, 34, 0.38);
}

.mh-reubicados-inline.mh-comp-validar-block {
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    border-style: solid;
}

.mh-perfil-tag-lbl {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    color: #27500A;
    margin: 0 0 6px;
}

.mh-perfil-tag-lbl--proc { color: #3C3489; }
.mh-perfil-tag-lbl--mat { color: #7B4A13; }
.mh-perfil-tag-lbl--mk { color: #0A5A7A; }

.mh-tags--block { margin-bottom: 10px; }

.mh-resumen-block {
    margin-top: 4px;
}

.mh-resumen-block--alt {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px dashed rgba(124, 58, 237, 0.3);
}

.mh-resumen-crm {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mh-resumen-row {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: rgba(0, 0, 0, 0.12);
}

.mh-resumen-row-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.mh-resumen-head-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.mh-resumen-btn-validar {
    font-size: 10px;
    font-weight: 600;
    line-height: 1;
    padding: 3px 8px;
    border-radius: 8px;
    border: 1px solid rgba(124, 58, 237, 0.45);
    background: rgba(124, 58, 237, 0.12);
    color: #ddd6fe;
    cursor: pointer;
}

.mh-resumen-btn-validar:hover {
    background: rgba(124, 58, 237, 0.22);
}

.mh-est--validar { background: rgba(124, 58, 237, 0.18); color: #ddd6fe; }

.mh-resumen-campo {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}

.mh-resumen-estado {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
}

.mh-est--validado { background: rgba(124, 58, 237, 0.18); color: #ddd6fe; }
.mh-est--aprobado { background: rgba(46, 160, 67, 0.15); color: #7ee787; }
.mh-est--pendiente { background: rgba(56, 139, 253, 0.15); color: #79c0ff; }
.mh-est--analisis { background: var(--amber-bg); color: var(--amber-text); }
.mh-est--pendienteia { background: rgba(163, 113, 247, 0.18); color: #e9d5ff; }
.mh-est--analisisia { background: rgba(210, 153, 34, 0.12); color: #e3b341; }
.mh-est--ignorado { background: var(--surface-3); color: var(--text-tertiary); }
.mh-est--vacio { background: var(--surface-3); color: var(--text-tertiary); }

.mh-resumen-row-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
}

.mh-resumen-par {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    line-height: 1.35;
}

.mh-resumen-k {
    flex: 0 0 36px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-tertiary);
}

.mh-resumen-v {
    flex: 1;
    min-width: 0;
    color: var(--text-secondary);
    word-break: break-word;
}

.mh-resumen-datos {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px 4px;
}

.mh-resumen-dato { color: var(--text-primary); }

.mh-resumen-dato--aprob { font-weight: 600; }

.mh-resumen-par--ref .mh-resumen-k,
.mh-resumen-par--ref .mh-resumen-v {
    color: var(--text-tertiary);
    font-size: 11px;
}

.mh-compact-ref {
    color: var(--text-tertiary);
    font-size: 11px;
}

.mh-compact-ref em {
    color: var(--text-tertiary);
    font-style: normal;
    opacity: 0.85;
}

.mh-resumen-sep {
    color: var(--text-tertiary);
    padding: 0 2px;
}

.mh-main-stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
    overflow: hidden;
}

.mh-stack-block {
    flex: 0 0 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.mh-collapsible {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
}

.mh-collapsible--grow[open] {
    flex: 1 1 0;
    min-height: 88px;
}

/* Con lista scrolleable: altura acotada por ítems, no estirar toda la columna. */
.mh-collapsible--scroll[open] {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
}

.mh-collapsible--empty:not([open]) {
    border-color: transparent;
    background: transparent;
}

.mh-collapsible-sum {
    list-style: none;
    cursor: pointer;
    user-select: none;
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary);
    margin: 0;
    padding: 8px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.mh-collapsible-sum::-webkit-details-marker { display: none; }

.mh-collapsible-sum::after {
    content: '▸';
    font-size: 10px;
    color: var(--text-muted);
    transition: transform 0.15s ease;
}

.mh-collapsible[open] > .mh-collapsible-sum::after {
    transform: rotate(90deg);
}

.mh-collapsible--empty:not([open]) .mh-collapsible-sum {
    padding: 4px 8px;
    opacity: 0.72;
}

.mh-collapsible-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 0 8px 8px;
    overflow: hidden;
}

.mh-collapsible--empty .mh-collapsible-body {
    padding-top: 0;
}

/** Lista con scroll visible dentro de sección abierta. */
.mh-panel-scroll,
.mh-list-scroll.mh-panel-scroll,
.mh-stack-scroll.mh-panel-scroll,
.mh-crm-hallazgos-stack.mh-panel-scroll {
    flex: 1 1 auto;
    min-height: 72px;
    max-height: min(34vh, 380px);
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    padding-right: 2px;
}

.mh-collapsible--scroll[open] .mh-collapsible-body {
    flex: 0 1 auto;
    min-height: 0;
}

.mh-aprob.mh-collapsible--scroll .mh-crm-block {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.mh-panel-scroll::-webkit-scrollbar,
.mh-list-scroll.mh-panel-scroll::-webkit-scrollbar,
.mh-stack-scroll.mh-panel-scroll::-webkit-scrollbar,
.mh-crm-hallazgos-stack.mh-panel-scroll::-webkit-scrollbar {
    width: 8px;
}

.mh-panel-scroll::-webkit-scrollbar-thumb,
.mh-list-scroll.mh-panel-scroll::-webkit-scrollbar-thumb,
.mh-stack-scroll.mh-panel-scroll::-webkit-scrollbar-thumb,
.mh-crm-hallazgos-stack.mh-panel-scroll::-webkit-scrollbar-thumb {
    background: var(--surface-3);
    border-radius: 4px;
}

.mh-panel-scroll::-webkit-scrollbar-thumb:hover,
.mh-list-scroll.mh-panel-scroll::-webkit-scrollbar-thumb:hover,
.mh-stack-scroll.mh-panel-scroll::-webkit-scrollbar-thumb:hover,
.mh-crm-hallazgos-stack.mh-panel-scroll::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

.mh-empty--inline {
    margin: 0;
    padding: 4px 0 2px;
    font-size: 11px;
}

.mh-card--compact {
    padding: 8px 10px;
    margin-bottom: 6px;
}

.mh-compact-line1,
.mh-compact-line2 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
    line-height: 1.35;
}

.mh-compact-line1 { margin-bottom: 4px; }

.mh-compact-line2 {
    font-size: 12px;
    color: var(--text-secondary);
}

.mh-compact-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    justify-content: flex-end;
}

.mh-compact-pair {
    max-width: 42%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mh-compact-pair em {
    font-style: normal;
    font-size: 10px;
    text-transform: uppercase;
    color: var(--text-tertiary);
    margin-right: 4px;
}

.mh-compact-arrow {
    color: var(--text-tertiary);
    flex-shrink: 0;
    font-size: 11px;
}

.mh-embed-chequear-hid {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

.mh-compact-more {
    margin-top: 6px;
    border-top: 1px dashed var(--border);
    padding-top: 6px;
}

.mh-compact-actions {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    margin-left: auto;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.mh-compact-actions .mh-compact-resolver[open] {
    flex: 1 1 100%;
    width: 100%;
    margin-top: 6px;
    padding-top: 8px;
    border-top: 1px dashed var(--border);
}

/* Chequear: misma fila compacta que Pendiente IA (sin borde amarillo). */
.mh-chequear-row {
    border: 1px solid var(--border);
    background: var(--surface-2);
    box-shadow: none;
    max-width: none;
    width: 100%;
    margin: 0 0 6px;
}

.mh-chequear-row--alt {
    border-style: dashed;
    opacity: 0.92;
}

.mh-compact-resolver {
    display: inline-block;
    vertical-align: middle;
}

.mh-compact-resolver > summary.mh-btn-resolver-sum {
    list-style: none;
    cursor: pointer;
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--surface-3);
    color: var(--text-secondary);
    text-transform: none;
    letter-spacing: 0;
    margin: 0;
}

.mh-compact-resolver > summary.mh-btn-resolver-sum::-webkit-details-marker {
    display: none;
}

.mh-compact-resolver[open] {
    display: block;
    width: 100%;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed var(--border);
}

.mh-compact-resolver[open] > summary.mh-btn-resolver-sum {
    margin-bottom: 8px;
}

.mh-compact-line2 .mh-compact-resolver[open] {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.mh-compact-line2:has(.mh-compact-resolver[open]) {
    flex-wrap: wrap;
}

.mh-compact-line2:has(.mh-compact-resolver[open]) .mh-compact-actions {
    flex: 1 1 100%;
    margin-left: 0;
    margin-top: 6px;
    padding-top: 8px;
    border-top: 1px dashed var(--border);
}

.mh-compact-more > summary {
    cursor: pointer;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    list-style: none;
    margin-bottom: 6px;
}

.mh-compact-more > summary::-webkit-details-marker { display: none; }

.mh-origen--inline {
    font-size: 11px;
    margin-bottom: 6px;
    line-height: 1.35;
}

.mh-embed-chequear-ev--compact {
    font-size: 11px;
    margin-bottom: 6px;
    color: var(--text-secondary);
    line-height: 1.35;
}

.mh-btn-det--inline {
    margin-left: auto;
    padding: 2px 8px;
    font-size: 10px;
}

.mh-stack-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: none;
    padding-right: 4px;
}

.mh-stack-hint {
    flex-shrink: 0;
    font-size: 11px;
    color: var(--text-muted);
    margin: 0 0 6px;
}

.mh-reubicados-inline {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px dashed var(--border);
}

.mh-layout--split .mh-crm-hallazgos-stack:not(.mh-panel-scroll) {
    max-height: none;
    flex: 1;
    min-height: 0;
    margin-bottom: 0;
}

/* flex-basis 0: mitad fija aunque Chequear tenga mucho contenido */
.mh-layout > .mh-top-row,
.mh-layout > .mh-bottom-row {
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
}

.mh-top-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
    gap: 12px;
    align-items: stretch;
}

.mh-bottom-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    align-items: stretch;
}

@media (max-width: 1280px) {
    .mh-bottom-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
    .mh-top-row,
    .mh-bottom-row { grid-template-columns: 1fr; }
}

.mh-panel {
    padding: 14px 16px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--surface);
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.mh-top-row > .mh-panel,
.mh-bottom-row > .mh-panel {
    height: 100%;
    max-height: 100%;
}

.mh-perfil,
.mh-aprob {
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.12) 0%, rgba(46, 160, 67, 0.1) 100%);
    border-color: rgba(124, 58, 237, 0.35);
}

.mh-perfil {
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 4px;
}

.mh-aprob {
    overflow: hidden;
}

.mh-aprob .mh-crm-block {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    padding-right: 4px;
}

.mh-crm-hallazgos-stack:not(.mh-panel-scroll) {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
    align-items: stretch;
    margin-bottom: 0;
    padding-right: 0;
    overflow: visible;
    max-height: none;
}

.mh-crm-canon-wrap,
.mh-reubicados-block {
    flex-shrink: 0;
}

.mh-perfil-tit {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--purple-text);
    margin-bottom: 8px;
}

.mh-perfil-res {
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 12px;
    white-space: pre-wrap;
    color: var(--text-primary);
}

.mh-tags { display: flex; flex-wrap: wrap; gap: 6px; }

.mh-tag {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 20px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: #7ee787;
}

.mh-tag.proc { color: #c4b5fd; border-color: rgba(163, 113, 247, 0.35); }

.mh-tag.mat { color: #e3b341; border-color: rgba(210, 153, 34, 0.35); }

.mh-tag.mk { color: #79c0ff; border-color: rgba(56, 139, 253, 0.35); }

.mh-section {
    padding: 0;
    min-height: 0;
}

.mh-bottom-row .mh-panel.mh-section {
    display: flex;
    flex-direction: column;
}

.mh-section-title {
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary);
    margin: 0 0 8px;
}

.mh-list-scroll {
    flex: 1;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 8px;
    padding-right: 4px;
}

.mh-list-scroll--compact {
    flex: 1;
    min-height: 0;
    max-height: none;
}

.mh-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    margin-bottom: 10px;
    background: var(--surface-2);
}

.mh-card.conflicto,
.mh-embed-chequear-card {
    border: 2px solid var(--amber);
    background: rgba(210, 153, 34, 0.08);
    box-shadow: 0 2px 12px rgba(210, 153, 34, 0.15);
}

.mh-embed-chequear-card--alt {
    border-style: dashed;
    background: rgba(210, 153, 34, 0.05);
}

.mh-card-readonly { opacity: 0.88; background: var(--surface); }

.mh-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.mh-campo {
    font-size: 12px;
    font-weight: 600;
    color: #c4b5fd;
    display: flex;
    align-items: center;
    gap: 8px;
}

.hcard-badges { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.mh-badge {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--surface-3);
    color: var(--text-secondary);
}

.mh-badge-ft { background: rgba(56, 139, 253, 0.15); color: #79c0ff; }

.mh-badge.conf { background: var(--amber-bg); color: var(--amber-text); }

.mh-estado { text-transform: uppercase; letter-spacing: 0.03em; }

.mh-origen {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 10px;
    line-height: 1.45;
}

.mh-origen strong {
    display: block;
    font-size: 10px;
    text-transform: uppercase;
    color: var(--text-tertiary);
    margin-bottom: 3px;
}

.mh-origen-link { color: #ffa657; word-break: break-all; }

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

.mh-cmp {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 10px;
}

.mh-embed-chequear-cmp { gap: 14px; }

@media (max-width: 560px) {
    .mh-cmp { grid-template-columns: 1fr; }
}

.mh-box {
    padding: 10px 12px;
    border-radius: var(--radius-md);
    background: var(--surface-3);
    font-size: 13px;
    line-height: 1.4;
    word-break: break-word;
    color: var(--text-primary);
}

.mh-box label {
    display: block;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-tertiary);
    margin-bottom: 4px;
}

.mh-box.crm { border-left: 3px solid var(--c-validado); }

.mh-box.ia { border-left: 3px solid #ffa657; }

.mh-alert {
    margin-bottom: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    background: var(--amber-bg);
    border: 1px solid rgba(210, 153, 34, 0.45);
    font-size: 12px;
    color: var(--amber-text);
    line-height: 1.45;
}

.mh-alert strong {
    display: block;
    margin-bottom: 4px;
    font-size: 11px;
    text-transform: uppercase;
}

.mh-evidencia-ro,
.mh-embed-chequear-ev {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    line-height: 1.4;
}

.mh-embed-chequear-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

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

.mh-actions button,
.mh-btn-det,
.mh-btn-val,
.mh-btn-ig,
.mh-btn-an {
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    padding: 7px 14px;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: filter var(--transition), opacity var(--transition);
}

.mh-btn-val { background: var(--c-validado); color: #fff; }

.mh-btn-val:hover { filter: brightness(1.08); }

.mh-btn-ig {
    background: var(--surface-3);
    color: var(--text-secondary);
    border: 1px solid var(--border) !important;
}

.mh-btn-an { background: rgba(124, 58, 237, 0.25); color: #ddd6fe; }

.mh-btn-det {
    background: var(--surface-2);
    color: var(--text-secondary);
    border: 1px solid var(--border) !important;
}

.mh-btn-loading { opacity: 0.55 !important; pointer-events: none; }

.mh-empty {
    padding: 16px;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 13px;
}

.mh-soc-ico { width: 18px; height: 18px; flex-shrink: 0; }

.mh-soc-head.instagram { color: #e1306c; }

.mh-soc-head.facebook { color: #1877f2; }

.mh-soc-head.linkedin { color: #0a66c2; }

.mh-soc-head.youtube { color: #ff0000; }

.mh-soc-head.mercadolibre { color: #3483fa; }

.mh-ia-link {
    display: inline-flex;
    margin-top: 6px;
    font-size: 12px;
    font-weight: 500;
    color: #ffa657;
    text-decoration: none;
    word-break: break-all;
}

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

.mh-val-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 220px;
    overflow-y: auto;
}

.mh-val-item {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-2);
}

.mh-val-label {
    font-size: 10px;
    text-transform: uppercase;
    color: var(--text-tertiary);
    font-weight: 600;
    margin-bottom: 4px;
}

.mh-val-value { font-size: 13px; color: var(--text-primary); line-height: 1.35; }

.mh-aprobados-en-perfil {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid rgba(124, 58, 237, 0.35);
}

.mh-crm-subtit-resumen {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary);
    margin: 0 0 8px;
}

.mh-crm-canon-wrap {
    margin-bottom: 8px;
    padding: 12px;
    border: 1px solid rgba(124, 58, 237, 0.3);
    border-radius: var(--radius-md);
    background: color-mix(in srgb, var(--surface) 85%, transparent);
    overflow-x: auto;
}

.mh-crm-canon-grid {
    width: fit-content;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
    border-collapse: collapse;
    font-size: 12px;
}

.mh-crm-canon-grid th,
.mh-crm-canon-grid td {
    border: 1px solid var(--border);
    padding: 10px 16px;
    vertical-align: top;
    text-align: left;
}

.mh-crm-canon-grid th {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-tertiary);
    background: var(--surface-3);
}

.mh-crm-td-name { font-weight: 600; color: var(--text-primary); white-space: nowrap; }

.mh-crm-td-badge { white-space: nowrap; }

.mh-crm-td-crm { word-break: break-word; color: var(--text-secondary); max-width: 280px; }

.mh-crm-sug-empty { color: var(--text-tertiary); font-style: italic; }

.mh-crm-slot {
    display: inline-block;
    font-size: 10px;
    padding: 3px 8px;
    border-radius: 6px;
    font-weight: 600;
}

.mh-slot-listo { background: var(--green-bg); color: #7ee787; }

.mh-slot-cola { background: var(--amber-bg); color: var(--amber-text); }

.mh-slot-aplicado { background: rgba(56, 139, 253, 0.15); color: #79c0ff; }

.mh-slot-vacio { background: var(--surface-3); color: var(--text-tertiary); }

.mh-crm-canon-grid tbody tr.mh-crm-row-a-validar td {
    background: rgba(46, 160, 67, 0.1);
    border-top: 2px solid rgba(46, 160, 67, 0.45);
}

.mh-crm-canon-grid tbody tr.mh-crm-row-a-validar td:first-child {
    box-shadow: inset 4px 0 0 0 var(--c-validado);
    padding-left: 18px;
}

.mh-crm-empty-msg {
    padding: 12px;
    border-radius: var(--radius-md);
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-secondary);
    text-align: center;
}

.mh-crm-empty-msg--stack { margin: 0; }

.mh-embed-chequear-card {
    width: 100%;
    max-width: min(100%, 720px);
    margin: 0 auto;
    box-sizing: border-box;
}

.mh-crm-hallazgos-stack .mh-embed-chequear-card { margin-bottom: 0; }

.mh-embed-chequear-form {
    margin-top: 8px;
    padding-top: 0;
    border-top: none;
}

.mh-crm-embed-controls { margin-bottom: 8px; }

.mh-crm-embed-lab {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.mh-crm-embed-select,
.mh-crm-embed-input {
    width: 100%;
    box-sizing: border-box;
    padding: 7px 9px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--surface-3);
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
}

.mh-crm-embed-radios {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.mh-crm-card-actions { display: flex; justify-content: flex-end; }

.mh-btn-crm {
    border: none;
    border-radius: var(--radius-md);
    padding: 8px 14px;
    background: var(--c-validado);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.mh-btn-crm-apply:hover { filter: brightness(1.08); }

.mh-reubicados-block { margin-top: 12px; }

.mh-reubicados-hint {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 0 0 8px;
    line-height: 1.4;
}

.mh-embed-chequear-hid { font-weight: 600; letter-spacing: 0.02em; }

/* Paneles operativos (monitoreo) */
.op-panel {
    padding: 14px 16px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--surface);
    min-height: 120px;
}

/* Consumo IA: sección aparte, mismo ancho que cola (col. tablero), debajo del scroll */
.consumo-ia-section {
    grid-column: 1;
    grid-row: 2;
    padding: 12px 24px 16px;
    border-top: 2px solid var(--border);
    background: var(--surface);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.25);
    flex-shrink: 0;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.consumo-ia-heading {
    margin-bottom: 10px;
}

.consumo-ia-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    align-items: stretch;
}

.consumo-ia-panel,
.consumo-ia-tabla {
    min-height: auto;
    min-width: 0;
}

.consumo-ia-panel-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary);
    margin: 0 0 10px;
}

.consumo-ia-hint {
    font-size: 11px;
    color: var(--text-secondary);
    margin: 0 0 10px;
    line-height: 1.4;
}

.consumo-ia-hint code {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    color: var(--text-muted);
}

.consumo-ia-frame {
    display: block;
    width: 100%;
    height: auto;
    min-height: 260px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg);
}

.ia-consumo-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    max-height: 320px;
    overflow-y: auto;
    max-width: 100%;
    width: 100%;
    min-width: 0;
    -webkit-overflow-scrolling: touch;
}

.ia-consumo-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}

.ia-consumo-table th,
.ia-consumo-table td {
    padding: 7px 10px;
    border-bottom: 1px solid var(--border-muted);
    text-align: left;
    white-space: nowrap;
}

.ia-consumo-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--surface-3);
    color: var(--text-tertiary);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.ia-consumo-table td {
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.ia-consumo-table tbody tr:hover td {
    background: rgba(56, 139, 253, 0.06);
}

.ia-consumo-table tr.es-hoy td {
    background: rgba(124, 58, 237, 0.12);
    color: var(--text-primary);
    font-weight: 600;
}

.ia-consumo-table tr.es-hoy td:first-child {
    box-shadow: inset 3px 0 0 var(--accent);
}

.op-log {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11.5px;
    line-height: 1.6;
    color: var(--text-secondary);
    background: #010409;
    border-radius: var(--radius-md);
    padding: 10px;
    overflow: auto;
}

/* ── SCROLLBARS ────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ── RESPONSIVE COMPARTIDO ─────────────────────────────── */
@media (max-width: 1100px) {
    .radar-workspace {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        width: 100%;
        max-width: 100%;
        height: auto;
        overflow-x: hidden;
        overflow-y: visible;
    }

    .monitoreo-page {
        overflow-x: hidden;
        max-width: 100%;
    }

    .monitoreo-page .radar-workspace,
    .monitoreo-page .radar-main {
        max-width: 100%;
        min-width: 0;
    }
    .radar-main { grid-column: 1; grid-row: 1; }
    .consumo-ia-section { grid-column: 1; grid-row: 2; }
    .radar-aside {
        grid-column: 1;
        grid-row: 3;
        border-left: none;
        border-top: 1px solid var(--border);
        height: min(50dvh, 420px);
        min-height: 280px;
    }
    .metrics-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Toggle de tema claro/oscuro (index / monitoreo) */
.radar-theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    flex-shrink: 0;
    transition: var(--transition);
}
.radar-theme-toggle:hover { color: var(--text); }
.radar-theme-toggle svg { width: 20px; height: 20px; }
.radar-theme-toggle .icon-sun { display: none; }
.radar-theme-toggle .icon-moon { display: inline; }
:root[data-theme="light"] .radar-theme-toggle .icon-sun { display: inline; }
:root[data-theme="light"] .radar-theme-toggle .icon-moon { display: none; }

/* Menú móvil (index / monitoreo) — ver js/radar-mobile.js */
.radar-nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    margin-left: 0;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
    color: var(--text);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
}

.radar-nav-backdrop {
    display: none;
    position: fixed;
    top: calc(var(--header-h) + var(--safe-top));
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 250;
    background: rgba(0, 0, 0, 0.55);
}

body.radar-nav-open .radar-nav-backdrop {
    display: block;
}

body.radar-scroll-lock {
    overflow: hidden;
    position: fixed;
    left: 0;
    right: 0;
    width: 100%;
}

body.radar-nav-open {
    touch-action: none;
}

@media (max-width: 768px) {
    html,
    body.radar-body,
    body.ficha-page {
        touch-action: manipulation;
        overscroll-behavior: none;
    }

    body.radar-nav-open .index-workspace,
    body.radar-nav-open .radar-workspace,
    body.radar-nav-open .ficha-wrap {
        touch-action: none;
    }

    body.radar-nav-open .radar-topbar .radar-nav {
        touch-action: pan-y;
        overscroll-behavior: contain;
    }

    input,
    select,
    textarea,
    .search-input,
    .sort-select {
        font-size: 16px !important;
    }

    .radar-topbar {
        padding: var(--safe-top) calc(12px + var(--safe-right)) 0 calc(12px + var(--safe-left));
        gap: 8px;
        min-height: calc(var(--header-h) + var(--safe-top));
    }

    .radar-header {
        gap: 8px;
        height: var(--header-h);
        flex: 1 1 auto;
    }

    .radar-logo span {
        display: none;
    }

    .radar-live-badge {
        font-size: 10px;
    }

    .radar-nav-toggle {
        display: inline-flex;
    }

    .radar-topbar .radar-nav {
        display: flex;
        position: fixed;
        top: calc(var(--header-h) + var(--safe-top));
        right: 0;
        bottom: 0;
        width: min(320px, calc(100vw - var(--safe-left)));
        margin-left: 0;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 14px calc(14px + var(--safe-right)) calc(18px + var(--safe-bottom)) 14px;
        background: var(--surface);
        border-left: 1px solid var(--border);
        box-shadow: var(--shadow-lg);
        z-index: 300;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        transform: translateX(105%);
        transition: transform 220ms ease, visibility 220ms ease;
        visibility: hidden;
        pointer-events: none;
    }

    body.radar-nav-open .radar-topbar .radar-nav {
        transform: translateX(0);
        visibility: visible;
        pointer-events: auto;
    }

    .radar-nav .btn-canal {
        width: 100%;
        justify-content: flex-start;
        min-height: 44px;
        padding: 10px 14px;
        font-size: 14px;
    }

    .radar-nav > span {
        padding: 8px 4px !important;
        white-space: normal !important;
    }

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

    /* Index: scroll de página, lista usable */
    .index-workspace {
        height: auto;
        min-height: calc(100dvh - var(--header-h) - var(--safe-top));
        overflow: visible;
        padding: 12px calc(14px + var(--safe-right)) calc(16px + var(--safe-bottom)) calc(14px + var(--safe-left));
    }

    .index-kpi-strip {
        flex: 0 0 auto;
        max-height: min(42vh, 360px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .index-clientes-panel {
        flex: 1 1 auto;
        min-height: min(58dvh, 560px);
    }

    .index-empresa-grid-scroll {
        min-height: 280px;
    }

    .grid-toolbar-text .search-input {
        max-width: none;
        width: 100%;
    }

    .empresa-card {
        padding: 14px 16px;
    }

    .empresa-card .card-actions .btn-canal,
    .empresa-card .js-open-ficha {
        min-height: 44px;
        padding: 10px 14px;
    }

    /* Monitoreo: ancho viewport, sin scroll horizontal de página */
    .monitoreo-page {
        overflow-x: hidden;
        max-width: 100%;
    }

    .monitoreo-page .radar-topbar,
    .monitoreo-page .radar-workspace,
    .monitoreo-page .radar-main,
    .monitoreo-page .consumo-ia-section,
    .monitoreo-page #section-cola {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }

    .monitoreo-page .radar-workspace {
        grid-template-columns: 1fr;
        height: auto;
        min-height: calc(100dvh - var(--header-h) - var(--safe-top));
        overflow-x: hidden;
        overflow-y: visible;
    }

    .monitoreo-page .radar-main {
        overflow-x: hidden;
        overflow-y: visible;
        padding: 14px calc(14px + var(--safe-right)) 16px calc(14px + var(--safe-left));
    }

    .monitoreo-page .cola-cards-grid {
        grid-template-columns: 1fr;
    }

    .monitoreo-page .consumo-ia-section {
        padding: 12px calc(14px + var(--safe-right)) 16px calc(14px + var(--safe-left));
    }

    .monitoreo-page .hallazgo-header {
        flex-wrap: wrap;
    }

    .monitoreo-page .hallazgo-empresa,
    .monitoreo-page .hallazgo-meta {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    .monitoreo-page .radar-aside {
        height: min(55dvh, 480px);
        min-height: 300px;
    }

    .monitoreo-page #run-status pre {
        max-width: 100%;
        min-width: 0;
        overflow-x: auto;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .monitoreo-page .radar-aside form {
        max-width: 100%;
    }

    .monitoreo-page .radar-select {
        max-width: 100%;
        width: 100%;
    }

    .hallazgo-card .card-actions .btn-canal {
        min-height: 44px;
    }

    /* Modales: pantalla fija, scroll solo dentro del modal */
    .modal-overlay,
    .crm-modal-overlay {
        padding: 0;
        align-items: stretch;
        overflow: hidden;
        backdrop-filter: none;
    }

    body.radar-scroll-lock .modal-overlay.visible,
    body.radar-scroll-lock .crm-modal-overlay.visible {
        position: fixed;
        inset: 0;
        z-index: 500;
    }

    .monitoreo-page .crm-modal-overlay.visible {
        z-index: 620;
    }

    .monitoreo-page .modal-decision-host.visible {
        z-index: 650;
    }

    .monitoreo-page .crm-modal-overlay .crm-modal,
    .monitoreo-page .crm-modal-overlay .analisis-lote-modal {
        display: flex;
        flex-direction: column;
        width: 100%;
        height: 100dvh;
        max-height: 100dvh;
        margin: 0;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .monitoreo-page .crm-modal-overlay .error-modal-body {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .monitoreo-page .consultor-modal .analisis-lote-list,
    .monitoreo-page .analisis-lote-modal .analisis-lote-list {
        max-height: none;
        flex: 1;
        min-height: 120px;
        overflow-y: auto;
    }

    .monitoreo-page .op-mini-btn,
    .monitoreo-page .crm-modal-overlay .btn-action {
        min-height: 44px;
        padding: 10px 14px;
    }

    .modal-ficha-shell {
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
    }

    .modal-ficha-frame {
        flex: 1;
        min-height: 0;
        height: calc(100dvh - 52px - var(--safe-top) - var(--safe-bottom));
    }

    .modal-ficha-head {
        padding: calc(8px + var(--safe-top)) 12px 8px;
    }

    .modal-ficha-open-full,
    .modal-ficha-close {
        min-height: 44px;
        min-width: 44px;
        padding: 10px 14px;
        font-size: 14px;
    }

    .crm-modal {
        max-width: 100%;
        max-height: 100dvh;
        height: 100dvh;
        border-radius: 0;
        margin: 0;
    }

    .modal-decision-iframe-wrap {
        width: 100%;
        max-width: 100%;
        max-height: 100dvh;
        height: 100dvh;
        border-radius: 0;
    }

    .modal-decision-frame {
        height: calc(100dvh - var(--safe-top) - var(--safe-bottom));
        max-height: none;
    }

    .ficha-page.embed-mode .modal-decision-iframe-wrap,
    .ficha-page.embed-mode .modal-decision-frame {
        width: 100%;
        max-height: 100dvh;
        height: calc(100dvh - var(--safe-top) - var(--safe-bottom));
    }

    /* Ficha: pestañas + una sección visible */
    .mh-tabs {
        display: flex;
        flex-wrap: nowrap;
        gap: 6px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding: 10px calc(14px + var(--safe-right)) 8px calc(14px + var(--safe-left));
        border-bottom: 1px solid var(--border);
        background: var(--surface);
        flex-shrink: 0;
        scrollbar-width: none;
    }

    .mh-tabs::-webkit-scrollbar { display: none; }

    .mh-tab {
        flex: 0 0 auto;
        min-height: 40px;
        padding: 8px 12px;
        border: 1px solid var(--border);
        border-radius: 20px;
        background: var(--surface-2);
        color: var(--text-secondary);
        font-family: inherit;
        font-size: 12px;
        font-weight: 500;
        cursor: pointer;
        white-space: nowrap;
    }

    .mh-tab.is-active {
        background: rgba(124, 58, 237, 0.2);
        border-color: rgba(124, 58, 237, 0.5);
        color: var(--text-primary);
    }

    body.ficha-page,
    html.ficha-html-embed {
        height: auto;
        overflow: visible;
    }

    body.ficha-page {
        min-height: 100dvh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    body.ficha-page .modal-hallazgos-root,
    body.ficha-page .ficha-wrap,
    body.ficha-page .content.ficha-wrap {
        overflow: visible;
        flex: none;
        min-height: 0;
    }

    .mh-layout.mh-layout--tabs {
        overflow: visible;
        flex: none;
        padding-bottom: calc(18px + var(--safe-bottom));
    }

    .mh-layout.mh-layout--split {
        display: block;
        grid-template-columns: none;
        overflow: visible;
    }

    .mh-layout.mh-layout--tabs > .mh-top-row,
    .mh-layout.mh-layout--tabs > .mh-bottom-row,
    .mh-layout.mh-layout--split > .mh-main-stack {
        display: contents;
    }

    .mh-layout.mh-layout--tabs .mh-panel,
    .mh-layout.mh-layout--split .mh-panel,
    .mh-layout.mh-layout--split .mh-sidebar,
    .mh-layout.mh-layout--split details.mh-collapsible {
        display: none;
        flex: none;
        min-height: min(65dvh, 640px);
        max-height: none;
        margin-bottom: 0;
        overflow: visible;
    }

    .mh-layout.mh-layout--tabs .mh-panel.mh-panel--active,
    .mh-layout.mh-layout--split .mh-panel.mh-panel--active,
    .mh-layout.mh-layout--split .mh-sidebar.mh-panel--active,
    .mh-layout.mh-layout--split details.mh-collapsible.mh-panel--active {
        display: flex;
    }

    .mh-layout.mh-layout--tabs .mh-panel .mh-list-scroll,
    .mh-layout.mh-layout--tabs .mh-perfil,
    .mh-layout.mh-layout--tabs .mh-aprob .mh-crm-block,
    .mh-layout.mh-layout--split .mh-sidebar-scroll,
    .mh-layout.mh-layout--split .mh-stack-scroll,
    .mh-layout.mh-layout--split .mh-crm-hallazgos-stack {
        flex: 1 1 auto;
        min-height: 200px;
        max-height: min(58dvh, 520px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .mh-top {
        padding: 12px calc(14px + var(--safe-right)) 12px calc(14px + var(--safe-left));
    }

    .mh-close,
    .mh-close-link {
        min-height: 44px;
        padding: 10px 14px;
    }

    .ficha-page .topbar {
        padding: 0 calc(14px + var(--safe-right)) 0 calc(14px + var(--safe-left));
        padding-top: var(--safe-top);
    }

    .ficha-page .run-btn {
        min-height: 44px;
        padding: 10px 12px;
    }

    .mh-crm-canon-grid {
        font-size: 12px;
    }

    .mh-crm-canon-grid th,
    .mh-crm-canon-grid td {
        padding: 8px 6px;
    }
}

@media (min-width: 769px) {
    .mh-tabs {
        display: none;
    }

}

/* Monitoreo: logs largos (Playwright) sin romper layout */
.monitoreo-page .radar-aside .aside-content {
    flex: 1;
    min-height: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

.monitoreo-page .radar-aside #op-log .log-line,
.monitoreo-page .radar-aside #op-log .log-block {
    word-break: break-word;
    overflow-wrap: anywhere;
}

/* Modal cola de decisión (embed) */
body.modal-decision-embed .error-modal-body {
    font-size: 15px;
    line-height: 1.5;
}
body.modal-decision-embed .crm-modal {
    overflow: visible;
}
body.modal-decision-embed .error-modal-body {
    overflow-x: hidden;
    overflow-y: auto;
    max-height: calc(92vh - 56px);
}
.iad-standby-meta {
    margin-bottom: 4px;
}
.iad-standby-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}
.iad-standby-kicker {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.iad-standby-ts {
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}
.iad-standby-id {
    font-size: 20px;
    font-weight: 600;
    line-height: 1.25;
    color: var(--text-primary);
    word-break: break-all;
}
.iad-standby-nombre {
    margin-top: 6px;
    font-size: 15px;
    color: var(--text-secondary);
}
.iad-standby-foot {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    margin-top: 10px;
    font-size: 13px;
    color: var(--text-muted);
}
.iad-standby-foot span::before {
    content: '· ';
    margin-right: 4px;
    opacity: 0.5;
}
.iad-standby-foot span:first-child::before {
    content: '';
    margin: 0;
}
.iad-picker-hint {
    margin: 0 0 4px;
    font-size: 13px;
    color: var(--text-muted);
}
#iad-paneles {
    overflow: visible;
    position: relative;
}

/* Modal cola: buscador de empresas (Vincular / Reasignar) */
.iad-cli-picker {
    position: relative;
}
.iad-cli-picker-list {
    position: absolute;
    z-index: 40;
    left: 0;
    right: 0;
    max-height: 280px;
    overflow-y: auto;
    margin: 4px 0 0;
    padding: 4px 0;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}
.iad-cli-picker-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    font-size: 14px;
    cursor: pointer;
}
.iad-cli-picker-item:hover,
.iad-cli-picker-item:focus {
    background: var(--surface-2);
}
.iad-cli-picker-emp {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.iad-cli-picker-id {
    flex-shrink: 0;
    color: var(--text-muted);
    font-size: 11px;
}
.iad-cli-picker-empty {
    padding: 8px 10px;
    font-size: 12px;
    color: var(--text-muted);
}

/* ============================================================
   FUTURISTIC HUD SEARCH PANEL (INDEX)
   ============================================================ */

.futuristic-hud {
    position: relative;
    width: 100%;
    min-height: calc(100vh - var(--header-h));
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    overflow: hidden;
    background: radial-gradient(circle at 50% 50%, color-mix(in srgb, var(--surface) 50%, transparent) 0%, transparent 70%);
}

.hud-layout {
    display: grid;
    /* Grid 3x3 para rodear el centro */
    grid-template-columns: repeat(3, minmax(320px, 1fr));
    grid-template-rows: auto auto auto;
    gap: 30px;
    width: 100%;
    max-width: 1400px;
    position: relative;
    z-index: 5;
}

.hud-center {
    grid-column: 2 / 3;
    grid-row: 2 / 3;
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* En mobile colapsa a 1 columna */
@media (max-width: 1100px) {
    .hud-layout {
        display: flex;
        flex-direction: column;
    }
    .hud-center {
        order: -1; /* Arriba del todo en mobile */
        margin-bottom: 30px;
    }
}

.search-container {
    width: 100%;
    position: relative;
}

.search-input-wrapper {
    position: relative;
    width: 100%;
    border-radius: 12px;
    background: color-mix(in srgb, var(--surface-2) 60%, transparent);
    border: 1px solid var(--border-md);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5), inset 0 0 10px rgba(249, 115, 22, 0.05);
    overflow: hidden;
    transition: var(--transition);
}

.search-input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 30px rgba(249, 115, 22, 0.2), inset 0 0 15px rgba(249, 115, 22, 0.1);
}

.search-icon {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    color: var(--accent);
    opacity: 0.8;
}

.futuristic-search-input {
    width: 100%;
    background: transparent;
    border: none;
    padding: 20px 20px 20px 60px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 1.2rem;
    color: var(--text-primary);
    outline: none;
}

.futuristic-search-input::placeholder {
    color: var(--text-dim);
}

/* scanline effect on search */
.scanline {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--accent);
    opacity: 0;
    transition: opacity 0.3s;
}

.search-input-wrapper:focus-within .scanline {
    opacity: 0.8;
    animation: scan 2s infinite linear;
}

@keyframes scan {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.search-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    width: 100%;
    background: color-mix(in srgb, var(--surface) 90%, transparent);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    list-style: none;
    max-height: 300px;
    overflow-y: auto;
    z-index: 20;
}

.search-dropdown.hidden {
    display: none;
}

.search-dropdown li {
    padding: 15px 20px;
    cursor: pointer;
    font-family: 'IBM Plex Sans', sans-serif;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-muted);
    transition: background 0.2s;
}

.search-dropdown li:hover {
    background: var(--surface-3);
}

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

.search-dropdown .company-name {
    font-weight: 600;
    color: var(--text);
}

.search-dropdown .company-cuit {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.85rem;
    color: var(--text-dim);
}

/* Core info center */
.hud-core-info {
    margin-top: 30px;
    text-align: center;
    animation: fadeInUp 0.5s forwards;
    width: 100%;
}

.hud-core-info.hidden {
    display: none;
}

.hud-core-info h2 {
    font-family: 'Archivo', sans-serif;
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(to right, var(--text-primary), var(--text-secondary));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 10px;
    line-height: 1.2;
}

.hud-crm-data {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
    font-family: 'IBM Plex Mono', monospace;
    color: var(--accent);
    font-size: 0.95rem;
    background: color-mix(in srgb, var(--accent) 10%, transparent);
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}

/* Grid Cards perimetrales */
.hud-card {
    background: color-mix(in srgb, var(--surface) 70%, transparent);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    animation: fadeInScale 0.4s ease-out forwards;
    opacity: 0;
    transform: scale(0.95);
    height: fit-content;
}

.hud-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, transparent, color-mix(in srgb, var(--surface-3) 20%, transparent));
    pointer-events: none;
}

.hud-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 1px solid var(--border-muted);
    padding-bottom: 12px;
}

.hud-card-title {
    font-family: 'IBM Plex Mono', monospace;
    text-transform: uppercase;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-dim);
    letter-spacing: 0.05em;
}

.hud-card-badge {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

/* Estados badges */
.badge-validado { background: var(--green-bg); color: var(--green-text); }
.badge-pendiente { background: var(--amber-bg); color: var(--amber-text); }
.badge-analisis { background: var(--purple-bg); color: var(--purple-text); }
.badge-ignorado { background: color-mix(in srgb, var(--c-ignorado) 15%, transparent); color: var(--c-ignorado); }
.badge-crm { background: color-mix(in srgb, var(--text-primary) 10%, transparent); color: var(--text-primary); border: 1px solid var(--border); }
.badge-papelera { background: rgba(255, 255, 255, 0.05); color: #888; text-decoration: line-through; border: 1px dashed var(--border); }
.badge-aprobado { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); border: 1px solid var(--accent); }

.hud-card-content {
    font-family: 'IBM Plex Sans', sans-serif;
    max-height: 250px;
    overflow-y: auto;
}

.hud-data-row {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid color-mix(in srgb, var(--border-muted) 50%, transparent);
}

.hud-data-row:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.hud-data-value {
    font-size: 1.05rem;
    color: var(--text-primary);
    word-break: break-word;
    display: block;
}

.hud-data-meta {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-top: 4px;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.hud-source-badge {
    background: var(--surface-2);
    border: 1px solid var(--border-muted);
    padding: 1px 6px;
    border-radius: 4px;
    font-family: 'IBM Plex Mono', monospace;
}

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

@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.hud-card:hover {
    border-color: var(--accent);
    box-shadow: 0 8px 30px rgba(249, 115, 22, 0.15);
    transform: translateY(-2px);
    transition: all 0.3s ease;
}

.hud-card::after {
    content: '';
    position: absolute;
    top: -1px;
    right: -1px;
    width: 20px;
    height: 20px;
    border-top: 2px solid var(--border-md);
    border-right: 2px solid var(--border-md);
    border-top-right-radius: 16px;
    transition: border-color 0.3s;
}

.hud-card:hover::after {
    border-color: var(--accent);
}
