@font-face {
    font-family: "EcaLab CJK";
    src: url("../fonts/NotoSansSC-EcaLab.otf") format("opentype");
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
}

:root {
    color-scheme: dark;
    --shell: #18201f;
    --panel: #202827;
    --panel-raised: #28302f;
    --map-sea: #c8dddf;
    --map-sea-deep: #b7d2d5;
    --land: #edf0eb;
    --land-border: #9da9a4;
    --ink: #f3f5f2;
    --ink-dark: #1f2928;
    --muted: #9aa6a2;
    --line: rgba(225, 232, 228, 0.13);
    --green: #4dbb91;
    --teal: #238598;
    --amber: #e0a33c;
    --coral: #d46655;
    --paper: #f5f3ec;
    --radius: 6px;
    --panel-width: 378px;
    --topbar-height: 62px;
    --dock-height: 252px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; min-height: 100%; }
body {
    height: 100vh;
    overflow: hidden;
    background: var(--shell);
    color: var(--ink);
    font-family: "EcaLab CJK", "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.45;
}
button, input, select { font: inherit; }
button { border: 0; cursor: pointer; }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
[hidden] { display: none !important; }
svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

#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(350px, 1fr) var(--dock-height); min-width: 0; min-height: 0; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 0 16px; background: #151c1b; border-bottom: 1px solid var(--line); z-index: 10; }
.brand-lockup { display: flex; align-items: center; gap: 10px; min-width: 244px; }
.brand-mark { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; color: #202724; background: var(--amber); border-radius: var(--radius); }
.brand-mark svg { width: 21px; height: 21px; }
.brand-title { font-size: 15px; font-weight: 760; white-space: nowrap; }
.brand-kicker { margin-top: 2px; color: var(--muted); font-size: 9px; }
.model-state { display: flex; align-items: center; justify-content: center; gap: 8px; color: #b5c0bc; font-size: 10px; white-space: nowrap; }
.model-state i { width: 7px; height: 7px; background: var(--green); border-radius: 50%; box-shadow: 0 0 0 3px rgba(77,187,145,.12); }
.model-state.is-updating i { background: var(--amber); }
.model-state b { width: 1px; height: 13px; background: rgba(255,255,255,.2); }
.topbar-actions, .segmented, .playback { display: flex; align-items: center; }
.topbar-actions { gap: 8px; }
.segmented { height: 34px; padding: 2px; background: rgba(255,255,255,.06); border: 1px solid var(--line); border-radius: var(--radius); }
.segment { height: 28px; padding: 0 10px; color: #a7b2ae; background: transparent; border-radius: 4px; font-size: 10px; font-weight: 680; white-space: nowrap; }
.segment.is-active { color: #17201e; background: #eef0eb; }
.playback { gap: 4px; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; color: #acb7b3; background: transparent; border: 1px solid var(--line); border-radius: var(--radius); }
.icon-button:hover, .icon-button.is-active { color: white; background: rgba(255,255,255,.09); border-color: rgba(255,255,255,.25); }
.icon-button.light { color: #31413e; background: rgba(249,248,242,.9); border-color: rgba(43,59,56,.17); box-shadow: 0 4px 12px rgba(39,58,56,.12); }

#mapStage { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: var(--map-sea); }
#map { width: 100%; height: 100%; background: var(--map-sea); }
.leaflet-container { font-family: "EcaLab CJK", "Segoe UI", sans-serif; }
.leaflet-control-attribution { font-size: 8px; }
.leaflet-control-attribution a { color: #266f7a; }
.leaflet-tooltip { padding: 0; color: #edf1ef; background: rgba(21,29,28,.96); border: 1px solid rgba(255,255,255,.18); border-radius: var(--radius); box-shadow: 0 12px 26px rgba(22,35,33,.25); }
.leaflet-tooltip::before { display: none; }
.leaflet-tooltip.route-tooltip, .leaflet-tooltip.point-tooltip { width: 220px; }
.leaflet-tooltip.port-label { width: auto; padding: 2px 5px; color: #20312f; background: rgba(250,249,243,.9); border: 1px solid rgba(31,54,50,.15); box-shadow: none; font-size: 10px; font-weight: 750; }
.port-dot { width: 12px; height: 12px; background: #fffaf0; border: 3px solid #243936; border-radius: 50%; box-shadow: 0 0 0 2px rgba(255,255,255,.55); }
.waypoint-dot { width: 12px; height: 12px; background: var(--amber); border: 2px solid #fffdf4; border-radius: 50%; box-shadow: 0 2px 6px rgba(29,43,40,.25); }
.ship-marker { width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; color: #fffaf0; background: #17312d; border: 2px solid #fff8e3; border-radius: 50%; box-shadow: 0 4px 10px rgba(14,37,32,.3); }
.ship-marker svg { width: 13px; height: 13px; }
.map-metrics, .map-tools, .edit-badge, .map-legend, .map-source { z-index: 500; }
.map-metrics { position: absolute; top: 14px; left: 16px; display: grid; grid-template-columns: repeat(4, minmax(118px, 1fr)); width: min(670px, calc(100% - 92px)); color: #edf1ee; background: rgba(23,31,30,.91); border: 1px solid rgba(255,255,255,.18); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(24,44,41,.14); }
.map-metrics > div { min-width: 0; padding: 9px 12px; border-right: 1px solid rgba(255,255,255,.12); }
.map-metrics > div:last-child { border-right: 0; }
.map-metrics span { display: block; overflow: hidden; color: #a4b1ad; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.map-metrics strong { display: block; margin-top: 3px; font-size: 16px; line-height: 1.2; letter-spacing: 0; }
.map-metrics strong.positive { color: #6dd3aa; }
.map-tools { position: absolute; top: 14px; right: 16px; display: grid; gap: 5px; }
.edit-badge { position: absolute; top: 66px; left: 16px; display: flex; align-items: center; gap: 6px; height: 28px; padding: 0 9px; color: #263230; background: #f1bd61; border: 1px solid rgba(93,61,13,.17); border-radius: var(--radius); font-size: 9px; font-weight: 750; box-shadow: 0 4px 12px rgba(68,49,18,.12); }
.edit-badge svg { width: 13px; height: 13px; }
.map-legend, .map-source { position: absolute; bottom: 12px; color: #263634; background: rgba(247,246,240,.91); border: 1px solid rgba(47,71,68,.16); border-radius: var(--radius); box-shadow: 0 4px 14px rgba(42,61,59,.1); }
.map-legend { left: 16px; display: flex; align-items: center; gap: 13px; padding: 7px 10px; font-size: 9px; }
.map-legend span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.legend-area { width: 12px; height: 9px; background: rgba(224,163,60,.45); border: 1px solid #c98622; }
.legend-line { width: 17px; height: 3px; border-radius: 2px; }
.legend-line.eca { background: var(--coral); }
.legend-line.open { background: var(--teal); }
.legend-port { width: 9px; height: 9px; background: var(--paper); border: 2px solid #263b37; border-radius: 50%; }
.map-source { right: 16px; padding: 7px 9px; font-size: 8px; white-space: nowrap; }
.map-tooltip { position: absolute; z-index: 12; width: 220px; padding: 10px 11px; color: #edf1ef; background: rgba(21,29,28,.96); border: 1px solid rgba(255,255,255,.18); border-radius: var(--radius); box-shadow: 0 12px 26px rgba(22,35,33,.25); pointer-events: none; }
.tooltip-title { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 7px; font-size: 11px; font-weight: 750; }
.tooltip-row { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; color: #a7b3af; font-size: 9px; }
.tooltip-row strong { color: #e5eae7; font-weight: 650; }

.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(--panel-raised); border-bottom: 1px solid var(--line); }
.dock-tab { position: relative; height: 40px; padding: 0 12px; color: var(--muted); background: transparent; font-size: 10px; font-weight: 700; white-space: nowrap; }
.dock-tab::after { content: ""; position: absolute; right: 10px; bottom: 0; left: 10px; height: 2px; background: transparent; }
.dock-tab.is-active { color: #68caa4; }
.dock-tab.is-active::after { background: var(--green); }
.analysis-context { min-width: 0; margin-left: auto; overflow: hidden; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.dock-panel { height: calc(var(--dock-height) - 40px); min-height: 0; overflow: hidden; }
.dock-panel[hidden] { display: none; }
.route-panel { display: grid; grid-template-columns: 250px minmax(300px, .9fr) minmax(330px, 1.1fr); }
.route-facts { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); background: var(--line); gap: 1px; border-right: 1px solid var(--line); }
.route-facts > div, .cost-facts > div { display: flex; flex-direction: column; justify-content: center; min-width: 0; padding: 10px 13px; background: var(--panel); }
.route-facts span, .cost-facts span { color: var(--muted); font-size: 9px; }
.route-facts strong, .cost-facts strong { margin-top: 3px; font-size: 15px; }
.dock-chart, .timeline-block { min-width: 0; min-height: 0; padding: 10px 14px 8px; border-right: 1px solid var(--line); }
.dock-title { display: flex; align-items: center; justify-content: space-between; height: 20px; color: #cdd4d1; font-size: 9px; font-weight: 720; }
.dock-title span:last-child { color: var(--muted); font-weight: 550; }
.dock-chart canvas { display: block; width: 100%; height: calc(100% - 20px); }
.timeline-block { border-right: 0; }
.timeline-list { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); height: calc(100% - 20px); align-items: center; }
.timeline-item { position: relative; min-width: 0; padding: 0 10px; border-left: 1px solid var(--line); }
.timeline-item:first-child { border-left: 0; }
.timeline-item i { display: block; width: 8px; height: 8px; margin-bottom: 8px; background: var(--green); border: 2px solid #d9efe6; border-radius: 50%; }
.timeline-item strong, .timeline-item span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timeline-item strong { font-size: 11px; }
.timeline-item span { margin-top: 3px; color: var(--muted); font-size: 8px; }
.cost-panel { display: grid; grid-template-columns: minmax(440px,1.4fr) minmax(350px,1fr); }
.cost-chart-block { border-right: 1px solid var(--line); }
.cost-facts { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); background: var(--line); gap: 1px; }
.sensitivity-panel { display: grid; grid-template-columns: minmax(480px,1.6fr) 180px minmax(230px,.8fr); }
.sensitivity-switch { display: flex; flex-direction: column; justify-content: center; gap: 6px; padding: 14px; border-right: 1px solid var(--line); }
.sensitivity-switch button { height: 34px; color: #adb8b4; background: #2a3331; border: 1px solid var(--line); border-radius: var(--radius); font-size: 9px; }
.sensitivity-switch button.is-active { color: #17201f; background: var(--amber); border-color: var(--amber); font-weight: 750; }
.sensitivity-readout { display: flex; flex-direction: column; justify-content: center; padding: 16px; color: #bac4c0; font-size: 10px; line-height: 1.65; }
.sensitivity-readout strong { display: block; margin-bottom: 5px; color: var(--ink); font-size: 18px; }
.method-panel { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); }
.method-panel > div { display: flex; flex-direction: column; justify-content: center; padding: 18px 22px; border-right: 1px solid var(--line); }
.method-panel > div:last-child { border-right: 0; }
.method-panel span { color: var(--amber); font-size: 8px; font-weight: 800; }
.method-panel strong { margin: 5px 0 7px; font-size: 15px; }
.method-panel p { color: var(--muted); font-size: 9px; line-height: 1.6; }

#strategyPanel { min-width: 0; overflow-x: hidden; overflow-y: auto; background: var(--panel); border-left: 1px solid var(--line); scrollbar-width: thin; scrollbar-color: #58625f transparent; }
.panel-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; min-height: 84px; padding: 18px 18px 14px; background: var(--panel-raised); border-bottom: 1px solid var(--line); }
.panel-heading span { display: block; margin-bottom: 3px; color: var(--amber); font-size: 8px; font-weight: 850; }
.panel-heading h1 { font-size: 20px; line-height: 1.1; letter-spacing: 0; }
.panel-heading b { padding: 4px 7px; color: #bdc6c3; background: #313a38; border-radius: 4px; font-size: 8px; white-space: nowrap; }
.control-section { padding: 15px 18px 16px; border-bottom: 1px solid var(--line); }
.section-heading { display: flex; align-items: center; gap: 7px; margin-bottom: 12px; font-size: 11px; font-weight: 750; }
.section-heading svg { width: 15px; height: 15px; color: var(--amber); }
.select-field, .field-grid label { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.select-field > span, .field-grid label > span { color: var(--muted); font-size: 9px; }
select { width: 100%; height: 34px; padding: 0 28px 0 9px; color: #e8ecea; background: #2b3432; border: 1px solid #47514e; border-radius: var(--radius); font-size: 10px; }
.route-summary { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); margin-top: 10px; background: var(--line); gap: 1px; }
.route-summary > div { min-width: 0; padding: 8px 7px; background: #242d2b; }
.route-summary span, .route-summary strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.route-summary span { color: var(--muted); font-size: 8px; }
.route-summary strong { margin-top: 3px; font-size: 11px; }
.button-row { display: flex; gap: 7px; margin-top: 10px; }
.button-secondary { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 10px; color: #dce2df; background: #2d3634; border: 1px solid #4a5552; border-radius: var(--radius); font-size: 9px; font-weight: 700; }
.button-secondary:hover, .button-secondary.is-active { color: #17201f; background: var(--amber); border-color: var(--amber); }
.button-secondary svg { width: 14px; height: 14px; }
.button-row .button-secondary:first-child { flex: 1; }
.icon-only { width: 36px; padding: 0; }
.scenario-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 6px; }
.scenario-button { min-height: 34px; padding: 6px; color: #aeb9b5; background: #2a3331; border: 1px solid var(--line); border-radius: var(--radius); font-size: 9px; font-weight: 680; }
.scenario-button.is-active { color: #1d2725; background: #e6e7df; border-color: #e6e7df; }
.range-field { display: block; margin-top: 12px; }
.range-field:first-of-type { margin-top: 0; }
.range-field > span { display: flex; justify-content: space-between; gap: 12px; color: #c1cac6; font-size: 9px; }
.range-field output { color: var(--amber); font-weight: 750; white-space: nowrap; }
.range-field input[type="range"] { width: 100%; height: 18px; margin-top: 5px; accent-color: var(--amber); cursor: pointer; }
.range-field > i { display: flex; justify-content: space-between; color: #788581; font-size: 7px; font-style: normal; }
.field-grid { display: grid; gap: 8px; }
.two-column { grid-template-columns: repeat(2,minmax(0,1fr)); }
.compact-controls .range-field { margin-top: 11px; }
.toggle-list { display: grid; gap: 1px; background: var(--line); }
.toggle-list label { display: flex; align-items: center; justify-content: space-between; min-height: 34px; padding: 0 9px; background: #252e2c; color: #bec7c3; font-size: 9px; }
.toggle-list input { width: 15px; height: 15px; accent-color: var(--amber); }
.data-note { display: flex; gap: 9px; padding: 15px 18px 20px; color: #8f9c98; }
.data-note svg { flex: 0 0 auto; width: 15px; height: 15px; color: var(--amber); }
.data-note strong, .data-note span { display: block; }
.data-note strong { margin-bottom: 4px; color: #c8cfcc; font-size: 9px; }
.data-note span { font-size: 8px; line-height: 1.6; }

@media (max-width: 1120px) {
    :root { --panel-width: 340px; }
    .model-state { display: none; }
    .route-panel { grid-template-columns: 220px minmax(260px,1fr); }
    .timeline-block { display: none; }
    .cost-facts { grid-template-columns: repeat(2,minmax(0,1fr)); }
}

@media (max-width: 760px) {
    body { height: auto; overflow-x: hidden; overflow-y: auto; }
    #appShell { display: block; height: auto; }
    #workspace { display: block; }
    .topbar { min-height: 104px; padding: 10px 12px; flex-wrap: wrap; }
    .brand-lockup { min-width: 0; }
    .brand-kicker { display: none; }
    .topbar-actions { width: 100%; justify-content: space-between; }
    .segment { padding: 0 7px; font-size: 9px; }
    #mapStage { height: 62vh; min-height: 500px; }
    .map-metrics { grid-template-columns: repeat(2,minmax(0,1fr)); width: calc(100% - 76px); }
    .map-metrics > div:nth-child(2) { border-right: 0; }
    .map-metrics > div:nth-child(-n+2) { border-bottom: 1px solid rgba(255,255,255,.12); }
    .map-legend { right: 12px; left: 12px; gap: 8px; overflow-x: auto; }
    .map-source { display: none; }
    .analytics-dock { height: auto; overflow: visible; }
    .dock-tabs { overflow-x: auto; }
    .analysis-context { display: none; }
    .dock-panel { height: auto; min-height: 330px; overflow: visible; }
    .route-panel, .cost-panel, .sensitivity-panel, .method-panel { display: block; }
    .route-facts { height: 150px; border-right: 0; border-bottom: 1px solid var(--line); }
    .dock-chart { height: 220px; border-right: 0; border-bottom: 1px solid var(--line); }
    .timeline-block { display: block; height: 150px; }
    .cost-facts { min-height: 170px; }
    .sensitivity-switch { flex-direction: row; border-right: 0; border-bottom: 1px solid var(--line); }
    .sensitivity-switch button { flex: 1; }
    .sensitivity-readout { min-height: 130px; }
    .method-panel > div { min-height: 150px; border-right: 0; border-bottom: 1px solid var(--line); }
    #strategyPanel { width: 100%; max-height: none; border-top: 1px solid var(--line); border-left: 0; }
}

@media (max-width: 430px) {
    .brand-title { font-size: 14px; }
    .playback .icon-button { width: 32px; }
    .map-metrics strong { font-size: 14px; }
    .map-legend { font-size: 8px; }
}
