@font-face {
    font-family: "TradeLab CJK";
    src: url("./NotoSansSC-TradeLab.ttf") format("truetype");
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
}

:root {
    color-scheme: dark;
    --ocean: #171d1f;
    --ocean-deep: #111617;
    --land: #343b3b;
    --land-stroke: #626c6b;
    --panel: #1b2021;
    --paper: #222829;
    --ink: #eef1f0;
    --muted: #9ca5a3;
    --line: rgba(211, 218, 216, 0.14);
    --green: #3fb795;
    --green-dark: #176f5b;
    --gold: #d9a441;
    --teal: #3c91a6;
    --red: #c75146;
    --blue: #356a92;
    --white: #f4f6f5;
    --radius: 6px;
    --panel-width: 382px;
    --topbar-height: 62px;
    --dock-height: 250px;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    width: 100%;
    min-height: 100%;
}

body {
    height: 100vh;
    overflow: hidden;
    background: var(--ocean-deep);
    color: var(--ink);
    font-family: "TradeLab CJK", "Segoe UI", "PingFang SC", "Noto Sans SC", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.4;
}

button, input, select {
    font: inherit;
}

button, select, input[type="range"], summary {
    outline: none;
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
summary:focus-visible {
    outline: 2px solid var(--green);
    outline-offset: 2px;
}

button {
    border: 0;
    cursor: pointer;
}

.icon-sprite {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

.button-icon,
.section-heading svg,
.scenario-button svg,
.brand-mark svg,
.model-notes summary svg,
.repository-link svg {
    width: 17px;
    height: 17px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex: 0 0 auto;
}

#appShell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--panel-width);
    width: 100%;
    height: 100%;
}

#workspace {
    display: grid;
    grid-template-rows: var(--topbar-height) minmax(340px, 1fr) var(--dock-height);
    min-width: 0;
    min-height: 0;
    background: var(--ocean);
}

/* Top command bar */

.topbar {
    position: relative;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    min-width: 0;
    padding: 0 16px;
    color: #eef1f0;
    background: #151a1b;
    border-bottom: 1px solid rgba(211, 218, 216, 0.14);
}

.brand-lockup {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 205px;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    color: #1b2020;
    background: var(--gold);
    border-radius: var(--radius);
}

.brand-mark svg {
    width: 21px;
    height: 21px;
    stroke-width: 1.9;
}

.brand-title {
    color: #f4f6f5;
    font-size: 15px;
    font-weight: 760;
    line-height: 1.25;
    white-space: nowrap;
}

.brand-kicker {
    margin-top: 2px;
    color: #98a2a0;
    font-size: 10px;
    white-space: nowrap;
}

.equilibrium-state {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 180px;
    color: #aeb7b5;
    font-size: 11px;
    white-space: nowrap;
}

.state-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4fbd8e;
    box-shadow: 0 0 0 3px rgba(79, 189, 142, 0.12);
}

.equilibrium-state.is-adjusting .state-dot {
    background: var(--gold);
    box-shadow: 0 0 0 3px rgba(217, 164, 65, 0.14);
}

.state-divider {
    width: 1px;
    height: 13px;
    background: rgba(214, 219, 218, 0.25);
}

.topbar-actions,
.playback,
.segmented {
    display: flex;
    align-items: center;
}

.topbar-actions {
    justify-content: flex-end;
    gap: 8px;
    min-width: 0;
}

.segmented {
    height: 34px;
    padding: 2px;
    background: rgba(232, 236, 235, 0.08);
    border: 1px solid rgba(214, 219, 218, 0.13);
    border-radius: var(--radius);
}

.segment {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    height: 28px;
    padding: 0 9px;
    color: #a0aaa8;
    background: transparent;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 650;
    white-space: nowrap;
}

.segment.is-active {
    color: #1b2020;
    background: #e9eceb;
}

.segment .button-icon {
    width: 14px;
    height: 14px;
}

.commodity-swatch {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.commodity-swatch.grain { background: var(--gold); }
.commodity-swatch.machinery { background: var(--teal); }

.playback {
    gap: 4px;
}

.icon-button,
.speed-button,
.language-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 34px;
    color: #aeb7b5;
    background: transparent;
    border: 1px solid rgba(214, 219, 218, 0.15);
    border-radius: var(--radius);
    transition: color 150ms ease, background 150ms ease, border-color 150ms ease;
}

.icon-button {
    width: 34px;
}

.icon-button:hover,
.speed-button:hover,
.language-button:hover,
.icon-button.is-active {
    color: #f6f8f7;
    background: rgba(238, 241, 240, 0.1);
    border-color: rgba(238, 241, 240, 0.28);
}

.speed-button {
    gap: 4px;
    min-width: 48px;
    padding: 0 7px;
    font-size: 11px;
    font-weight: 700;
}

.language-button {
    min-width: 42px;
    padding: 0 8px;
    color: #e8eceb;
    font-size: 11px;
    font-weight: 750;
}

/* Map */

#mapStage {
    position: relative;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    background: var(--ocean);
}

#tradeCanvas {
    display: block;
    width: 100%;
    height: 100%;
}

.map-metrics {
    position: absolute;
    top: 14px;
    left: 16px;
    display: grid;
    grid-template-columns: repeat(4, minmax(112px, 1fr));
    width: min(650px, calc(100% - 32px));
    color: #eef1f0;
    background: rgba(15, 20, 21, 0.84);
    border: 1px solid rgba(211, 218, 216, 0.17);
    border-radius: var(--radius);
    backdrop-filter: blur(8px);
}

.map-metric {
    min-width: 0;
    padding: 9px 12px;
    border-right: 1px solid rgba(211, 218, 216, 0.14);
}

.map-metric:last-child {
    border-right: 0;
}

.map-metric-label {
    display: block;
    overflow: hidden;
    color: #98a2a0;
    font-size: 9px;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.map-metric strong {
    display: block;
    margin-top: 3px;
    color: #f4f6f5;
    font-size: 16px;
    line-height: 1.15;
    letter-spacing: 0;
}

.map-metric strong.is-positive { color: #68c99f; }
.map-metric strong.is-negative { color: #ed8d7f; }
.map-metric strong.is-warning { color: #ecc265; }

.map-legend,
.map-unit {
    position: absolute;
    bottom: 12px;
    color: #abb3b2;
    background: rgba(15, 20, 21, 0.76);
    border: 1px solid rgba(211, 218, 216, 0.13);
    border-radius: var(--radius);
    backdrop-filter: blur(6px);
}

.map-legend {
    left: 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 7px 10px;
    font-size: 9px;
}

.map-legend > span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.legend-line {
    width: 16px;
    height: 3px;
    border-radius: 2px;
}

.legend-line.grain { background: var(--gold); }
.legend-line.machinery { background: var(--teal); }

.legend-port {
    width: 9px;
    height: 9px;
    border: 2px solid #68c99f;
    border-radius: 50%;
}

.map-unit {
    right: 16px;
    padding: 7px 9px;
    font-size: 9px;
    white-space: nowrap;
}

.map-tooltip {
    position: absolute;
    z-index: 12;
    width: 210px;
    padding: 10px 11px;
    color: #e9edec;
    background: rgba(10, 14, 15, 0.95);
    border: 1px solid rgba(216, 222, 220, 0.2);
    border-radius: var(--radius);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
    pointer-events: none;
}

.tooltip-title {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 7px;
    color: #f3f5f4;
    font-size: 11px;
    font-weight: 720;
}

.tooltip-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 2px 0;
    color: #9da6a4;
    font-size: 10px;
}

.tooltip-row strong {
    color: #dde2e0;
    font-weight: 650;
}

/* Analysis dock */

.analytics-dock {
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    background: var(--panel);
    border-top: 1px solid var(--line);
}

.dock-tabs {
    display: flex;
    align-items: center;
    gap: 2px;
    height: 40px;
    padding: 0 14px;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
}

.dock-tab {
    position: relative;
    height: 40px;
    padding: 0 12px;
    color: var(--muted);
    background: transparent;
    font-size: 11px;
    font-weight: 690;
    white-space: nowrap;
}

.dock-tab::after {
    content: "";
    position: absolute;
    right: 10px;
    bottom: 0;
    left: 10px;
    height: 2px;
    background: transparent;
}

.dock-tab:hover { color: var(--ink); }
.dock-tab.is-active { color: var(--green); }
.dock-tab.is-active::after { background: var(--green); }

.analysis-context {
    min-width: 0;
    margin-left: auto;
    overflow: hidden;
    color: var(--muted);
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dock-panel {
    display: grid;
    height: calc(var(--dock-height) - 40px);
    min-height: 0;
    overflow: hidden;
}

.dock-panel[hidden] {
    display: none;
}

.dock-panel[data-panel="overview"] {
    grid-template-columns: 220px minmax(275px, 0.9fr) minmax(280px, 1.1fr);
}

.account-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border-right: 1px solid var(--line);
}

.account-grid > div {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    padding: 10px 14px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.account-grid > div:nth-child(2n) { border-right: 0; }
.account-grid > div:nth-last-child(-n + 2) { border-bottom: 0; }

.account-grid span {
    overflow: hidden;
    color: var(--muted);
    font-size: 9px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.account-grid strong {
    margin-top: 4px;
    color: var(--ink);
    font-size: 16px;
    line-height: 1.1;
}

.dock-chart,
.route-ranking {
    min-width: 0;
    min-height: 0;
    padding: 10px 14px 8px;
    border-right: 1px solid var(--line);
}

.route-ranking { border-right: 0; }

.dock-section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    height: 20px;
    color: #cbd1cf;
    font-size: 9px;
    font-weight: 720;
    white-space: nowrap;
}

.chart-legend-pair,
.history-legend {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--muted);
    font-size: 8px;
    font-weight: 550;
}

.chart-legend-pair i,
.chart-legend-pair b,
.history-legend i {
    width: 10px;
    height: 3px;
    border-radius: 2px;
}

.chart-legend-pair i { background: var(--green); }
.chart-legend-pair b { background: #5c6563; }

.dock-chart canvas {
    display: block;
    width: 100%;
    height: calc(100% - 20px);
}

.route-table {
    display: flex;
    flex-direction: column;
    height: calc(100% - 20px);
}

.route-row {
    display: grid;
    grid-template-columns: minmax(105px, 1fr) minmax(70px, 1.4fr) 58px 54px;
    gap: 8px;
    align-items: center;
    min-height: 34px;
    border-bottom: 1px solid var(--line);
    color: #c7cecc;
    font-size: 9px;
}

.route-row:last-child { border-bottom: 0; }

.route-name {
    overflow: hidden;
    font-weight: 690;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.route-bar {
    position: relative;
    height: 6px;
    overflow: hidden;
    background: #2b3233;
    border-radius: 3px;
}

.route-bar i {
    display: block;
    height: 100%;
    background: var(--green);
    border-radius: 3px;
}

.route-volume,
.route-delta {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.route-delta.positive { color: var(--green); }
.route-delta.negative { color: var(--red); }

.dock-panel[data-panel="market"] {
    grid-template-columns: minmax(360px, 1.35fr) minmax(230px, 0.8fr) minmax(230px, 0.85fr);
}

.market-facts,
.market-story,
.scan-summary,
.scan-note {
    min-width: 0;
    padding: 14px;
    border-right: 1px solid var(--line);
}

.market-facts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-content: center;
    gap: 1px;
    background: var(--line);
    padding: 0;
}

.market-fact {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    padding: 11px 13px;
    background: var(--panel);
}

.market-fact span {
    overflow: hidden;
    color: var(--muted);
    font-size: 9px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.market-fact strong {
    margin-top: 4px;
    color: var(--ink);
    font-size: 15px;
}

.market-story {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 9px;
    border-right: 0;
    color: #c1c8c6;
    font-size: 10px;
    line-height: 1.55;
}

.story-chip {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    min-height: 23px;
    padding: 4px 7px;
    color: var(--green);
    background: rgba(63, 183, 149, 0.14);
    border-radius: 4px;
    font-size: 9px;
    font-weight: 680;
}

.dock-panel[data-panel="policy"] {
    grid-template-columns: minmax(420px, 1.5fr) minmax(210px, 0.65fr) minmax(220px, 0.75fr);
}

.scan-summary {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
}

.scan-summary > span:first-child {
    color: var(--muted);
    font-size: 9px;
}

.scan-summary strong {
    color: var(--green);
    font-size: 26px;
    line-height: 1;
}

#scanWelfareResult {
    color: #c1c8c6;
    font-size: 9px;
}

.scan-note {
    display: flex;
    align-items: center;
    border-right: 0;
    color: var(--muted);
    font-size: 10px;
    line-height: 1.55;
}

.dock-panel[data-panel="history"] {
    grid-template-columns: 1fr;
}

.history-chart-block {
    padding-right: 20px;
    padding-left: 20px;
    border-right: 0;
}

.history-legend i.welfare { background: var(--green); }
.history-legend i.trade { background: var(--teal); }
.history-legend i.price { background: var(--red); }

/* Policy panel */

#policyPanel {
    min-width: 0;
    overflow-x: hidden;
    overflow-y: auto;
    color: var(--ink);
    background: var(--panel);
    border-left: 1px solid var(--line);
    scrollbar-color: #515a59 transparent;
    scrollbar-width: thin;
}

#policyPanel::-webkit-scrollbar { width: 5px; }
#policyPanel::-webkit-scrollbar-thumb { background: #515a59; }

.panel-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    min-height: 82px;
    padding: 18px 18px 14px;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
}

.panel-eyebrow {
    display: block;
    margin-bottom: 3px;
    color: var(--green);
    font-size: 8px;
    font-weight: 800;
}

.panel-heading h1 {
    color: var(--ink);
    font-size: 20px;
    font-weight: 760;
    line-height: 1.1;
    letter-spacing: 0;
}

.panel-heading-actions {
    display: flex;
    align-items: center;
    gap: 7px;
    flex: 0 0 auto;
}

.repository-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    color: #a4adab;
    background: #252b2c;
    border: 1px solid #3d4546;
    border-radius: var(--radius);
    transition: color 150ms ease, border-color 150ms ease, background 150ms ease;
}

.repository-link:hover {
    color: #eef1f0;
    background: #2b3233;
    border-color: #626d6c;
}

.repository-link:focus-visible {
    outline: 2px solid var(--green);
    outline-offset: 2px;
}

.model-badge {
    flex: 0 0 auto;
    padding: 4px 6px;
    color: #b5bdbb;
    background: #2a3031;
    border-radius: 4px;
    font-size: 9px;
    font-weight: 680;
}

.control-section,
.signal-section {
    padding: 15px 18px 16px;
    border-bottom: 1px solid var(--line);
}

.compact-section { padding-bottom: 14px; }

.section-heading {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 12px;
    color: #dce1df;
    font-size: 11px;
    font-weight: 750;
}

.section-heading svg {
    width: 15px;
    height: 15px;
    color: var(--green);
}

.field-grid {
    display: grid;
    gap: 8px;
}

.two-column {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field-grid label,
.select-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}

.select-field { margin-top: 9px; }

.field-grid label > span,
.select-field > span {
    color: var(--muted);
    font-size: 9px;
    font-weight: 620;
}

select {
    width: 100%;
    height: 34px;
    padding: 0 27px 0 9px;
    overflow: hidden;
    color: #e6eae9;
    background: #252b2c;
    border: 1px solid #3f4748;
    border-radius: var(--radius);
    font-size: 11px;
    font-weight: 630;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.range-field {
    display: block;
    margin-top: 13px;
}

.range-field > span {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: #bac1c0;
    font-size: 10px;
}

.range-field output {
    flex: 0 0 auto;
    color: var(--green);
    font-size: 10px;
    font-weight: 760;
    font-variant-numeric: tabular-nums;
}

input[type="range"] {
    width: 100%;
    height: 20px;
    margin-top: 4px;
    appearance: none;
    background: transparent;
}

input[type="range"]::-webkit-slider-runnable-track {
    height: 4px;
    background: #394142;
    border-radius: 2px;
}

input[type="range"]::-moz-range-track {
    height: 4px;
    background: #394142;
    border-radius: 2px;
}

input[type="range"]::-webkit-slider-thumb {
    width: 15px;
    height: 15px;
    margin-top: -5px;
    appearance: none;
    background: #e8ebea;
    border: 2px solid var(--green);
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(17, 22, 23, 0.24);
}

input[type="range"]::-moz-range-thumb {
    width: 12px;
    height: 12px;
    background: #e8ebea;
    border: 2px solid var(--green);
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(17, 22, 23, 0.24);
}

.range-scale {
    display: flex;
    justify-content: space-between;
    margin-top: -2px;
    color: #788280;
    font-size: 8px;
    font-style: normal;
}

.button-primary,
.button-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 34px;
    padding: 0 11px;
    border-radius: var(--radius);
    font-size: 10px;
    font-weight: 720;
    transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.button-primary {
    color: #f7f9f8;
    background: var(--green-dark);
    border: 1px solid var(--green-dark);
}

.button-primary:hover { background: #125b4a; }

.button-secondary {
    align-self: flex-start;
    margin-top: 5px;
    color: var(--green);
    background: rgba(63, 183, 149, 0.11);
    border: 1px solid rgba(63, 183, 149, 0.38);
}

.button-secondary:hover {
    background: rgba(63, 183, 149, 0.18);
    border-color: rgba(63, 183, 149, 0.58);
}

.button-primary:disabled,
.button-secondary:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.button-primary:disabled:hover { background: var(--green-dark); }
.button-secondary:disabled:hover {
    background: transparent;
    border-color: rgba(63, 183, 149, 0.38);
}

.full-width {
    width: 100%;
    margin-top: 12px;
}

.scenario-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
}

.scenario-button {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 7px;
    min-width: 0;
    min-height: 36px;
    padding: 7px 9px;
    overflow: hidden;
    color: #c1c8c6;
    background: #252b2c;
    border: 1px solid #3d4546;
    border-radius: var(--radius);
    font-size: 10px;
    font-weight: 680;
    text-align: left;
}

.scenario-button svg {
    width: 15px;
    height: 15px;
    color: #909a98;
}

.scenario-button span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.scenario-button:hover {
    border-color: #626d6c;
}

.scenario-button.is-active {
    color: var(--green);
    background: rgba(63, 183, 149, 0.14);
    border-color: rgba(63, 183, 149, 0.48);
}

.scenario-button.is-active svg { color: var(--green); }

.toggle-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.toggle-list label {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
    min-width: 0;
    color: #adb5b3;
    font-size: 8px;
    cursor: pointer;
}

.toggle-list input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.toggle-track {
    position: relative;
    width: 30px;
    height: 17px;
    background: #41494a;
    border-radius: 9px;
    transition: background 150ms ease;
}

.toggle-track::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 11px;
    height: 11px;
    background: #e9eceb;
    border-radius: 50%;
    box-shadow: 0 1px 2px rgba(17, 22, 23, 0.26);
    transition: transform 150ms ease;
}

.toggle-list input:checked + .toggle-track { background: var(--green); }
.toggle-list input:checked + .toggle-track::after { transform: translateX(13px); }
.toggle-list input:focus-visible + .toggle-track { outline: 2px solid var(--green); outline-offset: 2px; }

.signal-section {
    background: var(--paper);
}

.signal-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.signal-item {
    display: grid;
    grid-template-columns: 6px 1fr auto;
    gap: 8px;
    align-items: center;
    min-height: 29px;
    padding: 5px 7px;
    color: #bbc2c0;
    background: rgba(238, 241, 240, 0.035);
    border: 1px solid var(--line);
    border-radius: 4px;
    font-size: 9px;
}

.signal-item > i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green);
}

.signal-item.warning > i { background: var(--gold); }
.signal-item.danger > i { background: var(--red); }
.signal-item.info > i { background: var(--teal); }

.signal-item strong {
    color: #dde2e0;
    font-size: 9px;
    font-weight: 760;
    white-space: nowrap;
}

.model-notes {
    border-bottom: 1px solid var(--line);
}

.model-notes summary {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 13px 18px;
    color: #c1c8c6;
    font-size: 10px;
    font-weight: 710;
    cursor: pointer;
    list-style: none;
}

.model-notes summary::-webkit-details-marker { display: none; }

.model-notes summary svg {
    width: 14px;
    height: 14px;
    color: var(--green);
}

.model-notes > div {
    padding: 0 18px 14px 39px;
    color: var(--muted);
    font-size: 9px;
    line-height: 1.55;
}

.model-notes p + p { margin-top: 6px; }

.panel-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 38px;
    padding: 9px 18px;
    color: #858f8d;
    font-size: 8px;
}

.panel-footer strong {
    color: #c1c8c6;
    font-weight: 720;
}

@media (max-width: 1380px) {
    :root { --panel-width: 360px; }
    .topbar { gap: 10px; padding: 0 12px; }
    .brand-kicker { display: none; }
    .brand-lockup { min-width: 188px; }
    .equilibrium-state { min-width: 130px; }
    .segment { padding-right: 7px; padding-left: 7px; }
    .dock-panel[data-panel="overview"] { grid-template-columns: 205px minmax(245px, 0.8fr) minmax(260px, 1fr); }
}

@media (min-width: 1161px) and (max-height: 680px) {
    body {
        height: auto;
        overflow-y: auto;
    }

    #appShell {
        height: 100vh;
        min-height: 652px;
    }
}

@media (max-width: 1160px) {
    body {
        height: auto;
        min-height: 100vh;
        overflow-x: hidden;
        overflow-y: auto;
    }

    #appShell {
        display: block;
        height: auto;
    }

    #workspace {
        grid-template-rows: var(--topbar-height) 520px auto;
        height: auto;
    }

    #policyPanel {
        width: 100%;
        overflow: visible;
        border-top: 1px solid var(--line);
        border-left: 0;
    }

    .analytics-dock { min-height: 450px; overflow: visible; }
    .dock-panel { height: auto; min-height: 405px; }
    .dock-panel[data-panel="overview"] { grid-template-columns: 220px minmax(260px, 0.85fr) minmax(280px, 1fr); }
    .control-section, .signal-section { padding-right: max(18px, calc((100% - 760px) / 2)); padding-left: max(18px, calc((100% - 760px) / 2)); }
    .panel-heading, .panel-footer, .model-notes summary { padding-right: max(18px, calc((100% - 760px) / 2)); padding-left: max(18px, calc((100% - 760px) / 2)); }
    .model-notes > div { padding-right: max(18px, calc((100% - 760px) / 2)); padding-left: max(39px, calc((100% - 718px) / 2)); }
}

@media (max-width: 780px) {
    :root { --topbar-height: auto; --dock-height: auto; }

    #workspace {
        display: grid;
        grid-template-rows: auto 500px auto;
    }

    .topbar {
        display: grid;
        grid-template-columns: 1fr auto;
        gap: 9px;
        padding: 10px 12px;
    }

    .equilibrium-state { display: none; }
    .topbar-actions { grid-column: 1 / -1; justify-content: space-between; }
    .commodity-filter { flex: 1 1 auto; }
    .commodity-filter .segment { flex: 1 1 0; }

    .map-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: calc(100% - 24px);
        top: 12px;
        left: 12px;
    }

    .map-metric:nth-child(2) { border-right: 0; }
    .map-metric:nth-child(-n + 2) { border-bottom: 1px solid rgba(211, 218, 216, 0.14); }
    .map-metric strong { font-size: 14px; }
    .map-legend { left: 12px; max-width: calc(100% - 24px); overflow: hidden; }
    .map-unit { right: 12px; bottom: 50px; }

    .dock-tabs {
        overflow-x: auto;
        padding-right: 8px;
        padding-left: 8px;
        scrollbar-width: none;
    }

    .dock-tabs::-webkit-scrollbar { display: none; }
    .dock-tab { flex: 0 0 auto; }
    .analysis-context { display: none; }

    .dock-panel,
    .dock-panel[data-panel="overview"],
    .dock-panel[data-panel="market"],
    .dock-panel[data-panel="policy"] {
        display: grid;
        grid-template-columns: 1fr;
        min-height: 0;
    }

    .dock-panel[hidden] { display: none; }
    .account-grid { min-height: 150px; border-right: 0; border-bottom: 1px solid var(--line); }
    .dock-chart, .route-ranking, .market-facts, .market-story, .scan-summary, .scan-note { min-height: 190px; border-right: 0; border-bottom: 1px solid var(--line); }
    .route-ranking { min-height: 205px; }
    .market-facts { min-height: 170px; }
    .market-story, .scan-summary, .scan-note { min-height: 130px; }
    .history-chart-block { min-height: 300px; }

    .scenario-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .toggle-list { max-width: 460px; }
}

@media (max-width: 520px) {
    #workspace { grid-template-rows: auto 470px auto; }
    .brand-title { font-size: 14px; }
    .brand-lockup { min-width: 0; }
    .brand-mark { width: 32px; height: 32px; }
    .topbar-actions { gap: 3px; }
    .segment { padding-right: 5px; padding-left: 5px; font-size: 10px; }
    .playback { gap: 3px; }
    .icon-button { width: 32px; }
    .speed-button { min-width: 42px; padding: 0 5px; }
    .language-button { min-width: 34px; padding: 0 4px; }
    .map-legend { gap: 8px; font-size: 8px; }
    .map-unit { font-size: 8px; }
    .dock-tab { padding-right: 10px; padding-left: 10px; }
    .two-column { grid-template-columns: 1fr; }
    .scenario-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .toggle-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .route-row { grid-template-columns: minmax(105px, 1fr) 56px 48px; }
    .route-bar { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}
