:root {
  --navy: #1f3a5f;
  --navy-light: #2e5481;
  --accent: #c79a45;      /* 沉穩金 */
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #21303f;
  --muted: #6b7a8d;
  --line: #e1e7ef;
  --ok: #2f8f5b;
  --shadow: 0 2px 14px rgba(31, 58, 95, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.7;
}

/* ── 頁首 ── */
.app-header {
  background: linear-gradient(135deg, var(--navy), var(--navy-light));
  color: #fff;
  padding: 22px 0;
}
.header-inner { max-width: 920px; margin: 0 auto; padding: 0 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.header-actions { display: flex; gap: 8px; }
.hbtn {
  display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid rgba(255,255,255,.5); background: rgba(255,255,255,.1); color: #fff;
  border-radius: 8px; padding: 7px 12px; font-size: 13px; cursor: pointer; font-weight: 600;
  font-family: inherit;
}
.hbtn:hover { background: rgba(255,255,255,.22); }

/* ── 區塊標題（PEST/五力/SWOT 等分組）── */
.field-heading {
  margin: 22px 0 2px; font-size: 16px; font-weight: 800; color: var(--navy);
  border-left: 5px solid var(--accent); padding-left: 10px;
}
.field-heading span { display: block; font-size: 12.5px; font-weight: 400; color: var(--muted); }

/* ── 九宮格等 grid 版面 ── */
.field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.field-grid .field { margin-top: 0; }

/* 報告子標題 */
.report .rep-sub { font-weight: 700; color: var(--navy-light); margin: 12px 0 2px; font-size: 14.5px; }
.app-header h1 { margin: 0; font-size: 26px; letter-spacing: 2px; }
.app-header .subtitle { margin: 6px 0 0; color: #cdd9e8; font-size: 14px; }

/* ── 步驟進度列 ── */
.stepnav {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 24px;
  max-width: 920px;
  margin: 0 auto;
  justify-content: center;
}
.stepnav button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  border-radius: 999px;
  padding: 5px 13px;
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
}
.stepnav button:hover { border-color: var(--navy-light); color: var(--navy); }
.stepnav button.active {
  background: var(--navy); color: #fff; border-color: var(--navy);
  font-weight: 600;
}
.stepnav button.done { border-color: var(--ok); color: var(--ok); }
.stepnav button.done.active { background: var(--navy); color:#fff; }

/* ── 主內容 ── */
.layout { max-width: 920px; margin: 28px auto 120px; padding: 0 24px; }
.step-content { animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.step-head { margin-bottom: 18px; }
.step-kicker { color: var(--accent); font-weight: 700; font-size: 13px; letter-spacing: 1px; }
.step-title { font-size: 22px; margin: 4px 0 8px; }
.step-intro {
  background: #eef3fa;
  border-left: 4px solid var(--navy-light);
  padding: 12px 16px;
  border-radius: 8px;
  color: #3a4b5e;
  font-size: 14.5px;
}

/* ── 欄位卡片 ── */
.field {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  margin-top: 16px;
  box-shadow: var(--shadow);
}
.field-label { font-weight: 700; font-size: 15.5px; display: flex; align-items: center; gap: 8px; }
.field-badge {
  display: inline-flex; align-items:center; justify-content:center;
  width: 24px; height: 24px; border-radius: 6px;
  background: var(--navy); color:#fff; font-size: 13px; font-weight:700;
}
.field-hint { color: var(--muted); font-size: 13px; margin: 4px 0 10px; }
.field textarea, .field input[type="text"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14.5px;
  font-family: inherit;
  color: var(--ink);
  resize: vertical;
  background: #fcfdff;
}
.field textarea:focus, .field input:focus {
  outline: none; border-color: var(--navy-light);
  box-shadow: 0 0 0 3px rgba(46,84,129,.12);
}

/* ── AI 幫手按鈕 ── */
.ai-row { margin-top: 10px; display: flex; align-items: center; gap: 10px; }
.btn-ai {
  border: 1px solid var(--accent);
  background: #fff8ec;
  color: #9a7320;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 600;
}
.btn-ai:hover { background: #f3e6c8; }
.ai-output {
  margin-top: 10px;
  background: #fbfaf4;
  border: 1px dashed var(--accent);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  color: #5a4a22;
  white-space: pre-wrap;
  display: none;
}
.ai-output.show { display: block; }

/* ── 底部導覽 ── */
.app-footer {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: #fff; border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px;
  box-shadow: 0 -2px 12px rgba(31,58,95,.06);
}
.save-status { color: var(--muted); font-size: 12.5px; }
.btn {
  border: none; border-radius: 9px; padding: 10px 20px;
  font-size: 15px; font-weight: 600; cursor: pointer;
}
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-light); }
.btn-ghost { background: #eef1f5; color: var(--navy); }
.btn-ghost:hover { background: #e2e7ee; }
.btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── 報告檢視 ── */
.report h3 { color: var(--navy); border-bottom: 2px solid var(--line); padding-bottom: 6px; margin-top: 22px; }
.report .ans { white-space: pre-wrap; background:#fff; border:1px solid var(--line); border-radius:8px; padding:10px 14px; margin:6px 0; }
.report .empty { color: var(--muted); font-style: italic; }
.report-actions { display:flex; gap:10px; margin-top:18px; }

/* ── 整合式 AI 按鈕（推導六大構面 / 產出三方案）── */
.ai-step { margin: 16px 0 4px; }
.btn-ai-step {
  font-size: 14.5px; font-weight: 700; padding: 11px 18px;
  background: linear-gradient(135deg, #fff3d6, #ffe7b0); border: 1px solid var(--accent);
  color: #8a6516; border-radius: 10px; cursor: pointer;
}
.btn-ai-step:hover { filter: brightness(0.97); }

/* ── AI 提問面板 ── */
.prompt-panel { font-size: 13.5px; }
.pp-title { font-weight: 600; color: #6b5a2a; margin: 4px 0 6px; }
.pp-text, .pp-paste {
  width: 100%; border: 1px solid var(--accent); border-radius: 8px;
  padding: 10px 12px; font-family: inherit; font-size: 13px; line-height: 1.6;
  background: #fffdf7; color: #4a3f22; resize: vertical;
}
.pp-text { min-height: 150px; }
.pp-paste { min-height: 90px; background: #fff; border-color: var(--line); margin-top: 2px; }
.pp-row { display: flex; align-items: center; gap: 12px; margin: 8px 0; flex-wrap: wrap; }
.pp-link { color: var(--navy); font-size: 13px; text-decoration: none; font-weight: 600; }
.pp-link:hover { text-decoration: underline; }
.pp-copied { color: var(--ok); font-size: 13px; font-weight: 600; opacity: 0; transition: opacity .2s; }
.pp-copied.show { opacity: 1; }
.pp-back { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--accent); }
.pp-result { color: var(--ok); font-size: 13px; font-weight: 600; }

/* ── 矩陣：Input/Output、策略敘述 ── */
.io-legend { font-size: 12px; color: var(--muted); margin: 8px 0 4px; }
.io-dot { display: inline-block; width: 11px; height: 11px; border-radius: 3px; vertical-align: -1px; margin-right: 3px; }
.io-dot.io-in { background: var(--navy-light); }
.io-dot.io-out { background: var(--ok); }
.mcolhead.io-out { background: #e4f2ea; }
.mcolhead.io-out .colname { color: #1f6b41; }
.narr-box { margin-top: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); }
.narr-head { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--navy); margin-bottom: 8px; }
.narr-text { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-family: inherit; font-size: 14px; resize: vertical; background: #fcfdff; }
.narr-text:focus { outline: none; border-color: var(--navy-light); box-shadow: 0 0 0 3px rgba(46,84,129,.12); }

/* ── 策略模組圖 ── */
.sm-legend { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.sm-l { display: inline-block; width: 16px; height: 4px; border-radius: 2px; vertical-align: 2px; margin-right: 3px; }
.sm-l.c { background: var(--navy); }
.sm-l.f { background: var(--ok); }
.sm-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: #fafbfd; padding: 6px; }

/* ── 選定方案（可複選）── */
.pick-hint { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.pick-row { display: flex; gap: 10px; flex-wrap: wrap; }
.pick { position: relative; flex: 1 1 180px; text-align: left; border: 1.5px solid var(--line); background: #fff; border-radius: 10px; padding: 12px 14px; cursor: pointer; }
.pick:hover:not(:disabled) { border-color: var(--navy-light); }
.pick.on { border-color: var(--ok); background: #f1faf4; box-shadow: 0 0 0 2px rgba(47,143,91,.25); }
.pick:disabled { opacity: .5; cursor: not-allowed; }
.pick .pick-l { font-weight: 700; color: var(--navy); font-size: 15px; }
.pick small { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; }
.pick .pick-badge { position: absolute; top: 8px; right: 8px; width: 22px; height: 22px; border-radius: 50%; background: var(--ok); color: #fff; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.pick:not(.on) .pick-badge { display: none; }

/* ── 策略勢態差距表 ── */
.gap-ai { margin-bottom: 8px; }
.gap-wrap { overflow-x: auto; }
.gap { border-collapse: collapse; width: 100%; }
.gap th, .gap td { border: 1px solid var(--line); padding: 5px; vertical-align: top; }
.gap th { color: #fff; font-size: 12.5px; padding: 7px; }
.gap th:nth-child(1) { background: var(--navy); } .gap th:nth-child(2) { background: var(--navy-light); }
.gap th:nth-child(3) { background: var(--ok); } .gap th:nth-child(4) { background: #c7902f; }
.gap-dim { background: var(--tint, #f2f6fa); white-space: nowrap; vertical-align: middle; }
.gap-dim b { color: var(--navy); display: block; } .gap-dim small { color: var(--muted); font-size: 10.5px; }
.gap td textarea { width: 100%; border: none; background: transparent; resize: vertical; font-family: inherit; font-size: 12.5px; min-height: 40px; color: var(--ink); }
.gap-diff textarea { background: #fbf3e8; border-radius: 4px; }
.gap td textarea:focus { outline: 1px solid var(--navy-light); border-radius: 4px; }

/* ── TOWS 組合矩陣 ── */
.tows-ai { margin-bottom: 8px; }
.tows-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tows-cell { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; box-shadow: var(--shadow); }
.tows-h { padding: 7px 12px; color: #fff; }
.tows-h b { font-size: 14.5px; } .tows-h span { font-size: 11.5px; opacity: .9; margin-left: 6px; }
.t-so .tows-h { background: var(--ok); }
.t-st .tows-h { background: var(--navy); }
.t-wo .tows-h { background: var(--navy-light); }
.t-wt .tows-h { background: #7a8aa0; }
.tows-cell textarea { width: 100%; border: none; padding: 8px 12px; font-family: inherit; font-size: 13px; resize: vertical; min-height: 80px; color: var(--ink); }
.tows-cell textarea:focus { outline: none; }

/* ── 能力 × 市場組合器 ── */
.cm-ai { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.cm-wrap { overflow-x: auto; }
.cm { border-collapse: collapse; width: 100%; }
.cm th, .cm td { border: 1px solid var(--line); padding: 4px; vertical-align: top; }
.cm th { background: var(--ok); color: #fff; font-size: 12px; padding: 6px; min-width: 150px; }
.cm .cm-corner { background: var(--navy); }
.cm-cap { background: var(--navy-light); color: #fff; font-weight: 700; font-size: 12.5px; white-space: nowrap; vertical-align: middle; }
.cm-dir { width: 80%; border: none; background: transparent; color: #fff; font-weight: 700; font-size: 12.5px; text-align: center; }
.cm-dir:focus { outline: 1px solid #fff; border-radius: 4px; }
.cm-deldir { border: none; background: transparent; color: #d6f0e0; cursor: pointer; font-size: 11px; }
.cm-deldir:hover { color: #fff; }
.cm td textarea { width: 100%; border: none; background: transparent; resize: vertical; font-family: inherit; font-size: 12px; min-height: 40px; color: var(--ink); }
.cm td textarea:focus { outline: 1px solid var(--navy-light); border-radius: 4px; }

/* ── 六大構面 Input/Output 兩欄表（仿範本）── */
.sixio { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.sixio th, .sixio td { border: 1px solid var(--line); padding: 8px 10px; vertical-align: top; }
.sixio-h { color: #fff; font-weight: 700; text-align: center; }
.io-in-h { background: var(--navy); width: 42%; }
.io-out-h { background: var(--ok); width: 42%; }
.sixio-labh { background: var(--navy-light); }
.sixio-in { background: #fff; }
.sixio-out { background: #f4faf6; }
.sixio-in div, .sixio-out div { margin-bottom: 4px; line-height: 1.5; }
.sixio-badge { text-align: center; background: var(--tint, #f2f6fa); white-space: nowrap; }
.sixio-badge b { display: block; font-size: 15px; color: var(--navy); }
.sixio-badge small { color: var(--muted); font-size: 10.5px; }
.sd-hint { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; background: #eef3fa; padding: 8px 12px; border-radius: 8px; }

/* ── 六大構面：Input/Output（舊·簡易帶）── */
.sd-iohead { display: flex; gap: 10px; margin-bottom: 6px; }
.io-tag { font-size: 11.5px; font-weight: 700; padding: 3px 10px; border-radius: 999px; color: #fff; }
.io-tag.io-in { background: var(--navy-light); }
.io-tag.io-out { background: var(--ok); }
.sd-io { width: 46px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 11px; font-weight: 700; }
.sd-io.io-in { background: var(--navy-light); }
.sd-io.io-out { background: var(--ok); }

/* ── 六大構面圖（彩色標籤帶）── */
.sixdim { display: flex; flex-direction: column; gap: 6px; }
.sd-band { display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; min-height: 46px; }
.sd-text { flex: 1; padding: 8px 12px; font-size: 13px; color: var(--ink); display: flex; align-items: center; background: #fff; }
.sd-badge { width: 150px; display: flex; flex-direction: column; justify-content: center; align-items: center; color: #fff; padding: 4px; }
.sd-badge.green { background: var(--ok); }
.sd-badge.navy { background: var(--navy-light); }
.sd-badge b { font-size: 19px; }
.sd-badge small { font-size: 10.5px; opacity: .92; }
.sd-empty { color: var(--muted); font-style: italic; }

/* ── PEST 四象限 + 五力 ── */
.pest-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pest-cell { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.pest-h { background: var(--navy); color: #fff; font-weight: 700; font-size: 13px; padding: 6px 10px; }
.pest-b { padding: 8px 10px; font-size: 12.5px; color: var(--ink); min-height: 40px; }
.ff-title { margin: 14px 0 6px; font-weight: 700; color: var(--navy); }
.ff { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.ff-row { display: flex; gap: 8px; justify-content: center; width: 100%; }
.ff-row.ff-mid { gap: 8px; }
.ff-box { border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font-size: 12px; color: var(--ink); width: 30%; min-width: 150px; background: #fff; }
.ff-box b { color: var(--navy); display: block; margin-bottom: 2px; }
.ff-row.ff-mid .ff-box:nth-child(2) { background: var(--greenLt, #ddefe4); border-color: var(--ok); }

/* ── 痛點 S/W 矩陣 ── */
.psw-wrap { overflow-x: auto; }
.psw { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.psw th, .psw td { border: 1px solid var(--line); padding: 6px 8px; text-align: center; }
.psw th { background: var(--navy); color: #fff; font-weight: 600; font-size: 12px; }
.psw .psw-corner { background: var(--navy); text-align: left; }
.psw .psw-res { background: var(--navy-light); color: #fff; font-weight: 700; text-align: left; white-space: nowrap; }
.psw-cell { cursor: pointer; font-weight: 700; min-width: 48px; background: #fff; }
.psw-cell:hover { background: #eef3fa; }
.psw-cell.v-S { background: #dcefe4; color: #1f6b41; }
.psw-cell.v-W { background: #f7dada; color: #9a2a2a; }
.psw-cell.v-SW { background: #fff0d6; color: #8a6516; }
.psw-tip { margin-top: 6px; font-size: 12px; color: var(--muted); }

/* ── 環條目表 ── */
.huan-wrap { overflow-x: auto; }
.huan { border-collapse: collapse; width: 100%; }
.huan th, .huan td { border: 1px solid var(--line); padding: 4px; vertical-align: top; }
.huan th { background: var(--navy); color: #fff; font-size: 12.5px; padding: 7px; }
.huan-row.s td:first-child { background: #dcefe4; }
.huan-row.w td:first-child { background: #f7dada; }
.huan textarea { width: 100%; border: none; resize: vertical; font-family: inherit; font-size: 12.5px; min-height: 38px; background: transparent; }
.huan textarea:focus { outline: 1px solid var(--navy-light); border-radius: 4px; }
.huan select { border: 1px solid var(--line); border-radius: 6px; padding: 4px; font-weight: 700; }
.huan-del { border: none; background: transparent; color: #c9d3de; cursor: pointer; }
.huan-del:hover { color: #b03a3a; }
.huan-add { margin-top: 8px; border: 1px dashed var(--navy-light); background: #fff; color: var(--navy); border-radius: 8px; padding: 7px 14px; font-size: 13px; font-weight: 600; cursor: pointer; }
.huan-add:hover { background: #eef3fa; }

/* ── 策略矩陣分頁（多矩陣）── */
.matrix-tabs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 14px 0 0; }
.mtab {
  display: inline-flex; align-items: center; gap: 4px;
  background: #fff; border: 1px solid var(--line); border-bottom: none;
  border-radius: 9px 9px 0 0; padding: 7px 12px; cursor: pointer; color: var(--muted);
  font-size: 13.5px; font-weight: 600;
}
.mtab:hover { color: var(--navy); }
.mtab.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.mtab-name { pointer-events: none; }
.mtab-ren, .mtab-del { border: none; background: transparent; cursor: pointer; font-size: 11px; color: inherit; opacity: .65; padding: 0 2px; }
.mtab-ren:hover, .mtab-del:hover { opacity: 1; }
.mtab.active .mtab-ren, .mtab.active .mtab-del { color: #cdd9e8; }
.mtab-add {
  border: 1px dashed var(--navy-light); background: #fff; color: var(--navy);
  border-radius: 8px; padding: 6px 12px; font-size: 13px; cursor: pointer; font-weight: 600;
}
.mtab-add:hover { background: #eef3fa; }

/* ── 策略矩陣 ── */
.matrix-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 14px 0; padding: 10px 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
}
.mode-switch { display: inline-flex; background: #eef1f5; border-radius: 8px; padding: 3px; }
.mbtn {
  border: 1px solid var(--line); background: #fff; color: var(--navy);
  border-radius: 7px; padding: 6px 12px; font-size: 13.5px; cursor: pointer; font-weight: 600;
}
.mode-switch .mbtn { border: none; background: transparent; }
.mode-switch .mbtn.active { background: var(--navy); color: #fff; }
.mbtn.add-col { border-color: var(--ok); color: var(--ok); }
.mbtn.danger { border-color: #d9a2a2; color: #b03a3a; margin-left: auto; }
.mbtn:hover { filter: brightness(0.97); }
.matrix-tip { font-size: 12.5px; color: var(--muted); flex: 1 1 200px; }

.matrix-wrap {
  overflow: auto; border: 1px solid var(--line); border-radius: 10px;
  background: #fafbfd; max-height: 70vh;
}
.matrix-grid { display: grid; position: relative; gap: 4px; padding: 4px; }

.mcorner {
  background: var(--navy); color: #fff; font-size: 12px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; text-align: center;
  border-radius: 6px; padding: 6px; position: sticky; left: 0; top: 0; z-index: 5;
}
.mcolhead {
  background: #eaf0f8; border: 1px solid var(--line); border-radius: 6px;
  padding: 5px; display: flex; align-items: center; gap: 4px;
  position: sticky; top: 0; z-index: 3;
}
.colname {
  flex: 1; border: none; background: transparent; font-weight: 700;
  font-size: 13.5px; color: var(--navy); text-align: center; width: 100%;
}
.colname:focus { outline: 1px solid var(--navy-light); border-radius: 4px; }
.delcol { border: none; background: transparent; color: #b6c0cc; cursor: pointer; font-size: 12px; }
.delcol:hover { color: #b03a3a; }

.mrowhead {
  background: var(--navy-light); color: #fff; border-radius: 6px; padding: 6px 8px;
  display: flex; flex-direction: column; justify-content: center;
  position: sticky; left: 0; z-index: 2;
}
.mrowhead .rl { font-size: 11px; opacity: .7; }
.mrowhead .rn { font-size: 18px; font-weight: 800; }
.mrowhead .rf { font-size: 11px; opacity: .9; line-height: 1.3; }

.mcell {
  background: #fff; border: 1px solid var(--line); border-radius: 6px;
  padding: 16px 4px 4px; position: relative; min-height: 64px;
}
.mcell .clabel {
  position: absolute; top: 2px; left: 4px; font-size: 10px; color: #b6c0cc; font-weight: 700;
  pointer-events: none;
}
.mitems { display: flex; flex-direction: column; gap: 4px; }
.mitem {
  display: flex; align-items: flex-start; gap: 3px;
  background: #f7f9fc; border: 1px solid var(--line); border-radius: 5px; padding: 2px 3px;
}
.mitem .ilabel { font-size: 9.5px; color: #8aa0b8; font-weight: 700; padding-top: 5px; min-width: 30px; }
.mitem .itext {
  flex: 1; border: none; background: transparent; resize: none;
  font-family: inherit; font-size: 12.5px; color: var(--ink); line-height: 1.45;
  padding: 3px 2px; min-height: 22px;
}
.mitem .itext:focus { outline: none; }
.mitem:focus-within { border-color: var(--navy-light); box-shadow: 0 0 0 2px rgba(46,84,129,.12); }
.mitem .idel { border: none; background: transparent; color: #c9d3de; cursor: pointer; font-size: 10px; padding: 2px; }
.mitem .idel:hover { color: #b03a3a; }
.iadd {
  margin-top: 5px; border: 1px dashed var(--line); background: #fff; color: var(--muted);
  border-radius: 5px; padding: 2px 6px; font-size: 11px; cursor: pointer; width: 100%;
}
.iadd:hover { border-color: var(--navy-light); color: var(--navy); }

/* 連線模式：點「項目」連線 */
.matrix-grid.link-mode .mitem { cursor: crosshair; }
.matrix-grid.link-mode .mitem .itext, .matrix-grid.link-mode .iadd { pointer-events: none; }
.matrix-grid.link-mode .mitem:hover { background: #fff6e8; border-color: var(--accent); }
.mitem.sel { background: #fff0d6 !important; border-color: var(--accent) !important; box-shadow: 0 0 0 2px rgba(199,154,69,.45); }

/* 價值單元建構器（第 1 步）＋ 參考庫 chips */
.vu-current { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; min-height: 30px; }
.vu-chip { display: inline-flex; align-items: center; gap: 3px; background: var(--navy); color: #fff; border-radius: 999px; padding: 4px 8px 4px 6px; font-size: 13px; font-weight: 600; }
.vu-chip.core { background: var(--accent); color: #3a2c08; }
.vu-cname { padding: 0 2px; }
.vu-star, .vu-mv, .vu-del { border: none; background: transparent; color: #cdd9e8; cursor: pointer; font-size: 11px; padding: 0 1px; }
.vu-chip.core .vu-star, .vu-chip.core .vu-mv, .vu-chip.core .vu-del { color: #8a6f2a; }
.vu-star { font-size: 13px; color: #ffd97a; }
.vu-chip.core .vu-star { color: #7a5a00; }
.vu-star:hover, .vu-mv:hover, .vu-del:hover { color: #fff; }
.vu-chip.core .vu-star:hover, .vu-chip.core .vu-mv:hover, .vu-chip.core .vu-del:hover { color: #000; }

/* 經營流程圖 */
.vu-flow-wrap { margin: 12px 0; padding: 12px; background: #f7f9fc; border: 1px solid var(--line); border-radius: 10px; }
.vu-flow-title { font-weight: 700; color: var(--navy); font-size: 13.5px; margin-bottom: 8px; }
.vu-flow-legend { font-weight: 400; color: var(--muted); font-size: 12px; }
.vu-flow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.flow-box { background: #fff; border: 1.5px solid var(--navy-light); color: var(--navy); border-radius: 8px; padding: 7px 12px; font-size: 13px; font-weight: 600; }
.flow-box.core { background: var(--accent); border-color: var(--accent); color: #3a2c08; box-shadow: 0 2px 8px rgba(199,154,69,.35); }
.flow-arrow { color: var(--navy-light); font-weight: 700; }
.vu-empty { color: var(--muted); font-size: 13px; font-style: italic; }
.vu-add-row { display: flex; gap: 8px; margin-bottom: 10px; }
.vu-input { flex: 1; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; font-family: inherit; font-size: 14px; }
.vu-input:focus { outline: none; border-color: var(--navy-light); box-shadow: 0 0 0 3px rgba(46,84,129,.12); }
.vu-add { border: 1px solid var(--ok); background: #fff; color: var(--ok); border-radius: 8px; padding: 8px 14px; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.vu-add:hover { background: #eaf6ef; }
.vu-ref { border-top: 1px dashed var(--line); padding-top: 10px; }
.ref-note { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.ref-group { margin: 8px 0; }
.ref-gname { font-size: 13px; font-weight: 700; color: var(--navy); margin-bottom: 4px; }
.ref-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ref-chip {
  border: 1px solid var(--line); background: #f4f7fb; color: var(--navy);
  border-radius: 999px; padding: 4px 11px; font-size: 12.5px; cursor: pointer;
}
.ref-chip:hover { background: var(--navy); color: #fff; border-color: var(--navy); }

.matrix-svg { position: absolute; top: 0; left: 0; pointer-events: none; z-index: 4; }
.matrix-svg line { pointer-events: stroke; }

/* ── 版權聲明 footer ── */
.copyright {
  margin-top: 30px; padding: 16px 18px 4px; border-top: 1px solid var(--line);
  color: var(--muted); font-size: 11.5px; line-height: 1.7; text-align: center;
}
.copyright p { margin: 4px 0; }
.copyright b { color: var(--navy); font-weight: 600; }
.copyright .cr-en { font-size: 10.5px; color: #8a98a8; }

@media print {
  .app-header, .stepnav, .app-footer, .btn-ai, .ai-output, .report-actions, .matrix-toolbar { display: none !important; }
  .layout { margin: 0; }
  .matrix-wrap { max-height: none; overflow: visible; }
  .copyright { margin-top: 16px; }
}
