/* ════════════════════════════════════════════════════════════════════
   WinHub.AI 戰情室 — command center theme
   ════════════════════════════════════════════════════════════════════ */
:root {
  --bg: #050a16;
  --bg2: #081020;
  --panel: rgba(13, 24, 46, 0.72);
  --panel-border: rgba(64, 156, 255, 0.16);
  --panel-border-hi: rgba(41, 230, 255, 0.45);
  --txt: #d7e3f4;
  --txt-dim: #7d8ca6;
  --cyan: #29e6ff;
  --blue: #409cff;
  --green: #38e8a0;
  --amber: #ffb547;
  --red: #ff5c6e;
  --violet: #ab7bff;
  --mono: "Orbitron", "Noto Sans TC", monospace;
  --sans: "Noto Sans TC", system-ui, sans-serif;
}

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

html { height: 100%; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--txt);
  overflow-x: hidden;
  font-size: 14px;
  /* 全高 flex column：頁面內容撐滿、footer 永遠貼底 */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.mono { font-family: var(--mono); letter-spacing: 0.04em; }
.accent { color: var(--cyan); }

/* ------------------------------------------------------- background --- */
.bg-grid {
  position: fixed; inset: 0; z-index: -2;
  background-image:
    linear-gradient(rgba(64, 156, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(64, 156, 255, 0.05) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(ellipse 90% 80% at 50% 0%, black 30%, transparent 100%);
}
.bg-glow {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(ellipse 60% 40% at 15% -5%, rgba(41, 230, 255, 0.08), transparent),
    radial-gradient(ellipse 50% 35% at 85% -5%, rgba(171, 123, 255, 0.07), transparent),
    radial-gradient(ellipse 80% 60% at 50% 110%, rgba(64, 156, 255, 0.06), transparent);
}

/* ----------------------------------------------------------- topbar --- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 26px 12px;
  border-bottom: 1px solid var(--panel-border);
  background: linear-gradient(180deg, rgba(8, 16, 32, 0.95), rgba(8, 16, 32, 0.75));
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 50;
}
.brand { display: flex; align-items: center; gap: 13px; min-width: 320px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 9px; position: relative;
  background: linear-gradient(135deg, rgba(41,230,255,.18), rgba(64,156,255,.08));
  border: 1px solid var(--panel-border-hi);
  box-shadow: 0 0 18px rgba(41, 230, 255, 0.25), inset 0 0 12px rgba(41,230,255,.15);
}
.brand-mark span {
  position: absolute; inset: 10px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, var(--cyan), var(--blue));
  animation: orbPulse 2.6s ease-in-out infinite;
}
@keyframes orbPulse {
  0%, 100% { box-shadow: 0 0 6px rgba(41,230,255,.8); transform: scale(1); }
  50% { box-shadow: 0 0 16px rgba(41,230,255,1); transform: scale(1.08); }
}
.brand-text h1 { font-size: 19px; font-weight: 900; letter-spacing: 0.02em; }
.brand-text h1 em { font-style: normal; color: var(--cyan); text-shadow: 0 0 14px rgba(41,230,255,.5); }
.brand-text p { font-size: 9px; letter-spacing: 0.32em; color: var(--txt-dim); margin-top: 2px; }

.tabs { display: flex; gap: 8px; position: relative; }
.tab-btn {
  font-family: var(--sans); font-size: 15px; font-weight: 700;
  color: var(--txt-dim); background: transparent;
  border: 1px solid transparent; border-radius: 10px;
  padding: 10px 22px; cursor: pointer; transition: all .25s;
  display: flex; align-items: center; gap: 9px;
}
.tab-btn .tab-num {
  font-family: var(--mono); font-size: 10px; opacity: .6;
  border: 1px solid currentColor; border-radius: 4px; padding: 1px 5px;
}
.tab-btn:hover { color: var(--txt); }
.tab-btn.active {
  color: var(--cyan);
  background: linear-gradient(180deg, rgba(41,230,255,.10), rgba(41,230,255,.03));
  border-color: var(--panel-border-hi);
  box-shadow: 0 0 22px rgba(41,230,255,.18), inset 0 0 14px rgba(41,230,255,.05);
  text-shadow: 0 0 12px rgba(41,230,255,.55);
}

.topbar-right { display: flex; align-items: center; gap: 18px; min-width: 320px; justify-content: flex-end; }
.conn { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--txt-dim); }
.conn .dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--amber);
  box-shadow: 0 0 8px var(--amber); animation: blink 1.4s infinite;
}
.conn.online .dot { background: var(--green); box-shadow: 0 0 8px var(--green); }
.conn.local .dot { background: var(--amber); }
@keyframes blink { 50% { opacity: .45; } }
.clock { font-family: var(--mono); font-size: 19px; font-weight: 700; color: var(--cyan); text-shadow: 0 0 10px rgba(41,230,255,.4); }

/* ------------------------------------------------------------ pages --- */
.page { display: none; padding: 18px 26px 30px; max-width: 1840px; margin: 0 auto; width: 100%; }
.page.active { display: block; animation: pageIn .45s ease; flex: 1 0 auto; }
@keyframes pageIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------ panels -- */
.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  backdrop-filter: blur(6px);
  position: relative;
  overflow: hidden;
}
.panel::before {
  content: ""; position: absolute; top: 0; left: 18px; right: 18px; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(41,230,255,.5), transparent);
  opacity: .5;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 16px 10px; gap: 10px; flex-wrap: wrap;
}
.panel-head h3 {
  font-size: 14px; font-weight: 700; letter-spacing: .03em;
  display: flex; align-items: center; gap: 8px;
}
.panel-head h3 small { color: var(--txt-dim); font-weight: 400; font-size: 11px; letter-spacing: .08em; }
.panel-head .ico { color: var(--cyan); font-style: normal; font-size: 15px; text-shadow: 0 0 8px rgba(41,230,255,.6); }
.hint { font-size: 11px; color: var(--txt-dim); }

.live-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--green);
  box-shadow: 0 0 8px var(--green); display: inline-block; animation: blink 1.2s infinite;
}

/* ------------------------------------------------------------ buttons - */
.btn {
  font-family: var(--sans); font-size: 13px; font-weight: 700; color: var(--txt);
  background: rgba(64, 156, 255, 0.10); border: 1px solid rgba(64, 156, 255, 0.35);
  border-radius: 9px; padding: 8px 16px; cursor: pointer; transition: all .2s;
}
.btn:hover { background: rgba(64, 156, 255, 0.22); box-shadow: 0 0 14px rgba(64,156,255,.25); }
.btn:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; }
.btn.primary {
  color: #04121f;
  background: linear-gradient(135deg, var(--cyan), var(--blue));
  border: none; box-shadow: 0 0 18px rgba(41, 230, 255, 0.35);
}
.btn.primary:hover { box-shadow: 0 0 26px rgba(41, 230, 255, 0.6); transform: translateY(-1px); }
.btn.ghost { background: transparent; border-color: var(--panel-border-hi); color: var(--cyan); }
.btn.scenario { width: 100%; text-align: left; padding: 10px 14px; }
.btn.scenario:hover { border-color: var(--amber); box-shadow: 0 0 14px rgba(255,181,71,.25); }

select, input[type="text"] {
  font-family: var(--sans); font-size: 13px; color: var(--txt);
  background: rgba(8, 16, 32, 0.8); border: 1px solid var(--panel-border);
  border-radius: 8px; padding: 8px 10px; outline: none;
}
select:focus, input[type="text"]:focus { border-color: var(--panel-border-hi); }

/* ════════════════════════════ TAB 1 — SHAP ═══════════════════════════ */
.hero-strip {
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px; padding: 18px 22px; margin-bottom: 16px; flex-wrap: wrap;
}
.hero-title h2 { font-size: 21px; font-weight: 900; letter-spacing: .02em; }
.hero-title .x { color: var(--cyan); margin: 0 4px; }
.hero-title p { color: var(--txt-dim); margin-top: 5px; font-size: 13px; }
.hero-title p b { color: var(--cyan); font-weight: 700; }
.hero-chips { display: flex; gap: 10px; flex-wrap: wrap; }
.chip {
  background: rgba(8, 16, 32, 0.65); border: 1px solid var(--panel-border);
  border-radius: 10px; padding: 8px 14px; text-align: center;
}
.chip label { display: block; font-size: 10px; color: var(--txt-dim); letter-spacing: .08em; margin-bottom: 3px; }
.chip b { font-size: 14px; }

.shap-layout { display: grid; grid-template-columns: 460px 1fr; gap: 16px; align-items: start; }

/* 左側資料表 */
.table-panel { position: sticky; top: 86px; }
.table-wrap { max-height: calc(100vh - 220px); overflow-y: auto; padding: 0 6px 10px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
thead th {
  position: sticky; top: 0; z-index: 2;
  background: #0a1426; color: var(--txt-dim); font-weight: 500;
  padding: 8px 6px; text-align: right; font-size: 11px; letter-spacing: .03em;
  border-bottom: 1px solid var(--panel-border);
}
thead th:first-child, thead th:nth-child(2) { text-align: left; }
thead th small { display: block; font-size: 9px; opacity: .7; }
tbody td { padding: 7px 6px; text-align: right; font-family: var(--mono); font-size: 11.5px; border-bottom: 1px solid rgba(64,156,255,.06); }
tbody td:first-child, tbody td:nth-child(2) { text-align: left; }
tbody tr { cursor: pointer; transition: background .15s; }
tbody tr:hover { background: rgba(41, 230, 255, 0.06); }
tbody tr.selected {
  background: linear-gradient(90deg, rgba(41,230,255,.14), rgba(41,230,255,.04));
  box-shadow: inset 3px 0 0 var(--cyan);
}
.risk-badge {
  display: inline-block; font-family: var(--sans); font-size: 10px; font-weight: 700;
  border-radius: 5px; padding: 2px 8px; letter-spacing: .05em;
}
.risk-low { color: var(--green); background: rgba(56,232,160,.12); border: 1px solid rgba(56,232,160,.3); }
.risk-mid { color: var(--amber); background: rgba(255,181,71,.12); border: 1px solid rgba(255,181,71,.3); }
.risk-high { color: var(--red); background: rgba(255,92,110,.14); border: 1px solid rgba(255,92,110,.4); animation: blink 1.6s infinite; }
td.hot { color: var(--red); text-shadow: 0 0 8px rgba(255,92,110,.5); }

/* 右側解析 */
.analysis-col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.subtabs { display: flex; gap: 8px; }
.subtab-btn {
  flex: 1; font-family: var(--sans); font-size: 13.5px; font-weight: 700;
  color: var(--txt-dim); background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: 10px; padding: 11px; cursor: pointer; transition: all .2s;
}
.subtab-btn.active {
  color: var(--cyan); border-color: var(--panel-border-hi);
  box-shadow: 0 0 16px rgba(41,230,255,.12); text-shadow: 0 0 10px rgba(41,230,255,.4);
}
.subtab-page { display: none; flex-direction: column; gap: 14px; }
.subtab-page.active { display: flex; animation: pageIn .35s ease; }

.sel-panel { padding-bottom: 14px; }
.sel-head { display: flex; justify-content: space-between; align-items: flex-end; padding: 14px 18px 10px; flex-wrap: wrap; gap: 10px; }
.sel-id label, .sel-pred label { display: block; font-size: 10.5px; color: var(--txt-dim); letter-spacing: .1em; margin-bottom: 3px; }
.sel-id b { font-size: 26px; color: var(--cyan); text-shadow: 0 0 14px rgba(41,230,255,.4); }
.sel-mc { margin-left: 10px; color: var(--txt-dim); font-size: 13px; }
.sel-pred { text-align: right; }
.sel-pred b { font-size: 26px; margin-right: 10px; }
.sel-features { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 4px 18px 2px; }
.feat-chip {
  background: rgba(8,16,32,.6); border: 1px solid var(--panel-border);
  border-radius: 9px; padding: 7px 10px; transition: all .3s;
}
.feat-chip label { display: block; font-size: 10px; color: var(--txt-dim); margin-bottom: 2px; }
.feat-chip b { font-family: var(--mono); font-size: 14px; }
.feat-chip small { color: var(--txt-dim); font-size: 9.5px; margin-left: 3px; }
.feat-chip.bad { border-color: rgba(255,92,110,.5); box-shadow: 0 0 12px rgba(255,92,110,.15); }
.feat-chip.bad b { color: var(--red); }

.run-panel .run-controls { display: flex; gap: 9px; align-items: center; }
.run-status { display: flex; align-items: center; gap: 14px; padding: 2px 18px 10px; }
.progress { flex: 1; height: 6px; border-radius: 4px; background: rgba(8,16,32,.9); overflow: hidden; }
.progress-fill {
  height: 100%; width: 0%; border-radius: 4px; transition: width .15s linear;
  background: linear-gradient(90deg, var(--blue), var(--cyan));
  box-shadow: 0 0 10px rgba(41,230,255,.6);
}
.iter { font-size: 11.5px; color: var(--txt-dim); white-space: nowrap; }
.iter span { color: var(--cyan); font-size: 13px; }
.run-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 12px; padding: 0 16px 16px; }
.run-grid h4 { font-size: 11.5px; color: var(--txt-dim); font-weight: 500; letter-spacing: .06em; margin-bottom: 6px; }
.chart { width: 100%; height: 260px; }
.chart.tall { height: 320px; }
.chart.dependence { height: 380px; }
.log-box {
  height: 196px; overflow-y: auto; border-radius: 9px;
  background: rgba(4, 9, 18, 0.85); border: 1px solid var(--panel-border);
  padding: 9px 11px; font-family: var(--mono); font-size: 10.5px; line-height: 1.85;
}
.log-line { white-space: nowrap; animation: logIn .3s ease; }
.log-line .lz { color: var(--violet); }
.log-line .lf { color: var(--cyan); }
.log-line .lv-pos { color: var(--red); }
.log-line .lv-neg { color: var(--green); }
.log-line.muted { color: var(--txt-dim); }
@keyframes logIn { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: none; } }
.log-explain { margin-top: 8px; font-size: 10.5px; color: var(--txt-dim); line-height: 1.7; }

.equation { font-size: 12.5px; color: var(--txt-dim); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.equation .op { color: var(--txt-dim); }
.equation #eq-baseline { color: var(--blue); }
.equation #eq-sum { color: var(--amber); }
.equation #eq-pred { color: var(--cyan); }
.equation .ok { color: var(--green); }
.waterfall-panel .chart { padding: 0 8px; }

.advice-panel { min-height: 150px; }
.advice-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 4px 16px 14px; }
.advice-empty { grid-column: 1 / -1; color: var(--txt-dim); font-size: 12.5px; padding: 16px 4px; text-align: center; }
.advice-card {
  background: rgba(8,16,32,.7); border: 1px solid rgba(255,181,71,.3);
  border-radius: 11px; padding: 13px 14px; position: relative;
  animation: adviceIn .5s ease backwards;
}
.advice-card:nth-child(2) { animation-delay: .12s; }
.advice-card:nth-child(3) { animation-delay: .24s; }
@keyframes adviceIn { from { opacity: 0; transform: translateY(12px) scale(.97); } to { opacity: 1; transform: none; } }
.advice-card .rank {
  position: absolute; top: 11px; right: 12px;
  font-family: var(--mono); font-size: 10px; color: var(--amber);
  border: 1px solid rgba(255,181,71,.4); border-radius: 4px; padding: 1px 6px;
}
.advice-card h5 { font-size: 13.5px; color: var(--amber); margin-bottom: 6px; padding-right: 70px; }
.advice-card p { font-size: 11.5px; color: var(--txt); line-height: 1.65; }
.advice-card .meta { display: flex; gap: 8px; margin-top: 9px; font-size: 10.5px; color: var(--txt-dim); }
.advice-card .meta b { color: var(--cyan); font-weight: 500; }
.whatif-result { padding: 0 16px 14px; }
.whatif-box {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: rgba(56,232,160,.06); border: 1px solid rgba(56,232,160,.35);
  border-radius: 11px; padding: 13px 18px; animation: adviceIn .5s ease;
}
.whatif-box .wf-num { font-family: var(--mono); font-size: 22px; }
.whatif-box .arrow { color: var(--green); font-size: 20px; }
.whatif-box p { font-size: 12px; color: var(--txt-dim); }
.whatif-box p b { color: var(--green); }

.global-note { padding: 0 18px 16px; font-size: 12px; color: var(--txt-dim); line-height: 1.7; }
.global-note .pos { color: var(--red); }

/* ════════════════════════════ TAB 2 — 戰情室 ═════════════════════════ */
.war-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 16px; margin-bottom: 12px;
}
.wt-label {
  font-size: 12.5px; font-weight: 700; color: var(--amber);
  letter-spacing: .06em; margin-right: 2px;
}
.wt-hint { margin-left: auto; font-size: 11px; color: var(--txt-dim); }
.btn.mini { padding: 6px 13px; font-size: 12px; border-radius: 8px; }
.btn.mini.scenario { width: auto; text-align: center; }

.kpi-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 14px; }
.kpi { padding: 13px 16px 11px; transition: border-color .3s, box-shadow .3s; }
.kpi label { font-size: 11px; color: var(--txt-dim); letter-spacing: .08em; }
.kpi-val { display: flex; align-items: baseline; gap: 5px; margin-top: 5px; }
.kpi-val b { font-size: 27px; font-weight: 700; color: var(--txt); transition: color .3s; }
.kpi-val .unit { font-size: 11px; color: var(--txt-dim); }
.kpi-delta { font-size: 10.5px; margin-top: 4px; height: 14px; color: var(--txt-dim); }
.kpi-delta.up { color: var(--green); }
.kpi-delta.down { color: var(--red); }
.kpi.alert { border-color: rgba(255,92,110,.55); box-shadow: 0 0 20px rgba(255,92,110,.18); }
.kpi.alert b { color: var(--red); }
.kpi.good b { color: var(--cyan); }

/* Copilot 常駐右欄；三欄以 grid stretch 等高，底部永遠切齊 */
.war-layout { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 14px; }
.war-main { display: grid; grid-template-columns: 1.15fr 1fr; gap: 14px; min-width: 0; }
.war-left, .war-mid, .war-right { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.war-left section.panel { flex: 1; display: flex; flex-direction: column; min-height: 0; }
/* height:0 + flex 撐滿：圖表的實際高度由欄高決定，
   ECharts 內層 div 的 inline 尺寸不會反向撐高版面（避免越長越高的迴圈） */
.war-left .war-chart { flex: 1 1 0; height: 0; min-height: 210px; }
.war-chart { height: 240px; }
.gauge-chart { height: 190px; }
.feed-panel { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.legend { display: flex; gap: 12px; font-size: 11px; color: var(--txt-dim); }
.legend .lg { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; }
.lg.run { background: var(--green); box-shadow: 0 0 6px var(--green); }
.lg.idle { background: var(--blue); }
.lg.warn { background: var(--amber); box-shadow: 0 0 6px var(--amber); }
.lg.down { background: var(--red); box-shadow: 0 0 6px var(--red); }

.machine-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; padding: 2px 14px 14px; }
.machine {
  border-radius: 10px; padding: 9px 10px; border: 1px solid var(--panel-border);
  background: rgba(8,16,32,.6); transition: all .35s; position: relative; overflow: hidden;
}
.machine .mid { font-family: var(--mono); font-size: 12.5px; font-weight: 700; }
.machine .mstat { font-size: 10px; margin-top: 2px; letter-spacing: .05em; }
.machine .mtemp { font-family: var(--mono); font-size: 10px; color: var(--txt-dim); margin-top: 4px; }
.machine.run { border-color: rgba(56,232,160,.4); }
.machine.run .mstat { color: var(--green); }
.machine.idle { border-color: rgba(64,156,255,.35); opacity: .8; }
.machine.idle .mstat { color: var(--blue); }
.machine.warn {
  border-color: rgba(255,181,71,.6); box-shadow: 0 0 16px rgba(255,181,71,.2);
  animation: machineWarn 1.2s ease-in-out infinite;
}
.machine.warn .mstat { color: var(--amber); }
@keyframes machineWarn { 50% { box-shadow: 0 0 26px rgba(255,181,71,.4); } }
.machine.down {
  border-color: rgba(255,92,110,.65); box-shadow: 0 0 18px rgba(255,92,110,.25);
  animation: machineWarn 1s ease-in-out infinite;
}
.machine.down .mstat { color: var(--red); }
.machine.down .mid { color: var(--red); }

.feed-panel .event-feed {
  /* height:0：事件累積只在面板內捲動，不撐高版面 */
  flex: 1 1 0; height: 0; min-height: 140px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 7px; padding: 2px 14px 14px;
}
.event {
  border-left: 3px solid var(--blue); border-radius: 7px;
  background: rgba(8,16,32,.65); padding: 8px 11px;
  font-size: 11.5px; animation: eventIn .4s ease;
}
@keyframes eventIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
.event .etime { font-family: var(--mono); font-size: 9.5px; color: var(--txt-dim); margin-right: 8px; }
.event .etag {
  font-size: 9.5px; font-weight: 700; border-radius: 4px; padding: 1px 6px; margin-right: 7px;
}
.event.info { border-left-color: var(--blue); }
.event.info .etag { color: var(--blue); background: rgba(64,156,255,.12); }
.event.warn { border-left-color: var(--amber); }
.event.warn .etag { color: var(--amber); background: rgba(255,181,71,.12); }
.event.crit { border-left-color: var(--red); box-shadow: 0 0 14px rgba(255,92,110,.12); }
.event.crit .etag { color: var(--red); background: rgba(255,92,110,.14); }

/* ------------------------------------------------------- copilot ------ */
.copilot-panel {
  display: flex; flex-direction: column;
  border-color: rgba(171, 123, 255, 0.35);
  box-shadow: 0 0 30px rgba(171, 123, 255, 0.08);
  flex: 1;            /* 跟著等高的右欄補滿 → 與左中欄底部切齊 */
  height: auto;
  min-height: 520px;
}
.copilot-panel::before { background: linear-gradient(90deg, transparent, rgba(171,123,255,.6), transparent); }
.copilot-head h3 { color: #cdb4ff; }
.copilot-orb {
  width: 14px; height: 14px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #d8c5ff, var(--violet));
  box-shadow: 0 0 12px rgba(171,123,255,.7); display: inline-block;
  transition: all .3s;
}
.copilot-orb.thinking { animation: orbThink .8s ease-in-out infinite; }
@keyframes orbThink {
  0%, 100% { box-shadow: 0 0 10px rgba(171,123,255,.7); transform: scale(1); }
  50% { box-shadow: 0 0 24px rgba(171,123,255,1); transform: scale(1.25); }
}
.copilot-src { font-size: 10px; color: var(--txt-dim); border: 1px solid var(--panel-border); border-radius: 5px; padding: 2px 8px; }
.copilot-feed {
  /* height:0：訊息串流只在面板內捲動，絕不改變整體版面高度 */
  flex: 1 1 0; height: 0; min-height: 0; overflow-y: auto; padding: 6px 14px;
  display: flex; flex-direction: column; gap: 12px;
}
.copilot-welcome {
  font-size: 12px; color: var(--txt-dim); line-height: 1.8;
  border: 1px dashed rgba(171,123,255,.35); border-radius: 10px; padding: 12px 14px;
}
.copilot-welcome b { color: #cdb4ff; }
.copilot-msg {
  background: rgba(20, 14, 40, 0.55); border: 1px solid rgba(171,123,255,.25);
  border-radius: 12px; padding: 11px 14px; animation: eventIn .4s ease;
}
.copilot-msg .cm-head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 7px;
  font-size: 10px; color: var(--txt-dim);
}
.copilot-msg .cm-mode {
  font-weight: 700; border-radius: 4px; padding: 1.5px 7px; letter-spacing: .05em;
}
.cm-mode.routine { color: var(--blue); background: rgba(64,156,255,.12); }
.cm-mode.event { color: var(--red); background: rgba(255,92,110,.14); }
.cm-mode.ask { color: var(--green); background: rgba(56,232,160,.12); }
.copilot-msg .cm-body { font-size: 12.5px; line-height: 1.85; white-space: pre-wrap; word-break: break-word; }
.cm-body b { color: var(--cyan); font-weight: 700; }
.cm-body .sec { color: #cdb4ff; font-weight: 700; }
.cursor {
  display: inline-block; width: 7px; height: 14px; vertical-align: -2px; margin-left: 2px;
  background: var(--cyan); box-shadow: 0 0 8px var(--cyan); animation: blink .7s infinite;
}
.copilot-actions { display: flex; align-items: center; gap: 12px; padding: 12px 14px 6px; }
.copilot-actions .btn { flex: 1; }
.auto-toggle { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--txt-dim); cursor: pointer; white-space: nowrap; }
.auto-toggle input { display: none; }
.auto-toggle .switch {
  width: 32px; height: 17px; border-radius: 10px; background: rgba(8,16,32,.9);
  border: 1px solid var(--panel-border); position: relative; transition: all .25s;
}
.auto-toggle .switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 11px; height: 11px;
  border-radius: 50%; background: var(--txt-dim); transition: all .25s;
}
.auto-toggle input:checked + .switch { background: rgba(56,232,160,.2); border-color: rgba(56,232,160,.5); }
.auto-toggle input:checked + .switch::after { left: 17px; background: var(--green); box-shadow: 0 0 8px var(--green); }
.copilot-ask { display: flex; gap: 8px; padding: 8px 14px 14px; }
.copilot-ask input { flex: 1; }

/* ------------------------------------------------------------ footer -- */
.footer {
  display: flex; justify-content: space-between; padding: 10px 26px 18px;
  color: var(--txt-dim); font-size: 11px;
  margin-top: auto; /* 內容不足一屏時仍貼底 */
}

/* ------------------------------------------------------- scrollbars --- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(64,156,255,.25); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(41,230,255,.4); }

/* ------------------------------------------------------- responsive --- */
@media (max-width: 1500px) {
  .war-layout { grid-template-columns: minmax(0, 1fr) 350px; }
}
@media (max-width: 1280px) {
  .shap-layout { grid-template-columns: 1fr; }
  .table-panel { position: static; }
  .table-wrap { max-height: 380px; }
  .kpi-row { grid-template-columns: repeat(3, 1fr); }
  .topbar { flex-wrap: wrap; gap: 10px; }
  .brand, .topbar-right { min-width: 0; }
  .war-main { grid-template-columns: 1fr; }
  .war-layout { grid-template-columns: minmax(0, 1fr) 330px; }
}
@media (max-width: 900px) {
  .war-layout { grid-template-columns: 1fr; }
  .copilot-panel { min-height: 480px; }
  .copilot-feed { height: auto; max-height: 380px; }
  .feed-panel .event-feed { height: auto; max-height: 300px; }
  .war-left .war-chart { height: 240px; flex: none; }
  .run-grid { grid-template-columns: 1fr; }
  .advice-list { grid-template-columns: 1fr; }
  .sel-features { grid-template-columns: repeat(2, 1fr); }
}
