:root {
    --bg: #eef3f7;
    --surface: #ffffff;
    --line: #d8e2ec;
    --line-strong: #b9c8d8;
    --text: #122033;
    --muted: #607084;
    --navy: #12345a;
    --blue: #1667d9;
    --green: #138a54;
    --green-soft: #edf9f2;
    --gold: #b87500;
    --shadow: 0 12px 34px rgba(18, 52, 90, 0.08);
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 18px 30px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 4px 18px rgba(18, 52, 90, 0.06);
}

.app-header h1 {
    margin: 0;
    color: var(--navy);
    font-size: 1.45rem;
    font-weight: 760;
    letter-spacing: 0;
}

.header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.primary-link,
.secondary-link,
.metric-btn,
.viewer-toolbar button {
    display: inline-flex;
    min-height: 38px;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    padding: 8px 13px;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.primary-link {
    border: 1px solid var(--green);
    background: var(--green);
    color: #ffffff;
}

.secondary-link,
.metric-btn,
.viewer-toolbar button {
    border: 1px solid var(--line-strong);
    background: #ffffff;
    color: var(--navy);
}

.primary-link:hover,
.secondary-link:hover,
.metric-btn:hover,
.viewer-toolbar button:hover {
    transform: translateY(-1px);
}

.primary-link:hover {
    background: #0f7446;
}

.secondary-link:hover,
.metric-btn:hover,
.viewer-toolbar button:hover {
    border-color: var(--blue);
    color: var(--blue);
}

a:focus-visible,
button:focus-visible,
select:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(22, 103, 217, 0.16);
    outline: none;
}

.home-shell {
    width: min(100%, 1500px);
    margin: 0 auto;
    padding: 20px 24px 36px;
}

.banner-overview,
.graph-panel,
.heatmap-panel {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.banner-overview {
    padding: 18px 22px 22px;
}

.overview-toolbar {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 18px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--line);
}

.setup-picker {
    display: grid;
    width: min(360px, 100%);
    gap: 7px;
    color: var(--muted);
    font-weight: 750;
    text-transform: uppercase;
}

select {
    min-height: 40px;
    width: 100%;
    padding: 8px 11px;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    background: #ffffff;
    color: var(--text);
    font: inherit;
    text-transform: none;
}

.banner-heading {
    padding: 18px 0 12px;
}

.banner-heading h2,
.graph-header h2 {
    margin: 0;
    color: var(--navy);
    font-size: 1.3rem;
    font-weight: 760;
    letter-spacing: 0;
}

.infographic-frame {
    margin: 0;
}

.infographic-open {
    display: block;
    width: 100%;
    border: 0;
    border-radius: 6px;
    background: transparent;
    padding: 0;
    cursor: zoom-in;
}

.infographic-open img {
    display: block;
    width: min(100%, 1240px);
    max-height: min(74vh, 860px);
    object-fit: contain;
    margin: 0 auto;
    border-radius: 4px;
}

.empty-infographic {
    display: none;
    min-height: 220px;
    place-items: center;
    color: var(--muted);
    font-weight: 650;
}

.infographic-frame.is-empty .infographic-open {
    display: none;
}

.infographic-frame.is-empty .empty-infographic {
    display: grid;
}

.graph-panel,
.heatmap-panel {
    margin-top: 18px;
    padding: 22px;
}

.heatmap-panel {
    padding-bottom: 18px;
}

.graph-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding-bottom: 16px;
}

.metric-toggle {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.metric-btn.active,
.part-filter-btn.active {
    border-color: rgba(19, 138, 84, 0.5);
    background: var(--green-soft);
    color: var(--green);
}

.high-value-filter {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin: -6px 0 12px;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 700;
}

.high-value-filter[hidden] {
    display: none;
}

.part-toggle {
    display: inline-flex;
    gap: 7px;
    flex-wrap: wrap;
}

.part-filter-btn {
    min-height: 34px;
    padding: 6px 11px;
    border-color: var(--line-strong);
    background: #ffffff;
    color: var(--navy);
}

.chart-wrap {
    position: relative;
    min-height: 420px;
    height: 52vh;
    max-height: 650px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #ffffff;
    padding: 12px;
}

.overview-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 9px 14px;
    margin-top: 14px;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--muted);
    font-size: 0.9rem;
}

.legend-swatch {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    border: 1px solid rgba(18, 32, 51, 0.14);
}

.heatmap-container {
    min-height: 220px;
    overflow: auto;
}

.heatmap-intro {
    max-width: 980px;
    margin-bottom: 18px;
    color: var(--muted);
    font-size: 0.93rem;
}

.heatmap-intro p {
    margin: 0;
}

.heatmap-intro p + p {
    margin-top: 7px;
}

.heatmap-section + .heatmap-section {
    position: relative;
    margin-top: 24px;
    padding-top: 20px;
}

.heatmap-section {
    width: max-content;
    min-width: 100%;
}

.heatmap-section + .heatmap-section::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    border-top: 1px solid var(--line);
}

.heatmap-header {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: center;
    margin-bottom: 10px;
}

.heatmap-header h3 {
    margin: 0 0 4px;
    color: var(--navy);
    font-size: 1rem;
}

.heatmap-header p {
    margin: 0;
    color: var(--muted);
    font-size: 0.84rem;
}

.heatmap-x {
    flex: 0 1 auto;
    max-width: min(620px, 50%);
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #f8fafc;
    padding: 7px 9px;
    color: var(--navy);
    font-size: 0.84rem;
    font-weight: 750;
    text-align: right;
}

.heatmap-grid {
    display: grid;
    grid-template-columns: minmax(210px, 260px) repeat(var(--heatmap-columns), minmax(38px, 1fr));
    min-width: max-content;
    border: 1px solid var(--line);
    border-radius: 6px;
    overflow: hidden;
}

.heatmap-corner,
.heatmap-col-header,
.heatmap-row-header,
.heatmap-cell {
    min-height: 36px;
    border-right: 1px solid rgba(255, 255, 255, 0.66);
    border-bottom: 1px solid rgba(255, 255, 255, 0.66);
}

.heatmap-corner,
.heatmap-col-header {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #eef6ff;
    color: var(--navy);
    font-size: 0.82rem;
    font-weight: 750;
}

.heatmap-corner {
    justify-content: flex-start;
    padding: 0 10px;
}

.heatmap-row-header {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    padding: 4px 10px;
    background: #f8fafc;
    color: var(--text);
    font-size: 0.88rem;
    font-weight: 700;
    white-space: normal;
    line-height: 1.18;
}

.heatmap-row-header small {
    display: block;
    margin-top: 1px;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 650;
    line-height: 1.18;
}

.heatmap-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #172033;
    font-size: 0.78rem;
    font-weight: 750;
    font-variant-numeric: tabular-nums;
}

.heatmap-cell-dark {
    color: #ffffff;
}

.heatmap-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    align-items: center;
    margin-top: 12px;
    color: var(--muted);
    font-size: 0.9rem;
}

.heatmap-legend span {
    display: inline-flex;
    gap: 7px;
    align-items: center;
}

.heatmap-legend-swatch {
    width: 18px;
    height: 14px;
    border: 1px solid rgba(18, 32, 51, 0.18);
    border-radius: 3px;
}

.heatmap-green {
    background: rgb(94, 176, 100);
}

.heatmap-yellow {
    background: rgb(245, 205, 72);
}

.heatmap-red {
    background: rgb(211, 65, 65);
}

.heatmap-empty {
    margin: 0;
    color: var(--muted);
}

.image-viewer {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    background: rgba(10, 18, 30, 0.92);
}

.image-viewer.is-open {
    display: block;
}

.viewer-toolbar {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 8px;
    border-radius: 8px;
    background: rgba(10, 18, 30, 0.58);
    backdrop-filter: blur(10px);
}

.viewer-stage {
    width: 100vw;
    height: 100vh;
    overflow: auto;
    padding: 0;
    cursor: zoom-in;
    overscroll-behavior: contain;
    user-select: none;
}

.viewer-stage.is-fit {
    display: grid;
    place-items: center;
}

.viewer-stage.is-zoomed {
    display: block;
    cursor: grab;
}

.viewer-stage.is-dragging {
    cursor: grabbing;
}

.viewer-stage img {
    display: block;
    max-width: none;
    margin: 0 auto;
    transform-origin: top left;
    user-select: none;
    -webkit-user-drag: none;
}

@media (max-width: 900px) {
    .app-header,
    .graph-header,
    .overview-toolbar {
        display: grid;
        align-items: start;
    }

    .app-header {
        padding: 16px;
    }

    .home-shell {
        padding: 14px;
    }

    .metric-toggle {
        justify-content: flex-start;
    }

    .chart-wrap {
        height: 460px;
    }
}
