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

:root {
    --bg-top: #f4f8fb;
    --bg-bottom: #e9f1f6;
    --panel-bg: #ffffff;
    --panel-border: #d6e2eb;
    --text-main: #15202b;
    --text-muted: #4d6376;
    --accent: #1d6fa5;
    --accent-2: #c85d2b;
    --highlight: #ffe59d;
    --chip-coef: #d7e9ff;
    --chip-assump: #d9f3df;
    --chip-both: #ffe3a5;
    --chip-unlinked: #edf2f6;
    --shadow: 0 12px 28px rgba(22, 42, 59, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--text-main);
    font-family: 'IBM Plex Sans', 'Space Grotesk', sans-serif;
    background:
        radial-gradient(circle at 10% -10%, #cfe7f5 0%, rgba(207, 231, 245, 0) 40%),
        radial-gradient(circle at 90% -20%, #ffe8d6 0%, rgba(255, 232, 214, 0) 45%),
        linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
    min-height: 100vh;
}

.hero {
    border-bottom: 1px solid #d2dee8;
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(4px);
}

.hero-inner {
    max-width: 1520px;
    margin: 0 auto;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.hero h1 {
    margin: 0;
    font-family: 'Space Grotesk', sans-serif;
    letter-spacing: -0.02em;
    font-size: 1.8rem;
}

.hero p {
    margin: 0.25rem 0 0;
    color: var(--text-muted);
}

.back-link {
    text-decoration: none;
    color: #fff;
    background: linear-gradient(135deg, #1f7ebb, #1f5f8d);
    padding: 0.52rem 0.85rem;
    border-radius: 10px;
    font-weight: 600;
    white-space: nowrap;
}

.layout {
    max-width: 1520px;
    margin: 0 auto;
    padding: 1.1rem 1.25rem 1.5rem;
}

.controls-panel {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 15px;
    box-shadow: var(--shadow);
    padding: 0.95rem;
    margin-bottom: 1rem;
}

.controls-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(140px, 1fr));
    gap: 0.7rem;
}

label {
    display: flex;
    flex-direction: column;
    gap: 0.32rem;
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 600;
}

select {
    border: 1px solid #cad9e5;
    border-radius: 10px;
    background: #fff;
    color: var(--text-main);
    padding: 0.5rem 0.62rem;
    font-size: 0.92rem;
}

.selection-summary {
    margin-top: 0.78rem;
    font-size: 0.9rem;
    color: #27445c;
    background: #f4f8fc;
    border: 1px solid #d6e3ee;
    border-radius: 10px;
    padding: 0.55rem 0.7rem;
}

.content-grid {
    display: grid;
    grid-template-columns: minmax(380px, 42%) minmax(520px, 58%);
    gap: 0.95rem;
}

.panel {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 0.9rem;
    min-height: 620px;
}

.panel-header h2 {
    margin: 0;
    font-size: 1.2rem;
    font-family: 'Space Grotesk', sans-serif;
}

.subtitle {
    margin: 0.3rem 0 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.spider-chart {
    min-height: 470px;
    margin-top: 0.6rem;
    border-radius: 12px;
    background: linear-gradient(180deg, #f8fbfd 0%, #f0f6fb 100%);
    border: 1px solid #dce6ef;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hover-help {
    margin-top: 0.55rem;
    color: var(--text-muted);
    font-size: 0.87rem;
}

.right-sections {
    margin-top: 0.72rem;
    display: grid;
    grid-template-rows: minmax(190px, 29%) minmax(160px, 23%) minmax(270px, 48%);
    gap: 0.8rem;
    height: calc(100% - 52px);
}

.subpanel {
    border: 1px solid #dbe6ef;
    border-radius: 12px;
    padding: 0.7rem;
    background: #fdfefe;
    overflow: hidden;
}

.subpanel h3 {
    margin: 0 0 0.45rem;
    font-size: 1rem;
    font-family: 'Space Grotesk', sans-serif;
}

.coefficient-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 0.58rem;
    max-height: 200px;
    overflow: auto;
    padding-right: 0.2rem;
}

.coefficient-card {
    border: 1px solid #d7e4ee;
    border-radius: 10px;
    padding: 0.55rem;
    background: #ffffff;
    transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease, opacity 0.16s ease;
}

.coefficient-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(32, 53, 69, 0.08);
}

.coefficient-card.active {
    border-color: #d06a2a;
    box-shadow: 0 10px 22px rgba(200, 93, 43, 0.23);
    background: #fff8f3;
}

.coefficient-card.dimmed {
    opacity: 0.35;
}

.assumption-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 0.55rem;
    max-height: 165px;
    overflow: auto;
    padding-right: 0.2rem;
}

.assumption-card {
    border: 1px solid #d7e4ee;
    border-radius: 10px;
    padding: 0.52rem;
    background: #ffffff;
    transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease, opacity 0.16s ease;
}

.assumption-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(32, 53, 69, 0.08);
}

.assumption-card.active {
    border-color: #3a8a48;
    box-shadow: 0 10px 20px rgba(58, 138, 72, 0.18);
    background: #f3fbf5;
}

.assumption-card.dimmed {
    opacity: 0.35;
}

.assumption-title {
    margin: 0;
    font-size: 0.9rem;
    color: #1d4a2b;
}

.assumption-meta {
    margin-top: 0.25rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.assumption-text {
    margin: 0.38rem 0 0;
    font-size: 0.83rem;
    line-height: 1.33;
    color: #2d4b3a;
}

.coefficient-title {
    margin: 0;
    font-size: 0.9rem;
    color: #153a53;
}

.coefficient-meta {
    margin-top: 0.25rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.metric-chip {
    background: #ebf3fa;
    border: 1px solid #d5e4ef;
    border-radius: 999px;
    font-size: 0.72rem;
    padding: 0.16rem 0.42rem;
    color: #294a63;
}

.metric-chip.missing {
    background: #f2f4f6;
    color: #738495;
}

.coefficient-text {
    margin: 0.4rem 0 0;
    font-size: 0.84rem;
    line-height: 1.35;
    color: #24384a;
}

.coefficient-logic {
    margin-top: 0.33rem;
    font-size: 0.79rem;
    line-height: 1.28;
    color: #40596d;
}

.legend-row {
    display: flex;
    gap: 0.38rem;
    align-items: center;
    margin-bottom: 0.5rem;
}

.legend-chip {
    border-radius: 999px;
    padding: 0.18rem 0.52rem;
    font-size: 0.72rem;
    border: 1px solid #d6e2ec;
    color: #355167;
}

.legend-chip.both {
    background: var(--chip-both);
}

.legend-chip.coefficient_only {
    background: var(--chip-coef);
}

.legend-chip.assumption_only {
    background: var(--chip-assump);
}

.legend-chip.unlinked {
    background: var(--chip-unlinked);
}

.narrative-fragments {
    max-height: 300px;
    overflow: auto;
    line-height: 1.75;
    font-size: 0.94rem;
    padding-right: 0.3rem;
}

.fragment {
    display: inline;
    border-radius: 6px;
    padding: 0.05rem 0.24rem;
    margin-right: 0.08rem;
    transition: opacity 0.14s ease, background-color 0.14s ease, box-shadow 0.14s ease;
}

.fragment.both {
    background: var(--chip-both);
}

.fragment.coefficient_only {
    background: var(--chip-coef);
}

.fragment.assumption_only {
    background: var(--chip-assump);
}

.fragment.unlinked {
    background: var(--chip-unlinked);
}

.fragment.active {
    box-shadow: inset 0 0 0 1px #9f4f1d, 0 0 0 1px #9f4f1d;
    background: var(--highlight);
}

.fragment.dimmed {
    opacity: 0.26;
}

.empty-note {
    color: var(--text-muted);
    font-size: 0.9rem;
    border: 1px dashed #cad8e5;
    border-radius: 10px;
    padding: 0.8rem;
    background: #f8fbfd;
}

.tooltip {
    position: fixed;
    z-index: 20;
    pointer-events: none;
    max-width: 420px;
    background: #12202d;
    color: #f8fbff;
    border-radius: 8px;
    padding: 0.5rem 0.6rem;
    font-size: 0.78rem;
    line-height: 1.35;
    box-shadow: 0 14px 28px rgba(18, 32, 45, 0.4);
}

.coefficient-point {
    cursor: pointer;
}

.coefficient-point.dimmed {
    opacity: 0.18;
}

.coefficient-point.active {
    stroke: #b44a17;
    stroke-width: 2.5;
}

@media (max-width: 1240px) {
    .controls-grid {
        grid-template-columns: repeat(3, minmax(170px, 1fr));
    }

    .content-grid {
        grid-template-columns: 1fr;
    }

    .panel {
        min-height: auto;
    }

    .right-sections {
        grid-template-rows: auto auto auto;
        height: auto;
    }

    .spider-chart {
        min-height: 420px;
    }
}

@media (max-width: 760px) {
    .hero-inner {
        flex-direction: column;
        align-items: flex-start;
    }

    .controls-grid {
        grid-template-columns: 1fr;
    }

    .coefficient-cards {
        grid-template-columns: 1fr;
        max-height: 300px;
    }
}
