/* Territoria — Notion-style soft light design tokens · base layer · do NOT hardcode hex outside :root */

:root {
  /* Colors — Notion-style soft light */
  --color-bg: #FAFAFA;
  --color-surface: #FFFFFF;
  --color-surface-2: #F4F4F5;
  --color-border: #E4E4E7;
  --color-border-strong: #D4D4D8;
  /* Chrome — paneles de navegación (topbar + sidebar). Azul-gris
     saturado para que SE VEA contra el centro blanco. La primera
     versión (#EEF2F8) era tan sutil que parecía blanco. */
  --color-chrome: #E2E9F3;
  --color-chrome-border: #C8D3E2;
  --color-text: #18181B;
  --color-text-mute: #71717A;
  --color-text-faint: #A1A1AA;
  --color-interactive: #6366F1;
  --color-interactive-hover: #4F46E5;
  --color-success: #16A34A;
  --color-danger: #DC2626;
  --color-warning: #EA580C;

  /* Typography */
  --font-sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.5rem;
  --text-2xl: 2rem;
  --text-3xl: 3rem;
  --leading-tight: 1.2;
  --leading-normal: 1.5;

  /* Spacing scale */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-8: 3rem;

  /* Radii / shadows / transitions */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.12);
  --transition-fast: 120ms ease;
  --transition-base: 200ms ease;

  /* Z-index */
  --z-base: 1;
  --z-elevated: 10;
  --z-modal: 100;
  --z-toast: 200;

  /* === Legacy token aliases — bridge old apple-theme rules to new tokens === */
  --font-system: var(--font-sans);
  --bg-primary: var(--color-bg);
  --bg-secondary: var(--color-surface);
  --bg-elevated: var(--color-surface);
  --bg-sidebar: var(--color-surface);
  --text-primary: var(--color-text);
  --text-secondary: var(--color-text-mute);
  --text-muted: var(--color-text-mute);
  --text-tertiary: var(--color-text-faint);
  --border-color: var(--color-border);
  --border-accent: rgba(99, 102, 241, 0.35);
  --accent-primary: var(--color-interactive);
  --accent-secondary: #8B5CF6;
  --accent-success: var(--color-success);
  --accent-warning: var(--color-warning);
  --accent-danger: var(--color-danger);
  --accent-info: var(--color-interactive);
  --shadow-focus: 0 0 0 4px rgba(99, 102, 241, 0.18);
  --bg-card: var(--color-surface);
  --bg-card-hover: var(--color-surface-2);
  --bg-input: var(--color-bg);
  --bg-subtle: var(--color-surface-2);
  --text-on-accent: #FFFFFF;
  --accent-primary-hover: var(--color-interactive-hover);
  --sidebar-width: 280px;
  --border-color-strong: var(--color-border-strong);

  /* === Section accent colors (hover/active states only) === */
  --section-inicio: var(--color-text);          /* neutro */
  --section-escenarios: var(--color-interactive); /* indigo #6366F1 */
  --section-analisis: #06B6D4;                  /* cyan-500 */
  --section-estrategia: #F59E0B;                /* amber-500 */
  --section-investigacion: #16A34A;             /* green-600 */
  --section-contactos: var(--color-text);       /* neutro */
  --section-salir: var(--color-danger);         /* red #DC2626 */
}

/* === Territoria — Plus Jakarta Sans + JetBrains Mono via Google Fonts (loaded in base.html) ===
   Note: Geist woff2 files remain on disk under /static/fonts/geist/ for rollback,
   but the @font-face blocks were removed in 2026-05-14 nav+font fix.
   Switched from Inter to Plus Jakarta Sans + light Notion-style palette
   on 2026-05-14 (jakarta_light pivot). */

/* === Territoria — baseline reset (tokens layer) === */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--color-interactive); text-decoration: none; }
a:hover { color: var(--color-interactive-hover); }

/* === LEGACY (Apple light theme) — kept for now, scheduled for cleanup in Phase 1 ===
   Component rules below still reference legacy tokens (--bg-primary, --accent-primary, etc.).
   Until P1 rewrites them to consume the Linear-puro tokens above, they will visually
   conflict. This is the intentional Phase 0 "broken-looking but functional" state. */

/* ===== Global placeholder styling ===== */
input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
    opacity: 1;
}

/* ===== Global minimal scrollbar (Apple-style) =====
   Hairline, casi invisible — solo aparece cuando hace falta. */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.20) transparent;
}
*::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
*::-webkit-scrollbar-track {
    background: transparent;
}
*::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.18);
    border-radius: 4px;
    transition: background 0.2s;
}
*::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.32);
}
*::-webkit-scrollbar-corner {
    background: transparent;
}

html {
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-system);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.55;
    letter-spacing: -0.01em;
    display: flex;
    min-height: 100vh;
}

a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: color 0.15s ease;
}

a:hover {
    color: var(--accent-primary-hover);
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* ===== Sidebar — estilo macOS / iOS Settings ===== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow-y: auto;
    box-shadow: 1px 0 0 rgba(0, 0, 0, 0.02);
}

.sidebar .logo {
    padding: 1.5rem 1.2rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar .logo h1 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.02em;
}

.sidebar .logo .logo-img {
    display: block;
    max-width: 100%;
    max-height: 44px;
    height: auto;
    width: auto;
    object-fit: contain;
}

.sidebar .logo .subtitle {
    font-size: 0.72rem;
    color: var(--text-muted);
    display: block;
    margin-top: 0.2rem;
    font-weight: 400;
}

.sidebar ul {
    list-style: none;
    padding: 0.5rem 0.6rem;
    flex: 1;
}

.sidebar ul li a {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 0.7rem;
    color: var(--text-primary);
    font-size: 0.92rem;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
    border-radius: var(--radius-md);
    margin: 0.1rem 0;
}

/* Short labels only show in mobile — desktop uses .nav-label */
.sidebar .nav-label-short { display: none; }

/* Mobile-only menu items (e.g. Salir) — desktop uses sidebar-footer instead */
.sidebar .nav-mobile-only { display: none; }

.sidebar ul li a:hover {
    color: var(--text-primary);
    background: var(--bg-subtle);
    text-decoration: none;
}

.sidebar ul li a.active {
    color: var(--text-on-accent);
    background: var(--accent-primary);
    font-weight: 600;
}

.sidebar ul li a.active:hover {
    background: var(--accent-primary-hover);
}

.nav-icon {
    font-size: 0.9rem;
    width: 1.2rem;
    text-align: center;
}

.sidebar-footer {
    padding: 1rem 1.2rem;
    border-top: 1px solid var(--border-color);
}

.sidebar-footer .version {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ===== Main Content ===== */
.content {
    margin-left: var(--sidebar-width);
    padding: 2rem;
    flex: 1;
    max-width: 1200px;
    width: calc(100% - var(--sidebar-width));
}

/* ===== Page Header ===== */
.page-header {
    position: relative;
    margin-bottom: 2rem;
    /* Reserva espacio a la derecha cuando hay actions absolutas, así el
       título largo no se mete por debajo del botón. */
    padding-right: 220px;
}

/* En pantallas chicas (mobile), liberamos el padding-right y dejamos que
   los botones caigan abajo del título. */
@media (max-width: 720px) {
    .page-header {
        padding-right: 0;
    }
}

/* Las acciones (botón "+ Nuevo X" + "¿Cómo funciona?") flotan a la
   derecha en absolute, así el h1 y el p.page-subtitle siempre stack
   normal abajo (display block default). Esto evita romper los templates
   legacy que tienen <h1> + <p> como hijos directos de .page-header sin
   envolver en un <div>. */
.page-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    position: absolute;
    top: 0;
    right: 0;
}

@media (max-width: 720px) {
    .page-header-actions {
        position: static;
        margin-top: 12px;
        flex-wrap: wrap;
    }
}

.page-header h1 {
    /* H1 con jerarquía clara: 28px / 700 / tracking apretado / line-height
       ajustado. Antes era 1.8rem (28.8px) sin weight ni tracking — se
       leía como un h2. Ahora tiene presencia de título de pantalla.
       El border-left toma el color de la campaña activa (campaign bleed):
       cada workspace tiene su acento visual sutil en cada pantalla. */
    font-size: 1.75rem;       /* 28px */
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    margin-bottom: 0.35rem;
    padding-left: 14px;
    border-left: 3px solid var(--campaign-color, var(--color-interactive));
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 0.9375rem;     /* 15px */
    line-height: 1.5;
    max-width: 64ch;          /* legibilidad — ~64 chars por línea */
    margin: 0;
}

/* ===== Cards — Apple style ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-fast), transform var(--transition-fast);
}
/* Hover lift solo en cards que son links (clickeables) — los cards
   genéricos con formularios o contenido estático adentro NO levitan,
   porque eso da sensación rara cuando uno está tipeando. */
a.card:hover,
.card.is-clickable:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.card h2 {
    font-size: 1.0625rem;     /* 17px — un toque menos para no competir con H1 */
    font-weight: 600;
    line-height: 1.35;
    letter-spacing: -0.01em;
    color: var(--text-primary);
    margin-bottom: 1rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid var(--border-color);
    letter-spacing: -0.01em;
}

.card h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.card-info {
    border-color: var(--accent-info);
    background: rgba(90, 200, 250, 0.06);
}

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

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.2rem;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.stat-card:hover {
    border-color: var(--border-color-strong);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent-primary);
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 0.3rem;
}

.stat-icon {
    position: absolute;
    top: 0.8rem;
    right: 1rem;
    font-size: 1.5rem;
    opacity: 0.3;
    color: var(--text-muted);
}

/* ===== Dashboard Grid ===== */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

/* ===== Tables ===== */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 0.6rem 0.8rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.data-table td {
    font-size: 0.9rem;
}

.data-table tbody tr:hover {
    background: rgba(79, 195, 247, 0.03);
}

/* ===== Badges ===== */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-electoral { background: rgba(99, 102, 241, 0.12); color: #4f46e5; }
.badge-encuesta { background: rgba(0, 122, 255, 0.12); color: var(--accent-primary); }
.badge-marketing { background: rgba(245, 158, 11, 0.12); color: #d97706; }
.badge-news { background: rgba(6, 182, 212, 0.12); color: #0891b2; }
.badge-service { background: rgba(34, 197, 94, 0.12); color: #16a34a; }
.badge-custom { background: rgba(107, 114, 128, 0.12); color: #4b5563; }

.reaction-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
}

.reaction-positiva { background: rgba(102, 187, 106, 0.2); color: #16a34a; }
.reaction-neutral { background: rgba(255, 167, 38, 0.15); color: #c2410c; }
.reaction-neutra { background: rgba(255, 167, 38, 0.15); color: #c2410c; }
.reaction-negativa { background: rgba(239, 83, 80, 0.2); color: #dc2626; }
.reaction-mixta { background: rgba(124, 77, 255, 0.2); color: #6d28d9; }

/* ===== Forms ===== */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.4rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="search"],
select,
textarea {
    width: 100%;
    padding: 0.6rem 0.85rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color-strong);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.92rem;
    font-family: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-focus);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

select {
    cursor: pointer;
    appearance: auto;
}

/* ===== Checkboxes ===== */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.7rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: border-color 0.2s;
}

.checkbox-label:hover {
    border-color: var(--accent-primary);
}

.checkbox-label input[type="checkbox"] {
    accent-color: var(--accent-primary);
    width: 1rem;
    height: 1rem;
}

.checkbox-label span {
    font-size: 0.9rem;
    color: var(--text-primary);
}

.checkbox-label small {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-left: auto;
}

/* ===== Buttons — Apple style ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.55rem 1.2rem;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-size: 0.92rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease,
                box-shadow 0.15s ease, transform 0.05s ease;
    text-decoration: none;
    font-family: inherit;
    letter-spacing: -0.01em;
}

.btn:hover {
    text-decoration: none;
}

.btn:active {
    transform: scale(0.98);
}

.btn:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
}

.btn-primary {
    background: var(--accent-primary);
    color: #FFFFFF;
    border-color: var(--accent-primary);
    box-shadow: 0 1px 2px rgba(99, 102, 241, 0.18);
}

.btn-primary:hover {
    background: var(--accent-primary-hover);
    border-color: var(--accent-primary-hover);
    color: #FFFFFF;
    box-shadow: 0 2px 6px rgba(99, 102, 241, 0.25);
}

/* Disabled state para todos los .btn — feedback visual consistente cuando
   el botón está en proceso (Testear mensajes, Analizar el caso, etc). */
.btn:disabled,
.btn[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;
}
.btn-primary:disabled {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--border-color-strong);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    color: var(--text-primary);
    background: var(--bg-card-hover);
    border-color: var(--border-color-strong);
}

.btn-lg {
    padding: 0.7rem 2rem;
    font-size: 1rem;
}

.btn-sm {
    padding: 0.25rem 0.6rem;
    font-size: 0.8rem;
}

/* ===== Filters Section ===== */
.filters-section {
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.8rem;
}

.filters-section summary {
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    padding: 0.3rem 0;
}

.filters-section summary:hover {
    color: var(--text-primary);
}

.filters-section[open] summary {
    margin-bottom: 0.8rem;
}

/* ===== Simulation Layout ===== */
.simulation-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: start;
}

.simulation-form-card {
    position: sticky;
    top: 2rem;
}

.simulation-results-area {
    min-height: 200px;
}

/* ===== Results ===== */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.results-header h2 {
    margin: 0;
    border: none;
    padding: 0;
}

.results-meta {
    display: flex;
    gap: 0.8rem;
    align-items: center;
}

.meta-item {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.meta-item.link {
    color: var(--accent-primary);
}

.results-query {
    background: var(--bg-input);
    padding: 0.8rem 1rem;
    border-radius: 6px;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    border-left: 3px solid var(--accent-primary);
}

.results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.result-card {
    margin-bottom: 1rem;
}

.result-summary {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 0.75rem;
    line-height: 1.5;
}

/* ===== Intensity Gauge ===== */
.intensity-gauge {
    margin: 1rem 0;
}

.gauge-bar {
    height: 12px;
    background: var(--bg-input);
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.gauge-fill {
    height: 100%;
    border-radius: 6px;
    background: linear-gradient(90deg, var(--accent-success), var(--accent-warning), var(--accent-danger));
    transition: width 0.5s ease;
}

.gauge-value {
    text-align: center;
    color: var(--text-primary);
    font-size: 1.2rem;
    font-weight: 600;
    margin-top: 0.5rem;
}

.gauge-labels {
    display: flex;
    justify-content: space-between;
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-top: 0.2rem;
}

.intensity-gauge.small .gauge-bar {
    height: 8px;
}

.intensity-gauge.small .gauge-value {
    font-size: 0.85rem;
}

/* ===== Stat Results Grid ===== */
.stat-results-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.8rem;
    margin-bottom: 1rem;
}

.stat-item {
    text-align: center;
    padding: 0.6rem;
    background: var(--bg-input);
    border-radius: 6px;
}

.stat-item-value {
    display: block;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--accent-primary);
}

.stat-item-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

/* ===== Loading / HTMX Indicator ===== */
.htmx-indicator {
    display: none;
    text-align: center;
    padding: 2rem;
}

.htmx-indicator p {
    color: var(--text-secondary);
    margin-top: 0.8rem;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: block;
}

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

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

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-muted);
    background: var(--color-surface);
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-md);
}

.empty-state p {
    margin-bottom: 0.8rem;
}

/* Ícono lucide centrado arriba — el template puede agregar un
   <i data-lucide="..." class="empty-state-icon"></i> al principio.
   Si no lo pone, el empty state sigue funcionando igual que antes. */
.empty-state-icon {
    width: 48px;
    height: 48px;
    color: var(--color-text-mute);
    margin: 0 auto 14px;
    display: block;
    stroke-width: 1.5;
    opacity: 0.6;
}

.empty-state-title {
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--color-text);
    margin: 0 0 6px;
}

.empty-state.small {
    padding: 1.2rem;
}
.empty-state.small .empty-state-icon { width: 32px; height: 32px; margin-bottom: 8px; }

.note {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-style: italic;
    margin-top: 0.5rem;
}

/* ===== Citizen ===== */
.search-card {
    max-width: 500px;
}

.search-input-group {
    display: flex;
    gap: 0.5rem;
}

.search-input-group input {
    flex: 1;
}

.citizen-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.info-list {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.4rem 1rem;
    font-size: 0.9rem;
}

.info-list dt {
    color: var(--text-muted);
    font-weight: 500;
}

.info-list dd {
    color: var(--text-primary);
}

.info-list dd small {
    color: var(--text-muted);
}

.archetype-badge {
    display: inline-block;
    padding: 0.4rem 0.8rem;
    background: rgba(124, 77, 255, 0.15);
    color: #6d28d9;
    border-radius: 6px;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.8rem;
}

.dimensions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
}

.dimension-card {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 1rem;
}

.dimension-card h3 {
    font-size: 0.9rem;
    color: var(--accent-primary);
    margin-bottom: 0.6rem;
}

/* Layout APILADO: etiqueta arriba (chica, muted) + valor abajo a ancho completo.
   Reemplaza el viejo "etiqueta | valor" lado a lado, que en tarjetas angostas
   exprimía el valor a una columna finita y rompía los valores largos letra por
   letra (ej. "centro_izquierda"). Apilado, cada valor usa todo el ancho de la
   tarjeta y nunca se corta. */
.dimension-list {
    display: block;
    font-size: 0.8rem;
    min-width: 0;
}

.dimension-list dt {
    color: var(--text-muted);
    font-size: 0.72rem;
    line-height: 1.25;
    margin-top: 0.5rem;
}

.dimension-list dt:first-child {
    margin-top: 0;
}

.dimension-list dd {
    color: var(--text-primary);
    margin: 0.1rem 0 0 0;
    line-height: 1.3;
    overflow-wrap: break-word;
}

/* Las tarjetas deben poder encogerse para entrar en la grilla (min-width:auto
   por defecto las dejaba estirar la página). */
.dimension-card { min-width: 0; }
.prob-bar-container { min-width: 0; }

/* ===== Probability Bars ===== */
.prob-bar-container {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.prob-label {
    min-width: 140px;
    font-size: 0.85em;
    color: var(--text-secondary);
}

.prob-bar-bg {
    flex: 1;
    height: 16px;
    background: var(--bg-subtle);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.prob-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #4fc3f7, #0288d1);
    border-radius: 4px;
    transition: width 0.3s;
}

/* Monte Carlo 95% confidence band — hatched overlay over the bar bg */
.prob-bar-uncertainty {
    position: absolute;
    top: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        45deg,
        rgba(255, 255, 255, 0.10),
        rgba(255, 255, 255, 0.10) 4px,
        rgba(255, 255, 255, 0.25) 4px,
        rgba(255, 255, 255, 0.25) 8px
    );
    border-left: 1px solid rgba(255, 255, 255, 0.35);
    border-right: 1px solid rgba(255, 255, 255, 0.35);
    pointer-events: auto;
    cursor: help;
}

.survey-stddev {
    font-size: 0.75em;
    color: var(--text-secondary, #888);
    font-weight: normal;
    margin-left: 2px;
}

.prob-value {
    min-width: 40px;
    text-align: right;
    font-size: 0.85em;
    color: var(--text-primary);
}

/* Make dimension list span full width when it contains prob bars */
.dimension-list dd .prob-bar-container:first-child {
    margin-top: 4px;
}

.dimension-list dd .prob-bar-container .prob-label:empty {
    display: none;
}

/* ===== Religion Card (Dimensiones del Perfil) =====
   Inferencia religiosa CONICET — no es certeza individual, solo un proxy
   estadístico. Paleta alineada a los acentos globales (dark azul noche). */
.dimension-card.religion-card h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dimension-card.religion-card .dim-icon {
    font-size: 1.15em;
    line-height: 1;
}

.dimension-card.religion-card .confidence-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-left: auto;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.3) inset;
}
.dimension-card.religion-card .confidence-alta     { background: var(--accent-success); }
.dimension-card.religion-card .confidence-moderada { background: var(--accent-warning); }
.dimension-card.religion-card .confidence-baja     { background: var(--accent-danger); }

.religion-badge {
    display: inline-block;
    padding: 0.35rem 0.7rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    line-height: 1.25;
    border: 1px solid transparent;
}
.religion-badge.religion-catolico_practicante {
    background: rgba(217, 119, 6, 0.18);
    color: #b45309;
    border-color: rgba(217, 119, 6, 0.30);
}
.religion-badge.religion-catolico_nominal {
    background: rgba(147, 51, 234, 0.15);
    color: #7c3aed;
    border-color: rgba(147, 51, 234, 0.28);
}
.religion-badge.religion-evangelico {
    background: rgba(22, 163, 74, 0.18);
    color: #16a34a;
    border-color: rgba(22, 163, 74, 0.30);
}
.religion-badge.religion-sin_religion {
    background: rgba(100, 116, 139, 0.18);
    color: #475569;
    border-color: rgba(100, 116, 139, 0.28);
}
.religion-badge.religion-otras {
    background: rgba(14, 165, 233, 0.18);
    color: #0284c7;
    border-color: rgba(14, 165, 233, 0.30);
}
.religion-badge.religion-unclassified {
    background: rgba(100, 116, 139, 0.10);
    color: var(--text-muted);
    font-style: italic;
    border-color: rgba(100, 116, 139, 0.20);
}

.religiosity-label {
    display: inline-block;
    padding: 0.18rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
    line-height: 1.3;
}
.religiosity-label.religiosity-baja     { background: rgba(100, 116, 139, 0.15); color: #475569; }
.religiosity-label.religiosity-media    { background: rgba(0, 122, 255, 0.15); color: #0066d6; }
.religiosity-label.religiosity-alta     { background: rgba(217, 119, 6, 0.15);  color: #b45309; }
.religiosity-label.religiosity-muy_alta { background: rgba(220, 38, 38, 0.15);  color: #dc2626; }

.religion-disclaimer {
    margin-top: 0.8rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
    line-height: 1.4;
}

/* ===== Reaction Result ===== */
.reaction-result-card {
    background: var(--bg-card);
    border: 1px solid var(--border-accent);
    border-radius: 8px;
    padding: 1.2rem;
    margin-top: 1rem;
}

.reaction-result-card h3 {
    color: var(--text-primary);
    font-size: 1rem;
    margin-bottom: 0.8rem;
}

.reaction-scenario {
    background: var(--bg-input);
    padding: 0.6rem 0.8rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    border-left: 3px solid var(--accent-secondary);
}

.reaction-main {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.reaction-main .intensity-gauge {
    flex: 1;
    margin: 0;
}

.reaction-narrative {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--bg-input);
    border-radius: 6px;
}

.reaction-narrative h4 {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.reaction-narrative p {
    color: var(--text-primary);
    font-size: 0.9rem;
    line-height: 1.6;
}

/* --- Reaction: Profile Summary Grid --- */
.reaction-profile-card,
.reaction-analysis-card {
    margin-top: 1rem;
}

.profile-summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1.2rem;
    margin-top: 1rem;
}

@media (max-width: 900px) {
    .profile-summary-grid { grid-template-columns: 1fr; }
}

.ps-col {}

.ps-list {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 10px;
    font-size: 0.85em;
}

.ps-list dt {
    color: var(--text-muted);
    font-weight: normal;
}

.ps-list dd {
    color: var(--text-primary);
    margin: 0;
}

/* --- Reaction: LLM Response Formatting --- */
.llm-response {
    color: var(--text-primary);
    font-size: 0.92rem;
    line-height: 1.7;
    padding: 1rem;
    background: var(--bg-input);
    border-radius: 6px;
    border-left: 3px solid var(--accent-primary);
}

.llm-response h3,
.llm-response h4,
.llm-response h5 {
    color: var(--accent-secondary);
    margin-top: 1rem;
    margin-bottom: 0.4rem;
}

.llm-response h3 { font-size: 1.05em; }
.llm-response h4 { font-size: 0.95em; }
.llm-response h5 { font-size: 0.88em; }

.llm-response p {
    margin-bottom: 0.6rem;
}

.llm-response li {
    margin-left: 1.2rem;
    margin-bottom: 0.3rem;
    list-style: disc;
}

.llm-response strong {
    color: var(--text-primary);
}

/* --- Simulation Progress Animation --- */
.simulation-progress {
    text-align: left;
    padding: 2rem;
    max-width: 500px;
}

.progress-animation {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 1.5rem;
}

.progress-icon {
    font-size: 2rem;
    animation: swim 2s ease-in-out infinite;
}

@keyframes swim {
    0%, 100% { transform: translateX(0) rotate(0deg); }
    25% { transform: translateX(8px) rotate(5deg); }
    75% { transform: translateX(-8px) rotate(-5deg); }
}

.progress-bar-track {
    flex: 1;
    height: 6px;
    background: var(--bg-input);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-animated {
    height: 100%;
    width: 30%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 4px;
    animation: progress-slide 2s ease-in-out infinite;
}

@keyframes progress-slide {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(400%); }
}

.progress-title {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.progress-step-list {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem 0;
}

.progress-step-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    opacity: 0.75;
    transition: all 0.5s ease;
}

.progress-step-list li.step-active {
    color: var(--accent-secondary);
    opacity: 1;
    font-weight: 500;
}

.progress-step-list li.step-done {
    color: #16a34a;
    opacity: 0.8;
}

.step-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
    transition: all 0.5s ease;
}

.step-active .step-dot {
    background: var(--accent-secondary);
    box-shadow: 0 0 8px var(--accent-secondary);
    animation: pulse-dot 1.5s ease-in-out infinite;
}

.step-done .step-dot {
    background: #66bb6a;
}

@keyframes pulse-dot {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.4); }
}

.progress-note {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
}

/* ===== Live Simulation Progress ===== */
.simulation-live { padding: 1rem 0; }

.live-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.live-timer {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--accent-secondary);
    font-family: monospace;
}

.timer-icon { margin-right: 8px; }

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

.live-progress-bar {
    height: 8px;
    background: var(--bg-input);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 4px;
}

.live-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 4px;
    transition: width 0.5s ease;
}

.live-progress-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.live-feed {
    max-height: 500px;
    overflow-y: auto;
}

.live-response-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px 14px;
    margin-bottom: 8px;
    animation: fadeSlideIn 0.4s ease;
}

@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

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

.lr-label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.lr-count {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.lr-body {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}

.lr-emotion {
    color: var(--accent-secondary);
    font-size: 0.85rem;
}

.lr-intensity {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.lr-reasoning {
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.4;
    font-style: italic;
}

/* ===== Map ===== */
.map-container {
    width: 100%;
    height: 450px;
    min-height: 250px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-input);
    margin-bottom: 16px;
}

.map-legend {
    /* Sólida sobre el basemap claro — fondo blanco con sombra Apple
       para flotar sobre el mapa sin perder contraste. */
    background: #ffffff;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.82em;
    line-height: 1.7;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
}

.map-legend strong {
    display: block;
    margin-bottom: 4px;
    color: var(--text-primary);
}
.map-legend .map-legend-pop {
    background: rgba(0, 122, 255, 0.2);
}
.map-legend .nse-legend-row,
.map-legend .nse-legend-desc {
    color: #475569;
}
.map-legend .map-legend-single-value {
    background: rgba(0, 0, 0, 0.15);
    border-color: rgba(0, 0, 0, 0.3);
}
.map-legend .map-legend-single-value .sv-label {
    color: #475569;
}
.map-legend .map-legend-labels {
    color: #475569;
}

.map-popup {
    font-size: 0.9em;
    line-height: 1.6;
    color: #222;
}

.map-popup strong {
    color: #111;
}

/* Override Leaflet popup for dark theme */
.leaflet-popup-content-wrapper {
    border-radius: 6px;
}

.leaflet-container {
    background: var(--bg-input);
}

/* ===== Layer Selector Pills ===== */
.layer-pills { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.layer-pill {
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    font-size: 0.82rem;
    transition: all 0.2s;
    background: var(--bg-card);
    user-select: none;
}
.layer-pill.active {
    background: var(--accent-primary, #2563eb);
    color: white;
    border-color: var(--accent-primary, #2563eb);
}
.layer-pill:hover:not(.active) { background: rgba(0, 122, 255, 0.08); }

/* ===== Map Legend (inline) ===== */
.map-legend-inline { font-size: 0.8rem; color: var(--text-secondary); }
.map-legend-pop {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.6rem;
    margin: 0.35rem 0;
    padding: 0.3rem 0.55rem;
    background: rgba(0, 122, 255, 0.12);
    border-left: 3px solid var(--accent-primary);
    border-radius: 4px;
    font-size: 0.8rem;
}
.map-legend-pop .pop-label {
    font-weight: 600;
    color: var(--text-primary);
}
.map-legend-pop .pop-value {
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}
.map-legend-gradient {
    height: 12px; border-radius: 6px; margin: 0.25rem 0;
}
.map-legend-labels { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--text-secondary); }
.map-legend-labels .lbl-min { font-weight: 500; }
.map-legend-labels .lbl-max { font-weight: 500; }

/* NSE category legend with descriptions */
.nse-legend {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin-top: 0.5rem;
}
.nse-legend-row {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.78rem;
    line-height: 1.35;
    color: var(--text-secondary);
}
.nse-legend-row strong {
    min-width: 44px;
    color: var(--text-primary);
    font-weight: 700;
}
.nse-legend-dot {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 4px;
    flex-shrink: 0;
    margin-top: 2px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
}
.nse-legend-desc {
    color: var(--text-secondary);
    font-size: 0.76rem;
}

.map-legend-single-value {
    margin-top: 0.4rem;
    padding: 0.4rem 0.7rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    text-align: center;
    font-size: 0.82rem;
}
.map-legend-single-value .sv-label {
    color: var(--text-secondary);
}
.map-legend-single-value .sv-value {
    color: var(--text-primary);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.map-legend-items { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.map-legend-item { display: flex; align-items: center; gap: 0.3rem; font-size: 0.8rem; }
.map-legend-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }

/* Map tooltip styling */
.map-tooltip {
    font-size: 0.85rem;
    line-height: 1.5;
    padding: 6px 10px;
}

/* ===== Pulse Sources Panel ===== */
.pulse-panel { margin-top: 1rem; }
.pulse-panel-header { display: flex; justify-content: space-between; align-items: center; }
.pulse-source-item { padding: 0.5rem 0; border-bottom: 1px solid #e5e7eb; }
.pulse-source-item a { color: var(--accent-primary); text-decoration: none; font-weight: 500; }
.pulse-source-item a:hover { text-decoration: underline; }
.pulse-source-domain { font-size: 0.75rem; color: #9ca3af; }
.pulse-source-snippet { font-size: 0.82rem; color: #6b7280; margin-top: 0.25rem; }
.tab-btn { padding: 0.35rem 0.75rem; border: 1px solid var(--border-color); border-radius: 4px; background: var(--bg-card); cursor: pointer; margin-right: 0.5rem; }
.tab-btn.active { background: var(--accent-primary); color: white; border-color: var(--accent-primary); }
.pulse-pagination { display: flex; justify-content: center; gap: 0.5rem; margin-top: 0.75rem; }
.pulse-pagination button { padding: 0.25rem 0.6rem; border: 1px solid var(--border-color); border-radius: 4px; background: var(--bg-card); cursor: pointer; }
.pulse-pagination button:disabled { opacity: 0.4; cursor: default; }

/* ===== Sidebar user info / logout ===== */
.sidebar-footer .user-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    padding: 0.5rem 0.6rem;
    margin-bottom: 0.5rem;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 6px;
    font-size: 0.8rem;
}
.sidebar-footer .user-name {
    color: #64748b;
    font-weight: 500;
}
.sidebar-footer .logout-link {
    color: #dc2626;
    font-size: 0.75rem;
    font-weight: 600;
    text-decoration: none;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    transition: background 0.15s;
}
.sidebar-footer .logout-link:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #dc2626;
}

/* ===== Strategy / message tester form ===== */
.strategy-form { max-width: 980px; }
.strategy-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1.25rem 1.4rem;
    margin-bottom: 1.25rem;
}
.strategy-section h2 {
    font-size: 1.05rem;
    margin: 0 0 0.25rem 0;
    color: var(--text-primary);
    border-bottom: none;
    padding-bottom: 0;
}
.strategy-section .section-hint {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin: 0 0 1rem 0;
}

/* Message-type cards */
.msg-type-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 0.75rem;
}
.msg-type-card {
    display: block;
    cursor: pointer;
    position: relative;
}
.msg-type-card input[type="radio"] {
    position: absolute; opacity: 0; pointer-events: none;
}
.msg-type-card-inner {
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 0.85rem 1rem;
    background: rgba(0, 0, 0, 0.02);
    transition: all 0.15s ease;
    height: 100%;
}
.msg-type-card:hover .msg-type-card-inner {
    border-color: var(--accent-primary);
    background: rgba(0, 122, 255, 0.08);
}
.msg-type-card.selected .msg-type-card-inner {
    border-color: var(--accent-primary);
    background: rgba(0, 122, 255, 0.14);
    box-shadow: 0 1px 3px rgba(0, 122, 255, 0.25);
}
.msg-type-label {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 0.15rem;
}
.level-tag {
    display: inline-block;
    background: rgba(0, 122, 255, 0.14);
    color: var(--accent-primary);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 0.12rem 0.45rem;
    border-radius: 4px;
    margin-left: 0.4rem;
    vertical-align: middle;
}
.level-tag-l3 {
    background: rgba(245, 158, 11, 0.2);
    color: #b45309;
}
.msg-type-card.selected .msg-type-label { color: var(--accent-primary); }
.msg-type-short {
    font-size: 0.8rem;
    color: var(--text-primary);
    font-style: italic;
    margin-bottom: 0.5rem;
}
.msg-type-desc {
    font-size: 0.82rem;
    line-height: 1.4;
    color: var(--text-primary);
}

/* Messages stack */
.messages-stack { display: flex; flex-direction: column; gap: 0.85rem; }
.message-input-wrap { position: relative; }
.message-input-wrap label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    font-size: 0.88rem;
    color: var(--text-primary);
    margin-bottom: 0.3rem;
}
.msg-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent-primary);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 600;
}
.msg-optional {
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 400;
    font-style: italic;
}
.message-input-wrap textarea {
    width: 100%;
    padding: 0.55rem 0.7rem;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1.4;
    resize: vertical;
    box-sizing: border-box;
}
.message-input-wrap textarea:focus {
    border-color: var(--accent-primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.2);
}
.msg-char-count {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-align: right;
    margin-top: 0.15rem;
}

/* Population filters */
.pop-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 0.9rem;
    margin-bottom: 0.85rem;
}
.pop-grid .form-group { margin: 0; }
.pop-grid select {
    width: 100%;
    padding: 0.45rem 0.6rem;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9rem;
}
.advanced-filters {
    background: rgba(0, 0, 0, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
}
.advanced-filters summary {
    cursor: pointer;
    font-weight: 500;
    font-size: 0.88rem;
    color: var(--text-primary);
    padding: 0.2rem 0;
}
.advanced-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-top: 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px dashed var(--border-color);
}
.advanced-grid .form-group { margin: 0; }
.advanced-grid input,
.advanced-grid select {
    width: 100%;
    padding: 0.4rem 0.55rem;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.88rem;
    box-sizing: border-box;
}

/* Submit row */
.strategy-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.5rem;
}
.btn.btn-lg {
    padding: 0.7rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 600;
}
.strategy-status {
    color: #6b7280;
    font-size: 0.85rem;
}
.strategy-result { margin-top: 1.25rem; }

/* ===== Strategy Live Focus Group (Stage 3) ===== */
.focus-group {
    background: var(--bg-card);
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 1.1rem 1.25rem 1.25rem;
    margin-top: 1rem;
    max-width: 1100px;
    box-shadow: var(--shadow-md);
}

.fg-topbar {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    margin-bottom: 0.85rem;
}
.fg-spinner {
    width: 28px; height: 28px;
    border: 3px solid #dbeafe;
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: fg-spin 0.9s linear infinite;
    flex-shrink: 0;
}
@keyframes fg-spin { to { transform: rotate(360deg); } }
.fg-title-block { flex: 1; }
.fg-title { font-weight: 700; color: var(--text-primary); font-size: 1rem; }
.fg-sub { font-size: 0.82rem; color: #64748b; margin-top: 0.1rem; }
.fg-counter {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.fg-counter .fg-done { color: var(--accent-primary); font-size: 1.3rem; }
.fg-counter .fg-sep { color: #64748b; margin: 0 0.15rem; }
.fg-counter .fg-total { color: #64748b; }

.fg-bar-wrap {
    background: #eff2f7;
    border-radius: 999px;
    height: 8px;
    overflow: hidden;
    margin-bottom: 1.2rem;
}
.fg-bar {
    background: linear-gradient(90deg, var(--accent-primary), #5AC8FA, var(--accent-success));
    height: 100%;
    border-radius: 999px;
    transition: width 0.4s ease;
}

.fg-main {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}
@media (max-width: 820px) {
    .fg-main { grid-template-columns: 1fr; }
}

/* ----- Tallies (left column) ----- */
.fg-tallies {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.tally {
    background: rgba(0, 0, 0, 0.06);
    border: 1px solid #e2e8f0;
    border-left: 4px solid var(--msg-color, #2563eb);
    border-radius: 8px;
    padding: 0.65rem 0.85rem;
}
.tally-head {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin-bottom: 0.45rem;
}
.tally-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px; height: 22px;
    border-radius: 50%;
    color: #fff;
    font-size: 0.78rem;
    font-weight: 700;
    flex-shrink: 0;
}
.tally-text {
    font-size: 0.85rem;
    color: #334155;
    line-height: 1.35;
}
.tally-bar-wrap {
    background: #e5e7eb;
    border-radius: 999px;
    height: 6px;
    overflow: hidden;
    margin-bottom: 0.35rem;
}
.tally-bar {
    background: var(--msg-color, #2563eb);
    height: 100%;
    transition: width 0.5s ease-out;
    border-radius: 999px;
}
.tally-stats {
    font-size: 0.78rem;
    color: #64748b;
    font-variant-numeric: tabular-nums;
}
.tally-stats .tally-wins,
.tally-stats .tally-score,
.tally-stats .tally-action {
    color: var(--text-primary);
    font-weight: 600;
}

/* ----- Live feed (right column) ----- */
.fg-feed-wrap {
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.fg-feed-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #64748b;
    font-weight: 700;
    margin-bottom: 0.5rem;
}
.fg-feed {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    max-height: 520px;
    overflow-y: auto;
    padding-right: 0.3rem;
}
.fg-feed-empty {
    color: #475569;
    font-style: italic;
    font-size: 0.85rem;
    padding: 1rem 0;
    text-align: center;
}

.fg-card {
    background: var(--bg-card);
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
    transition: transform 0.35s ease, opacity 0.35s ease;
    opacity: 1;
    transform: translateX(0);
}
.fg-card-enter {
    opacity: 0;
    transform: translateX(20px);
}
.fg-card-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.3rem;
}
.fg-card-label {
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--text-primary);
}
.fg-card-size {
    font-size: 0.7rem;
    color: #475569;
    font-variant-numeric: tabular-nums;
}
.fg-card-vote {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}
.fg-card-voted-for {
    display: inline-block;
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.15rem 0.55rem;
    border-radius: 4px;
    letter-spacing: 0.02em;
}
.fg-card-score {
    font-size: 0.8rem;
    color: #475569;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.fg-card-quote {
    color: #334155;
    font-size: 0.83rem;
    line-height: 1.4;
    font-style: italic;
    padding-left: 0.55rem;
    border-left: 2px solid #e5e7eb;
}

/* ===== Strategy results page ===== */
.inline-dl { display: grid; grid-template-columns: auto 1fr; gap: 0.4rem 0.75rem; margin: 0; font-size: 0.88rem; }
.inline-dl dt { font-weight: 600; color: #475569; }
.inline-dl dd { margin: 0; color: var(--text-primary); }

/* Winner card — dark-mode friendly. Antes el fondo era verde pastel
   casi blanco (#ecfdf5 → #d1fae5) con texto también verde pastel, lo
   que hacía ilegible el contenido sobre la UI dark. Ahora: fondo
   tinteado semi-transparente sobre el bg del card, borde verde
   brillante, y texto con el color principal de la UI. */
.winner-card {
    background: linear-gradient(135deg,
        rgba(34, 197, 94, 0.10) 0%,
        rgba(34, 197, 94, 0.18) 100%);
    border: 1px solid #22c55e;
    box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.25);
    padding: 1.5rem 1.75rem;
    margin-bottom: 1.25rem;
    position: relative;
    color: var(--text-primary, #e5e7eb);
}
.winner-badge {
    display: inline-block;
    background: #22c55e;
    color: #0b1220;   /* dark text for contrast on bright green */
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    padding: 0.25rem 0.65rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
}
.winner-msg-number {
    font-size: 0.85rem;
    color: #16a34a;
    font-weight: 700;
    margin-bottom: 0.4rem;
    letter-spacing: 0.03em;
}
.winner-text {
    font-size: 1.1rem;
    line-height: 1.45;
    color: var(--text-primary, #e5e7eb);
    border-left: 3px solid #22c55e;
    padding: 0.2rem 0 0.2rem 0.85rem;
    margin: 0.5rem 0 1rem 0;
    font-style: italic;
}
.winner-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.85rem;
    margin-top: 0.5rem;
}
.winner-stats > div {
    background: rgba(52, 199, 89, 0.08);
    border: 1px solid rgba(52, 199, 89, 0.30);
    border-radius: var(--radius-md);
    padding: 0.55rem 0.75rem;
    text-align: center;
}
.winner-stats .stat-n {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: #16a34a;
    line-height: 1.1;
}
.winner-stats .stat-l {
    display: block;
    font-size: 0.72rem;
    color: var(--text-secondary, #9ca3af);
    margin-top: 0.15rem;
}

.segment-table th, .segment-table td { font-size: 0.85rem; }
.segment-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.vote-chip {
    display: inline-block;
    background: #eff6ff;
    color: var(--accent-primary);
    padding: 0.12rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-right: 0.25rem;
    margin-bottom: 0.2rem;
    font-variant-numeric: tabular-nums;
}

.rank-table .msg-num { font-weight: 600; width: 30px; }
.rank-table .msg-txt {
    max-width: 420px;
    color: var(--text-primary, #e5e7eb);
    font-size: 0.88rem;
}
.rank-table .num { text-align: right; font-variant-numeric: tabular-nums; }
/* Winner row — dark-mode friendly: tinted green bg with brighter left
   border instead of pastel background that killed readability. Text
   stays the same color as the other rows so nothing gets washed out. */
.rank-table .row-winner {
    background: rgba(34, 197, 94, 0.12);
    box-shadow: inset 3px 0 0 #22c55e;
}
.rank-table .row-winner .msg-num { color: #22c55e; font-weight: 700; }
.rank-table .row-winner td { color: var(--text-primary, #e5e7eb); }
.rank-table .row-winner .msg-txt { color: var(--text-primary, #e5e7eb); }

.msg-reactions-block {
    padding: 0.85rem 0;
    border-bottom: 1px solid #e5e7eb;
}
.msg-reactions-block:last-child { border-bottom: none; }
.msg-reactions-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.6rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px dashed #e5e7eb;
}
.msg-reactions-text { flex: 1; font-size: 0.9rem; color: var(--text-primary); font-weight: 500; }
.msg-reactions-score {
    background: #eff6ff;
    color: var(--accent-primary);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
}
.reactions-col { margin-top: 0.5rem; }
.reactions-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    display: inline-block;
    margin-bottom: 0.4rem;
}
.reactions-label.good { background: rgba(34, 197, 94, 0.16); color: #16a34a; }
.reactions-label.bad { background: rgba(239, 68, 68, 0.16); color: #dc2626; }
.reactions-label.neutral { background: rgba(234, 179, 8, 0.14); color: #b45309; }
.reactions-threshold {
    font-size: 0.65rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: none;
    opacity: 0.75;
    margin-left: 0.35rem;
}
/* Reaction items — dark-mode friendly. Antes los fondos eran verde/rosa
   pastel casi blanco (#f0fdf4 / #fef2f2) con texto #334155 gris oscuro,
   ilegible sobre el tema dark. Ahora: fondo tinteado semi-transparente,
   borde accent brillante, texto usa var(--text-primary). */
.reaction-item {
    padding: 0.55rem 0.85rem;
    border-radius: 6px;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
    color: var(--text-primary, #e5e7eb);
}
.reaction-item.good {
    background: rgba(34, 197, 94, 0.10);
    border-left: 3px solid #22c55e;
}
.reaction-item.bad {
    background: rgba(239, 68, 68, 0.10);
    border-left: 3px solid #ef4444;
}
.reaction-item.neutral {
    background: rgba(234, 179, 8, 0.08);
    border-left: 3px solid #eab308;
}
.reaction-empty {
    padding: 0.55rem 0.85rem;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.08);
    border-left: 3px dashed #64748b;
    color: var(--text-secondary, #9ca3af);
    font-size: 0.82rem;
    font-style: italic;
    margin-bottom: 0.4rem;
}
.reaction-label {
    font-size: 0.72rem;
    color: var(--text-secondary, #9ca3af);
    font-weight: 600;
    margin-bottom: 0.2rem;
}
.reaction-item.good .reaction-label { color: #16a34a; }
.reaction-item.bad .reaction-label { color: #dc2626; }
.reaction-item.neutral .reaction-label { color: #b45309; }
.reaction-score {
    color: var(--text-muted, #6b7280);
    font-weight: 500;
    margin-left: 0.25rem;
}
.reaction-text {
    color: var(--text-primary, #e5e7eb);
    line-height: 1.5;
    font-style: italic;
}

/* ===== Map description panel ("Panorama general" reading block) =====
   Dark card matching the rest of the app — titles in accent blue, body in
   secondary-text so it reads comfortably on the dark surface. */
.map-description-panel {
    margin-top: 0.75rem;
    min-height: 2rem;
    padding: 1rem 1.15rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.92rem;
    line-height: 1.6;
    color: var(--text-primary);
}
.map-description-panel:empty {
    display: none;
}

.map-desc-para {
    margin: 0 0 0.9rem 0;
    line-height: 1.6;
    color: var(--text-primary);
}
.map-desc-para:last-child {
    margin-bottom: 0;
}
.map-desc-para strong {
    color: var(--text-primary);
    font-weight: 600;
}
/* Section headings at start of paragraph ("Panorama general:", etc.) */
.map-desc-para strong:first-child {
    display: block;
    font-size: 1rem;
    color: var(--accent-primary);
    margin-bottom: 0.35rem;
    font-weight: 600;
}

/* ===== Inline DNI quick search (on profile page) ===== */
.dni-quick-search {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.88rem;
    flex-wrap: wrap;
}
.dni-quick-search label {
    font-weight: 500;
    color: var(--text-primary);
}
.dni-quick-search input[type="number"] {
    padding: 0.35rem 0.6rem;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.88rem;
    width: 180px;
}
.dni-quick-search .btn-sm {
    padding: 0.35rem 0.9rem;
    font-size: 0.85rem;
}

/* ===== Map filters (age / gender) ===== */
.map-filters {
    margin-top: 0.6rem;
    padding: 0.6rem 0.8rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
}
.map-filters-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}
.map-filter-group {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.map-filter-group label {
    font-size: 0.82rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin: 0;
}
.map-filter-input {
    padding: 0.3rem 0.5rem;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.85rem;
    width: auto;
}
.map-filter-input[type="number"] { width: 70px; }
.map-filter-dash { color: var(--text-muted); }
.map-advanced-filters {
    margin-top: 0.6rem;
    padding-top: 0.5rem;
    border-top: 1px dashed var(--border-color);
}
.map-advanced-filters summary {
    cursor: pointer;
    font-size: 0.82rem;
    color: var(--text-secondary);
    font-weight: 500;
    padding: 0.2rem 0;
    user-select: none;
}
.map-advanced-filters summary:hover {
    color: var(--text-primary);
}
.map-advanced-filters[open] summary {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}
.map-advanced-filters .map-filters-row {
    padding-left: 0.5rem;
}

.map-filter-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.6rem;
}
.inherited-filters-prefix {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-right: 0.3rem;
    font-weight: 500;
}
.map-filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.35rem 0.25rem 0.65rem;
    background: rgba(0, 122, 255, 0.18);
    color: var(--text-primary);
    border: 1px solid rgba(0, 122, 255, 0.35);
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 500;
}
.map-filter-chip .chip-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0 0.3rem;
    font-size: 1rem;
    line-height: 1;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.map-filter-chip .chip-close:hover {
    background: rgba(239, 68, 68, 0.25);
    color: #dc2626;
}
.map-filter-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}
.map-filter-actions .map-filter-badge {
    margin-top: 0;
    flex: 1 1 auto;
    min-width: 200px;
}
.filter-export-btn {
    flex: 0 0 auto;
    white-space: nowrap;
}
.map-filter-badge {
    padding: 0.45rem 0.7rem;
    background: rgba(0, 122, 255, 0.1);
    border-left: 3px solid var(--accent-primary);
    border-radius: 4px;
    font-size: 0.85rem;
    color: var(--text-primary);
}
.map-filter-badge .badge-total {
    color: var(--text-muted);
    font-size: 0.78rem;
    margin-left: 0.2rem;
}
.map-filter-warning {
    margin-top: 0.4rem;
    padding: 0.35rem 0.6rem;
    background: rgba(245, 158, 11, 0.12);
    border-left: 3px solid var(--accent-warning);
    border-radius: 4px;
    font-size: 0.78rem;
    color: var(--text-secondary);
}
/* superseded by ux audit fix 2026-05-14 - was dark-theme rgba black overlay
   that blended into the light Notion-soft palette. Owned now by the
   .btn-secondary block lower in this file (line ~3411). */
/* .btn-secondary { background: rgba(0, 0, 0, 0.15); color: var(--text-primary); border: 1px solid var(--border-color); } */
/* .btn-secondary:hover { background: rgba(0, 0, 0, 0.25); } */

/* ===== Layer explainer (what/how under the pills) ===== */
.layer-explainer {
    margin-top: 0.6rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--accent-primary);
    border-radius: 6px;
    padding: 0.55rem 0.8rem;
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.4;
}
.layer-explainer-title {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}
.layer-explainer-body p {
    margin: 0.2rem 0;
    color: var(--text-secondary);
}
.layer-explainer-body code {
    background: rgba(0, 122, 255, 0.12);
    padding: 0.05rem 0.3rem;
    border-radius: 4px;
    font-size: 0.78rem;
    color: var(--text-primary);
}

/* ===== Map + side panel layout =====
   Left column (map + legend + Panorama general) governs the height via normal
   flow. Right column (news links) is absolutely positioned to match, with
   internal scroll — so a long news list never pushes the layout down.
   The right column only exists for the "Pulso Social" layer: JS toggles
   .has-side-panel on the container so other layers get full width. */
.map-with-side {
    position: relative;
}
.map-with-side.has-side-panel {
    padding-right: calc(300px + 1rem);
}
.map-side-left {
    min-width: 0;
}
.map-side-right {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 300px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem 0.85rem;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    box-sizing: border-box;
}
@media (max-width: 900px) {
    .map-with-side.has-side-panel { padding-right: 0; }
    .map-side-right {
        position: static;
        width: 100%;
        max-height: 360px;
        margin-top: 1rem;
    }
}
.weekly-panel-header {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
    margin-bottom: 0.5rem;
}
.weekly-panel-header h3 {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-primary);
    border-bottom: none;
    padding-bottom: 0;
}
.weekly-panel-subtitle {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.2rem;
}
#weekly-panel-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}
#weekly-panel-tabs .tab-btn {
    padding: 0.4rem 0.55rem;
    font-size: 0.78rem;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    cursor: pointer;
    color: var(--text-secondary);
    margin-right: 0;
}
#weekly-panel-tabs .tab-btn.active {
    color: var(--accent-primary);
    border-bottom-color: var(--accent-primary);
    background: transparent;
}
#weekly-panel-tabs .count {
    display: inline-block;
    background: rgba(0, 0, 0, 0.18);
    color: var(--text-primary);
    border-radius: 10px;
    padding: 0 0.4rem;
    font-size: 0.7rem;
    margin-left: 0.2rem;
}
#weekly-panel-tabs .tab-btn.active .count {
    background: var(--accent-primary);
    color: #fff;
}
.weekly-source-item {
    padding: 0.55rem 0;
    border-bottom: 1px dashed var(--border-color);
    font-size: 0.82rem;
}
.weekly-source-item:last-child { border-bottom: none; }
.weekly-source-item a {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 500;
    line-height: 1.3;
    display: inline-block;
}
.weekly-source-item a:hover { text-decoration: underline; }
.weekly-source-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}
.weekly-source-snippet {
    color: var(--text-secondary);
    margin-top: 0.25rem;
    line-height: 1.35;
    font-size: 0.78rem;
}

/* Pulsing locality marker */
@keyframes pulse-marker {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.6); opacity: 0.5; }
    100% { transform: scale(1); opacity: 1; }
}
.locality-pulse-marker {
    animation: pulse-marker 1.5s ease-in-out infinite;
}

/* ===== Actions ===== */
.actions {
    display: flex;
    gap: 0.8rem;
    margin-top: 1.5rem;
}

/* ===== Layers Used ===== */
.layers-used {
    text-align: right;
    margin-top: 1rem;
    color: var(--text-muted);
}

/* ===== Setup Steps ===== */
.setup-steps {
    padding-left: 1.2rem;
}

.setup-steps li {
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.setup-steps code {
    background: var(--bg-input);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--accent-primary);
}

/* ===== Flash Messages ===== */
.flash-messages {
    margin-bottom: 1rem;
}

.flash {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.flash-error {
    background: rgba(239, 83, 80, 0.1);
    border: 1px solid rgba(239, 83, 80, 0.3);
    color: #dc2626;
}

.flash-success {
    background: rgba(102, 187, 106, 0.1);
    border: 1px solid rgba(102, 187, 106, 0.3);
    color: #16a34a;
}

.flash-info {
    background: rgba(41, 182, 246, 0.1);
    border: 1px solid rgba(41, 182, 246, 0.3);
    color: #0284c7;
}

.error {
    color: var(--accent-danger);
}

/* ===== Sim Meta ===== */
.sim-meta {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1rem;
}

.sim-query {
    background: var(--bg-input);
    padding: 1rem;
    border-radius: 6px;
    border-left: 3px solid var(--accent-primary);
}

.sim-query p {
    margin-top: 0.4rem;
    color: var(--text-secondary);
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
    .simulation-layout {
        grid-template-columns: 1fr;
    }

    .simulation-form-card {
        position: static;
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        width: 120px;
        overflow: hidden;
    }

    .sidebar .logo h1 {
        font-size: 1.1rem;
        white-space: nowrap;
        overflow: hidden;
    }

    .sidebar .logo .logo-img {
        max-height: 36px;
    }

    .sidebar .logo .subtitle,
    .sidebar-footer .version,
    .sidebar .nav-label {
        display: none;
    }

    .sidebar .nav-label-short {
        display: inline;
        font-size: 0.78rem;
    }

    .sidebar ul li a {
        padding: 0.55rem 0.7rem;
        gap: 0.4rem;
    }

    .nav-icon {
        font-size: 0.85rem;
    }

    /* En mobile el logout vive como item del menú (.nav-mobile-only),
       así que ocultamos el user-info del footer — solo queda la versión */
    .sidebar-footer .user-info {
        display: none;
    }
    .sidebar-footer {
        padding: 0.6rem 0.5rem;
    }

    /* Activar el item "Salir" en mobile */
    .sidebar .nav-mobile-only {
        display: block;
        margin-top: 0.5rem;
        padding-top: 0.5rem;
        border-top: 1px solid var(--border-color);
    }
    .sidebar .nav-logout-mobile {
        color: #dc2626 !important;
    }
    .sidebar .nav-logout-mobile:hover {
        background: rgba(239, 68, 68, 0.15) !important;
        color: #b91c1c !important;
    }

    .content {
        margin-left: 120px;
        width: calc(100% - 120px);
        padding: 0.85rem;
    }

    .dashboard-grid,
    .citizen-grid,
    .results-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.6rem;
    }

    .map-container {
        height: 300px;
    }

    /* Tablas con muchas columnas: scroll horizontal dentro de la card
       en lugar de romper el layout de la página */
    .card:has(> .data-table) {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .data-table th,
    .data-table td {
        padding: 0.4rem 0.5rem;
        font-size: 0.82rem;
        white-space: nowrap;
    }
    .data-table th {
        font-size: 0.7rem;
    }
}

/* Pantallas muy chicas (iPhone SE, Android chico): stats en una sola columna */
@media (max-width: 420px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .stat-value {
        font-size: 1.6rem;
    }
}

/* ─── Analyst text formatting (format_analysis filter) ─── */
.analysis-block {
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--text-primary);
}
.analysis-block p {
    margin: 0 0 12px 0;
}
.analysis-block p:last-child {
    margin-bottom: 0;
}
.analysis-body {
    background: transparent;
}
.analysis-conclusion {
    background: rgba(124, 94, 232, 0.08);
    border-left: 3px solid #7c5ee8;
    padding: 10px 14px;
    border-radius: 6px;
    font-weight: 500;
    color: var(--text-primary);
    margin-top: 14px !important;
}
/* Subheading dentro del análisis — reemplaza los "### Título" markdown
   crudos del LLM por un encabezado visual limpio. */
.analysis-heading {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--accent-primary, #4fc3f7);
    margin: 14px 0 4px 0 !important;
    letter-spacing: 0.02em;
}
.analysis-heading:first-child { margin-top: 0 !important; }
.analysis-bullets {
    list-style: none;
    padding: 0;
    margin: 0;
}
.analysis-bullets li {
    padding: 8px 12px 8px 30px;
    position: relative;
    background: rgba(0,0,0,0.03);
    border-radius: 6px;
    margin-bottom: 6px;
    line-height: 1.6;
}
.analysis-bullets li::before {
    content: "•";
    position: absolute;
    left: 12px;
    top: 8px;
    color: #7c5ee8;
    font-weight: 700;
    font-size: 1.1em;
}

/* ============================================================
 * ===== Territoria — Command Center Layout (P1) ==============
 * ============================================================
 * 5-zone CSS grid that replaces the legacy `.sidebar + .content`
 * flex shell. Activated by `body.cc`. The inspector zone is a
 * 0-width track by default and expands when `body.cc.inspector-open`
 * is set (via HTMX trigger or `?inspector=...` query in base.html).
 *
 * Tokens come from the :root block at the top of this file (P0).
 * Legacy `.sidebar` rules above are intentionally NOT removed yet —
 * they will be scrubbed at the end of P1 once every page renders
 * correctly inside the CC shell. */

body.cc {
  display: grid;
  grid-template-areas:
    "top    top      top"
    "left   center   right"
    "bottom bottom   bottom";
  grid-template-columns: 280px 1fr 0px;
  grid-template-rows: 96px 1fr 48px;
  min-height: 100vh;
  gap: 0;
  /* override legacy `body { display: flex }` if it cascades from below */
  flex-direction: initial;
  color: var(--color-text);
  /* Subtle aurora — continuity from login but much dialed down (0.10-0.14 opacity
     instead of 0.30-0.38). Only visible through cc-center (translucent) and at
     edges. Nav/inspector zones stay solid for data legibility. */
  background-color: #F5F7FB;
  background-image:
    radial-gradient(at 12% 18%, rgba(37, 99, 235, 0.14) 0px, transparent 55%),
    radial-gradient(at 88% 12%, rgba(6, 182, 212, 0.13) 0px, transparent 55%),
    radial-gradient(at 82% 88%, rgba(79, 70, 229, 0.10) 0px, transparent 55%),
    radial-gradient(at 18% 92%, rgba(15, 118, 110, 0.08) 0px, transparent 55%);
  background-attachment: fixed;
}

/* Workspace center semi-translucent so the aurora bleeds through subtly.
   Cards / panels inside the workspace remain solid white (defined elsewhere). */
body.cc .cc-center {
  background: rgba(250, 250, 252, 0.55);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
}

/* Top bar / left sidebar tienen el chrome tintado (azul-gris) para que
   se distingan del área de contenido blanco. El right inspector y el
   bottom timeline siguen en blanco — su contenido es denso y necesita
   máximo contraste. */
body.cc .cc-top,
body.cc .cc-left {
  background: var(--color-chrome);
}
body.cc .cc-right,
body.cc .cc-bottom {
  background: var(--color-surface);
}

body.cc.inspector-open { grid-template-columns: 280px 1fr 380px; }

/* Hide the legacy compatibility shim nodes from layout while keeping them
 * queryable for any lingering JS selectors. */
body.cc .legacy-compat,
body.cc .legacy-compat * { display: none !important; }

/* --- Zones ----------------------------------------------------- */
.cc-top {
  grid-area: top;
  border-bottom: 1px solid var(--color-chrome-border);
  background: var(--color-chrome);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: 0 var(--space-5);
  z-index: var(--z-elevated);
}

.cc-left {
  grid-area: left;
  border-right: 1px solid var(--color-chrome-border);
  background: var(--color-chrome);
  overflow-y: auto;
  min-width: 0;
}

.cc-center {
  grid-area: center;
  overflow-y: auto;
  padding: var(--space-5);
  background: var(--color-bg);
  min-width: 0;
}

.cc-right {
  grid-area: right;
  border-left: 1px solid var(--color-border);
  background: var(--color-surface);
  overflow-y: auto;
  overflow-x: hidden;
  transition: width var(--transition-base);
  min-width: 0;
}
body.cc:not(.inspector-open) .cc-right { display: none; }

.cc-bottom {
  grid-area: bottom;
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
  display: flex;
  align-items: center;
  padding: 0 var(--space-4);
  font-size: var(--text-xs);
  color: var(--color-text-mute);
}

/* --- Topbar internals ----------------------------------------- */
.cc-brand {
  display: flex;
  align-items: center;
  height: 100%;
  padding: 8px 0;
  color: var(--color-text);
  text-decoration: none;
}
.cc-brand strong { font-weight: 600; }
.cc-brand-dot { color: var(--color-text-mute); }
.cc-brand:hover { color: var(--color-interactive); }

.cc-brand-logo {
  height: 80px;
  width: auto;
  display: block;
}

.cc-cmd-trigger {
  margin-left: auto;
  margin-right: auto;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--color-surface-2);
  color: var(--color-text-mute);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 6px var(--space-3);
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  cursor: pointer;
  min-width: 280px;
  transition: border-color var(--transition-fast), color var(--transition-fast);
}
.cc-cmd-trigger:hover {
  border-color: var(--color-border-strong);
  color: var(--color-text);
}
.cc-cmd-trigger-label { flex: 1; text-align: left; }
.cc-kbd, .cc-cmd-trigger kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--color-bg);
  color: var(--color-text-mute);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  line-height: 1;
}

.cc-user {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-xs);
  color: var(--color-text-mute);
}
.cc-user-name { color: var(--color-text); }
.cc-user-logout {
  color: var(--color-text-mute);
  text-decoration: none;
  border-left: 1px solid var(--color-border);
  padding-left: var(--space-3);
}
.cc-user-logout:hover { color: var(--color-danger); }
.cc-user-dot {
  color: var(--color-success);
  font-size: 10px;
}

/* --- Left panel internals ------------------------------------- */
.cc-side-nav {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: var(--space-4);
  gap: var(--space-3);
}
.cc-side-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0 var(--space-1);
}
.cc-side-title {
  margin: 0;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text);
}
.cc-side-hint {
  font-size: 10px;
  color: var(--color-text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.cc-escenario-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}
.cc-escenario-empty {
  padding: var(--space-3);
  font-size: var(--text-xs);
  color: var(--color-text-mute);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  text-align: center;
}
.cc-side-footer {
  margin-top: auto;
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border);
}
.cc-side-cta {
  display: block;
  font-size: var(--text-xs);
  color: var(--color-interactive);
  text-decoration: none;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
}
.cc-side-cta:hover {
  background: var(--color-surface-2);
  color: var(--color-interactive-hover);
}

/* --- Inspector internals -------------------------------------- */
.cc-inspector {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.cc-inspector-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
}
.cc-inspector-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
}
.cc-inspector-close {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text-mute);
  border-radius: var(--radius-sm);
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}
.cc-inspector-close:hover {
  color: var(--color-text);
  border-color: var(--color-border-strong);
}
.cc-inspector-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-text);
}
.cc-inspector-empty {
  color: var(--color-text-mute);
  font-size: var(--text-xs);
  text-align: center;
  margin: var(--space-6) 0;
}

/* --- Timeline strip ------------------------------------------- */
.cc-timeline-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.cc-timeline-label {
  color: var(--color-text);
  font-weight: 500;
  font-size: var(--text-xs);
}
.cc-timeline-hint { color: var(--color-text-faint); }

/* --- Command palette modal ------------------------------------ */
#cmd-palette[hidden] { display: none !important; }
#cmd-palette {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
}
.cc-palette-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(24, 24, 27, 0.35);
  backdrop-filter: blur(2px);
}
.cc-palette-panel {
  position: relative;
  margin: 12vh auto 0;
  width: min(560px, calc(100vw - var(--space-8)));
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.cc-palette-input {
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  padding: var(--space-4);
  border-bottom: 1px solid var(--color-border);
}
.cc-palette-list {
  list-style: none;
  margin: 0;
  padding: var(--space-2) 0;
  max-height: 50vh;
  overflow-y: auto;
}
.cc-palette-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  cursor: pointer;
  color: var(--color-text);
  font-size: var(--text-sm);
}
.cc-palette-item.is-active,
.cc-palette-item:hover {
  background: var(--color-surface-2);
}
.cc-palette-item-hint {
  color: var(--color-text-mute);
  font-size: var(--text-xs);
}
.cc-palette-empty {
  padding: var(--space-4);
  color: var(--color-text-mute);
  text-align: center;
  font-size: var(--text-xs);
}
.cc-palette-footer {
  border-top: 1px solid var(--color-border);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-xs);
  color: var(--color-text-mute);
  display: flex;
  gap: var(--space-3);
}
.cc-palette-footer kbd {
  font-family: var(--font-mono);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
  margin-right: 2px;
}

/* --- Narrow desktop fallback (<1280px) ------------------------ */
@media (max-width: 1279px) {
  body.cc { grid-template-columns: 240px 1fr 0px; }
  body.cc.inspector-open { grid-template-columns: 240px 1fr 0px; }
  body.cc.inspector-open .cc-right {
    position: fixed;
    right: 0;
    top: 96px;
    bottom: 48px;
    width: 380px;
    z-index: var(--z-elevated);
    box-shadow: var(--shadow-lg);
    display: block;
  }
  .cc-bottom { height: 40px; }
}

/* --- Mobile stub (<1024px) — out of scope per design ---------- */
@media (max-width: 1023px) {
  body.cc {
    grid-template-areas:
      "top"
      "center"
      "bottom";
    grid-template-columns: 1fr;
    grid-template-rows: 80px 1fr 40px;
  }
  body.cc .cc-left,
  body.cc .cc-right { display: none; }
}

/* ===== Workspace Tabs ===== */
/* Unified workspace shell used by `escenario_view.html` (and future
   workspaces). The structure is `.ws > .ws-header + .ws-tabs + .ws-panels`.
   Tabs use ARIA roles and `[hidden]` on inactive panels — keeps state in
   the DOM, not in display:none, so screen readers and HTMX swaps work
   correctly. Active indicator is a 2px accent bottom border on the
   selected tab; hover only lifts color, never adds layout shift. */
.ws { display: flex; flex-direction: column; gap: var(--space-4); }
.ws-header { display: flex; justify-content: space-between; align-items: baseline; padding-bottom: var(--space-3); border-bottom: 1px solid var(--color-border); }
.ws-title { font-size: var(--text-2xl); font-weight: 600; color: var(--color-text); margin: 0; letter-spacing: -0.02em; }
.ws-meta { color: var(--color-text-mute); font-size: var(--text-sm); font-family: var(--font-mono); }
.ws-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--color-border); }
.ws-tabs [role="tab"] {
  background: transparent; border: 0; padding: var(--space-3) var(--space-4);
  color: var(--color-text-mute); font: inherit; cursor: pointer;
  border-bottom: 2px solid transparent; transition: color var(--transition-fast), border-color var(--transition-fast);
}
.ws-tabs [role="tab"]:hover { color: var(--color-text); }
.ws-tabs [role="tab"][aria-selected="true"] {
  color: var(--color-text); border-bottom-color: var(--color-interactive);
}
.ws-panels { padding-top: var(--space-4); }
.ws-empty { color: var(--color-text-mute); font-size: var(--text-base); padding: var(--space-6) 0; text-align: center; }

/* ===== Inspector ===== */
.cc-inspector-close {
  position: absolute; top: var(--space-3); right: var(--space-3);
  background: transparent; border: 0; color: var(--color-text-mute);
  font-size: var(--text-xl); cursor: pointer; padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm); transition: color var(--transition-fast), background var(--transition-fast);
}
.cc-inspector-close:hover { color: var(--color-text); background: var(--color-surface-2); }
.cc-right { padding: var(--space-5); position: relative; }
#inspector-content { padding-top: var(--space-5); }

/* ===== Workspace Empty Hero (P7) ===== */
.ws-empty-hero {
  padding: var(--space-6) var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  text-align: center;
  margin-bottom: var(--space-5);
}
.ws-empty-hero h2 {
  font-size: var(--text-2xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 var(--space-3) 0;
  color: var(--color-text);
}
.ws-empty-hero p {
  color: var(--color-text-mute);
  font-size: var(--text-base);
  margin: 0 0 var(--space-5) 0;
}
.ws-cta-group {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
}
.btn {
  display: inline-block;
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: var(--text-base);
  border: 1px solid transparent;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}
/* === Territoria button system — ux audit fix 2026-05-14 ============
   Source of truth for .btn-primary / .btn-secondary on Notion-soft light.
   White on indigo: #FFFFFF over #6366F1 = ~5.6:1 (WCAG AA pass).
   White on hover: #FFFFFF over #4F46E5 = ~6.4:1 (WCAG AA pass).
   Text on surface-2: #18181B over #F4F4F5 = ~15.5:1 (AAA).
   ================================================================= */
.btn-primary {
  background: var(--color-interactive);
  color: #FFFFFF;
  border-color: var(--color-interactive);
}
.btn-primary:hover,
.btn-primary:focus,
.btn-primary:focus-visible {
  background: var(--color-interactive-hover);
  border-color: var(--color-interactive-hover);
  color: #FFFFFF;
}
.btn-primary:focus-visible {
  outline: 2px solid var(--color-interactive);
  outline-offset: 2px;
}
.btn-primary:active {
  background: var(--color-interactive-hover);
  border-color: var(--color-interactive-hover);
  color: #FFFFFF;
  transform: scale(0.98);
}
.btn-primary:disabled,
.btn-primary[disabled] {
  background: var(--color-text-faint);
  border-color: var(--color-text-faint);
  color: #FFFFFF;
  cursor: not-allowed;
  opacity: 0.6;
  pointer-events: none;
}
.btn-secondary {
  background: transparent;
  color: var(--color-text);
  border-color: var(--color-border-strong);
}
.btn-secondary:hover,
.btn-secondary:focus,
.btn-secondary:focus-visible {
  background: var(--color-surface-2);
  border-color: var(--color-text-mute);
  color: var(--color-text);
}
.btn-secondary:focus-visible {
  outline: 2px solid var(--color-interactive);
  outline-offset: 2px;
}
.btn-secondary:disabled,
.btn-secondary[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}
/* Optional variants — keep contrast consistent (white on solid). */
.btn-danger {
  background: var(--color-danger);
  color: #FFFFFF;
  border-color: var(--color-danger);
}
.btn-danger:hover,
.btn-danger:focus {
  background: #B91C1C;
  border-color: #B91C1C;
  color: #FFFFFF;
}
.btn-success {
  background: var(--color-success);
  color: #FFFFFF;
  border-color: var(--color-success);
}
.btn-success:hover,
.btn-success:focus {
  background: #15803D;
  border-color: #15803D;
  color: #FFFFFF;
}

/* ===================================================================
 * Top Nav (Territoria) — Stripe-style nav with dropdowns
 * Added 2026-05-14 to replace ⌘K-only navigation. Lives inside .cc-top
 * (which already supplies grid-area + background + border).
 * =================================================================== */
.cc-top {
  /* Re-affirm layout in case .cc-top was modified upstream. */
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: 0 var(--space-5);
  height: 96px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.cc-brand {
  font-family: var(--font-sans);
  font-size: var(--text-lg);
  color: var(--color-text);
  text-decoration: none;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.cc-brand strong { font-weight: 700; }

.cc-nav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex: 1;
  margin-left: var(--space-5);
}

.cc-nav-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  background: transparent;
  border: 0;
  color: var(--color-text-mute);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  transition: color var(--transition-fast), background var(--transition-fast);
}
/* Sobre el chrome azul-gris del topbar, el surface-2 (gris claro) queda
   casi invisible. Usamos un tinte violeta translúcido para que TODOS los
   nav-links activos se vean iguales (Inicio, Escenarios, Contactos) y
   no quede solo Escenarios con su pill linda y los demás planos. */
.cc-nav-link:hover {
  color: var(--color-text);
  background: rgba(99, 102, 241, 0.06);
}
.cc-nav-link.is-active,
.cc-nav-link[aria-expanded="true"] {
  color: var(--color-text);
  background: rgba(99, 102, 241, 0.10);
}
.cc-caret { font-size: 0.7em; opacity: 0.7; }

.cc-nav-group { position: relative; }
.cc-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 200px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: var(--space-1);
  display: none;
  z-index: var(--z-elevated);
}
.cc-nav-group[data-open="true"] .cc-dropdown { display: block; }
.cc-dropdown a {
  display: block;
  padding: var(--space-2) var(--space-3);
  color: var(--color-text);
  text-decoration: none;
  font-size: var(--text-sm);
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast), color var(--transition-fast);
}
.cc-dropdown a:hover {
  background: var(--color-surface-2);
  color: var(--color-interactive);
}

.cc-top-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-left: auto;
}
.cc-cmd-trigger {
  /* Override earlier `.cc-cmd-trigger` block — top nav variant is compact. */
  margin: 0;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-1) var(--space-2);
  color: var(--color-text-mute);
  cursor: pointer;
  font: inherit;
  font-size: var(--text-xs);
  transition: color var(--transition-fast), border-color var(--transition-fast);
}
.cc-cmd-trigger:hover {
  color: var(--color-text);
  border-color: var(--color-border-strong);
}
.cc-cmd-trigger kbd {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  background: transparent;
  border: 0;
  padding: 0;
  color: inherit;
}
.cc-logout {
  font-size: var(--text-sm);
  color: var(--color-text-mute);
  text-decoration: none;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background var(--transition-fast);
}
.cc-logout:hover {
  color: var(--color-danger);
  background: var(--color-surface-2);
}

/* ===== Command Center · Left Panel · Escenario List ===== */
.cc-escenario-list {
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}
.cc-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: var(--space-2);
    border-bottom: 1px solid var(--color-border);
}
.cc-section-title {
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-mute);
    margin: 0;
}
.cc-section-action {
    color: var(--color-text-mute);
    text-decoration: none;
    font-size: var(--text-lg);
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast), color var(--transition-fast);
}
.cc-section-action:hover { background: var(--color-surface-2); color: var(--color-text); }
.cc-escenario-items {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}
.cc-escenario-item a {
    display: flex;
    flex-direction: column;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--color-text);
    transition: background var(--transition-fast), border-color var(--transition-fast);
    /* Border-left que el color por kind sobrescribe — 3px sólido para
       crear barra de acento. Default neutro por si llega un kind nuevo. */
    border-left: 3px solid var(--color-border, transparent);
}
.cc-escenario-item a:hover { background: var(--color-surface-2); }
.cc-escenario-item.is-active a { background: var(--color-surface-2); color: var(--color-interactive); }

/* Acento por tipo de artefacto — border-left + color del ícono.
   Cada kind tiene su identidad visual:
     escenario  → violeta (acción de simular)
     estrategia → ámbar  (Mensaje Lab, energía creativa)
     resolver   → rojo   (Dolores Lab, urgencia)
     ensayo     → cyan   (Oratoria, voz/audio)
     flyer      → rosa   (visual, diseño)
     informe    → verde  (investigación, documento)                  */
.cc-escenario-item.cc-item-escenario a  { border-left-color: #6366F1; }
.cc-escenario-item.cc-item-estrategia a { border-left-color: #F59E0B; }
.cc-escenario-item.cc-item-resolver a   { border-left-color: #DC2626; }
.cc-escenario-item.cc-item-ensayo a     { border-left-color: #06B6D4; }
.cc-escenario-item.cc-item-flyer a      { border-left-color: #DB2777; }
.cc-escenario-item.cc-item-informe a    { border-left-color: #16A34A; }

.cc-escenario-item.cc-item-escenario .cc-item-icon  { color: #6366F1; }
.cc-escenario-item.cc-item-estrategia .cc-item-icon { color: #F59E0B; }
.cc-escenario-item.cc-item-resolver .cc-item-icon   { color: #DC2626; }
.cc-escenario-item.cc-item-ensayo .cc-item-icon     { color: #06B6D4; }
.cc-escenario-item.cc-item-flyer .cc-item-icon      { color: #DB2777; }
.cc-escenario-item.cc-item-informe .cc-item-icon    { color: #16A34A; }
.cc-escenario-name {
    font-size: var(--text-sm);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cc-escenario-meta {
    font-size: var(--text-xs);
    color: var(--color-text-mute);
    font-family: var(--font-mono);
    margin-top: 2px;
}
.cc-empty {
    padding: var(--space-4) var(--space-3);
    text-align: center;
}
.cc-empty-icon {
    width: 32px;
    height: 32px;
    color: var(--color-text-mute);
    opacity: 0.45;
    stroke-width: 1.5;
    margin: 0 auto var(--space-2);
    display: block;
}
.cc-empty p { color: var(--color-text-mute); font-size: var(--text-sm); margin: 0 0 var(--space-2) 0; }
.cc-empty-cta {
    color: var(--color-interactive);
    text-decoration: none;
    font-size: var(--text-sm);
    font-weight: 500;
}
.cc-empty-cta:hover { color: var(--color-interactive-hover); }

/* ===== Top Nav · Lucide Icons ===== */
.cc-nav-icon,
.cc-dropdown-icon {
  width: 16px;
  height: 16px;
  stroke-width: 1.75;
  color: var(--color-text-mute);
  flex-shrink: 0;
  transition: color var(--transition-fast);
}

.cc-nav-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.cc-nav-link:hover .cc-nav-icon,
.cc-nav-link.is-active .cc-nav-icon,
.cc-nav-link[aria-expanded="true"] .cc-nav-icon {
  color: var(--color-text);
}

.cc-dropdown a {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.cc-dropdown a:hover .cc-dropdown-icon {
  color: var(--color-interactive);
}

/* Slightly smaller icons in dropdown for visual rhythm */
.cc-dropdown-icon {
  width: 14px;
  height: 14px;
}

/* ===== Top Nav · Section Accent Colors (hover/active only) ===== */
.cc-nav-link[data-section]:hover .cc-nav-icon,
.cc-nav-link[data-section][aria-expanded="true"] .cc-nav-icon,
.cc-nav-link[data-section].is-active .cc-nav-icon {
  transition: color var(--transition-fast);
}

.cc-nav-link[data-section="inicio"]:hover .cc-nav-icon,
.cc-nav-link[data-section="inicio"].is-active .cc-nav-icon {
  color: var(--section-inicio);
}
.cc-nav-link[data-section="escenarios"]:hover .cc-nav-icon,
.cc-nav-link[data-section="escenarios"].is-active .cc-nav-icon {
  color: var(--section-escenarios);
}
.cc-nav-link[data-section="analisis"]:hover .cc-nav-icon,
.cc-nav-link[data-section="analisis"][aria-expanded="true"] .cc-nav-icon {
  color: var(--section-analisis);
}
.cc-nav-link[data-section="estrategia"]:hover .cc-nav-icon,
.cc-nav-link[data-section="estrategia"][aria-expanded="true"] .cc-nav-icon {
  color: var(--section-estrategia);
}
.cc-nav-link[data-section="investigacion"]:hover .cc-nav-icon,
.cc-nav-link[data-section="investigacion"][aria-expanded="true"] .cc-nav-icon {
  color: var(--section-investigacion);
}
.cc-nav-link[data-section="contactos"]:hover .cc-nav-icon,
.cc-nav-link[data-section="contactos"].is-active .cc-nav-icon {
  color: var(--section-contactos);
}
.cc-nav-link[data-section="salir"]:hover .cc-nav-icon,
.cc-nav-link[data-section="salir"]:hover {
  color: var(--section-salir);
}

/* Salir is rendered as .cc-logout (not .cc-nav-link) — mirror the red hover */
.cc-logout[data-section="salir"]:hover,
.cc-logout[data-section="salir"]:hover .cc-nav-icon {
  color: var(--section-salir);
}

/* Subtle background tint when dropdown is open or item is active */
.cc-nav-link[data-section="analisis"][aria-expanded="true"] {
  background: rgba(6, 182, 212, 0.08);
}
.cc-nav-link[data-section="estrategia"][aria-expanded="true"] {
  background: rgba(245, 158, 11, 0.08);
}
.cc-nav-link[data-section="investigacion"][aria-expanded="true"] {
  background: rgba(22, 163, 74, 0.08);
}
/* Escenarios — el tinte ya lo aporta la regla genérica .is-active arriba
   (línea ~3620). Antes acá había un override específico que daba 0.08
   mientras la genérica daba 0.10; quitamos el override para que Inicio,
   Escenarios y Contactos se vean idénticos cuando están activos. */



/* ===== Left Panel  Activity Items ===== */
.cc-item-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-width: 0;
}
.cc-item-icon {
    width: 14px;
    height: 14px;
    stroke-width: 1.75;
    color: var(--color-text-mute);
    flex-shrink: 0;
}

/* Subtle accent per item type (icon color only  keeps the list calm) */
.cc-item-escenario .cc-item-icon { color: var(--color-interactive); }
.cc-item-estrategia .cc-item-icon { color: #F59E0B; }
.cc-item-resolver   .cc-item-icon { color: #06B6D4; }
.cc-item-ensayo     .cc-item-icon { color: #16A34A; }
.cc-item-flyer      .cc-item-icon { color: #D946EF; }
.cc-item-informe    .cc-item-icon { color: #0EA5E9; }

/* Truncate long titles */
.cc-item-row .cc-escenario-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===== Vox chat (mounted inside Inspector — see _inspector.html) ===== */
.va-msg {
  padding: var(--space-3) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  line-height: 1.5;
  max-width: 88%;
  word-wrap: break-word;
}
.va-msg-user {
  background: var(--color-interactive);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.va-msg-assistant {
  background: var(--color-surface-2);
  color: var(--color-text);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.va-msg-assistant p { margin: 0 0 8px 0; }
.va-msg-assistant p:last-child { margin: 0; }
.va-msg-assistant ul, .va-msg-assistant ol { margin: 8px 0; padding-left: 20px; }
.va-msg-assistant code {
  background: var(--color-bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.9em;
}
.va-msg-assistant pre {
  background: var(--color-bg);
  padding: 12px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.85em;
}

.va-typing {
  display: flex; gap: 4px; padding: var(--space-3);
}
.va-typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--color-text-mute);
  animation: va-typing-bounce 1.4s infinite ease-in-out both;
}
.va-typing span:nth-child(2) { animation-delay: 0.15s; }
.va-typing span:nth-child(3) { animation-delay: 0.30s; }
@keyframes va-typing-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

.va-suggestions {
  display: flex; flex-direction: column; gap: 6px;
  margin-top: var(--space-3);
}
.va-suggestion {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); padding: var(--space-2) var(--space-3);
  text-align: left; font-size: var(--text-sm); color: var(--color-text);
  cursor: pointer; transition: border-color var(--transition-fast), background var(--transition-fast);
}
.va-suggestion:hover { border-color: var(--color-interactive); background: rgba(99, 102, 241, 0.04); }

.va-send {
  background: var(--color-interactive);
  color: #fff;
  border: 0;
  border-radius: var(--radius-md);
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background var(--transition-fast);
  flex-shrink: 0;
}
.va-send:hover { background: var(--color-interactive-hover); }
.va-send-icon { width: 16px; height: 16px; stroke-width: 2.5; }

/* ===== Vox Floating Bubble (bottom-right trigger) ===== */
.vox-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--color-interactive);
  color: #fff;
  border: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35), 0 1px 4px rgba(0,0,0,0.08);
  z-index: 1001;
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.vox-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(99, 102, 241, 0.50), 0 2px 8px rgba(0,0,0,0.10);
}
.vox-bubble-icon {
  width: 24px;
  height: 24px;
  stroke-width: 2;
  color: currentColor;
  /* Animación ambiente: respiro lento + un titileo corto cada ciclo.
     Pensada para que la lamparita esté VIVA sin distraer. Total 6s, loop
     infinito. El 92% / 95% / 100% concentra el "flicker" al final del
     ciclo así no parece bug. */
  animation: vox-bulb-breathe 6s ease-in-out infinite;
  transform-origin: center;
}

@keyframes vox-bulb-breathe {
   0%   { opacity: 0.78; filter: drop-shadow(0 0 0 transparent); transform: scale(1); }
  45%   { opacity: 1.00; filter: drop-shadow(0 0 6px rgba(253, 224, 71, 0.55)); transform: scale(1.04); }
  60%   { opacity: 0.85; filter: drop-shadow(0 0 0 transparent); transform: scale(1); }
  /* Titileo rapidito al final del ciclo */
  88%   { opacity: 1.00; filter: drop-shadow(0 0 5px rgba(253, 224, 71, 0.55)); }
  92%   { opacity: 0.65; filter: drop-shadow(0 0 0 transparent); }
  96%   { opacity: 1.00; filter: drop-shadow(0 0 5px rgba(253, 224, 71, 0.55)); }
 100%   { opacity: 0.78; filter: drop-shadow(0 0 0 transparent); transform: scale(1); }
}

/* Si el user prefiere reduced motion, no titilamos. */
@media (prefers-reduced-motion: reduce) {
  .vox-bubble-icon {
    animation: none;
    opacity: 1;
  }
}

/* Cuando el panel está abierto la lamparita se queda quieta — la
   conversación es lo importante, ya no hace falta llamar la atención. */
body.vox-open .vox-bubble-icon,
.vox-bubble:hover .vox-bubble-icon {
  animation: none;
  opacity: 1;
  filter: drop-shadow(0 0 6px rgba(253, 224, 71, 0.7));
}

/* Attention pulse — fires periodically while the user hasn't opened Vox yet. */
@keyframes vox-bubble-pulse {
  0%   { box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35), 0 0 0 0    rgba(99, 102, 241, 0.45); transform: scale(1); }
  50%  { box-shadow: 0 6px 24px rgba(99, 102, 241, 0.55), 0 0 0 14px rgba(99, 102, 241, 0.00); transform: scale(1.08); }
  100% { box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35), 0 0 0 0    rgba(99, 102, 241, 0.00); transform: scale(1); }
}
.vox-bubble.is-pulsing { animation: vox-bubble-pulse 1.4s ease-out 3; }

/* Persistent red dot — visible until the user actually opens the panel. */
.vox-bubble.has-unread::after {
  content: "";
  position: absolute;
  top: 4px;
  right: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color-danger);
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(220, 38, 38, 0.3);
}

/* ===== Vox Floating Panel (opens above the bubble) ===== */
.vox-panel {
  position: fixed;
  bottom: 96px;     /* sits above the bubble (bubble bottom 24 + height 56 + gap 16) */
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 48px);
  height: 580px;
  max-height: calc(100vh - 120px);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.15), 0 4px 16px rgba(15, 23, 42, 0.08);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  opacity: 0;
  transform: translateY(12px) scale(0.97);
  transform-origin: bottom right;
  transition: opacity 220ms ease, transform 220ms ease;
}
.vox-panel.is-open { opacity: 1; transform: translateY(0) scale(1); }
.vox-panel[hidden] { display: none; }

.vox-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
}
.vox-panel-title { display: flex; align-items: baseline; gap: var(--space-2); }
.vox-panel-title h3 { margin: 0; font-size: var(--text-base); font-weight: 600; color: var(--color-text); letter-spacing: -0.01em; }
.vox-panel-subtitle { font-size: var(--text-xs); color: var(--color-text-mute); font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; }
.vox-panel-close {
  background: transparent; border: 0; font-size: 24px; line-height: 1; color: var(--color-text-mute);
  cursor: pointer; padding: 4px 8px; border-radius: var(--radius-sm);
  transition: background var(--transition-fast), color var(--transition-fast);
}
.vox-panel-close:hover { background: var(--color-surface-2); color: var(--color-text); }

.vox-panel .va-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.vox-panel .va-form {
  display: flex;
  gap: 8px;
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--color-border);
  align-items: flex-end;
}
#vox-input {
  flex: 1;
  background: var(--color-bg);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--color-text);
  resize: none;
  min-height: 38px;
  max-height: 120px;
  line-height: 1.4;
  transition: border-color var(--transition-fast);
}
#vox-input:focus { outline: none; border-color: var(--color-interactive); }

/* Mobile narrow viewport */
@media (max-width: 480px) {
  .vox-panel { width: calc(100vw - 16px); right: 8px; bottom: 88px; height: calc(100vh - 120px); }
}

/* ===== Flyer Lab ===== */
.flyer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-4);
  margin-top: var(--space-4);
}
.flyer-card {
  display: block;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  text-decoration: none;
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition-fast),
              box-shadow var(--transition-fast),
              transform var(--transition-fast);
}
.flyer-card:hover {
  border-color: var(--color-border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.flyer-card-img {
  aspect-ratio: 1 / 1;
  background: var(--color-surface-2);
  display: flex; align-items: center; justify-content: center;
}
.flyer-card-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.flyer-card-img-empty { color: var(--color-text-mute); }
.flyer-card-body { padding: var(--space-3); }
.flyer-card-msg { font-size: var(--text-sm); color: var(--color-text); margin-bottom: var(--space-2); line-height: 1.4; }
.flyer-card-meta { display: flex; justify-content: space-between; align-items: center; font-size: var(--text-xs); color: var(--color-text-mute); font-family: var(--font-mono); }
.flyer-card-badge { padding: 2px 6px; border-radius: 4px; background: var(--color-surface-2); }
.flyer-card-badge-complete { background: rgba(22,163,74,0.10); color: var(--color-success); }
.flyer-card-badge-error    { background: rgba(220,38,38,0.10); color: var(--color-danger); }

.flyer-form { max-width: 720px; }
.form-help { font-size: var(--text-xs); color: var(--color-text-mute); margin: 4px 0 0; }
.style-pills { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.style-pill {
  flex: 1; min-width: 140px; cursor: pointer;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3); text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
.style-pill input { display: none; }
.style-pill:has(input:checked) {
  border-color: var(--color-interactive);
  background: rgba(99, 102, 241, 0.06);
}
.style-pill-icon { width: 20px; height: 20px; color: var(--color-text-mute); }
.style-pill:has(input:checked) .style-pill-icon { color: var(--color-interactive); }

/* Mode toggle: Generar vs Subir */
.mode-pills { display: flex; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-3); }
.mode-pill {
  flex: 1; min-width: 220px; cursor: pointer;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  display: flex; align-items: center; gap: var(--space-3);
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
.mode-pill input { display: none; }
.mode-pill:has(input:checked) {
  border-color: var(--color-interactive);
  background: rgba(99, 102, 241, 0.06);
}
.mode-pill-icon { width: 28px; height: 28px; color: var(--color-text-mute); flex-shrink: 0; }
.mode-pill:has(input:checked) .mode-pill-icon { color: var(--color-interactive); }
.mode-pill small { color: var(--color-text-mute); font-size: var(--text-xs); }

/* Conditional show/hide based on data-mode on the wrapper */
#flyer-modes[data-mode="generate"] .mode-section-upload { display: none; }
#flyer-modes[data-mode="upload"] .mode-section-generate { display: none; }

.filters-block { margin-top: var(--space-4); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: var(--space-3); }
.filters-block summary { cursor: pointer; font-weight: 500; color: var(--color-text-mute); }
.filters-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--space-3); margin-top: var(--space-3); }

.form-actions { margin-top: var(--space-5); display: flex; gap: var(--space-2); }

.flyer-view-grid { display: grid; grid-template-columns: 360px 1fr; gap: var(--space-5); align-items: start; }
.flyer-view-img img { width: 100%; border-radius: var(--radius-md); border: 1px solid var(--color-border); }
.flyer-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--space-3); margin-bottom: var(--space-4); }
.summary-stat {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3); text-align: center;
  box-shadow: var(--shadow-sm);
}
/* Números grandes con tabular-nums para que se alineen como en finanzas;
   font-feature ss01 mejora 1/I/l distinction en Plus Jakarta. */
.summary-stat-value {
  font-size: var(--text-3xl, 30px);
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "ss01" on;
  line-height: 1.1;
}
.summary-stat-label {
  font-size: var(--text-xs);
  color: var(--color-text-mute);
  margin-top: 6px;
  cursor: help;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}

/* ===== Veredicto narrativo de Flyer Lab ===== */
.flyer-verdict {
  margin-bottom: var(--space-4);
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border, #e5e7eb);
  border-left-width: 4px;
  background: var(--color-surface, #fff);
}
.flyer-verdict-success {
  border-left-color: #16a34a;
  background: #f0fdf4;
}
.flyer-verdict-warn {
  border-left-color: #f59e0b;
  background: #fffbeb;
}
.flyer-verdict-danger {
  border-left-color: #dc2626;
  background: #fef2f2;
}
.flyer-verdict-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.flyer-verdict-icon {
  font-size: 18px;
  line-height: 1;
}
.flyer-verdict-success .flyer-verdict-icon { color: #16a34a; }
.flyer-verdict-warn .flyer-verdict-icon { color: #d97706; }
.flyer-verdict-danger .flyer-verdict-icon { color: #dc2626; }
.flyer-verdict-headline {
  font-size: var(--text-base, 15px);
  font-weight: 600;
  color: var(--color-text-strong, #0f172a);
}
.flyer-verdict-explanation {
  margin: 0 0 8px 0;
  font-size: var(--text-sm, 13px);
  color: var(--color-text, #1f2937);
  line-height: 1.5;
}
.flyer-verdict-nextstep {
  margin: 0;
  font-size: var(--text-sm, 13px);
  color: var(--color-text-mute, #4b5563);
  line-height: 1.5;
}
.flyer-verdict-nextstep strong {
  color: var(--color-text-strong, #0f172a);
}

/* ===== Audiencia evaluada (perfil demográfico) ===== */
.flyer-audience {
  margin-bottom: var(--space-4);
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border, #e5e7eb);
  background: var(--color-surface, #fff);
}
.flyer-audience-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.flyer-audience-icon {
  font-size: 16px;
  line-height: 1;
}
.flyer-audience-title {
  font-size: var(--text-sm, 13px);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-mute, #71717a);
}
.flyer-audience-narrative {
  margin: 0 0 12px 0;
  font-size: var(--text-sm, 13px);
  color: var(--color-text, #1f2937);
  line-height: 1.5;
}
.flyer-audience-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}
.flyer-audience-chip {
  padding: 8px 10px;
  background: var(--color-surface-2, #f9fafb);
  border: 1px solid var(--color-border, #e5e7eb);
  border-radius: var(--radius-sm, 6px);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.flyer-audience-chip-k {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-mute, #71717a);
}
.flyer-audience-chip-v {
  font-size: var(--text-sm, 13px);
  font-weight: 600;
  color: var(--color-text-strong, #0f172a);
}
.flyer-audience-chip-v small {
  font-weight: 500;
  color: var(--color-text-mute, #71717a);
}

.tribu-reactions { display: flex; flex-direction: column; gap: var(--space-2); }
.tribu-reaction {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
}
.tribu-reaction summary { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; cursor: pointer; }
.tribu-reaction-label { font-weight: 500; flex: 1; }
.tribu-reaction-size { font-size: var(--text-xs); color: var(--color-text-mute); font-family: var(--font-mono); }
.tribu-reaction-pill { padding: 2px 8px; border-radius: 4px; font-size: var(--text-xs); }
.tribu-reaction-pill-positivo { background: rgba(22,163,74,0.10); color: var(--color-success); }
.tribu-reaction-pill-negativo { background: rgba(220,38,38,0.10); color: var(--color-danger); }
.tribu-reaction-pill-neutral { background: var(--color-surface-2); color: var(--color-text-mute); }
.tribu-reaction-pct { font-size: var(--text-xs); color: var(--color-text-mute); }
.tribu-reaction-body { padding-top: var(--space-2); border-top: 1px dashed var(--color-border); margin-top: var(--space-2); }
.tribu-reaction-body ul { margin: 4px 0 8px; padding-left: 20px; }

@media (max-width: 900px) {
  .flyer-view-grid { grid-template-columns: 1fr; }
}

/* ===== Custom Popup (alert/confirm replacement) ===== */
.vt-popup-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  transition: opacity 200ms ease;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.vt-popup-backdrop.is-open { opacity: 1; }

.vt-popup-dialog {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.20), 0 4px 16px rgba(15, 23, 42, 0.10);
  padding: var(--space-5);
  max-width: 440px;
  width: calc(100vw - 32px);
  transform: translateY(12px) scale(0.97);
  transition: transform 220ms ease, opacity 200ms ease;
  opacity: 0;
}
.vt-popup-backdrop.is-open .vt-popup-dialog { transform: translateY(0) scale(1); opacity: 1; }

.vt-popup-header { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-3); }
.vt-popup-icon { width: 24px; height: 24px; flex-shrink: 0; stroke-width: 1.75; }
.vt-popup-info    .vt-popup-icon { color: var(--color-interactive); }
.vt-popup-warning .vt-popup-icon { color: var(--color-warning); }
.vt-popup-danger  .vt-popup-icon { color: var(--color-danger); }
.vt-popup-success .vt-popup-icon { color: var(--color-success); }
.vt-popup-title { margin: 0; font-size: var(--text-lg); font-weight: 600; color: var(--color-text); letter-spacing: -0.01em; }

.vt-popup-body {
  font-size: var(--text-sm);
  color: var(--color-text);
  line-height: 1.5;
  margin-bottom: var(--space-5);
}

.vt-popup-actions { display: flex; gap: var(--space-2); justify-content: flex-end; }
.vt-popup-btn {
  background: transparent;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-4);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  color: var(--color-text);
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}
.vt-popup-btn:hover { background: var(--color-surface-2); border-color: var(--color-text-mute); }
.vt-popup-btn:focus-visible { outline: 2px solid var(--color-interactive); outline-offset: 2px; }

.vt-popup-btn-primary {
  background: var(--color-interactive);
  border-color: var(--color-interactive);
  color: #FFFFFF;
}
.vt-popup-btn-primary:hover {
  background: var(--color-interactive-hover);
  border-color: var(--color-interactive-hover);
  color: #FFFFFF;
}
/* Danger variant of the primary button (delete confirms, etc.) */
.vt-popup-btn-danger.vt-popup-btn-primary {
  background: var(--color-danger);
  border-color: var(--color-danger);
}
.vt-popup-btn-danger.vt-popup-btn-primary:hover {
  background: #B91C1C;
  border-color: #B91C1C;
}

/* ===== Home Pipeline ===== */
.home-hero {
  margin: var(--space-2) 0 var(--space-5);
  text-align: center;
}
.home-hero h1 {
  font-size: var(--text-3xl);
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0 0 var(--space-2);
  color: var(--color-text);
}
.home-hero-subtitle {
  font-size: var(--text-base);
  color: var(--color-text-mute);
  margin: 0 auto;
  max-width: none;
  line-height: 1.5;
}
@media (min-width: 980px) {
  /* En desktop el subtítulo entra en una sola línea; en pantallas chicas
     hace wrap natural para no desbordar. */
  .home-hero-subtitle { white-space: nowrap; }
}
.home-hero-hint {
  color: var(--color-interactive);
  font-weight: 500;
}

.pipeline-flow {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.pipeline-stage {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.pipeline-stage-source { max-width: 620px; }

.pipeline-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  text-decoration: none;
  color: var(--color-text);
  display: flex;
  gap: var(--space-4);
  align-items: flex-start;
  transition: border-color var(--transition-fast),
              transform var(--transition-fast),
              box-shadow var(--transition-fast);
  width: 100%;
  box-sizing: border-box;
}
.pipeline-card:hover {
  border-color: var(--color-border-strong);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06), 0 2px 6px rgba(15, 23, 42, 0.04);
}
.pipeline-card-icon-wrap {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.pipeline-card-icon { width: 26px; height: 26px; stroke-width: 1.75; color: var(--color-interactive); }
.pipeline-card-icon-large { width: 32px; height: 32px; stroke-width: 1.75; }
.pipeline-card-body { flex: 1; min-width: 0; }
.pipeline-card-step {
  font-size: var(--text-xs);
  color: var(--color-text-mute);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}
.pipeline-card h3 {
  margin: 0 0 var(--space-2);
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--color-text);
}
.pipeline-card h4 {
  margin: var(--space-3) 0 4px;
  font-size: var(--text-base);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--color-text);
}
.pipeline-card p {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--color-text-mute);
  line-height: 1.5;
}
.pipeline-card-link {
  display: inline-block;
  margin-top: var(--space-3);
  color: var(--color-interactive);
  font-size: var(--text-sm);
  font-weight: 500;
}
.pipeline-card:hover .pipeline-card-link {
  color: var(--color-interactive-hover);
}

/* Arrow between sections — vertical line with a chevron */
.pipeline-arrow {
  width: 2px;
  height: 36px;
  background: linear-gradient(to bottom, var(--color-border-strong), var(--color-interactive));
  margin: var(--space-2) 0;
  position: relative;
}
.pipeline-arrow::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 50%;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 8px solid var(--color-interactive);
  transform: translateX(-50%);
}
.pipeline-arrow-fan { height: 48px; }

/* Action cards (the fan-out) */
.pipeline-fan-label,
.pipeline-aside-label {
  font-size: var(--text-xs);
  color: var(--color-text-mute);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-4);
  width: 100%;
  text-align: center;
}

.pipeline-fan-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
  width: 100%;
}
@media (max-width: 1200px) {
  .pipeline-fan-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .pipeline-fan-grid { grid-template-columns: 1fr; }
}

.pipeline-card-action {
  flex-direction: column;
  gap: 0;
  align-items: flex-start;
  position: relative;
  overflow: hidden;
}
.pipeline-action-num {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--color-surface-2);
  color: var(--color-text-mute);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: 700;
  font-family: var(--font-mono);
}

/* Section-specific accent colors on the action cards (match the panel-izq accents) */
.pipeline-color-padron  .pipeline-card-icon { color: var(--color-text); }
.pipeline-color-tribus  .pipeline-card-icon { color: var(--color-interactive); }
.pipeline-color-radio   .pipeline-card-icon,
.pipeline-color-radio   .pipeline-card-icon-large { color: #06B6D4; }
.pipeline-color-radio   .pipeline-card-icon-wrap { background: rgba(6, 182, 212, 0.08); }
.pipeline-color-play    .pipeline-card-icon,
.pipeline-color-play    .pipeline-card-icon-large { color: var(--color-interactive); }
.pipeline-color-play    .pipeline-card-icon-wrap { background: rgba(99, 102, 241, 0.08); }
.pipeline-color-bandage .pipeline-card-icon,
.pipeline-color-bandage .pipeline-card-icon-large { color: #F59E0B; }
.pipeline-color-bandage .pipeline-card-icon-wrap { background: rgba(245, 158, 11, 0.08); }
.pipeline-color-flask   .pipeline-card-icon,
.pipeline-color-flask   .pipeline-card-icon-large { color: #16A34A; }
.pipeline-color-flask   .pipeline-card-icon-wrap { background: rgba(22, 163, 74, 0.08); }
.pipeline-color-image   .pipeline-card-icon,
.pipeline-color-image   .pipeline-card-icon-large { color: #D946EF; }
.pipeline-color-image   .pipeline-card-icon-wrap { background: rgba(217, 70, 239, 0.08); }
.pipeline-color-mic     .pipeline-card-icon,
.pipeline-color-mic     .pipeline-card-icon-large { color: #EC4899; }
.pipeline-color-mic     .pipeline-card-icon-wrap { background: rgba(236, 72, 153, 0.08); }

/* Aside section (investigación complementaria) */
.pipeline-stage-aside {
  margin-top: var(--space-6);
  padding-top: var(--space-5);
  border-top: 1px dashed var(--color-border);
}
.pipeline-aside-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
}
@media (max-width: 720px) {
  .pipeline-aside-grid { grid-template-columns: 1fr; }
}
.pipeline-card-aside {
  background: var(--color-surface-2);
  flex-direction: row;
  align-items: center;
  padding: var(--space-3) var(--space-4);
  gap: var(--space-3);
}
.pipeline-card-aside .pipeline-card-icon {
  width: 24px;
  height: 24px;
  color: var(--color-text-mute);
}
.pipeline-card-aside h4 { margin: 0; font-size: var(--text-sm); font-weight: 600; }
.pipeline-card-aside p { margin: 2px 0 0; font-size: var(--text-xs); }

/* "Continue last work" CTA */
.home-continue {
  margin-top: var(--space-6);
  padding-top: var(--space-5);
  border-top: 1px solid var(--color-border);
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
}
.home-continue h2 {
  font-size: var(--text-xl);
  font-weight: 600;
  margin: 0 0 var(--space-3);
  color: var(--color-text);
  letter-spacing: -0.01em;
}
.home-continue-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--color-text);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.home-continue-card:hover {
  border-color: var(--color-interactive);
  box-shadow: var(--shadow-sm);
}
.home-continue-icon {
  width: 32px;
  height: 32px;
  color: var(--color-interactive);
  flex-shrink: 0;
}
.home-continue-body { flex: 1; min-width: 0; }
.home-continue-body h3 {
  margin: 0;
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.home-continue-meta {
  display: block;
  font-size: var(--text-xs);
  color: var(--color-text-mute);
  font-family: var(--font-mono);
  margin-top: 4px;
}
.home-continue-arrow {
  width: 20px;
  height: 20px;
  color: var(--color-text-mute);
  flex-shrink: 0;
}

/* ===== Workspace switcher (campaña activa) =====
   Pill clickeable entre el logo y el nav que muestra la campaña activa.
   Click abre dropdown con todas las campañas + link a gestión. */
.cc-campaign-switch {
  position: relative;
  margin-left: 8px;
  margin-right: 8px;
}
.cc-campaign-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 10px;
  /* Sobre el chrome azul-grisáceo del topbar, usamos blanco para destacar */
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-chrome-border, #DCE3ED);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text, #1a1a1a);
  cursor: pointer;
  max-width: 220px;
  transition: background var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.cc-campaign-pill:hover {
  background: #ffffff;
  border-color: var(--color-border-strong, #d1d5db);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}
.cc-campaign-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}
.cc-campaign-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cc-campaign-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 260px;
  max-width: 320px;
  background: #fff;
  border: 1px solid var(--color-border, #e5e7eb);
  border-radius: 10px;
  box-shadow: 0 10px 32px rgba(0,0,0,0.10);
  padding: 6px;
  z-index: 100;
  display: none;
}
.cc-campaign-switch[data-open="true"] .cc-campaign-dropdown {
  display: block;
}
.cc-dropdown-section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-mute, #71717a);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 6px 10px 4px;
}
.cc-campaign-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--color-text, #1a1a1a);
  font-size: 13px;
  transition: background var(--transition-fast);
}
.cc-campaign-item:hover {
  background: var(--color-surface-2, #f3f4f6);
  text-decoration: none;
}
.cc-campaign-item.is-active {
  background: var(--color-surface-2, #f3f4f6);
}
.cc-campaign-item-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}
.cc-campaign-item-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cc-campaign-item-meta {
  font-size: 11px;
  color: var(--color-text-mute, #71717a);
  margin-top: 1px;
}
.cc-campaign-check {
  width: 14px;
  height: 14px;
  color: var(--color-interactive, #2563eb);
  flex-shrink: 0;
}
.cc-dropdown-divider {
  height: 1px;
  background: var(--color-border, #e5e7eb);
  margin: 6px 4px;
}
.cc-campaign-manage {
  color: var(--color-interactive, #2563eb);
  font-weight: 500;
}
.cc-campaign-action-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* ===== Global breadcrumb (Volver al inicio) =====
   Visible pill-style "back" button — sits at the top of every workspace
   page (except the home itself). Designed con presencia: borde + sombra
   sutil + hover azul, así nadie tiene que apretar la flechita atrás del
   browser. */
.cc-breadcrumb {
  margin-bottom: var(--space-5);
}
.cc-breadcrumb-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-strong, #1a1a1a);
  text-decoration: none;
  padding: 8px 14px 8px 10px;
  background: var(--color-surface-1, #ffffff);
  border: 1px solid var(--color-border, #e5e5e5);
  border-radius: 999px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: color var(--transition-fast),
              background var(--transition-fast),
              border-color var(--transition-fast),
              box-shadow var(--transition-fast),
              transform var(--transition-fast);
}
.cc-breadcrumb-back:hover {
  color: var(--color-interactive, #2563eb);
  background: var(--color-surface-2, #f7f7f7);
  border-color: var(--color-interactive, #2563eb);
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.12);
}
.cc-breadcrumb-back:hover .cc-breadcrumb-icon {
  transform: translateX(-3px);
}
.cc-breadcrumb-back:active {
  transform: translateY(1px);
}
.cc-breadcrumb-icon {
  width: 16px;
  height: 16px;
  stroke-width: 2.25;
  transition: transform var(--transition-fast);
}

/* ============================================================================
   Ficha de votante compuesta (composed voter card) — prefix fv- to avoid
   collisions with legacy .gauge-* / .chip rules. Ported from the approved
   demo (demos/_ficha_template.html) onto the existing Territoria tokens.
   Layout lessons applied: minmax(0,1fr) grids, min-width:0, canvas
   max-width:100%, flex:1 on the header text block, no max-width on the bio.
   ========================================================================== */

.fv-head { display: flex; gap: 1.5rem; margin: 1.25rem 0 0; align-items: flex-start; }
.fv-head .fv-head-main { flex: 1 1 0; min-width: 0; }
.fv-avatar { flex: none; width: 152px; text-align: center; }
.fv-avatar img.fv-avatar-photo {
  display: block; width: 132px; height: 132px; border-radius: var(--radius-lg);
  object-fit: cover; border: 3px solid var(--color-surface);
  outline: 2px solid var(--color-interactive); outline-offset: 3px;
  box-shadow: var(--shadow-md);
}
.fv-avatar svg.fv-avatar-main {
  width: 132px; height: 132px; border-radius: var(--radius-lg);
  outline: 2px solid var(--color-interactive); outline-offset: 3px;
}
/* Opportunity ring (IOS) drawn AROUND the avatar — a conic-gradient gauge that
   fills up to --ios-pct in --ios-color over a light track. It never touches the
   avatar body geometry: the silhouette stays the generic anonymized avatar, the
   ring is purely an environment-opportunity band overlaid on top. */
.fv-avatar-ring {
  position: relative; width: 152px; height: 152px; margin: 0 auto;
  border-radius: 50%;
  background: conic-gradient(var(--ios-color, #eab308) var(--ios-pct, 0%),
                             #e5e7eb var(--ios-pct, 0%));
  padding: 10px; box-sizing: border-box;
}
.fv-avatar-ring-inner {
  width: 100%; height: 100%; border-radius: 50%;
  background: var(--color-surface); padding: 3px; box-sizing: border-box;
  display: flex; align-items: center; justify-content: center;
}
.fv-avatar-ring-inner img.fv-avatar-photo,
.fv-avatar-ring-inner svg.fv-avatar-main {
  width: 100%; height: 100%; border-radius: 50%; outline: none;
  outline-offset: 0; object-fit: cover; border: none; box-shadow: none;
}
.fv-avatar-ios-badge {
  position: absolute; bottom: 4px; right: 4px; min-width: 26px; height: 22px;
  padding: 0 6px; border-radius: 99px; background: var(--ios-color, #eab308);
  color: #fff; font-size: 0.72rem; font-weight: 800; line-height: 22px;
  text-align: center; box-shadow: var(--shadow-sm);
  border: 2px solid var(--color-surface);
}
.fv-avatar-chips { display: flex; flex-wrap: wrap; gap: 0.3rem; justify-content: center; margin-top: 0.5rem; }
.fv-avatar-chip {
  display: inline-flex; align-items: center; gap: 0.2rem; font-size: 0.66rem;
  font-weight: 600; background: var(--color-surface-2);
  border: 1px solid var(--color-border); color: var(--color-text-mute);
  padding: 0.12rem 0.45rem; border-radius: 99px; white-space: nowrap;
}
.fv-avatar-cap { font-size: 0.62rem; color: var(--color-text-faint); font-weight: 600; margin-top: 0.55rem; line-height: 1.3; }
.fv-avatar-alt { margin-top: 0.65rem; display: flex; align-items: center; gap: 0.45rem; justify-content: center; }
.fv-avatar-alt svg { flex: none; width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--color-border); background: #EEF0FE; }
.fv-avatar-alt span { font-size: 0.6rem; color: var(--color-text-faint); font-weight: 600; text-align: left; line-height: 1.25; max-width: 5.6rem; }
.fv-sub { font-family: var(--font-mono); font-size: 0.78rem; color: var(--color-text-faint); margin: 0.15rem 0 0.7rem; }
.fv-bio { margin: 0 0 0.9rem; font-size: 0.95rem; }
.fv-bio-tag { font-size: 0.68rem; color: var(--color-text-faint); font-weight: 600; }
.fv-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.7rem; }
.fv-chip {
  display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.78rem;
  font-weight: 600; background: var(--color-surface-2);
  border: 1px solid var(--color-border); color: var(--color-text);
  padding: 0.22rem 0.65rem; border-radius: 99px;
}
.fv-chip .fv-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--color-interactive); }
.fv-chip.fv-chip-accent { background: rgba(99,102,241,0.10); border-color: rgba(99,102,241,0.30); color: var(--color-interactive-hover); }

/* --- two-column layout --- */
.fv-cols { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 1.25rem; margin-top: 1.5rem; align-items: start; }
.fv-col { display: flex; flex-direction: column; gap: 1.25rem; min-width: 0; }
.fv-card-title { margin: 0 0 0.8rem; font-size: 0.78rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.09em; color: var(--color-text-mute); border-bottom: none; padding-bottom: 0; }

/* --- charts --- */
.fv-chart-box { position: relative; height: 320px; min-width: 0; }
.fv-chart-box canvas, .fv-gauge-box canvas { max-width: 100%; }
.fv-chart-note { font-size: 0.74rem; color: var(--color-text-faint); text-align: center; margin: 0.6rem 0 0; }
/* Tendencia política: resaltada del gris tenue con el acento indigo del tema */
.fv-tendencia-highlight {
  font-size: 0.8rem; line-height: 1.45; color: var(--color-text); margin: 0.8rem 0 0;
  background: rgba(99,102,241,0.08); border: 1px solid rgba(99,102,241,0.30);
  border-left: 3px solid var(--color-interactive);
  border-radius: var(--radius-md); padding: 0.55rem 0.75rem;
}
.fv-tendencia-highlight strong { color: var(--color-interactive-hover); font-weight: 700; }
.fv-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.fv-gauge-box { position: relative; height: 118px; min-width: 0; }
.fv-gauge-value { position: absolute; left: 0; right: 0; top: 56%; text-align: center; font-weight: 800; font-size: 1.35rem; letter-spacing: -0.02em; pointer-events: none; }
.fv-gauge-label { text-align: center; font-size: 0.76rem; font-weight: 600; color: var(--color-text-mute); margin-top: 0.3rem; }

/* --- provenance badges --- */
.fv-src-legend { display: flex; flex-wrap: wrap; gap: 0.4rem 1.1rem; margin-bottom: 0.9rem; font-size: 0.75rem; color: var(--color-text-mute); align-items: center; }
.fv-prov-list { display: flex; flex-direction: column; }
.fv-prov-row { display: flex; align-items: center; gap: 0.7rem; padding: 0.42rem 0.2rem; border-bottom: 1px solid var(--color-border); font-size: 0.85rem; }
.fv-prov-row:last-child { border-bottom: none; }
.fv-prov-row .fv-pv-field { color: var(--color-text-mute); }
.fv-prov-row .fv-pv-value { font-weight: 600; margin-left: auto; text-align: right; min-width: 0; overflow-wrap: anywhere; }
.fv-src-badge { flex: none; display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.66rem; font-weight: 700; letter-spacing: 0.02em; padding: 0.12rem 0.5rem; border-radius: 99px; white-space: nowrap; }
.fv-src-hard { background: var(--color-success); border: 1px solid var(--color-success); color: #fff; }
.fv-src-inf  { background: transparent; border: 1px solid var(--color-interactive); color: var(--color-interactive-hover); }
.fv-src-llm  { background: linear-gradient(90deg, rgba(139,92,246,0.22) 50%, transparent 50%); border: 1px solid var(--accent-secondary); color: #6D28D9; }

/* --- financial enrichment block (AFIP/BCRA) --- */
.fv-fin-block { margin-top: 0.9rem; padding-top: 0.9rem; border-top: 1px dashed var(--color-border); }
.fv-fin-title { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem; font-size: 0.82rem; font-weight: 700; color: var(--color-text); margin-bottom: 0.6rem; }
.fv-fin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 0.5rem 1rem; }
.fv-fin-item { display: flex; flex-direction: column; min-width: 0; }
.fv-fin-item .fv-fin-k { font-size: 0.7rem; color: var(--color-text-mute); }
.fv-fin-item .fv-fin-v { font-size: 0.85rem; font-weight: 600; overflow-wrap: anywhere; }
.fv-fin-reading { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.7rem; padding: 0.5rem 0.7rem; border-radius: 10px; font-size: 0.82rem; line-height: 1.4; background: var(--color-surface-alt, #F4F4F5); }
.fv-fin-reading--deteriorando { background: rgba(220,38,38,0.10); }
.fv-fin-reading--mejorando { background: rgba(22,163,74,0.10); }
.fv-fin-reading--estable { background: rgba(217,119,6,0.08); }

/* --- tribe card --- */
.fv-tribe-card {
  background: linear-gradient(160deg, #FFFFFF 0%, #EEF0FE 100%);
  border: 1px solid rgba(99,102,241,0.35); border-radius: 16px; padding: 1.5rem;
  box-shadow: var(--shadow-md); position: relative; overflow: hidden;
}
.fv-tribe-card::before { content: ""; position: absolute; top: -40px; right: -40px; width: 140px; height: 140px; border-radius: 50%; background: rgba(99,102,241,0.10); }
.fv-tribe-kicker { font-size: 0.66rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.12em; color: var(--color-interactive); }
.fv-tribe-card h3 { margin: 0.3rem 0 0.6rem; font-size: 1.05rem; font-weight: 800; line-height: 1.3; letter-spacing: -0.01em; color: var(--color-text); border: none; padding: 0; }
.fv-tribe-desc { font-size: 0.82rem; color: var(--color-text-mute); margin: 0 0 0.9rem; position: relative; }
.fv-affinity-row { display: flex; align-items: center; gap: 0.7rem; margin-bottom: 0.9rem; }
.fv-affinity-num { font-size: 1.8rem; font-weight: 800; letter-spacing: -0.03em; color: var(--color-interactive-hover); }
.fv-affinity-bar { flex: 1; height: 8px; background: rgba(99,102,241,0.15); border-radius: 99px; overflow: hidden; }
.fv-affinity-bar i { display: block; height: 100%; background: var(--color-interactive); border-radius: 99px; }
.fv-tribe-traits { list-style: none; margin: 0; padding: 0; font-size: 0.83rem; }
.fv-tribe-traits li { display: flex; gap: 0.5rem; padding: 0.26rem 0; align-items: baseline; }
.fv-tribe-traits li::before { content: "\2713"; color: var(--color-success); font-weight: 800; }
.fv-tribe-note { font-size: 0.74rem; color: var(--color-text-faint); margin-top: 0.8rem; border-top: 1px dashed rgba(99,102,241,0.3); padding-top: 0.7rem; position: relative; }

/* --- channels / consumption --- */
.fv-chan-row { display: flex; align-items: center; gap: 0.6rem; padding: 0.3rem 0; }
.fv-chan-ic { flex: none; width: 30px; height: 22px; border-radius: 6px; color: #fff; font-size: 0.62rem; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; letter-spacing: 0.03em; }
.fv-chan-ic-media { background: var(--color-surface-2); color: var(--color-text-mute); border: 1px solid var(--color-border); }
.fv-chan-name { font-size: 0.82rem; font-weight: 600; width: 7.2rem; flex: none; }
.fv-chan-bar { flex: 1; height: 7px; background: var(--color-surface-2); border-radius: 99px; overflow: hidden; }
.fv-chan-bar i { display: block; height: 100%; background: var(--color-interactive); border-radius: 99px; }
.fv-chan-bar-media i { background: var(--color-text-faint); }
.fv-chan-pct { flex: none; width: 2.6rem; text-align: right; font-family: var(--font-mono); font-size: 0.72rem; color: var(--color-text-mute); }
.fv-chan-kicker { font-size: 0.72rem; font-weight: 700; color: var(--color-text-faint); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 0.4rem; }
.fv-consume-line { font-size: 0.82rem; color: var(--color-text-mute); border-top: 1px dashed var(--color-border); margin-top: 0.9rem; padding-top: 0.8rem; }
.fv-consume-line b { color: var(--color-text); }

/* --- segment anthropometry + opportunity index side by side ---
   Two equal cards in one row so they sit side by side (~50/50). The
   .fv-anthro-ios-full modifier makes the row span the FULL ficha width
   (it now lives OUTSIDE the narrow two-column grid, like the "Campos del
   perfil" section) with comfortable top spacing. Each child .card stretches
   to equal height; the row collapses to a single column on narrow widths
   (matches .fv-cols behaviour). */
.fv-anthro-ios-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; align-items: stretch; }
.fv-anthro-ios-row > .card { margin: 0; min-width: 0; display: flex; flex-direction: column; }
.fv-anthro-ios-full { margin-top: 1.5rem; margin-bottom: 1.75rem; }
@media (max-width: 900px) { .fv-anthro-ios-row { grid-template-columns: minmax(0, 1fr); } }

/* --- estimated anthropometric profile (individual — legacy, kept for back-compat) --- */
.fv-anthro-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.6rem; }
.fv-anthro-cell { text-align: center; background: var(--color-bg-subtle, #f6f7fb); border: 1px solid var(--color-border); border-radius: 10px; padding: 0.6rem 0.3rem; min-width: 0; }
.fv-anthro-num { font-weight: 800; font-size: 1.2rem; letter-spacing: -0.02em; color: var(--color-text); }
.fv-anthro-unit { font-size: 0.72rem; font-weight: 600; color: var(--color-text-mute); }
.fv-anthro-lbl { font-size: 0.7rem; font-weight: 600; color: var(--color-text-mute); margin-top: 0.25rem; text-transform: capitalize; }
.fv-anthro-sub { display: block; font-size: 0.6rem; font-weight: 600; color: var(--color-text-faint); text-transform: none; letter-spacing: 0; }
@media (max-width: 560px) { .fv-anthro-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* --- SEGMENT anthropometric distribution (tribe/archetype) ---
   Horizontal, comfortable layout: tribe label + sample n, then two inner
   columns (IMC distribution bars | talles más comunes + peso/altura promedio). */
.fv-seg-tribe { font-size: 0.84rem; font-weight: 700; color: var(--color-text); margin-bottom: 0.9rem; }
.fv-seg-n { display: inline-block; margin-left: 0.4rem; font-size: 0.72rem; font-weight: 600; color: var(--color-text-mute); }
.fv-seg-cols { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 1.4rem; align-items: start; }
@media (max-width: 560px) { .fv-seg-cols { grid-template-columns: minmax(0, 1fr); } }
.fv-seg-block { min-width: 0; }
.fv-seg-kicker { font-size: 0.7rem; font-weight: 700; color: var(--color-text-faint); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 0.55rem; }
.fv-seg-bar-row { display: flex; align-items: center; gap: 0.5rem; padding: 0.18rem 0; }
.fv-seg-bar-lbl { flex: none; width: 5.6rem; font-size: 0.74rem; font-weight: 600; color: var(--color-text-mute); }
.fv-seg-bar { flex: 1 1 auto; height: 0.6rem; background: var(--color-bg-subtle, #f6f7fb); border: 1px solid var(--color-border); border-radius: 99px; overflow: hidden; }
.fv-seg-bar i { display: block; height: 100%; border-radius: 99px; background: var(--color-text-mute); }
.fv-seg-bar--normal i { background: #16A34A; }
.fv-seg-bar--sobrepeso i { background: #D97706; }
.fv-seg-bar--obesidad i { background: #DC2626; }
.fv-seg-bar--bajo_peso i { background: #0EA5E9; }
.fv-seg-bar-val { flex: none; width: 2.6rem; text-align: right; font-size: 0.76rem; font-weight: 700; color: var(--color-text); font-family: var(--font-mono); }
.fv-seg-talles { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.9rem; }
.fv-seg-talle { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.82rem; font-weight: 700; background: var(--color-surface-2); border: 1px solid var(--color-border); color: var(--color-text); padding: 0.22rem 0.7rem; border-radius: 99px; }
.fv-seg-talle b { font-weight: 800; color: var(--color-interactive-hover); }
.fv-seg-prom { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }
.fv-seg-prom-cell { text-align: center; background: var(--color-bg-subtle, #f6f7fb); border: 1px solid var(--color-border); border-radius: 10px; padding: 0.6rem 0.3rem; min-width: 0; }
.fv-seg-prom-num { font-weight: 800; font-size: 1.15rem; letter-spacing: -0.02em; color: var(--color-text); }
.fv-seg-prom-lbl { font-size: 0.68rem; font-weight: 600; color: var(--color-text-mute); margin-top: 0.25rem; }

/* --- estimated socioeconomic opportunity index (IOS) --- */
.fv-ios-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.6rem; margin-bottom: 0.7rem; }
.fv-ios-score { font-weight: 800; font-size: 2rem; line-height: 1; letter-spacing: -0.03em; color: var(--color-text); }
.fv-ios-scale { font-size: 0.82rem; font-weight: 600; color: var(--color-text-mute); }
.fv-ios-nivel { font-size: 0.74rem; font-weight: 600; color: var(--color-text-mute); text-transform: capitalize; }
.fv-ios-nivel b { color: var(--color-text); }
.fv-ios-decomp { display: flex; flex-direction: column; gap: 0.45rem; }
.fv-ios-bar-row { display: flex; align-items: center; gap: 0.5rem; }
.fv-ios-bar-lbl { flex: none; width: 5.2rem; font-size: 0.72rem; font-weight: 600; color: var(--color-text-mute); }
.fv-ios-bar { flex: 1 1 auto; height: 0.55rem; background: var(--color-bg-subtle, #f6f7fb); border: 1px solid var(--color-border); border-radius: 99px; overflow: hidden; }
.fv-ios-bar i { display: block; height: 100%; border-radius: 99px; }
.fv-ios-bar-cap i { background: #4F46E5; }
.fv-ios-bar-conn i { background: #0E7490; }
.fv-ios-bar-val { flex: none; width: 1.8rem; text-align: right; font-size: 0.74rem; font-weight: 700; color: var(--color-text); }

/* --- chat with the simulated citizen --- */
.fv-chat-section { margin-top: 1.5rem; }
.fv-chat-box { display: flex; flex-direction: column; gap: 0.7rem; max-width: 760px; margin: 0 auto; }
.fv-bubble { max-width: 88%; padding: 0.7rem 0.95rem; border-radius: 14px; font-size: 0.9rem; line-height: 1.5; }
.fv-bubble-q { align-self: flex-end; background: var(--color-interactive); color: #fff; border-bottom-right-radius: 4px; }
.fv-bubble-a { align-self: flex-start; background: var(--color-surface-2); border: 1px solid var(--color-border); border-bottom-left-radius: 4px; white-space: pre-wrap; }
.fv-bubble-err { align-self: flex-start; background: rgba(220,38,38,0.08); border: 1px solid rgba(220,38,38,0.35); color: var(--color-danger); border-bottom-left-radius: 4px; }
.fv-bubble-meta { font-size: 0.68rem; color: var(--color-text-faint); font-weight: 600; }
.fv-bubble-meta.fv-right { text-align: right; }
.fv-disclaimer-tag { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.72rem; font-weight: 600; color: var(--color-text-mute); background: var(--color-surface-2); border: 1px solid var(--color-border); padding: 0.2rem 0.6rem; border-radius: 99px; }
.fv-chat-input { display: flex; gap: 0.6rem; margin-top: 0.9rem; }
.fv-chat-input input {
  flex: 1; padding: 0.65rem 0.95rem; border-radius: 99px;
  border: 1px solid var(--color-border); background: var(--color-surface);
  font-family: var(--font-sans); font-size: 0.88rem; color: var(--color-text);
}
.fv-chat-input input:disabled { background: var(--color-surface-2); color: var(--color-text-mute); }
.fv-chat-input button {
  padding: 0.65rem 1.2rem; border-radius: 99px; border: none;
  background: var(--color-interactive); color: #fff;
  font-family: var(--font-sans); font-weight: 700; font-size: 0.88rem; cursor: pointer;
}
.fv-chat-input button:hover { background: var(--color-interactive-hover); }
.fv-chat-input button:disabled { background: var(--color-border); color: var(--color-text-faint); cursor: not-allowed; }
.fv-chat-spinner { align-self: flex-start; display: inline-flex; gap: 0.3rem; padding: 0.7rem 0.95rem; }
.fv-chat-spinner span { width: 7px; height: 7px; border-radius: 50%; background: var(--color-text-faint); animation: fv-blink 1.2s infinite ease-in-out; }
.fv-chat-spinner span:nth-child(2) { animation-delay: 0.2s; }
.fv-chat-spinner span:nth-child(3) { animation-delay: 0.4s; }
@keyframes fv-blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }
details.fv-analysis { margin-top: 0.4rem; font-size: 0.84rem; align-self: stretch; }
details.fv-analysis summary { cursor: pointer; font-weight: 700; color: var(--color-interactive-hover); font-size: 0.82rem; }
details.fv-analysis .fv-analysis-body { margin-top: 0.6rem; padding: 1rem 1.2rem; background: var(--color-surface-2); border: 1px solid var(--color-border); border-radius: var(--radius-md); color: var(--color-text-mute); white-space: pre-wrap; }
.fv-sources { margin-top: 0.6rem; font-family: var(--font-mono); font-size: 0.68rem; color: var(--color-text-faint); }
.fv-sources ul { margin: 0.2rem 0 0; padding-left: 1.1rem; }
.fv-sources li { word-break: break-all; }

/* --- accordion: full 11-dimension profile --- */
.fv-dims-section { margin-top: 1.5rem; }
.fv-dims-intro { font-size: 0.8rem; color: var(--color-text-mute); margin: -0.2rem 0 1rem; max-width: 80ch; }
details.fv-dim { border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); margin-bottom: 0.55rem; overflow: hidden; }
details.fv-dim[open] { box-shadow: var(--shadow-sm); border-color: var(--color-border-strong); }
details.fv-dim summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 0.7rem; padding: 0.68rem 0.95rem; font-weight: 700; font-size: 0.88rem; letter-spacing: -0.01em; }
details.fv-dim summary::-webkit-details-marker { display: none; }
details.fv-dim summary::before { content: "\25B8"; color: var(--color-text-faint); font-size: 0.8rem; transition: transform 0.15s ease; }
details.fv-dim[open] summary::before { transform: rotate(90deg); }
details.fv-dim summary:hover { background: var(--color-surface-2); }
.fv-dim-count { margin-left: auto; font-family: var(--font-mono); font-size: 0.68rem; color: var(--color-text-faint); font-weight: 500; white-space: nowrap; }
.fv-dim-table { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: 0.82rem; border-top: 1px solid var(--color-border); }
.fv-dim-table > tbody > tr > th { text-align: left; font-weight: 600; color: var(--color-text-mute); padding: 0.45rem 0.95rem; vertical-align: top; width: 40%; border-bottom: 1px solid var(--color-border); }
.fv-dim-table > tbody > tr > td { padding: 0.45rem 0.95rem; border-bottom: 1px solid var(--color-border); font-weight: 600; overflow-wrap: break-word; }
.fv-dim-table > tbody > tr:last-child > th, .fv-dim-table > tbody > tr:last-child > td { border-bottom: none; }
table.fv-dim-sub { width: 100%; max-width: 22rem; border-collapse: collapse; font-size: 0.78rem; }
table.fv-dim-sub th { font-weight: 500; color: var(--color-text-mute); text-align: left; padding: 0.12rem 0.6rem 0.12rem 0; border: none; }
table.fv-dim-sub td { text-align: right; font-family: var(--font-mono); font-weight: 500; padding: 0.12rem 0; border: none; white-space: nowrap; }
.fv-dim-chip { display: inline-block; font-size: 0.74rem; font-weight: 600; background: var(--color-surface-2); border: 1px solid var(--color-border); border-radius: 99px; padding: 0.08rem 0.55rem; margin: 0.08rem 0.18rem 0.08rem 0; }
.fv-dim-code { font-family: var(--font-mono); font-size: 0.72rem; color: var(--color-text-mute); font-weight: 500; word-break: break-all; }

.fv-eth-footer { margin-top: 3rem; padding: 1.2rem 1.5rem; background: var(--color-surface-2); border: 1px solid var(--color-border); border-radius: var(--radius-lg); text-align: center; font-size: 0.82rem; color: var(--color-text-mute); }
.fv-eth-footer strong { color: var(--color-text); letter-spacing: 0.04em; }

@media (max-width: 880px) {
  .fv-cols, .fv-grid-3 { grid-template-columns: minmax(0, 1fr); }
  .fv-head { flex-direction: column; }
}

/* ===================================================================
   Relationship graph — voter card button + modal
   Domicile/surname coincidence graph (mirrorfish/relations.py).
   =================================================================== */
.fv-head-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}
.fv-rel-open { display: inline-flex; align-items: center; gap: 0.35rem; }
.fv-rel-hint { font-size: 0.74rem; color: var(--color-text-mute, #71717A); }

.fv-rel-noscroll { overflow: hidden; }

.fv-rel-modal { position: fixed; inset: 0; z-index: 1000; }
.fv-rel-modal[hidden] { display: none; }
.fv-rel-backdrop {
  position: absolute; inset: 0;
  background: rgba(24, 24, 27, 0.55);
  backdrop-filter: blur(2px);
}
.fv-rel-dialog {
  position: absolute; inset: 3vh 50% auto auto;
  transform: translateX(50%);
  width: min(1180px, 94vw); max-height: 94vh;
  display: flex; flex-direction: column;
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border, #E4E4E7);
  border-radius: 14px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}
.fv-rel-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; padding: 1rem 1.25rem 0.75rem;
  border-bottom: 1px solid var(--color-border, #E4E4E7);
}
.fv-rel-head h2 { margin: 0; font-size: 1.1rem; font-weight: 800; letter-spacing: -0.02em; }
.fv-rel-sub { margin: 0.2rem 0 0; font-size: 0.82rem; color: var(--color-text-mute, #71717A); }
.fv-rel-x {
  border: 0; background: transparent; font-size: 1.6rem; line-height: 1;
  color: var(--color-text-mute, #71717A); cursor: pointer; padding: 0 0.2rem;
}
.fv-rel-x:hover { color: var(--color-text, #18181B); }
.fv-rel-disclaimer {
  margin: 0.75rem 1.25rem 0; padding: 0.55rem 0.85rem;
  background: rgba(234, 88, 12, 0.08);
  border: 1px solid rgba(234, 88, 12, 0.25);
  border-radius: 8px; font-size: 0.78rem; color: #C2410C; font-weight: 600;
}
.fv-rel-story {
  margin: 0.6rem 1.25rem 0; padding: 0.55rem 0.8rem;
  background: var(--color-surface-2, #F4F4F5);
  border: 1px solid var(--color-border, #E4E4E7);
  border-radius: 8px; font-size: 0.84rem; line-height: 1.45;
}
.fv-rel-body {
  display: grid; grid-template-columns: minmax(0, 1fr) 300px;
  gap: 1rem; padding: 1rem 1.25rem 1.25rem; min-height: 0; overflow: auto;
}
.fv-rel-graph { position: relative; min-width: 0; }
#fv-rel-cy {
  /* altura que tracke el viewport (era 600px fijo): box más consistente entre
     pantallas, evita que quede corto/largo según la máquina */
  width: 100%; height: clamp(420px, 70vh, 720px); border-radius: 10px;
  background: radial-gradient(circle at 50% 38%, #FFFFFF 0%, #F1F5F9 100%);
  border: 1px solid var(--color-border, #E4E4E7);
}
/* Botón flotante "Centrar" sobre el grafo */
.fv-rel-recenter {
  position: absolute; top: 10px; right: 10px; z-index: 5;
  font-size: 0.74rem; font-weight: 700; cursor: pointer;
  color: #fff; border: none; border-radius: 8px; padding: 6px 11px;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  box-shadow: 0 2px 8px rgba(99,102,241,.3);
  transition: transform .15s, filter .15s;
}
.fv-rel-recenter:hover { transform: translateY(-1px); filter: brightness(1.08); }
.fv-rel-loading, .fv-rel-fallback {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-size: 0.86rem; color: var(--color-text-faint, #A1A1AA); text-align: center;
}
.fv-rel-fallback { color: #C2410C; }
.fv-rel-retry {
  margin-top: 8px; cursor: pointer; font-weight: 700; font-size: 0.8rem;
  color: #fff; border: none; border-radius: 8px; padding: 7px 16px;
  background: #6366f1; transition: filter .15s;
}
.fv-rel-retry:hover { filter: brightness(1.1); }

.fv-rel-side { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.fv-rel-card {
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border, #E4E4E7);
  border-radius: 10px; padding: 0.85rem 1rem;
}
.fv-rel-card h3 {
  margin: 0 0 0.6rem; font-size: 0.72rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--color-text-mute, #71717A);
}
.fv-rel-kv {
  display: flex; justify-content: space-between; gap: 0.6rem;
  font-size: 0.8rem; padding: 0.26rem 0;
  border-bottom: 1px dashed var(--color-border, #E4E4E7);
}
.fv-rel-kv:last-child { border-bottom: 0; }
.fv-rel-kv span { color: var(--color-text-mute, #71717A); }
.fv-rel-kv b { font-weight: 600; text-align: right; word-break: break-word; }
.fv-rel-tag {
  display: inline-block; font-size: 0.66rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
  padding: 0.14rem 0.5rem; border-radius: 99px;
}
.fv-rel-tag-casa { background: rgba(22, 163, 74, 0.12); color: #15803D; }
.fv-rel-tag-edif { background: rgba(99, 102, 241, 0.12); color: #4F46E5; }

.fv-rel-legrow {
  display: flex; align-items: center; gap: 0.5rem; font-size: 0.8rem;
  padding: 0.3rem 0; border-bottom: 1px dashed var(--color-border, #E4E4E7);
}
.fv-rel-legrow:last-of-type { border-bottom: 0; }
.fv-rel-dot {
  flex: none; width: 13px; height: 13px; border-radius: 50%;
  border: 1.5px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
}
.fv-rel-legempty span:not(.fv-rel-dot):not(.fv-rel-cnt) { color: var(--color-text-faint, #A1A1AA); }
.fv-rel-cnt {
  margin-left: auto; font-family: var(--font-mono, monospace);
  font-size: 0.74rem; color: var(--color-text-mute, #71717A); font-weight: 600;
}
.fv-rel-note { font-size: 0.72rem; color: var(--color-text-faint, #A1A1AA); margin: 0.55rem 0 0; line-height: 1.4; }

.fv-rel-empty { font-size: 0.82rem; color: var(--color-text-faint, #A1A1AA); margin: 0; }
.fv-rel-selname { font-size: 1rem; font-weight: 800; margin: 0 0 0.1rem; }
.fv-rel-badge {
  display: inline-block; font-size: 0.66rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
  padding: 0.14rem 0.5rem; border-radius: 99px; color: #fff; margin-bottom: 0.55rem;
}
.fv-rel-fact { font-size: 0.8rem; color: var(--color-text-mute, #71717A); margin: 0 0 0.6rem; line-height: 1.45; }
.fv-rel-gotolink {
  display: inline-block; margin-top: 0.7rem; font-size: 0.82rem; font-weight: 700;
  color: var(--color-interactive, #6366F1); text-decoration: none;
}
.fv-rel-gotolink:hover { text-decoration: underline; }

@media (max-width: 880px) {
  .fv-rel-body { grid-template-columns: minmax(0, 1fr); }
  #fv-rel-cy { height: 440px; }
}

/* ── Acceso destacado a Ciudad Viva en el inicio ───────────────────────── */
.home-simcity-banner {
  display: flex; align-items: center; gap: 1.4rem;
  margin: 0 0 1.75rem; padding: 1.35rem 1.6rem;
  border-radius: 16px; position: relative; overflow: hidden;
  text-decoration: none; color: #fff;
  background: linear-gradient(120deg, #0EA5E9 0%, #6366F1 52%, #8B5CF6 100%);
  box-shadow: 0 12px 32px -10px rgba(99, 102, 241, .5);
  transition: transform .18s ease, box-shadow .18s ease;
}
.home-simcity-banner:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 44px -10px rgba(99, 102, 241, .6);
}
.home-simcity-icon {
  flex: 0 0 auto; width: 56px; height: 56px; border-radius: 14px;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, .18);
  border: 1px solid rgba(255, 255, 255, .28);
}
.home-simcity-icon svg { width: 30px; height: 30px; }
.home-simcity-body { flex: 1 1 auto; min-width: 0; }
.home-simcity-body h2 {
  margin: .25rem 0 .3rem; font-size: 1.35rem; font-weight: 800; color: #fff;
}
.home-simcity-body p {
  margin: 0; font-size: .9rem; line-height: 1.4; color: rgba(255, 255, 255, .92);
}
.home-simcity-badge {
  display: inline-flex; align-items: center; gap: .4rem;
  font-size: .7rem; font-weight: 800; letter-spacing: .08em;
  padding: .2rem .55rem; border-radius: 999px;
  background: rgba(255, 255, 255, .2); color: #fff;
}
.home-simcity-dot {
  width: 8px; height: 8px; border-radius: 50%; background: #34D399;
  box-shadow: 0 0 0 0 rgba(52, 211, 153, .7);
  animation: home-simcity-pulse 1.6s infinite;
}
@keyframes home-simcity-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(52, 211, 153, .7); }
  70%  { box-shadow: 0 0 0 8px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}
.home-simcity-cta {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: .45rem;
  font-size: .92rem; font-weight: 700; color: #fff; white-space: nowrap;
  padding: .6rem 1rem; border-radius: 10px;
  background: rgba(255, 255, 255, .16);
  border: 1px solid rgba(255, 255, 255, .3);
  transition: background .18s ease;
}
.home-simcity-banner:hover .home-simcity-cta { background: rgba(255, 255, 255, .28); }
.home-simcity-cta-arrow { width: 17px; height: 17px; }
@media (max-width: 720px) {
  .home-simcity-banner { flex-wrap: wrap; gap: 1rem; }
  .home-simcity-cta { width: 100%; justify-content: center; }
}
