:root {
    --navy: #10233a;
    --navy-deep: #0b1a2c;
    --ink: #1c2733;
    --muted: #5c6b7a;
    --paper: #f6f1e8;
    --card: #fffdf8;
    --line: #d9d1c3;
    --amber: #c98516;
    --high: #b42318;
    --mid: #c98516;
    --low: #087443;
}

html, body {
    height: 100%;
}

body {
    margin: 0;
    color: var(--ink);
    background: var(--paper);
    font-family: "Source Sans 3", "Segoe UI", sans-serif;
}

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-nav {
    background: var(--navy-deep);
    padding-top: 0.4rem;
    padding-bottom: 0.4rem;
}

.navbar-brand {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
}

.brand-mark {
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.brand-sub {
    font-size: 0.8rem;
    color: #c8d2dc;
    font-weight: 400;
}

.app-main {
    flex: 1;
    width: min(1180px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 1.75rem 0 3rem;
}

.app-main:has(.map-page) {
    width: calc(100% - 1.25rem);
    max-width: 1920px;
    padding-top: 0.35rem;
    padding-bottom: 1.25rem;
}

.hero h1, h1 {
    letter-spacing: -0.03em;
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.75rem;
    color: var(--amber);
    font-weight: 700;
    margin-bottom: 0.35rem;
}

.section-title {
    font-size: 1.15rem;
    margin-bottom: 1rem;
}

h2.h5 {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.tech-card {
    display: block;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 1.25rem 1.35rem;
    text-decoration: none;
    color: inherit;
    height: 100%;
    box-shadow: 0 8px 24px rgba(16, 35, 58, 0.05);
}

.tech-card:hover {
    border-color: var(--navy);
    color: inherit;
}

.tech-card h3 {
    margin-bottom: 0.5rem;
}

.stretched-link-label {
    color: var(--navy);
    font-weight: 600;
}

.market-sizes {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 1.1rem;
    margin: 0.4rem 0 0.75rem;
    font-size: 0.9rem;
    color: var(--muted);
}

.market-sizes span {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.tech-card .market-sizes {
    margin-bottom: 0.85rem;
}

.stat-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 1rem;
}

.stat-card span {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    color: var(--muted);
    font-size: 0.85rem;
}

.stat-card strong {
    font-size: 1.25rem;
}

.opportunity-table {
    background: var(--card);
}

.opportunity-table thead th {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.score-chip {
    display: inline-block;
    min-width: 2.6rem;
    text-align: center;
    border-radius: 999px;
    padding: 0.15rem 0.55rem;
    font-weight: 700;
    color: #fff;
}

.score-chip.opp-high, .opp-high { color: var(--high); }
.score-chip.opp-high { background: var(--high); color: #fff; }
.score-chip.opp-mid, .opp-mid { color: var(--mid); }
.score-chip.opp-mid { background: var(--mid); color: #fff; }
.score-chip.opp-low, .opp-low { color: var(--low); }
.score-chip.opp-low { background: var(--low); color: #fff; }

.supply-bar-block {
    width: 100%;
    min-width: 9rem;
}

.supply-bar {
    display: flex;
    height: 10px;
    width: 100%;
    background: #e7b0aa;
    border-radius: 99px;
    overflow: hidden;
}

.supply-bar-domestic {
    height: 100%;
    background: var(--low);
}

.supply-bar-export-track {
    margin-top: 0.35rem;
    background: #d9e6f4;
}

.supply-bar-export {
    height: 100%;
    background: #1a5fb4;
}

.supply-bar-labels {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    width: 100%;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 0.25rem;
}

.supply-bar-export-label {
    color: #1a5fb4;
    white-space: nowrap;
}

.supply-bar-import {
    margin-left: auto;
    text-align: right;
    white-space: nowrap;
}

.bar-cell {
    min-width: 160px;
}

.sort-head {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    font-weight: inherit;
    color: inherit;
    text-transform: inherit;
    letter-spacing: inherit;
    cursor: pointer;
    text-align: inherit;
}

.sort-head:hover {
    color: var(--navy);
}

.filter-row {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.link-list {
    list-style: none;
    padding: 0;
}

.link-list li {
    padding: 0.2rem 0;
}

.map-page {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    overscroll-behavior: none;
}

.map-heading {
    display: flex;
    justify-content: space-between;
    /* align-items: baseline; */
    gap: 1rem 1.5rem;
    flex-wrap: wrap;
}

.map-heading .market-sizes {
    margin: 0 0 0 auto;
    text-align: right;
    justify-content: flex-end;
    font-size: 1.8rem;
    color: var(--ink);
}

.map-heading .market-sizes strong {
    font-weight: 700;
}

.map-heading .info-hint {
    font-size: 0.85rem;
}

.map-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem 1rem;
    flex-wrap: wrap;
}

.map-nav {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
    justify-content: flex-start;
}

.map-nav .btn {
    font-size: 0.87rem;
    padding: 0.18rem 0.48rem;
    line-height: 1.2;
}

.map-swaps {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    justify-content: flex-end;
    margin-left: auto;
}

.map-orient {
    display: inline-flex;
    gap: 0.15rem;
}

.map-orient .btn {
    min-width: 2rem;
    padding-left: 0.42rem;
    padding-right: 0.42rem;
    font-size: 1.05rem;
    line-height: 1;
}

.map-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 1rem;
    min-height: calc(100vh - 12rem);
}

.map-stage {
    background: #eef3f7;
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: clip;
    cursor: grab;
    min-height: calc(100vh - 12rem);
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: none;
    touch-action: none;
    overscroll-behavior: none;
}

.map-stage,
.map-stage svg,
.map-stage text {
    user-select: none;
    -webkit-user-select: none;
}

.mindmap text {
    pointer-events: none;
}

.map-stage:active,
.map-stage.is-panning {
    cursor: grabbing;
}

.mindmap {
    width: 100%;
    height: 100%;
    min-height: calc(100vh - 12rem);
    display: block;
}

.mindmap-link {
    fill: none;
    stroke: #9aa8b5;
    stroke-width: 2;
}

.mindmap-link.on-path {
    stroke: var(--navy);
    stroke-width: 3;
}

.mindmap-node {
    cursor: pointer;
}

.mindmap-node > .node-body {
    fill: #fff;
    stroke: #c5d0da;
    stroke-width: 1.5;
}

.mindmap-node.selected > .node-body {
    stroke: var(--navy);
    stroke-width: 2.5;
}

.mindmap-node.opp-high > .node-body { stroke: var(--high); fill: #fde8e6; }
.mindmap-node.opp-mid > .node-body { stroke: var(--mid); fill: #fff4d6; }
.mindmap-node.opp-low > .node-body { stroke: var(--low); fill: #f3fbf6; }

.node-name {
    font-size: 16px;
    font-weight: 700;
    fill: var(--ink);
}

.node-emphasis {
    font-size: 13px;
    font-weight: 700;
    fill: var(--ink);
}

.node-meta {
    font-size: 12px;
    fill: var(--muted);
}

.node-toggle-hit {
    fill: transparent;
    cursor: pointer;
}

.node-toggle-bg {
    fill: #fff;
    stroke: var(--navy);
    stroke-width: 1.6;
    pointer-events: none;
}

.node-toggle {
    font-size: 16px;
    font-weight: 700;
    fill: var(--navy);
}

.node-score {
    font-size: 16px;
    font-weight: 800;
    fill: var(--ink);
}

.node-swap-pill {
    fill: var(--navy);
    pointer-events: none;
}

.mindmap-node.opp-high .node-swap-pill { fill: var(--high); }
.mindmap-node.opp-mid .node-swap-pill { fill: var(--mid); }
.mindmap-node.opp-low .node-swap-pill { fill: var(--low); }

.node-swap-label {
    font-size: 12px;
    font-weight: 700;
    fill: #fff;
}

.map-detail {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 1rem;
}

.side-copy {
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 0.85rem;
}

.side-caption {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    margin-bottom: 0.2rem;
}

.side-score {
    margin-bottom: 0.55rem;
}

.side-score strong {
    display: block;
    font-size: 1.15rem;
}

.score-banner {
    display: block;
    width: 100%;
    margin-top: 0.65rem;
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    text-align: center;
    font-size: 1rem;
}

.side-block {
    margin-top: 0.85rem;
}

.side-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem 0.75rem;
}

.side-metrics span {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
    margin-bottom: 0.15rem;
}

.side-metrics strong {
    display: block;
    font-size: 0.92rem;
    line-height: 1.2;
}

.side-outlook {
    font-size: 0.92rem;
    font-weight: 600;
}

.legend-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.75rem;
    margin-top: 0.75rem;
    font-size: 0.75rem;
}

.info-hint {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 0.9em;
    height: 0.9em;
    padding: 0;
    margin-right: 1ch;
    border: none;
    border-radius: 50%;
    background: #fff;
    color: var(--muted);
    font-size: 0.65rem;
    font-style: italic;
    font-weight: 700;
    line-height: 1;
    cursor: help;
    position: relative;
    top: -0.35em;
    vertical-align: super;
    text-transform: none;
    letter-spacing: 0;
}

.info-hint:hover,
.info-hint:focus {
    color: var(--navy);
    outline: none;
}

.info-hint:hover::after,
.info-hint:focus::after {
    content: attr(data-tip);
    position: absolute;
    top: calc(100% + 0.4rem);
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    max-width: 240px;
    padding: 0.45rem 0.6rem;
    border-radius: 8px;
    background: var(--navy);
    color: #fff;
    font-size: 0.75rem;
    font-style: normal;
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
    line-height: 1.35;
    z-index: 30;
    box-shadow: 0 8px 20px rgba(16, 35, 58, 0.2);
    pointer-events: none;
}

.map-detail .info-hint:hover::after,
.map-detail .info-hint:focus::after {
    left: auto;
    right: 0;
    transform: none;
}

.legend {
    font-size: 0.85rem;
    color: var(--muted);
}

.build-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
    font-size: 0.9rem;
    color: var(--muted);
    margin: 0.15rem 0 0.85rem;
}

.swap-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.swap-list .btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
}

.swap-name {
    font-weight: 600;
}

.swap-meta {
    font-size: 0.75rem;
    opacity: 0.8;
}

.slot-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.swatch {
    display: inline-block;
    width: 0.8rem;
    height: 0.8rem;
    border-radius: 2px;
    margin-right: 0.35rem;
    vertical-align: -1px;
    border: none;
}

.swatch.opp-high { background: var(--high); color: var(--high); }
.swatch.opp-mid { background: var(--mid); color: var(--mid); }
.swatch.opp-low { background: var(--low); color: var(--low); }

.map-page.is-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 4000;
    background: #eef3f7;
    padding: 0;
    gap: 0;
}

.map-page.is-fullscreen .map-grid {
    height: 100%;
    min-height: 100%;
    grid-template-columns: 1fr;
    gap: 0;
}

.map-page.is-fullscreen .map-stage,
.map-page.is-fullscreen .mindmap {
    height: 100%;
    min-height: 100%;
    border: none;
    border-radius: 0;
}

.map-page.is-fullscreen .map-chrome {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    right: 0.75rem;
    z-index: 5;
    background: rgba(255, 253, 248, 0.94);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    box-shadow: 0 10px 30px rgba(16, 35, 58, 0.12);
}

.map-page.is-fullscreen .map-heading .market-sizes {
    font-size: 1.35rem;
}

.map-page.is-fullscreen .map-detail {
    position: absolute;
    top: 7.25rem;
    right: 0.75rem;
    width: min(340px, 38vw);
    max-height: calc(100vh - 8.25rem);
    overflow: auto;
    z-index: 5;
    box-shadow: 0 10px 30px rgba(16, 35, 58, 0.12);
}

body:has(.map-page.is-fullscreen) {
    overflow: hidden;
}

@media print {
    .app-nav,
    .map-chrome,
    #blazor-error-ui,
    #components-reconnect-modal {
        display: none !important;
    }

    body:has(.map-page) {
        background: #fff;
        color: #1c2733;
        height: auto;
        overflow: visible;
    }

    body:has(.map-page) .app-shell,
    body:has(.map-page) .app-main,
    body:has(.map-page) .map-page {
        display: block;
        width: 100%;
        max-width: none;
        min-height: 0;
        height: auto;
        margin: 0;
        padding: 0;
        background: #fff;
        position: static;
        inset: auto;
        z-index: auto;
    }

    body:has(.map-page) .map-grid {
        min-height: 0;
        gap: 8mm;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    body:has(.map-page) .map-stage,
    body:has(.map-page) .mindmap {
        min-height: 0 !important;
        border-radius: 0;
        background: #fff;
        overflow: hidden;
    }

    body:has(.map-page) .map-detail {
        position: static;
        width: 100%;
        max-height: none;
        overflow: visible;
        box-shadow: none;
        break-inside: avoid;
    }

    body:has(.map-page) .map-detail .btn,
    body:has(.map-page) .info-hint {
        display: none;
    }
}

@media print and (orientation: portrait) {
    @page {
        margin: 8mm;
    }

    body:has(.map-page) .map-grid {
        display: block;
    }

    body:has(.map-page) .map-stage {
        width: 100%;
        height: 100vh;
        max-height: 100vh;
        overflow: hidden;
        border: 1px solid #d9d1c3;
        break-after: page;
        page-break-after: always;
    }

    body:has(.map-page) .mindmap {
        width: 100% !important;
        height: 100% !important;
        min-height: 0 !important;
        max-height: 100% !important;
        display: block;
    }

    body:has(.map-page) .map-detail {
        break-before: page;
        page-break-before: always;
        width: 100%;
    }
}

@media print and (orientation: landscape) {
    @page {
        margin: 8mm;
    }

    body:has(.map-page) .map-grid {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 70mm;
        align-items: stretch;
        height: 100vh;
        gap: 6mm;
    }

    body:has(.map-page) .map-stage {
        width: 100%;
        height: 100%;
        max-height: 100vh;
        overflow: hidden;
        border: 1px solid #d9d1c3;
    }

    body:has(.map-page) .mindmap {
        width: 100% !important;
        height: 100% !important;
        min-height: 0 !important;
        max-height: 100% !important;
        display: block;
    }

    body:has(.map-page) .map-detail {
        width: 70mm;
    }
}

@media (max-width: 900px) {
    .map-grid {
        grid-template-columns: 1fr;
        min-height: 0;
    }

    .map-stage, .mindmap {
        min-height: 70vh;
    }

    .map-page.is-fullscreen .map-detail {
        top: auto;
        bottom: 0.75rem;
        left: 0.75rem;
        right: 0.75rem;
        width: auto;
        max-height: 40vh;
    }
}

h1:focus {
    outline: none;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

.blazor-error-boundary {
    background: #b32121;
    padding: 1rem;
    color: white;
}

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}
