/**
 * Atlas y Cronología de Civilizaciones Antiguas - Hoja de Estilos Canónica
 * Fijate Tools - fijate.com
 */

/* ==========================================================================
   1. VARIABLES CSS Y TEMAS (OSCURO / CLARO)
   ========================================================================== */
:root {
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-heading: 'Outfit', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Tema Oscuro Canónico (Midnight Slate con acentos Papiro y Lapislázuli) */
    --bg-base: #0b0f17;
    --bg-surface: #111723;
    --bg-surface-alt: #162030;
    --bg-card: #131b28;
    --bg-card-hover: #192436;
    --bg-input: #0e1420;
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-focus: #e5a93c;
    --border-hover: rgba(229, 169, 60, 0.4);

    --text-primary: #f0f4fc;
    --text-secondary: #9cb1ce;
    --text-muted: #6f85a5;

    --color-gold: #e5a93c;
    --color-gold-light: #fcd374;
    --color-gold-glow: rgba(229, 169, 60, 0.2);

    --color-lapis: #2b7fff;
    --color-lapis-light: #60a5fa;
    --color-lapis-glow: rgba(43, 127, 255, 0.2);

    --color-terracotta: #d9534f;
    --color-emerald: #10b981;
    --color-amber: #f59e0b;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);

    /* Variables de contraste para el radar y métricas */
    --radar-grid-line: rgba(255, 255, 255, 0.18);
    --radar-grid-fill-even: rgba(255, 255, 255, 0.015);
    --radar-grid-fill-odd: rgba(255, 255, 255, 0.04);
    --radar-scale-bg: #111723;
    --radar-scale-text: #9cb1ce;
    --radar-badge-bg: rgba(19, 27, 40, 0.95);
    --radar-badge-border: rgba(255, 255, 255, 0.16);

    --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23e5a93c' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

[data-theme="light"] {
    --bg-base: #f8f6f0;
    --bg-surface: #ffffff;
    --bg-surface-alt: #f1ede4;
    --bg-card: #ffffff;
    --bg-card-hover: #faf8f3;
    --bg-input: #ffffff;
    --border-subtle: #ded8cb;
    --border-focus: #b87310;
    --border-hover: rgba(184, 115, 16, 0.5);

    --text-primary: #1e242e;
    --text-secondary: #4a5568;
    --text-muted: #718096;

    --color-gold: #b87310;
    --color-gold-light: #945905;
    --color-gold-glow: rgba(184, 115, 16, 0.15);

    --color-lapis: #1d5fcc;
    --color-lapis-light: #184ea8;
    --color-lapis-glow: rgba(29, 95, 204, 0.12);

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);

    /* Variables de contraste para el radar y métricas (tema claro) */
    --radar-grid-line: rgba(0, 0, 0, 0.16);
    --radar-grid-fill-even: rgba(0, 0, 0, 0.015);
    --radar-grid-fill-odd: rgba(0, 0, 0, 0.035);
    --radar-scale-bg: #f1ede4;
    --radar-scale-text: #4a5568;
    --radar-badge-bg: rgba(255, 255, 255, 0.96);
    --radar-badge-border: #ded8cb;

    --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23b87310' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

/* ==========================================================================
   2. CONTENCIÓN GENERAL Y LAYOUT CANÓNICO
   ========================================================================== */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font-main);
    line-height: 1.6;
    overflow-x: clip;
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.tool-layout {
    width: 100%;
    max-width: 1240px;
    margin: 1.5rem auto 3rem;
    padding: 0 1rem;
    flex: 1 0 auto;
}

.tool-with-sidebar {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
}

.tool-main-content {
    flex: 1 1 0%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* ==========================================================================
   3. CABECERA INTRODUCTORIA Y HERO
   ========================================================================== */
.hero-card {
    background: linear-gradient(135deg, var(--bg-surface) 0%, var(--bg-surface-alt) 100%);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.5rem 1.75rem;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.hero-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--color-gold) 0%, var(--color-lapis) 100%);
}

.hero-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.hero-icon-box {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    background: var(--color-gold-glow);
    border: 1px solid rgba(229, 169, 60, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-gold);
    flex-shrink: 0;
}

.hero-title-area {
    flex: 1;
    min-width: 250px;
}

.hero-title {
    margin: 0;
    font-family: var(--font-heading);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.25;
}

.hero-subtitle {
    margin: 0.35rem 0 0;
    font-size: 0.95rem;
    color: var(--text-secondary);
}

/* ==========================================================================
   4. PESTAÑAS PRINCIPALES (NAVEGACIÓN DE LA SUITE)
   ========================================================================== */
.tabs-nav-wrapper {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 0.4rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.tabs-nav {
    display: flex;
    gap: 0.4rem;
    min-width: max-content;
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.65rem 1rem;
    min-height: 42px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: var(--font-heading);
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: var(--bg-surface-alt);
}

.tab-btn.active {
    background: var(--color-gold-glow);
    color: var(--color-gold);
    border-color: rgba(229, 169, 60, 0.35);
}

.tab-btn svg {
    flex-shrink: 0;
}

.tab-content {
    display: none;
    flex-direction: column;
    gap: 1.5rem;
}

.tab-content.active {
    display: flex;
    animation: fadeIn 0.25s ease-out;
}

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

/* ==========================================================================
   5. MÓDULO 1: SINCRONIZADOR HISTÓRICO MUNDIAL
   ========================================================================== */
.sync-panel-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.sync-timeline-control {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.timeline-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.timeline-year-display {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
}

.timeline-year-badge {
    font-family: var(--font-mono);
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-gold);
    background: var(--color-gold-glow);
    padding: 0.2rem 0.8rem;
    border-radius: var(--radius-md);
    border: 1px solid rgba(229, 169, 60, 0.3);
}

.timeline-epoch-title {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary);
}

.timeline-slider-wrapper {
    position: relative;
    width: 100%;
    padding: 0.5rem 0;
}

.timeline-slider {
    width: 100%;
    height: 10px;
    border-radius: var(--radius-full);
    background: var(--bg-surface-alt);
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
    accent-color: var(--color-gold);
}

.timeline-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--color-gold);
    border: 3px solid var(--bg-base);
    box-shadow: 0 0 10px rgba(229, 169, 60, 0.5);
    cursor: grab;
}

.timeline-ticks {
    display: flex;
    justify-content: space-between;
    padding: 0.25rem 0 0;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.timeline-milestones-row {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    scrollbar-width: thin;
}

.milestone-chip {
    padding: 0.4rem 0.75rem;
    font-size: 0.82rem;
    font-family: var(--font-heading);
    font-weight: 500;
    background: var(--bg-surface-alt);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
}

.milestone-chip:hover {
    color: var(--text-primary);
    border-color: var(--color-gold);
}

.milestone-chip.active {
    background: var(--color-gold);
    color: #0b0f17;
    font-weight: 700;
    border-color: var(--color-gold);
}

.sync-epoch-summary {
    background: var(--bg-card);
    border-left: 4px solid var(--color-gold);
    padding: 1rem 1.25rem;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.sync-regions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.sync-region-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1.15rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.sync-region-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-hover);
}

.sync-region-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 0.5rem;
}

.sync-region-tag {
    font-family: var(--font-heading);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-gold);
    font-weight: 700;
}

.sync-civ-name {
    margin: 0;
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.sync-item-row {
    font-size: 0.88rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.sync-item-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

.sync-item-value {
    color: var(--text-secondary);
}

/* ==========================================================================
   6. MÓDULO 2: CONVERSOR DE CALENDARIOS Y NUMERALES
   ========================================================================== */
.converter-subtabs {
    display: flex;
    gap: 0.5rem;
    background: var(--bg-surface-alt);
    padding: 0.35rem;
    border-radius: var(--radius-md);
    width: fit-content;
}

.subtab-btn {
    padding: 0.5rem 1rem;
    min-height: 38px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.subtab-btn.active {
    background: var(--bg-card);
    color: var(--color-gold);
    box-shadow: var(--shadow-sm);
}

.converter-controls-box {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.date-picker-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0.75rem;
    align-items: flex-end;
}

.input-field-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.input-field-group label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
}

.input-control {
    width: 100%;
    min-height: 42px;
    padding: 0.5rem 0.75rem;
    background-color: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    font-family: var(--font-main);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.15s ease;
}

.input-control:focus {
    border-color: var(--border-focus);
}

select.input-control {
    appearance: none;
    background-image: var(--select-arrow);
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 16px;
    padding-right: 40px;
    cursor: pointer;
}

select.input-control option {
    background-color: var(--bg-surface);
    color: var(--text-primary);
}

.btn-primary {
    min-height: 42px;
    padding: 0.6rem 1.25rem;
    background: var(--color-gold);
    color: #0b0f17;
    border: 1px solid var(--color-gold);
    border-radius: var(--radius-sm);
    font-family: var(--font-heading);
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: opacity 0.15s ease, transform 0.1s ease;
}

.btn-primary:hover {
    opacity: 0.92;
    transform: translateY(-1px);
}

.calendars-display-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.25rem;
}

.calendar-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    position: relative;
}

.calendar-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.calendar-card-title {
    margin: 0;
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.calendar-badge {
    font-size: 0.72rem;
    font-family: var(--font-mono);
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-full);
    background: var(--color-gold-glow);
    color: var(--color-gold);
    border: 1px solid rgba(229, 169, 60, 0.3);
}

.calendar-main-result {
    font-family: var(--font-mono);
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--color-gold-light);
    background: var(--bg-surface-alt);
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius-sm);
    word-break: break-all;
}

.calendar-breakdown-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    font-size: 0.88rem;
}

.calendar-breakdown-item {
    display: flex;
    justify-content: space-between;
    padding: 0.25rem 0;
    border-bottom: 1px dashed var(--border-subtle);
}

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

/* Tableros Numerales Antiguos */
.numerals-display-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.25rem;
}

.numeral-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.numeral-display-box {
    background: var(--bg-surface-alt);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80px;
}

.numeral-glyph-large {
    font-size: 2.2rem;
    color: var(--color-gold);
    font-family: 'Segoe UI Historic', 'Noto Sans Cuneiform', 'Noto Sans Egyptian Hieroglyphs', var(--font-mono);
    letter-spacing: 0.15em;
    text-align: center;
    word-break: break-word;
}

/* Niveles verticales mayas */
.maya-vertical-tower {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
}

.maya-level-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-surface);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
}

.maya-level-visual {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    min-width: 60px;
}

.maya-dots-row {
    display: flex;
    gap: 4px;
}

.maya-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-gold);
}

.maya-bar {
    width: 36px;
    height: 5px;
    border-radius: 2px;
    background: var(--color-gold);
}

.maya-shell {
    font-size: 1.1rem;
}

/* ==========================================================================
   7. MÓDULO 3: COMPARADOR DE IMPERIOS 1 VS 1
   ========================================================================== */
.comparator-selectors-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.comparator-versus-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 1rem;
    align-items: center;
}

.versus-badge {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg-surface-alt);
    border: 2px solid var(--color-gold);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 0.85rem;
    color: var(--color-gold);
}

.radar-chart-container {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.radar-svg {
    max-width: 580px;
    width: 100%;
    height: auto;
    overflow: visible;
}

.radar-badge-rect {
    transition: stroke 0.2s ease, fill 0.2s ease;
}

.radar-point-circle {
    transition: r 0.2s ease, filter 0.2s ease;
    cursor: pointer;
}

.radar-point-circle:hover {
    r: 6.5;
}

.radar-legend {
    display: flex;
    gap: 1.25rem;
    margin-top: 1.25rem;
    flex-wrap: wrap;
    justify-content: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-size: 0.95rem;
    font-weight: 700;
    padding: 0.45rem 1rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
}

.legend-color-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dot-civ-a {
    background: var(--color-lapis);
    box-shadow: 0 0 8px var(--color-lapis);
}

.dot-civ-b {
    background: var(--color-gold);
    box-shadow: 0 0 8px var(--color-gold);
}

/* ==========================================================================
   DESGLOSE DE MÉTRICAS COMPARATIVAS ENFRENTADAS (0 - 100)
   ========================================================================== */
.radar-metrics-breakdown {
    margin-top: 2rem;
}

.breakdown-title {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 1rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

.metric-comparison-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.metric-comparison-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
}

.metric-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.metric-card-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.metric-card-advantage {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-full);
    white-space: nowrap;
}

.adv-civ-a {
    background: rgba(43, 127, 255, 0.16);
    color: var(--color-lapis-light);
    border: 1px solid rgba(43, 127, 255, 0.35);
}

.adv-civ-b {
    background: rgba(229, 169, 60, 0.16);
    color: var(--color-gold-light);
    border: 1px solid rgba(229, 169, 60, 0.35);
}

.adv-tie {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
    border: 1px solid var(--border-subtle);
}

[data-theme="light"] .adv-tie {
    background: rgba(0, 0, 0, 0.06);
    color: var(--text-secondary);
}

.metric-card-bars {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.metric-bar-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.metric-civ-name {
    font-size: 0.82rem;
    font-weight: 600;
    width: 105px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 0;
}

.metric-bar-track {
    flex: 1 1 0%;
    width: 0;
    min-width: 0;
    height: 8px;
    background: var(--bg-surface-alt);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.metric-bar-fill {
    height: 100%;
    border-radius: var(--radius-full);
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.fill-civ-a {
    background: linear-gradient(90deg, #1d5fcc, #60a5fa);
}

.fill-civ-b {
    background: linear-gradient(90deg, #b87310, #fcd374);
}

.metric-civ-val {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 700;
    width: 28px;
    text-align: right;
    flex-shrink: 0;
}

.civ-a-text {
    color: var(--color-lapis-light);
}

.civ-b-text {
    color: var(--color-gold-light);
}

/* ==========================================================================
   TABLA COMPARATIVA HISTÓRICA
   ========================================================================== */
.comparison-table-wrapper {
    overflow-x: auto;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    margin-top: 1.5rem;
}

.comparison-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

.comparison-table th,
.comparison-table td {
    padding: 0.9rem 1.1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-subtle);
}

.comparison-table th {
    background: var(--bg-surface-alt);
    font-family: var(--font-heading);
    font-weight: 700;
    color: var(--text-primary);
}

.comparison-table td:first-child {
    font-weight: 600;
    color: var(--text-primary);
    width: 28%;
}

.comparison-table tr.row-summary {
    background: var(--bg-surface-alt);
}

.comparison-table tr.row-summary td {
    font-weight: 700;
    font-size: 0.95rem;
}

.civ-a-col {
    color: var(--color-lapis-light);
    font-weight: 600;
}

.civ-b-col {
    color: var(--color-gold-light);
    font-weight: 600;
}

/* ==========================================================================
   8. MÓDULO 4: SIMULADOR SISTÉMICO DE COLAPSO
   ========================================================================== */
.collapse-panel-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.collapse-preset-selector {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.collapse-preset-selector label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}

.collapse-scenario-intro {
    background: var(--bg-card);
    border-left: 4px solid var(--color-lapis);
    padding: 1rem 1.25rem;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    font-size: 0.92rem;
    color: var(--text-secondary);
}

.collapse-sliders-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1.5rem;
}

.slider-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.slider-label-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.88rem;
    font-weight: 600;
}

.slider-val-badge {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    padding: 0.1rem 0.45rem;
    border-radius: var(--radius-sm);
    background: var(--bg-surface-alt);
    color: var(--color-gold);
}

.collapse-range {
    width: 100%;
    height: 8px;
    border-radius: var(--radius-full);
    background: var(--bg-surface-alt);
    outline: none;
    -webkit-appearance: none;
    cursor: pointer;
}

.collapse-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--color-gold);
    border: 2px solid var(--bg-base);
    cursor: grab;
}

.resilience-meter-box {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.resilience-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.resilience-title {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 700;
}

.resilience-score {
    font-family: var(--font-mono);
    font-size: 1.8rem;
    font-weight: 800;
}

.resilience-bar-track {
    width: 100%;
    height: 14px;
    background: var(--bg-surface-alt);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.resilience-bar-fill {
    height: 100%;
    border-radius: var(--radius-full);
    transition: width 0.3s ease, background-color 0.3s ease;
}

.verdict-box {
    padding: 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.estado-estable {
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #34d399;
}

.estado-alerta {
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: #fbbf24;
}

.estado-critico {
    background: rgba(217, 83, 79, 0.12);
    border: 1px solid rgba(217, 83, 79, 0.3);
    color: #f87171;
}

.estado-colapso {
    background: rgba(153, 27, 27, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #fca5a5;
}

/* ==========================================================================
   9. MÓDULO 5: EVALUADOR SOCIOLÓGICO DE SUPERVIVENCIA
   ========================================================================== */
.quiz-panel-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.quiz-progress-bar-wrapper {
    width: 100%;
    height: 6px;
    background: var(--bg-surface-alt);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.quiz-progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-gold), var(--color-lapis));
    width: 12.5%;
    transition: width 0.25s ease;
}

.quiz-question-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.quiz-question-number {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-gold);
}

.quiz-question-text {
    margin: 0;
    font-family: var(--font-heading);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.35;
}

.quiz-options-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.quiz-option-btn {
    width: 100%;
    min-height: 48px;
    padding: 0.85rem 1.15rem;
    background: var(--bg-surface-alt);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.95rem;
    text-align: left;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.quiz-option-btn:hover {
    border-color: var(--color-gold);
    background: var(--color-gold-glow);
    transform: translateX(3px);
}

.quiz-option-indicator {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1.5px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}

.quiz-result-card {
    display: none;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1.75rem;
    flex-direction: column;
    gap: 1.25rem;
    animation: fadeIn 0.3s ease;
}

.quiz-result-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 1rem;
}

.quiz-role-icon {
    font-size: 2.5rem;
}

.quiz-role-title {
    margin: 0;
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--color-gold);
}

.actuarial-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
}

.actuarial-card {
    background: var(--bg-surface-alt);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.actuarial-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
}

.actuarial-value {
    font-family: var(--font-mono);
    font-size: 1.05rem;
    color: var(--text-primary);
    font-weight: 600;
}

/* ==========================================================================
   10. MODAL ACCESIBLE DE FICHA DE CIVILIZACIÓN (CERO ALERTS)
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(5, 8, 13, 0.8);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 9999;
}

.modal-overlay.active {
    display: flex;
    animation: fadeIn 0.2s ease;
}

.modal-dialog {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 680px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.5rem 1.75rem;
    box-shadow: var(--shadow-lg);
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 0.75rem;
}

.modal-title {
    margin: 0;
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-close-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-surface-alt);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.15s ease;
}

.modal-close-btn:hover {
    color: var(--text-primary);
    border-color: var(--color-gold);
}

/* ==========================================================================
   11. ADAPTACIÓN RESPONSIVA MÓVIL (< 768px)
   ========================================================================== */
@media (max-width: 768px) {
    .tool-layout {
        margin: 1rem auto 2rem;
        padding: 0 0.75rem;
    }

    .hero-card {
        padding: 1.25rem;
    }

    .hero-title {
        font-size: 1.35rem;
    }

    .tab-btn {
        padding: 0.5rem 0.85rem;
        font-size: 0.85rem;
    }

    .timeline-year-badge {
        font-size: 1.5rem;
    }

    .comparator-versus-row {
        grid-template-columns: 1fr;
        justify-items: center;
    }

    .versus-badge {
        margin: 0.25rem 0;
    }

    .sync-regions-grid {
        grid-template-columns: 1fr;
    }

    .date-picker-row {
        grid-template-columns: 1fr;
    }

    .calendars-display-grid,
    .numerals-display-grid {
        grid-template-columns: 1fr;
    }
}
