/* ============================================================
   TAIWAN-STRAIT-SIM — 介面樣式
   版面：CMO 式三欄（左 OOB / 中地圖 / 右資訊）+ 頂列功能表 + 底部訊息記錄
   微觀操作層（Broken Arrow 式命令列與單位卡）浮在地圖右下。
   視覺語彙沿用 TF101 主站：Orbitron 標題 / Rajdhani 內文 / #FF8C00 主色
   ============================================================ */

:root {
    --accent: #FF8C00;
    --roc: #4FC3F7;
    --pla: #FF5252;
    --bg-0: #05080f;
    --bg-1: rgba(10, 15, 25, 0.94);
    --bg-2: rgba(18, 26, 40, 0.9);
    --line: rgba(120, 150, 190, 0.22);
    --text: #E6EEF8;
    --text-dim: #8FA3BD;
    --topbar-h: 54px;
    --bottombar-h: 132px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: var(--bg-0);
    color: var(--text);
    font-family: 'Rajdhani', 'Noto Sans TC', sans-serif;
    overflow: hidden;
}

button { font-family: inherit; color: inherit; cursor: pointer; }

/* ═══════════════════════════ 頂列 ═══════════════════════════ */

#topbar {
    position: relative;
    z-index: 60;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 14px;
    background: linear-gradient(180deg, #0a1018, #05080f);
    border-bottom: 1px solid var(--line);
}

.brand img { height: 26px; display: block; }
.title-block .eyebrow {
    font-family: 'Orbitron', sans-serif;
    font-size: 8px;
    letter-spacing: 2px;
    color: var(--accent);
}
.title-block .ttl { font-size: 14px; font-weight: 700; letter-spacing: 2px; }

.tb-spacer { flex: 1; }

.tb-group { display: flex; flex-direction: column; gap: 1px; }
.tb-label {
    font-family: 'Orbitron', sans-serif;
    font-size: 7.5px;
    letter-spacing: 1.4px;
    color: var(--text-dim);
}
.tb-value { font-size: 12px; font-weight: 600; }
.tb-value b { font-weight: 700; color: var(--accent); }
.tb-clock {
    font-family: 'Orbitron', sans-serif;
    font-size: 15px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* 功能表（CMO 的下拉式選單） */
#menubar { display: flex; gap: 2px; }
.menu { position: relative; }
.menu-title {
    background: transparent;
    border: 1px solid transparent;
    padding: 5px 10px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 3px;
}
.menu-title:hover { background: var(--bg-2); border-color: var(--line); }
.menu-list {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 210px;
    background: var(--bg-1);
    border: 1px solid var(--line);
    border-radius: 3px;
    padding: 4px;
    z-index: 70;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}
.menu-list.open { display: block; }
.menu-item {
    display: block;
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    padding: 6px 10px;
    font-size: 13px;
    border-radius: 2px;
}
.menu-item:hover { background: rgba(255, 140, 0, 0.15); color: var(--accent); }

.speed-row { display: flex; gap: 2px; }
.speed-btn {
    background: var(--bg-2);
    border: 1px solid var(--line);
    color: var(--text-dim);
    padding: 2px 6px;
    font-size: 10px;
    font-family: 'Orbitron', sans-serif;
    border-radius: 2px;
}
.speed-btn:hover { color: var(--text); }
.speed-btn.active { background: rgba(255, 140, 0, 0.22); border-color: var(--accent); color: var(--accent); }

.btn {
    background: var(--bg-2);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 3px;
    padding: 6px 10px;
    font-size: 13px;
    font-weight: 600;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: 4px 8px; font-size: 12px; }
.btn-xs { padding: 2px 7px; font-size: 11px; }
.btn.danger:hover { border-color: var(--pla); color: var(--pla); }
.btn-play {
    font-family: 'Orbitron', sans-serif;
    font-size: 12px;
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(255, 140, 0, 0.12);
    min-width: 92px;
}
.btn-play.running { background: rgba(76, 175, 80, 0.15); border-color: #4CAF50; color: #4CAF50; }

/* ═══════════════════════════ 主體三欄 ═══════════════════════════ */

#stage {
    position: relative;
    height: calc(100% - var(--topbar-h) - var(--bottombar-h));
    display: grid;
    grid-template-columns: 268px 1fr 272px;
}

#left-col, #right-col {
    background: var(--bg-1);
    border-right: 1px solid var(--line);
    overflow-y: auto;
    padding: 0;
}
#right-col { border-right: none; border-left: 1px solid var(--line); padding: 10px 12px; }

.col-block { padding: 10px 12px; border-bottom: 1px solid var(--line); }

.block-title {
    margin: 0 0 8px;
    font-family: 'Orbitron', sans-serif;
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 1.8px;
    color: var(--accent);
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}
.block-title .hint {
    font-family: 'Rajdhani', sans-serif;
    font-size: 10px;
    letter-spacing: 0;
    color: var(--text-dim);
}

#map-wrap { position: relative; overflow: hidden; }
/* 底圖壓暗去彩度，與戰術 HUD 同一色調空間。刻意不用 invert()：
   MapEngine 已把建築量體重新上色為深藍灰，反轉會讓它們變亮而失去閱讀性。 */
#map { position: absolute; inset: 0; filter: saturate(0.45) brightness(0.52) contrast(1.08); }
#tactical { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 5; }

/* ═══════════════════════════ 戰鬥序列 ═══════════════════════════ */

.oob-hint {
    font-size: 11px;
    color: var(--text-dim);
    padding: 4px 0 8px;
    line-height: 1.4;
    border-bottom: 1px dashed rgba(120, 150, 190, 0.18);
    margin-bottom: 6px;
}

.oob-row {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 5px 4px;
    border-radius: 3px;
    cursor: pointer;
}
.oob-row:hover { background: rgba(255, 255, 255, 0.04); }
.oob-row.focused { background: rgba(255, 140, 0, 0.1); box-shadow: inset 2px 0 0 var(--accent); }
.oob-row.dead { opacity: 0.35; }

.focus-dot {
    background: transparent;
    border: none;
    color: var(--accent);
    font-size: 14px;
    line-height: 1;
    padding: 0 2px;
}
.oob-main { flex: 1; min-width: 0; }
.oob-name { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.oob-sub { font-size: 10.5px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.oob-bar { height: 3px; background: rgba(0, 0, 0, 0.5); border-radius: 2px; margin-top: 3px; overflow: hidden; }
.oob-fill { height: 100%; }
.oob-pct { font-family: 'Orbitron', sans-serif; font-size: 10px; font-weight: 700; }

/* ═══════════════════════════ 戰力條 ═══════════════════════════ */

.force { margin-bottom: 8px; }
.force-head { display: flex; justify-content: space-between; font-size: 11.5px; font-weight: 600; margin-bottom: 3px; }
.force-head b { font-family: 'Orbitron', sans-serif; font-size: 10.5px; }
.force-track { height: 5px; background: rgba(0, 0, 0, 0.5); border-radius: 3px; overflow: hidden; }
.force-fill { height: 100%; transition: width 0.3s ease-out; }
.force-fill.roc { background: linear-gradient(90deg, #29B6F6, var(--roc)); }
.force-fill.pla { background: linear-gradient(90deg, #C62828, var(--pla)); }

/* ═══════════════════════════ 右欄資訊面板 ═══════════════════════════ */

.info-panel { font-size: 12px; }
.panel-empty { color: var(--text-dim); text-align: center; padding: 16px 0; font-size: 12px; }

.unit-head { padding-bottom: 8px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.unit-title { font-size: 14px; font-weight: 700; }
.unit-sub { font-size: 11px; color: var(--text-dim); }

.sec { border-bottom: 1px solid rgba(120, 150, 190, 0.12); }
.sec-head {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 5px;
    background: transparent;
    border: none;
    padding: 6px 0;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--accent);
    text-align: left;
}
.sec-caret { font-size: 9px; transition: transform 0.15s; }
.sec-head.collapsed .sec-caret { transform: rotate(-90deg); }
.sec-body { padding: 0 0 8px 12px; }

.kv-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 2px 0; }
.kv-label { color: var(--text-dim); font-size: 11.5px; }
.kv-value { font-weight: 600; font-variant-numeric: tabular-nums; font-size: 11.5px; text-align: right; }

/* ══════════ CMO §4.5 右欄面板（ui/unitpanel.js）══════════
   版面與配色照 Command: Modern Operations 的單位資訊面板移植：
   深海軍藍底、每個區塊一條標題列（左標題右摺疊箭頭）、
   淺灰的傳統 Win32 風格按鈕矩陣、藍色可點連結、綠色續航讀數。 */

.cmo-panel {
    --cmo-bg: #0b1526;
    --cmo-head: #16263e;
    --cmo-line: #2c4160;
    --cmo-btn: #c9ccc4;
    --cmo-btn-hi: #e4e6df;
    --cmo-btn-text: #14181c;
    --cmo-link: #6FB4FF;
    font-size: 11.5px;
    color: #dbe4f0;
    margin: -10px -12px;
}

.cmo-block { border-bottom: 1px solid var(--cmo-line); background: var(--cmo-bg); }
.cmo-block-head {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    background: var(--cmo-head);
    border: none;
    border-top: 1px solid #3a5578;
    border-bottom: 1px solid #071018;
    padding: 4px 8px;
    text-align: left;
}
.cmo-block-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 8.5px;
    font-weight: 700;
    letter-spacing: 1.3px;
    color: #eaf1fb;
}
.cmo-caret { color: #9fb6d4; font-size: 11px; line-height: 1; }
.cmo-block-body { padding: 6px 8px 9px; display: flex; flex-direction: column; gap: 3px; }

.cmo-unit-name { font-size: 12.5px; font-weight: 700; color: #ffffff; }
.cmo-type { font-size: 11px; color: #b6c6da; }
.cmo-strong { font-weight: 700; }

/* 單位縮圖：CMO 放照片，這裡放 APP-6 框型 + 兵種內符 + 素質標籤 */
.cmo-portrait {
    position: relative;
    height: 74px;
    border: 1px solid;
    border-radius: 2px;
    background: linear-gradient(160deg, rgba(20, 40, 70, 0.9), rgba(6, 12, 22, 0.95));
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 2px 0 4px;
}
.cmo-portrait-symbol {
    width: 54px;
    height: 36px;
    border: 2px solid;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 19px;
    line-height: 1;
    background: rgba(255, 255, 255, 0.05);
}
.cmo-portrait-echelon {
    position: absolute;
    top: 12px;
    font-family: 'Orbitron', sans-serif;
    font-size: 10px;
    font-weight: 700;
}
.cmo-portrait-prof {
    position: absolute;
    right: 5px;
    bottom: 3px;
    font-size: 10px;
    font-weight: 700;
    color: #ffd166;
    text-shadow: 0 1px 2px #000;
}

.cmo-row { display: flex; align-items: center; gap: 6px; min-height: 16px; }
.cmo-key { color: #9db2cc; flex-shrink: 0; }
.cmo-val { font-weight: 600; font-variant-numeric: tabular-nums; margin-left: auto; text-align: right; }
.cmo-indent { padding-left: 12px; }
.cmo-line { font-variant-numeric: tabular-nums; line-height: 1.45; }
.cmo-green { color: #6EE36E; font-weight: 600; }
.cmo-unknown { color: #6FB4FF; }
.cmo-note { color: #93a7c0; font-size: 10.5px; line-height: 1.45; }
.cmo-sep { border-top: 1px solid var(--cmo-line); margin: 3px 0; }

.cmo-link { color: var(--cmo-link); text-decoration: underline; cursor: pointer; }
.cmo-link:hover { color: #A8D4FF; }

/* CMO 的傳統淺灰按鈕 */
.cmo-btn {
    background: linear-gradient(180deg, var(--cmo-btn-hi), var(--cmo-btn));
    color: var(--cmo-btn-text);
    border: 1px solid #7d8378;
    border-radius: 2px;
    padding: 3px 7px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.25;
}
.cmo-btn:hover { background: #f2f3ee; border-color: var(--accent); }
.cmo-btn:disabled { background: #4a5158; color: #8b939b; border-color: #333a40; cursor: default; }
.cmo-btn-wide { width: 100%; margin: 2px 0; }
.cmo-btn-inline { margin-left: auto; }
.cmo-btn.danger { background: linear-gradient(180deg, #f0b9b9, #d68d8d); }

.cmo-btn-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; margin-top: 3px; }

.cmo-meter {
    flex: 1;
    height: 9px;
    background: #05090f;
    border: 1px solid #2c4160;
    margin-left: auto;
    max-width: 140px;
}
.cmo-meter-fill { height: 100%; }

.cmo-select {
    width: 100%;
    background: #e8eae4;
    color: #14181c;
    border: 1px solid #7d8378;
    border-radius: 2px;
    padding: 2px 4px;
    font-family: 'Rajdhani', sans-serif;
    font-size: 11px;
    margin: 3px 0;
}

/* 姿態 / 檔位按鈕矩陣（CMO 的 UNIT ALT/SPEED） */
.cmo-nav-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #0e1b2e;
    border: 1px solid var(--cmo-line);
    padding: 2px 8px;
}
.cmo-nav-arrow { color: #9fb6d4; font-size: 10px; }
.cmo-nav-title { font-family: 'Orbitron', sans-serif; font-size: 8.5px; letter-spacing: 1.4px; }
.cmo-grid-head {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3px;
    font-size: 10px;
    color: #9db2cc;
    text-align: center;
    padding-top: 2px;
}
.cmo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; }
.cmo-grid-btn {
    background: linear-gradient(180deg, var(--cmo-btn-hi), var(--cmo-btn));
    color: var(--cmo-btn-text);
    border: 1px solid #7d8378;
    border-radius: 2px;
    padding: 3px 2px;
    font-size: 10.5px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cmo-grid-btn:hover:not(:disabled) { background: #f2f3ee; border-color: var(--accent); }
.cmo-grid-btn.on { background: linear-gradient(180deg, #ffc98a, #ff9d3d); border-color: var(--accent); }
.cmo-grid-btn.off, .cmo-grid-btn:disabled { background: #3f464d; color: #838b93; border-color: #2b3138; cursor: default; }

/* 補給條 */
.cmo-fuel-row { display: flex; align-items: center; gap: 6px; }
.cmo-fuel-name { background: #1d4f86; color: #fff; padding: 1px 5px; font-size: 10.5px; }
.cmo-fuel-track { flex: 1; height: 9px; background: #05090f; border: 1px solid #2c4160; }
.cmo-fuel-fill { height: 100%; background: #4FC3F7; }

/* 火力任務 */
.cmo-fire-active { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.cmo-fire-brev { font-family: 'Orbitron', sans-serif; font-size: 10px; color: var(--accent); letter-spacing: 0.8px; }
.cmo-fire-phase { font-size: 10.5px; color: #ffd166; }
.cmo-fire-type { display: flex; justify-content: space-between; gap: 6px; padding: 1px 0; }
.cmo-fire-hint { color: #93a7c0; font-size: 10.5px; }

/* EMCON 三段開關 */
.cmo-check { display: flex; align-items: center; gap: 5px; margin: 4px 0 2px; font-size: 11px; }
.cmo-toggle-row { display: flex; align-items: center; gap: 3px; }
.cmo-toggle-label { flex: 1; color: #9db2cc; font-size: 11px; }
.cmo-toggle {
    background: linear-gradient(180deg, var(--cmo-btn-hi), var(--cmo-btn));
    color: var(--cmo-btn-text);
    border: 1px solid #7d8378;
    border-radius: 2px;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: 700;
    min-width: 52px;
}
.cmo-toggle.on { background: linear-gradient(180deg, #a8e6a8, #63c463); border-color: #2f7d2f; }
.cmo-toggle.off, .cmo-toggle:disabled { background: #3f464d; color: #838b93; border-color: #2b3138; cursor: default; }

/* DETECTIONS：CMO 的 Last Detections 卡片列 */
.cmo-detections { display: flex; flex-direction: column; gap: 4px; max-height: 320px; overflow-y: auto; }
.cmo-detection {
    background: #0e1b2e;
    border: 1px solid var(--cmo-line);
    border-left: 2px solid var(--accent);
    padding: 3px 6px;
    line-height: 1.4;
}
.cmo-det-line { font-size: 11px; }
.cmo-det-key { color: #9db2cc; }
.cmo-det-meta { font-size: 10px; color: #8ea3bd; font-variant-numeric: tabular-nums; }

.ui-select, .ui-input {
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid var(--line);
    color: var(--text);
    border-radius: 2px;
    padding: 2px 5px;
    font-family: 'Rajdhani', sans-serif;
    font-size: 11.5px;
    max-width: 130px;
}
.ui-input[type="number"] { width: 70px; }

.los-controls { display: flex; flex-direction: column; gap: 5px; }
.los-controls label { display: flex; justify-content: space-between; align-items: center; font-size: 11.5px; color: var(--text-dim); }
.los-controls input {
    width: 70px;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid var(--line);
    color: var(--text);
    border-radius: 2px;
    padding: 2px 5px;
    font-family: 'Orbitron', sans-serif;
    font-size: 10.5px;
}

/* ═══════════════════ Broken Arrow 式微觀操作層 ═══════════════════ */

#micro-hud {
    position: absolute;
    right: 10px;
    bottom: 10px;
    z-index: 20;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    pointer-events: none;
}
#micro-hud > * { pointer-events: auto; }

.unit-cards { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; max-width: 520px; }
.unit-card {
    width: 76px;
    background: var(--bg-1);
    border: 1px solid var(--line);
    border-radius: 3px;
    padding: 4px 5px;
    text-align: left;
    position: relative;
}
.unit-card:hover { border-color: var(--accent); }
.unit-card.more {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    font-family: 'Orbitron', sans-serif;
    font-size: 12px;
    color: var(--text-dim);
}
.uc-kind { font-size: 9px; font-family: 'Orbitron', sans-serif; letter-spacing: 0.5px; }
.uc-name { font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-dim); }
.uc-track { height: 3px; background: rgba(0, 0, 0, 0.55); border-radius: 2px; margin-top: 2px; overflow: hidden; }
.uc-track.thin { height: 2px; }
.uc-fill { height: 100%; }
.uc-flag {
    position: absolute;
    top: 2px;
    right: 3px;
    font-size: 8px;
    color: #FFD166;
    font-weight: 700;
}
.uc-flag.hold { color: var(--pla); }

.order-panel {
    background: var(--bg-1);
    border: 1px solid var(--line);
    border-radius: 3px;
    padding: 6px 8px;
}
.order-panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: 'Orbitron', sans-serif;
    font-size: 8.5px;
    letter-spacing: 1.5px;
    color: var(--accent);
    margin-bottom: 6px;
}
.queue-ind { color: var(--text-dim); border: 1px solid var(--line); border-radius: 2px; padding: 1px 4px; }
.queue-ind.on { color: var(--accent); border-color: var(--accent); background: rgba(255, 140, 0, 0.15); }

.order-bar { display: grid; grid-template-columns: repeat(5, 62px); gap: 4px; }
.order-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    background: var(--bg-2);
    border: 1px solid var(--line);
    border-radius: 3px;
    padding: 5px 2px;
}
.order-btn:hover { border-color: var(--accent); }
.order-btn.armed { background: rgba(255, 140, 0, 0.22); border-color: var(--accent); }
.order-btn.disabled, .order-btn:disabled { opacity: 0.35; cursor: default; }
.order-btn.disabled:hover, .order-btn:disabled:hover { border-color: var(--line); }
.order-key { font-family: 'Orbitron', sans-serif; font-size: 12px; font-weight: 700; color: var(--accent); }
.order-label { font-size: 10px; color: var(--text-dim); }

/* 射擊種類選單（NATO 呼叫火力電文的 TYPE OF FIRE） */
.fire-menu {
    margin-top: 6px;
    border-top: 1px solid var(--line);
    padding-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.fire-menu-head {
    font-family: 'Orbitron', sans-serif;
    font-size: 8px;
    letter-spacing: 1.4px;
    color: var(--accent);
    margin-bottom: 2px;
}
.fire-menu-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    background: var(--bg-2);
    border: 1px solid var(--line);
    border-radius: 2px;
    padding: 3px 7px;
    text-align: left;
}
.fire-menu-item:hover { border-color: var(--accent); background: rgba(255, 140, 0, 0.12); }
.fire-brev { font-family: 'Orbitron', sans-serif; font-size: 9px; letter-spacing: 0.8px; color: var(--accent); }
.fire-label { font-size: 11px; color: var(--text-dim); }

/* ═══════════════ CMO §4.1 右鍵內容選單 ═══════════════ */

.ctx-menu {
    position: fixed;
    z-index: 200;
    min-width: 250px;
    max-width: 330px;
    background: var(--bg-1);
    border: 1px solid var(--line);
    border-radius: 3px;
    box-shadow: 0 10px 34px rgba(0, 0, 0, 0.75);
    padding: 3px;
    font-size: 12px;
}
.ctx-header {
    font-family: 'Orbitron', sans-serif;
    font-size: 8.5px;
    letter-spacing: 1.2px;
    color: var(--accent);
    padding: 5px 8px 4px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ctx-sep { border-top: 1px solid var(--line); margin: 3px 0; }
.ctx-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    background: transparent;
    border: none;
    border-radius: 2px;
    padding: 4px 8px;
    text-align: left;
}
.ctx-item:hover { background: rgba(255, 140, 0, 0.16); }
.ctx-label { font-size: 12px; font-weight: 600; }
.ctx-hint { font-size: 10.5px; color: var(--text-dim); line-height: 1.35; }
.ctx-item:hover .ctx-label { color: var(--accent); }

.ctx-submenu { position: relative; }
.ctx-submenu-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 4px 8px;
    border-radius: 2px;
    cursor: default;
}
.ctx-submenu:hover .ctx-submenu-head,
.ctx-submenu.open .ctx-submenu-head { background: rgba(255, 140, 0, 0.16); color: var(--accent); }
.ctx-submenu-head { cursor: pointer; }
.ctx-arrow { color: var(--text-dim); font-size: 10px; }
.ctx-submenu-body {
    display: none;
    position: absolute;
    left: 100%;
    top: -3px;
    min-width: 260px;
    background: var(--bg-1);
    border: 1px solid var(--line);
    border-radius: 3px;
    box-shadow: 0 10px 34px rgba(0, 0, 0, 0.75);
    padding: 3px;
}
.ctx-submenu:hover .ctx-submenu-body,
.ctx-submenu.open .ctx-submenu-body { display: block; }

.layer-switch {
    position: absolute;
    right: 10px;
    top: 10px;
    z-index: 15;
    display: flex;
    gap: 2px;
    background: var(--bg-1);
    border: 1px solid var(--line);
    border-radius: 3px;
    padding: 3px;
}
.layer-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-dim);
    padding: 4px 9px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 2px;
}
.layer-btn:hover { color: var(--text); }
.layer-btn.active { background: rgba(255, 140, 0, 0.22); border-color: var(--accent); color: var(--accent); }

#legend {
    position: absolute;
    left: 10px;
    bottom: 10px;
    z-index: 15;
    background: var(--bg-1);
    border: 1px solid var(--line);
    border-radius: 3px;
    padding: 7px 10px;
    font-size: 10.5px;
    color: var(--text-dim);
}
.legend-row { display: flex; align-items: center; gap: 6px; padding: 1.5px 0; }
.swatch { width: 13px; height: 9px; display: inline-block; flex-shrink: 0; }
.swatch.rect { border: 1.5px solid var(--roc); background: rgba(79, 195, 247, 0.18); }
.swatch.diamond { border: 1.5px solid var(--pla); background: rgba(255, 82, 82, 0.18); transform: rotate(45deg) scale(0.8); }
.swatch.qmark {
    border: 1.5px dashed #FFC107;
    border-radius: 50%;
    width: 12px;
    height: 12px;
    color: #FFC107;
    font-size: 9px;
    text-align: center;
    line-height: 9px;
    font-weight: 700;
}
.swatch.line { height: 2px; }
.swatch.line.green { background: #4CAF50; }
.swatch.line.red { background: var(--pla); }
.swatch.focus { border: 1.5px solid rgba(255, 140, 0, 0.7); border-radius: 50%; width: 12px; height: 12px; }
.swatch.impact {
    border: 1.5px solid var(--accent);
    background: rgba(255, 140, 0, 0.16);
    border-radius: 50%;
    width: 12px;
    height: 12px;
}

/* ═══════════════════════════ 底部 ═══════════════════════════ */

#bottombar {
    position: relative;
    height: var(--bottombar-h);
    background: var(--bg-1);
    border-top: 1px solid var(--line);
    display: flex;
    flex-direction: column;
}
.log-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-family: 'Orbitron', sans-serif;
    font-size: 8.5px;
    letter-spacing: 1.8px;
    color: var(--accent);
    padding: 5px 14px 3px;
}
.log-head .hint {
    font-family: 'Rajdhani', sans-serif;
    font-size: 10px;
    letter-spacing: 0;
    color: var(--text-dim);
}
.log-controls { display: flex; align-items: center; gap: 4px; }
.log-scope-btn {
    background: var(--bg-2);
    border: 1px solid var(--line);
    color: var(--text-dim);
    padding: 2px 8px;
    font-family: 'Rajdhani', sans-serif;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0;
    border-radius: 2px;
}
.log-scope-btn:hover { color: var(--text); }
.log-scope-btn.active { background: rgba(255, 140, 0, 0.22); border-color: var(--accent); color: var(--accent); }
.log-pin-btn {
    background: rgba(79, 195, 247, 0.14);
    border: 1px solid var(--roc);
    color: var(--roc);
    padding: 2px 8px;
    font-family: 'Rajdhani', sans-serif;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0;
    border-radius: 2px;
}
.log-empty { color: var(--text-dim); font-size: 11.5px; padding: 6px 0; }
.log { flex: 1; overflow-y: auto; padding: 0 14px 4px; font-size: 11.5px; line-height: 1.5; }
.log-line {
    padding: 1px 0 1px 7px;
    border-left: 2px solid var(--accent);
    margin-bottom: 2px;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
}
/* 事件分級配色，仿 error log：KILL 最搶眼，FIRE/HIT 例行交戰最淡。 */
.log-line.log-kill { color: #FF8C00; font-weight: 700; }
.log-line.log-rout { color: #FFC107; }
.log-line.log-mode { color: #4FC3F7; }
.log-line.log-hit { color: #FFD166; }
.log-line.log-fire { color: var(--text-dim); opacity: 0.72; }
.log-line.log-fires { color: #FF8C00; }
.log-line.log-detect { color: #4FC3F7; }
.log-line.log-order { color: #E6EEF8; font-weight: 600; }
.statusbar {
    padding: 4px 14px;
    background: rgba(5, 8, 15, 0.94);
    border-top: 1px solid var(--line);
    font-size: 11.5px;
    color: var(--text-dim);
}

/* ═══════════════════════════ 對話框 ═══════════════════════════ */

#dialog-host { position: fixed; inset: 0; z-index: 100; }
.dialog-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); }
.dialog {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(880px, 92vw);
    max-height: 84vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-1);
    border: 1px solid var(--line);
    border-radius: 4px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
}
.dialog-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 9px 14px;
    border-bottom: 1px solid var(--line);
}
.dialog-title { font-family: 'Orbitron', sans-serif; font-size: 12px; letter-spacing: 1.5px; color: var(--accent); }
.dialog-close { background: transparent; border: none; font-size: 15px; color: var(--text-dim); }
.dialog-close:hover { color: var(--pla); }
.dialog-body { padding: 12px 14px; overflow-y: auto; }

.mission-editor { display: grid; grid-template-columns: 250px 1fr; gap: 14px; padding: 0; }
.me-list { border-right: 1px solid var(--line); padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.me-list-head { display: flex; flex-direction: column; gap: 6px; font-size: 11px; color: var(--text-dim); }
.me-actions { display: flex; gap: 4px; }
.me-items { overflow-y: auto; display: flex; flex-direction: column; gap: 3px; }
.me-item { padding: 6px 8px; border: 1px solid transparent; border-radius: 3px; cursor: pointer; }
.me-item:hover { background: rgba(255, 255, 255, 0.04); }
.me-item.active { background: rgba(255, 140, 0, 0.12); border-color: var(--accent); }
.me-item-name { font-size: 12.5px; font-weight: 600; }
.me-item-sub { font-size: 10.5px; color: var(--text-dim); }

.me-detail { padding: 10px 12px 14px 0; overflow-y: auto; }
.me-tabs { display: flex; gap: 3px; border-bottom: 1px solid var(--line); margin-bottom: 10px; }
.me-tab {
    background: transparent;
    border: 1px solid transparent;
    border-bottom: none;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dim);
    border-radius: 3px 3px 0 0;
}
.me-tab:hover { color: var(--text); }
.me-tab.active { background: var(--bg-2); border-color: var(--line); color: var(--accent); }

.me-pane { display: flex; flex-direction: column; gap: 8px; }
.me-hint { font-size: 11px; color: var(--text-dim); line-height: 1.5; }
.me-sep {
    font-family: 'Orbitron', sans-serif;
    font-size: 9px;
    letter-spacing: 1.4px;
    color: var(--accent);
    border-top: 1px solid var(--line);
    padding-top: 8px;
    margin-top: 4px;
}
.me-unit-list { display: flex; flex-direction: column; gap: 2px; max-height: 320px; overflow-y: auto; }
.me-unit { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 3px; cursor: pointer; font-size: 12px; }
.me-unit:hover { background: rgba(255, 255, 255, 0.04); }
.me-unit-name { flex: 1; }
.me-unit-sub { color: var(--text-dim); font-size: 11px; }

.form-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 12px; }
.form-row label { color: var(--text-dim); }
.form-row .ui-input { max-width: 220px; flex: 1; }

.doctrine-dialog { display: flex; flex-direction: column; gap: 10px; }

.oob-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.oob-table th, .oob-table td { text-align: left; padding: 4px 8px; border-bottom: 1px solid rgba(120, 150, 190, 0.14); }
.oob-table th { font-family: 'Orbitron', sans-serif; font-size: 9px; letter-spacing: 1px; color: var(--accent); }
.oob-table tr.dead { opacity: 0.4; }

/* ═══════════════════════════ MapLibre 調色 ═══════════════════════════ */

.maplibregl-ctrl-group { background: var(--bg-1) !important; border: 1px solid var(--line) !important; }
.maplibregl-ctrl-group button + button { border-top: 1px solid var(--line) !important; }
.maplibregl-ctrl-attrib { font-size: 9px; }

@media (max-width: 1280px) {
    #stage { grid-template-columns: 220px 1fr 232px; }
    .order-bar { grid-template-columns: repeat(5, 54px); }
}
