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

:root {
    --primary-color: #2563eb;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --background-color: #f8fafc;
    --surface-color: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --border-radius: 8px;
    --transition: all 0.2s ease-in-out;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary);
    line-height: 1.6;
}

/* Layout principal */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    --header-fg: rgba(255, 255, 255, 0.97);
    --header-fg-muted: rgba(226, 232, 240, 0.88);
    background:
        radial-gradient(ellipse 120% 100% at 0% 0%, rgba(56, 189, 248, 0.22) 0%, transparent 45%),
        radial-gradient(ellipse 80% 70% at 100% 20%, rgba(99, 102, 241, 0.2) 0%, transparent 42%),
        radial-gradient(ellipse 90% 80% at 50% 120%, rgba(37, 99, 235, 0.45) 0%, transparent 55%),
        linear-gradient(165deg, #0f172a 0%, #1e3a8a 38%, #1d4ed8 72%, #172554 100%);
    color: var(--header-fg);
    padding: 0;
    text-align: left;
    box-shadow:
        0 8px 32px -8px rgba(15, 23, 42, 0.55),
        0 1px 0 rgba(255, 255, 255, 0.08) inset;
    position: relative;
    overflow: hidden;
}

.header-accent {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(
        90deg,
        rgba(56, 189, 248, 0.95) 0%,
        rgba(129, 140, 248, 0.9) 45%,
        rgba(96, 165, 250, 0.85) 100%
    );
    z-index: 2;
    pointer-events: none;
}

.header::before {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        -12deg,
        transparent,
        transparent 56px,
        rgba(255, 255, 255, 0.012) 56px,
        rgba(255, 255, 255, 0.012) 57px
    );
    pointer-events: none;
}

.header::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.18), transparent);
    pointer-events: none;
}

.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: clamp(1rem, 3vw, 2rem);
    padding: clamp(1.1rem, 2.4vw, 1.65rem) clamp(1rem, 2.5vw, 1.5rem);
    min-height: 4.25rem;
}

.header-toolbar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-lang-toggle {
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.92);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 6px;
    padding: 0.4rem 0.65rem;
    line-height: 1;
    cursor: pointer;
    transition: var(--transition);
}

.btn-lang-toggle:hover {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.35);
}

.btn-lang-toggle:focus-visible {
    outline: 2px solid rgba(56, 189, 248, 0.85);
    outline-offset: 2px;
}

.btn-header-actions {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.95rem;
    font-size: 0.8125rem;
    font-weight: 600;
    font-family: inherit;
    letter-spacing: 0.01em;
    color: var(--header-fg);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 10px;
    cursor: pointer;
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.12) inset,
        0 4px 14px -4px rgba(15, 23, 42, 0.35);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.btn-header-actions:hover {
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.35);
    color: #fff;
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.18) inset,
        0 6px 20px -4px rgba(15, 23, 42, 0.4);
}

.btn-header-actions:focus {
    outline: none;
    box-shadow:
        0 0 0 2px rgba(15, 23, 42, 0.5),
        0 0 0 4px rgba(147, 197, 253, 0.55);
}

.btn-header-actions:active {
    transform: translateY(1px);
}

.btn-header-actions i {
    font-size: 0.95rem;
    opacity: 0.92;
}

.btn-header-actions__label {
    white-space: nowrap;
}

.header-content {
    flex: 1;
    min-width: 0;
    display: flex;
    justify-content: flex-start;
    padding: 0;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: clamp(0.9rem, 2.4vw, 1.5rem);
    max-width: min(56rem, 100%);
    text-align: left;
}

.header-brand__mark {
    flex-shrink: 0;
    width: clamp(2.75rem, 6.5vw, 3.5rem);
    height: clamp(2.75rem, 6.5vw, 3.5rem);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.05) 100%);
    border: 1px solid rgba(255, 255, 255, 0.28);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.35) inset,
        0 12px 32px -14px rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.header-brand__mark i {
    font-size: clamp(1.15rem, 3vw, 1.45rem);
    color: #fff;
    filter: drop-shadow(0 1px 3px rgba(15, 23, 42, 0.35));
}

.header-brand__text {
    min-width: 0;
}

.header-brand__kicker {
    font-size: clamp(0.65rem, 0.55vw + 0.55rem, 0.75rem);
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(186, 230, 253, 0.92);
    margin: 0 0 0.35rem;
    line-height: 1.2;
}

.header-brand__text h1 {
    font-size: clamp(1.35rem, 2.2vw + 0.45rem, 2.15rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.15;
    margin: 0;
    text-wrap: balance;
    color: #fff;
    text-shadow: 0 1px 3px rgba(15, 23, 42, 0.25);
}

.header-brand__tagline {
    font-size: clamp(0.875rem, 0.9vw + 0.55rem, 1.02rem);
    font-weight: 400;
    line-height: 1.5;
    margin: 0.45rem 0 0;
    max-width: 42ch;
    color: var(--header-fg-muted);
}

/* Panel de controles */
.controls-panel {
    background: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    padding: 0.45rem 0;
    box-shadow: var(--shadow-sm);
}

.controls-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 0.85rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 0.65rem;
}

.controls-panel h3 {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-size: 1.05rem;
    font-weight: 600;
}

.controls-panel h3 i {
    margin-right: 0.5rem;
    color: var(--primary-color);
}

/* Barra de menú: variable INE en mapa */
.map-variable-bar {
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    padding: 0.4rem 0.75rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.map-variable-bar-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.55rem;
    width: 100%;
}

/* Secciones: barra de variable INE */
.map-variable-bar__section {
    display: flex;
    align-items: stretch;
    gap: 0.5rem;
    flex-wrap: wrap;
    box-sizing: border-box;
    width: 100%;
    flex: 0 0 auto;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.map-variable-bar__section--variable {
    width: 100%;
    flex: 0 0 auto;
    min-width: 0;
    padding-left: 0;
    padding-top: 0;
}

.map-variable-bar__section--variable .map-variable-bar__label.map-variable-bar__label--block {
    display: block;
    text-align: left;
    width: 100%;
    box-sizing: border-box;
}

.map-variable-bar__section--variable .map-variable-bar__options {
    justify-content: center;
}

.map-variable-stack {
    display: flex;
    flex-direction: column;
    gap: 0.28rem;
    width: 100%;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.4rem 0.55rem 0.45rem;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.map-variable-bar__label--block {
    white-space: normal;
}

.map-variable-bar__sublabel {
    font-size: 0.72rem;
    font-weight: 600;
    color: #64748b;
    line-height: 1.3;
    margin-top: 0.15rem;
}

.map-variable-bar__options--compact {
    gap: 0.35rem;
}

.map-variable-btn--compact {
    padding: 0.22rem 0.4rem;
    font-size: 0.68rem;
    font-weight: 500;
    gap: 0.2rem;
}

.map-variable-btn--compact i {
    font-size: 0.85em;
}

/* Años (select base .bar-year-select arriba) */
.bar-year-select {
    width: auto;
    min-width: 5.5rem;
    max-width: 7rem;
    padding: 0.4rem 0.55rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    font-weight: 600;
    text-align: center;
    background: #fff;
    cursor: pointer;
}

.bar-year-select--inline {
    min-width: 4.25rem;
    max-width: 5.5rem;
    padding: 0.28rem 0.4rem;
    font-size: 0.95rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    color: #0f172a;
    border-width: 2px;
    border-color: #94a3b8;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
    flex-shrink: 0;
}

.bar-year-select--inline:focus {
    border-color: var(--primary-color);
}

.bar-year-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgb(37 99 235 / 0.12);
}

/* Panel lateral Opciones */
.actions-drawer {
    position: fixed;
    inset: 0;
    z-index: 9990;
    pointer-events: none;
    visibility: hidden;
}

.actions-drawer.is-open {
    pointer-events: auto;
    visibility: visible;
}

.actions-drawer__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    opacity: 0;
    transition: opacity 0.25s ease;
    cursor: pointer;
}

.actions-drawer.is-open .actions-drawer__backdrop {
    opacity: 1;
}

.actions-drawer__panel {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    max-height: 100dvh;
    width: min(20rem, 92vw);
    padding-bottom: env(safe-area-inset-bottom, 0);
    padding-right: env(safe-area-inset-right, 0);
    background: var(--surface-color);
    box-shadow: -4px 0 24px rgba(15, 23, 42, 0.18);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.28s ease;
    border-left: 1px solid var(--border-color);
}

.actions-drawer.is-open .actions-drawer__panel {
    transform: translateX(0);
}

.actions-drawer__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem 1rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.actions-drawer__title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.actions-drawer__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.actions-drawer__close:hover {
    background: var(--background-color);
    color: var(--text-primary);
}

.actions-drawer__body {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.actions-drawer__lede {
    margin: 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.45;
}

.btn-actions-drawer-export {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.65rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
    background: var(--primary-color);
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 1px 2px rgba(37, 99, 235, 0.25);
}

.btn-actions-drawer-export:hover {
    filter: brightness(1.06);
}

.btn-actions-drawer-export:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgb(37 99 235 / 0.35);
}

.btn-actions-drawer-export i {
    font-size: 1rem;
}

.actions-drawer__section {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    padding-bottom: 1rem;
    margin-bottom: 0.25rem;
    border-bottom: 1px solid var(--border-color);
}

.actions-drawer__section:last-child {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0;
}

.actions-drawer__section-title {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
}

.actions-drawer__muted {
    margin: 0;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.45;
}

.btn-share-native {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    width: 100%;
    padding: 0.55rem 0.85rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
}

.btn-share-native:hover {
    background: #e2e8f0;
    border-color: #94a3b8;
}

.btn-share-native:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgb(37 99 235 / 0.2);
}

.actions-drawer__share-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.45rem;
}

.btn-share-platform {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    min-height: 3.25rem;
    padding: 0.4rem 0.35rem;
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
}

.btn-share-platform i {
    font-size: 1.15rem;
    line-height: 1;
}

.btn-share-platform:hover {
    border-color: var(--primary-color);
    background: rgb(37 99 235 / 0.06);
}

.btn-share-platform:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgb(37 99 235 / 0.35);
}

.btn-share-platform--whatsapp i {
    color: #25d366;
}

.btn-share-platform--twitter i {
    color: #0f1419;
}

.btn-share-platform--facebook i {
    color: #1877f2;
}

.btn-share-platform--linkedin i {
    color: #0a66c2;
}

.btn-share-platform--telegram i {
    color: #26a5e4;
}

.btn-share-platform--reddit i {
    color: #ff4500;
}

.btn-share-platform--email i {
    color: #64748b;
}

.btn-share-platform--copy i {
    color: var(--primary-color);
}

/* Sección 2: Visualizar en mapa */
.map-variable-bar__label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

.map-variable-bar__label.map-variable-bar__label--block {
    white-space: normal;
    font-size: 0.72rem;
    font-weight: 600;
    color: #475569;
    line-height: 1.25;
}

.map-variable-bar__options {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.map-variable-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.32rem 0.55rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--surface-color);
    color: var(--text-primary);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.map-variable-btn:hover {
    border-color: var(--primary-color);
    background: #eff6ff;
    color: var(--primary-color);
}

.map-variable-btn.active {
    border-color: var(--primary-color);
    background: var(--primary-color);
    color: white;
}

.map-variable-btn.active:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
    color: white;
}

.stat-group__hint {
    font-size: 0.8rem;
    color: #64748b;
    margin: 0 0 0.5rem 0;
    line-height: 1.35;
}

.comparison-national-hint {
    font-size: 0.85rem;
    color: #475569;
    margin: 0 0 0.75rem 0;
    padding: 0.5rem 0.65rem;
    background: #f1f5f9;
    border-radius: 6px;
    line-height: 1.4;
}

.census-metric-title {
    font-size: 0.85rem;
    font-weight: 600;
    margin: 0.65rem 0 0.15rem 0;
    color: #334155;
}

.stat-group--census {
    border-top: 1px dashed var(--border-color);
    padding-top: 0.5rem;
    margin-top: 0.25rem;
}

.stat-group--primary {
    background: linear-gradient(145deg, #f8fafc 0%, #eff6ff 55%, #f1f5f9 100%);
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    padding: 0.75rem 0.9rem 0.85rem;
    margin-bottom: 0.65rem;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.stat-group__active-title {
    margin: 0 0 0.35rem 0;
    font-size: 1rem;
    color: #1e3a8a;
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.stat-group__active-sub {
    font-size: 0.78rem;
    color: #64748b;
    margin: 0 0 0.55rem 0;
    line-height: 1.35;
}

.comparison-metric-visual {
    margin-top: 0.35rem;
}

.comparison-kpi-grid {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 0.35rem 0.5rem;
    align-items: stretch;
    max-width: 420px;
}

.comparison-kpi {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.5rem 0.55rem 0.55rem;
    text-align: center;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.comparison-kpi--base {
    border-color: #bfdbfe;
}

.comparison-kpi--target {
    border-color: #cbd5e1;
}

.comparison-kpi-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.2rem;
}

.comparison-kpi-value {
    font-size: 1.05rem;
    font-weight: 700;
    color: #0f172a;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

.comparison-kpi-mid {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
}

.comparison-kpi-arrow {
    font-size: 1.15rem;
    color: #94a3b8;
    line-height: 1;
}

.comparison-delta-line {
    margin-top: 0.55rem;
    padding: 0.45rem 0.5rem;
    border-radius: 8px;
    font-size: 0.82rem;
    line-height: 1.45;
    max-width: 420px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.35rem;
}

.comparison-delta-line--neutral {
    background: #f1f5f9;
    color: #475569;
}

.comparison-delta-line--up {
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #a7f3d0;
}

.comparison-delta-line--down {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.comparison-delta-pct {
    font-weight: 700;
}

.comparison-delta-abs {
    font-weight: 500;
    opacity: 0.95;
}

.comparison-delta-sep {
    opacity: 0.45;
    user-select: none;
}

.comparison-details-more {
    margin-top: 0.35rem;
    margin-bottom: 0.35rem;
}

.comparison-details-more summary {
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--primary-color);
    padding: 0.25rem 0;
}

.comparison-details-more summary:hover {
    text-decoration: underline;
}

.stat-group--nested {
    border-top: none;
    margin-top: 0.35rem;
    padding-top: 0;
}

.map-variable-btn i {
    font-size: 0.95em;
    opacity: 0.95;
}

.map-variable-btn.disabled,
.map-variable-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
    background: var(--surface-color);
    color: var(--text-secondary);
    border-color: var(--border-color);
}

.map-variable-btn.disabled:hover,
.map-variable-btn:disabled:hover {
    border-color: var(--border-color);
    background: var(--surface-color);
    color: var(--text-secondary);
}

/* Variable seleccionada aun con barra deshabilitada (p. ej. carga sin región) */
.map-variable-btn.active:disabled,
.map-variable-btn.active.disabled {
    opacity: 1;
    cursor: not-allowed;
    pointer-events: none;
    border-color: var(--primary-color);
    background: var(--primary-color);
    color: #fff;
}

.map-variable-btn.active:disabled:hover,
.map-variable-btn.active.disabled:hover {
    border-color: #1d4ed8;
    background: #1d4ed8;
    color: #fff;
}

.map-variable-btn.active:disabled i,
.map-variable-btn.active.disabled i {
    opacity: 1;
    color: inherit;
}

/* Selectores de ubicación */
.location-selector .select-group--location {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.location-selector__title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
    min-height: 0;
}

.location-section-title {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
}

.location-selector__geolocate-slot {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.45rem;
    flex-wrap: wrap;
    min-width: 0;
}

.geolocate-detected {
    font-size: 0.72rem;
    font-weight: 600;
    color: #475569;
    max-width: 22rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.2;
}

.geolocate-detected:empty {
    display: none;
}

.location-selects-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.45rem;
    align-items: stretch;
}

@media (max-width: 640px) {
    .location-selects-row {
        grid-template-columns: 1fr;
    }
}

.btn-geolocate-inline {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.75rem;
    padding: 0.15rem 0.45rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
    flex-shrink: 0;
}

.btn-geolocate-inline:hover {
    color: var(--primary-color);
    background: rgba(37, 99, 235, 0.08);
}

.btn-geolocate-inline:disabled {
    opacity: 0.7;
    cursor: wait;
}

.form-select {
    padding: 0.5rem 0.65rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--surface-color);
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: var(--transition);
    cursor: pointer;
}

.form-select--location {
    min-width: 0;
    width: 100%;
}

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

.form-select:disabled {
    background: #f1f5f9;
    color: var(--text-secondary);
    cursor: not-allowed;
}

/* Títulos de sección (año u otros); la ubicación usa .location-section-title */
.year-selector h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.35rem 0;
    padding: 0;
}

/* Reducir espaciado en grupos de selectores */
.select-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Reducir espaciado en grupos de años */
.year-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

/* Reducir espaciado en grupos de opciones */
.option-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

/* Reducir padding en secciones */
.location-selector,
.year-selector {
    padding: 0.35rem 0;
    border-bottom: 1px solid #e2e8f0;
}

.location-selector:last-child,
.year-selector:last-child {
    border-bottom: none;
}

/* Selector de años */
.year-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.year-input {
    display: flex;
    flex-direction: column;
}

.year-input label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.form-input {
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--surface-color);
    color: var(--text-primary);
    font-size: 1rem;
    transition: var(--transition);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgb(37 99 235 / 0.1);
}

/* Botones */
.btn-primary {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    justify-content: center;
}

.btn-primary:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

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

.btn-secondary {
    background: var(--surface-color);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

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

/* Opciones de mapa */
.option-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.checkbox-label input[type="checkbox"] {
    display: none;
}

.checkmark {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    position: relative;
    transition: var(--transition);
}

.checkbox-label input[type="checkbox"]:checked + .checkmark {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.checkbox-label input[type="checkbox"]:checked + .checkmark::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 12px;
    font-weight: bold;
}

/* Contenedor de mapas */
.maps-container {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 1rem;
    padding: 1rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.map-wrapper {
    background: var(--surface-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.map-header {
    background: var(--background-color);
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.map-header h3,
.map-panel-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.map-panel-title {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
    margin: 0;
    line-height: 1.2;
}

.map-panel-title__prefix {
    font-weight: 600;
    color: var(--text-primary);
}

.map-header-year-select {
    min-width: 4.5rem;
}

.map-header-year-value {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 4.25rem;
    padding: 0.28rem 0.5rem;
    font-size: 0.95rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    color: #0f172a;
    border: 2px solid #94a3b8;
    border-radius: var(--border-radius);
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
    flex-shrink: 0;
    line-height: 1.2;
    user-select: none;
}

.map-controls {
    display: flex;
    gap: 0.5rem;
}

.map {
    flex: 1;
    min-height: 500px;
    position: relative;
}

/* Fuentes de datos debajo de cada mapa */
.map-data-sources {
    border-top: 1px solid var(--border-color);
    background: linear-gradient(180deg, #fafbfc 0%, #f8fafc 100%);
    padding: 0.6rem 1rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.map-data-sources .data-sources-map {
    margin-bottom: 0;
}

.map-data-sources .data-sources-map h5 {
    font-size: 0.8rem;
    margin-bottom: 0.25rem;
}

.map-data-sources .data-sources-map ul {
    font-size: 0.7rem;
    padding-left: 1rem;
}

.map-data-sources .data-sources-map li {
    margin-bottom: 0.15rem;
}

/* Footer */
.site-footer {
    margin-top: auto;
    border-top: 1px solid var(--border-color);
    background: var(--surface-color);
}

.site-footer__inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.75rem clamp(1rem, 3vw, 1.5rem) 2.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
}

.site-footer__product-intro {
    margin: 0;
    max-width: 52rem;
    font-size: 0.9rem;
    line-height: 1.55;
    color: var(--text-secondary);
}

.site-footer__product-link {
    color: var(--primary-color);
    font-weight: 600;
    text-decoration: none;
}

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

.site-footer__title {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin: 0 0 0.65rem;
}

.site-footer__table-wrap {
    overflow-x: auto;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    background: #fafbfc;
}

.site-footer__changelog {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.site-footer__changelog th,
.site-footer__changelog td {
    padding: 0.65rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.site-footer__changelog th {
    background: #f1f5f9;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

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

.site-footer__changelog td:first-child {
    white-space: nowrap;
    color: var(--text-primary);
    font-weight: 500;
    width: 8.5rem;
}

.site-footer__changelog td:nth-child(2) {
    white-space: nowrap;
    width: 5.5rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--primary-color);
}

.site-footer__changelog td:last-child {
    color: var(--text-secondary);
}

.site-footer__version {
    display: inline-block;
}

.site-footer__pro {
    border-radius: 14px;
    padding: clamp(1.1rem, 2.5vw, 1.45rem) clamp(1rem, 2.5vw, 1.5rem);
    background:
        radial-gradient(ellipse 80% 120% at 100% 0%, rgba(56, 189, 248, 0.18) 0%, transparent 50%),
        linear-gradient(155deg, #0f172a 0%, #1e3a8a 48%, #172554 100%);
    color: rgba(248, 250, 252, 0.95);
    box-shadow: 0 8px 28px -12px rgba(15, 23, 42, 0.35);
}

.site-footer__title--pro {
    color: rgba(186, 230, 253, 0.95);
    letter-spacing: 0.1em;
}

.site-footer__pro-layout {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem 1.75rem;
}

.site-footer__pro-main {
    flex: 1;
    min-width: 0;
}

.site-footer__brand-line {
    margin: 0 0 0.5rem;
}

.site-footer__brand {
    font-size: clamp(1.15rem, 2.5vw, 1.45rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #fff;
    text-decoration: none;
    border-bottom: 2px solid rgba(56, 189, 248, 0.55);
    transition: color 0.2s ease, border-color 0.2s ease;
}

.site-footer__brand:hover {
    color: #e0f2fe;
    border-color: rgba(125, 211, 252, 0.9);
}

.site-footer__pitch {
    margin: 0;
    font-size: 0.92rem;
    line-height: 1.55;
    color: rgba(226, 232, 240, 0.92);
}

.site-footer__cta {
    display: inline-block;
    margin-left: 0.25rem;
    font-weight: 600;
    color: #7dd3fc;
    text-decoration: none;
    border-bottom: 1px solid rgba(125, 211, 252, 0.45);
    transition: color 0.2s ease, border-color 0.2s ease;
}

.site-footer__cta:hover {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.65);
}

.site-footer__avatar-wrap {
    flex-shrink: 0;
    display: block;
    border-radius: 50%;
    padding: 3px;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.35), rgba(56, 189, 248, 0.35));
    box-shadow: 0 6px 20px -8px rgba(0, 0, 0, 0.45);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.site-footer__avatar-wrap:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px -10px rgba(0, 0, 0, 0.5);
}

.site-footer__avatar {
    display: block;
    width: 112px;
    height: 112px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(15, 23, 42, 0.35);
    background: #1e293b;
}

@media (max-width: 600px) {
    .site-footer__pro-layout {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .site-footer__pro-main {
        order: 1;
    }

    .site-footer__avatar-wrap {
        order: 0;
    }

    .site-footer__changelog td:first-child,
    .site-footer__changelog td:nth-child(2) {
        width: auto;
    }
}

/* Divisor entre mapas */
.map-divider {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.divider-line {
    width: 2px;
    height: 60px;
    background: var(--border-color);
}

.divider-text {
    background: var(--primary-color);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 50%;
    font-weight: 600;
    font-size: 0.875rem;
    margin: 0.5rem 0;
}

.data-sources-map {
    margin-bottom: 1rem;
}

.data-sources-map:last-child {
    margin-bottom: 0;
}

.data-sources-map h5 {
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 0.35rem;
    font-weight: 600;
}

.data-sources-map ul {
    margin: 0;
    padding-left: 1.25rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.data-sources-map li {
    margin-bottom: 0.25rem;
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loading-overlay.show {
    display: flex;
}

.loading-spinner {
    background: var(--surface-color);
    padding: 2rem;
    border-radius: var(--border-radius);
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.loading-spinner i {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.loading-spinner p {
    color: var(--text-primary);
    font-size: 1rem;
}

/* Responsive design */
@media (max-width: 1024px) {
    .maps-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
    }
    
    .map-divider {
        flex-direction: row;
        padding: 0.5rem;
    }
    
    .divider-line {
        width: 60px;
        height: 2px;
    }
    
    .divider-text {
        margin: 0 0.5rem;
    }
}

@media (max-width: 768px) {
    .header-brand__text h1 {
        font-size: clamp(1.35rem, 5vw, 1.95rem);
    }
    
    .controls-container {
        grid-template-columns: 1fr;
        gap: 0.65rem;
    }
    
    .year-group {
        grid-template-columns: 1fr;
    }
    
    .map-header {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }
    
    .map-header h3,
    .map-panel-title {
        width: 100%;
    }
    
    .map-controls {
        width: 100%;
        justify-content: flex-end;
    }
}

@media (max-width: 480px) {
    .header-inner {
        flex-wrap: wrap;
        align-items: flex-start;
        row-gap: 0.75rem;
        padding: 1rem 0.75rem 1.1rem;
    }

    .header-toolbar {
        width: 100%;
        justify-content: flex-end;
        order: -1;
    }

    .header-content {
        width: 100%;
    }

    .btn-header-actions {
        padding: 0.45rem 0.65rem;
        font-size: 0.78rem;
    }

    .btn-header-actions__label {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    .header-brand {
        gap: 0.75rem;
    }

    .header-brand__mark {
        border-radius: 14px;
    }

    .header-brand__text h1 {
        font-size: 1.35rem;
    }

    .header-brand__tagline {
        font-size: 0.86rem;
        max-width: none;
    }
    
    .controls-panel {
        padding: 0.45rem 0;
    }
    
    .maps-container {
        padding: 0.5rem;
    }
    
    .map {
        min-height: 300px;
    }
}

/* Estilos para Leaflet */
.leaflet-container {
    font-family: inherit;
}

.leaflet-popup-content-wrapper {
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
}

.leaflet-popup-content {
    font-size: 0.875rem;
    line-height: 1.4;
}

.popup-content__footnote {
    margin: 0.65rem 0 0;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.72rem;
    line-height: 1.35;
    color: var(--text-secondary);
}

.leaflet-control-zoom a {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.leaflet-control-zoom a:hover {
    background: var(--background-color);
}

/* Animaciones */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.map-wrapper {
    animation: fadeIn 0.3s ease-out;
}

/* Estados de hover y focus mejorados */
.form-select:hover:not(:disabled) {
    border-color: var(--primary-color);
}

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

/* Modal de exportación */
.export-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10001;
}

.export-modal.show {
    display: flex;
}

.export-modal-content {
    background: var(--surface-color);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    max-width: 500px;
    width: 90%;
}

.export-modal h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.export-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.export-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
}

.export-option:hover {
    border-color: var(--primary-color);
    background: var(--background-color);
}

.export-option.selected {
    border-color: var(--primary-color);
    background: rgb(37 99 235 / 0.1);
}

.export-option input[type="radio"] {
    margin: 0;
}

.export-option-content {
    flex: 1;
}

.export-option-content h4 {
    margin-bottom: 0.25rem;
    color: var(--text-primary);
    font-size: 1rem;
}

.export-option-content p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin: 0;
}

.export-modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

.export-modal-actions .btn-secondary {
    flex: 0 0 auto;
}

.export-modal-actions .btn-primary {
    flex: 0 0 auto;
}

/* Scrollbar personalizado */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--background-color);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Estilos para fuente de datos en popups */
.data-source {
    background: #f0f9ff;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    border-left: 3px solid #0ea5e9;
    margin: 0.5rem 0;
    font-size: 0.75rem;
    color: #0369a1;
}

.data-source strong {
    color: #0369a1;
}

/* Estilos para popups de límites */
.boundary-popup {
    min-width: 200px;
}

.boundary-popup h4 {
    margin: 0 0 0.5rem 0;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
}

.boundary-popup p {
    margin: 0.25rem 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.boundary-popup strong {
    color: var(--text-primary);
    font-weight: 600;
}
