/* =========================================================================
 * IPR 自動填寫 — 樣式
 * ========================================================================= */

:root {
  --bg: #f3f5f8;
  --card: #ffffff;
  --line: #e2e6ec;
  --line-soft: #eef1f5;
  --ink: #16191f;
  --ink-2: #4a5460;
  --ink-3: #5f6b7a;
  --accent: #14508c;
  --accent-hover: #0f3f70;
  --accent-weak: #eaf1f9;
  --ok: #0a6b3d;
  --ok-weak: #e7f4ec;
  --warn: #8a5300;
  --warn-weak: #fdf3e2;
  --err: #a4262c;
  --err-weak: #fbeceb;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px -16px rgba(16, 24, 40, .18);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC",
    "Noto Sans TC", "Microsoft JhengHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

/* ── 頂欄 ───────────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
  width: 30px; height: 30px;
  border-radius: 9px;
  background: linear-gradient(150deg, #1c63a8, #0e3d6b);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35);
  flex: none;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 16.5px; letter-spacing: .01em; }
.brand-text small { color: var(--ink-3); font-size: 13px; }

.topbar-note {
  font-size: 13px;
  color: var(--ink-3);
  white-space: nowrap;
}

/* ── 版面 ───────────────────────────────────────────────── */

.wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 28px 24px 64px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.card-head { margin-bottom: 18px; }

.card-head h2 {
  margin: 0 0 6px;
  font-size: 16.5px;
  font-weight: 650;
  letter-spacing: .01em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.step {
  display: inline-grid;
  place-items: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent-weak);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  flex: none;
}

.sub {
  margin: 0;
  color: var(--ink-2);
  font-size: 13.5px;
}

/* ── 上載區 ─────────────────────────────────────────────── */

.drop {
  border: 1.5px dashed #cfd6e0;
  border-radius: 12px;
  background: #fbfcfd;
  padding: 30px 20px;
  text-align: center;
  transition: border-color .15s, background .15s;
}

.drop:hover { border-color: #b4bfcd; background: #f8fafc; }

.drop.is-over {
  border-color: var(--accent);
  background: var(--accent-weak);
}

.drop-icon { color: #9aa5b4; margin-bottom: 6px; }

.drop { cursor: pointer; }
.drop:hover { border-color: #b9c4d2; background: #fdfefe; }
.drop.is-over .drop-icon { color: var(--accent); }

.drop-hint {
  margin-top: 10px;
  font-size: 13px;
  color: var(--ink-3);
}

/* ── 按鈕 ───────────────────────────────────────────────── */

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 550;
  padding: 9px 18px;
  border-radius: 9px;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, opacity .15s;
}

.btn:hover { background: #f6f8fa; border-color: #ccd4de; }
.btn:active { transform: translateY(.5px); }

.btn:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  padding: 11px 26px;
  font-size: 14.5px;
}

.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-primary:disabled {
  background: #c3cdd9;
  border-color: #c3cdd9;
  color: #fff;
  cursor: not-allowed;
}

.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: #f1f4f7; border-color: transparent; }

.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary:disabled { opacity: 1; }

/* ── 檔案卡片 ───────────────────────────────────────────── */

.files { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.files:empty { margin-top: 0; }

.fitem {
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 14px 16px;
  background: #fff;
}

.fitem.is-error { border-color: #f0c9c7; background: var(--err-weak); }

.fitem.is-blocked { border-color: #f0dcbb; background: #fffdf8; }

.fitem.is-blocked .badge-sup { background: #f7e7cd; color: var(--warn); }

/* OCR 來源的檔案：加一條左側色帶，讓它在清單裡一眼可辨 */
.fitem.is-ocr {
  border-color: #cfd9ec;
  box-shadow: inset 3px 0 0 0 #4b6ea8;
}

.fitem.is-ocr .badge-sup { background: #e6ecf7; color: #35507d; }

.fitem-top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.badge-sup {
  flex: none;
  width: 30px; height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--accent-weak);
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 700;
}

.fitem.is-error .badge-sup { background: #f6dcda; color: var(--err); }

.fitem-main { flex: 1; min-width: 0; }

.fitem-name {
  font-weight: 600;
  font-size: 14.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ocr-chip {
  flex: none;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .04em;
  color: #35507d;
  background: #e6ecf7;
  border: 1px solid #cfd9ec;
  border-radius: 5px;
  padding: 1px 6px;
  white-space: nowrap;
}

/* OCR 進度 */
.ocr-progress { margin-top: 10px; }

.ocr-bar {
  height: 5px;
  border-radius: 3px;
  background: #e6ecf7;
  overflow: hidden;
}

.ocr-bar span {
  display: block;
  height: 100%;
  background: #4b6ea8;
  border-radius: 3px;
  transition: width .2s ease;
}

.ocr-status {
  margin-top: 6px;
  font-size: 13px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.fitem-file {
  font-size: 13px;
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fitem-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-top: 8px;
  font-size: 13px;
  color: var(--ink-2);
}

.fitem-meta b { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }

.fitem-tools { display: flex; gap: 4px; flex: none; }

.icon-btn {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-3);
  width: 28px; height: 28px;
  border-radius: 7px;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 14px;
  line-height: 1;
}

.icon-btn:hover { background: #f1f4f7; color: var(--ink); }
.icon-btn:disabled { opacity: .3; cursor: default; }
.icon-btn:disabled:hover { background: transparent; }

/* ── 警示 ───────────────────────────────────────────────── */

.notes { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }

.note {
  font-size: 13px;
  line-height: 1.5;
  padding: 7px 11px;
  border-radius: 8px;
  border: 1px solid transparent;
}

.note-info { background: #f3f6fa; color: var(--ink-2); border-color: #e4eaf2; }
.note-warn { background: var(--warn-weak); color: var(--warn); border-color: #f2e0c2; }
.note-error { background: var(--err-weak); color: var(--err); border-color: #f2cfcd; }

/* OCR 來源提示：比一般警告更醒目，但不至於像錯誤 */
.note-ocr {
  background: #eef3fb;
  color: #2c4674;
  border-color: #c9d6ec;
  border-left: 3px solid #4b6ea8;
  font-weight: 500;
}

.alert {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 13.5px;
  line-height: 1.55;
}

.alert-error { background: var(--err-weak); color: var(--err); border: 1px solid #f2cfcd; }

/* ── 表單 ───────────────────────────────────────────────── */

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

.field { display: flex; flex-direction: column; gap: 6px; }
.field-wide { margin-top: 16px; }

.label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  display: flex;
  align-items: center;
  gap: 6px;
}

.opt {
  font-weight: 400;
  font-size: 11.5px;
  color: var(--ink-3);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0 5px;
}

input[type="text"],
select,
textarea {
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #d7dde6;
  border-radius: 9px;
  padding: 9px 11px;
  width: 100%;
  transition: border-color .15s;
}

textarea { resize: vertical; min-height: 62px; line-height: 1.55; }

input[type="text"]:hover,
select:hover,
textarea:hover { border-color: #c3ccd8; }

.help {
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.55;
  letter-spacing: .005em;
}

/* ── 說明圖示（滑鼠移上去才顯示） ───────────────────────── */

.hint {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  flex: none;
  border-radius: 50%;
  border: 1px solid #b9c4d2;
  color: #6b7a8d;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1;
  cursor: help;
  position: relative;
  user-select: none;
  transition: background .12s, border-color .12s, color .12s;
}

.hint:hover,
.hint:focus {
  background: var(--brand, #14508c);
  border-color: var(--brand, #14508c);
  color: #fff;
  outline: none;
}

.hint::after {
  content: attr(data-tip);
  position: absolute;
  left: -10px;
  bottom: calc(100% + 9px);
  width: max-content;
  max-width: min(320px, 78vw);
  background: #1f2937;
  color: #fff;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.6;
  letter-spacing: .01em;
  padding: 9px 11px;
  border-radius: 8px;
  white-space: normal;
  text-align: left;
  box-shadow: 0 8px 22px rgba(15, 23, 42, .22);
  opacity: 0;
  visibility: hidden;
  transition: opacity .12s;
  pointer-events: none;
  z-index: 40;
}

.hint::before {
  content: '';
  position: absolute;
  left: 3px;
  bottom: calc(100% + 3px);
  border: 6px solid transparent;
  border-top-color: #1f2937;
  opacity: 0;
  visibility: hidden;
  transition: opacity .12s;
  pointer-events: none;
  z-index: 40;
}

.hint:hover::after,
.hint:hover::before,
.hint:focus::after,
.hint:focus::before,
.hint.is-open::after,
.hint.is-open::before {
  opacity: 1;
  visibility: visible;
}

/* 手機沒有 hover，點一下 ? 也會展開（.is-open 由 app.js 加上） */
@media (hover: none) {
  .hint { cursor: pointer; }
}

/* ── 進階設定（預設收起，減少畫面複雜度） ───────────────── */

.advanced {
  margin-top: 20px;
  border-top: 1px solid var(--line, #e5e9f0);
  padding-top: 14px;
}

.advanced > summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2, #475569);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.advanced > summary::-webkit-details-marker { display: none; }

.advanced > summary::before {
  /* 用 CSS 畫三角形，不用 ▸ 字元：中文字型常把它渲染成「、」 */
  content: '';
  width: 0;
  height: 0;
  border-left: 5px solid #8b97a8;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform .15s;
  flex: none;
}

.advanced[open] > summary::before { transform: rotate(90deg); }

.adv-note {
  font-weight: 400;
  font-size: 13px;
  color: var(--ink-3, #8b97a8);
}

.adv-grid { margin-top: 14px; }

/* ── 科目表狀態 ─────────────────────────────────────────── */

.coa-status {
  margin-top: 18px;
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.55;
  background: #f5f7fa;
  color: var(--ink-2);
  border: 1px solid var(--line-soft);
}

.coa-status b { color: var(--ink); }
.coa-status code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
}

/* ── 動作區 ─────────────────────────────────────────────── */

.card-actions { padding: 20px 24px; }

.actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ── 頁腳 ───────────────────────────────────────────────── */

.foot {
  margin-top: 4px;
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.65;
}

.foot p { margin: 0 0 8px; }
.foot .dim { color: var(--ink-3); }

/* ── 彈出視窗 ───────────────────────────────────────────── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(16, 22, 32, .46);
  backdrop-filter: blur(2px);
  display: grid;
  place-items: center;
  padding: 24px;
  animation: fade .16s ease-out;
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }

.modal {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 26px 26px 22px;
  box-shadow: 0 24px 64px -20px rgba(16, 24, 40, .45);
  animation: rise .18s ease-out;
}

.modal-head h2 {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: .01em;
}

.modal-head p {
  margin: 0;
  font-size: 13.5px;
  color: var(--ink-2);
  line-height: 1.6;
}

.ac-box {
  margin: 20px 0 18px;
  padding: 18px 20px;
  border-radius: 12px;
  background: #f7f9fb;
  border: 1px solid var(--line);
}

.ac-label {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--ink-3);
  text-transform: uppercase;
}

.ac-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 30px;
  font-weight: 600;
  letter-spacing: .02em;
  line-height: 1.25;
  margin-top: 2px;
  color: var(--ink);
  word-break: break-all;
}

.ac-value.is-missing { font-size: 19px; color: var(--err); font-family: inherit; font-weight: 600; }

.ac-full {
  margin-top: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  color: var(--ink-2);
  word-break: break-all;
}

.ac-full:empty { display: none; }

.ac-note {
  margin-top: 10px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-2);
}

.ac-note:empty { display: none; }
.ac-note.is-warn { color: var(--warn); }
.ac-note.is-ok { color: var(--ok); }

.modal .notes { margin: 0 0 16px; }

.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13.5px;
  color: var(--ink);
  cursor: pointer;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  transition: background .15s, border-color .15s;
}

.check:hover { background: #f9fbfc; }

.check input {
  margin: 3px 0 0;
  width: 16px; height: 16px;
  accent-color: var(--accent);
  flex: none;
  cursor: pointer;
}

.check:has(input:checked) { background: var(--ok-weak); border-color: #c6e3d2; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

/* ── 進度 ───────────────────────────────────────────────── */

.busy {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255, 255, 255, .45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: -2px;
  margin-right: 8px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── 響應式 ─────────────────────────────────────────────── */

@media (max-width: 640px) {
  .wrap { padding: 20px 14px 48px; }
  .card { padding: 18px; }
  .grid { grid-template-columns: 1fr; }
  .topbar-note { display: none; }
  .ac-value { font-size: 24px; }
  .modal { padding: 22px 18px 18px; }
  .fitem-meta { gap: 4px 12px; }
}

/* ---- 附表選擇（checkbox 列） ---- */
.chk-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  align-items: center;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
}

.chk {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
}

.chk input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
  margin: 0;
}

.chk input:disabled { cursor: default; }
.chk:has(input:disabled) { color: var(--ink-3); cursor: default; }

.chk.is-on { color: var(--accent); font-weight: 600; }

/* ── 經費代碼（Fund / FC / A/C / Unit / Dept. / Prog.）────── */

.seg-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 4px;
}

.seg {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.seg > span {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--ink-3);
  text-transform: uppercase;
}

.seg input {
  width: 100%;
  min-width: 62px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.seg-ac { flex: 1 1 96px; }
.seg-ac input { border-color: var(--accent); background: var(--accent-weak); font-weight: 600; }

.seg input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-weak);
}

.seg input::placeholder { color: var(--ink-3); }

/* ── 生成按鈕旁的一句說明 ───────────────────────────────── */

.action-note {
  font-size: 13px;
  color: var(--ink-3, #8b97a8);
  line-height: 1.5;
  align-self: center;
}

/* 進階設定裡的全寬欄位要跨滿兩欄，否則經費代碼會被擠成兩行兩行 */
.adv-grid > .field-wide { grid-column: 1 / -1; }

.adv-grid .seg-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.adv-grid .seg { flex: 1 1 120px; }

/* AI 救援：只在解析失敗的卡片出現（2026-10-29） */
.fitem-ai {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-ai {
  font-size: 13px;
  padding: 6px 14px;
  border-color: #c9d6ec;
  background: #eef3fb;
  color: #2c4674;
  font-weight: 600;
}

.btn-ai:hover { background: #e3ecfa; border-color: #b7c9e6; }

.ai-hint { font-size: 13px; color: var(--ink-3); }


/* ── Hero（2026-10-29 review：頁面缺少「這是什麼」）────────── */
.hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.hero h1 {
  margin: 0 0 6px;
  font-size: 22px;
  line-height: 1.35;
  font-weight: 700;
  letter-spacing: -.005em;
}

.hero-sub {
  margin: 0;
  max-width: 62ch;
  font-size: 14px;
  line-height: 1.7;
  color: var(--ink-2);
}

.hero-badge {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ok);
  background: #edf6f1;
  border: 1px solid #cfe6da;
  border-radius: 999px;
  padding: 5px 13px;
  white-space: nowrap;
  margin-top: 2px;
}

.hero-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
}

/* 破壞性操作：視覺上要看得出來（清除全部） */
.btn-danger { color: var(--err); border-color: transparent; }
.btn-danger:hover { background: #fbf0ef; border-color: #f2cfcd; }

.brand-text small { display: block; margin-top: 2px; font-weight: 400; }

@media (max-width: 640px) {
  .hero h1 { font-size: 19px; }
  .hero-badge { margin-top: 0; }
}


/* 清除全部：和主 CTA 拉開距離，避免誤按（2026-10-29 review） */
.card-actions .actions #reset { margin-left: auto; }

@media (max-width: 640px) {
  .card-actions .actions #reset { margin-left: 0; }
  .adv-note { display: block; margin-top: 4px; }
  .advanced > summary { align-items: flex-start; }
}

/* =========================================================================
 * 2026-10-29 視覺改版（參照 Figma 版：黑白主色、大標題、步驟條、水平拖放區）
 * 只覆寫視覺，不動任何元件結構或 JS 行為
 * ========================================================================= */

:root {
  --bg: #f3f3f4;
  --card: #ffffff;
  --line: #e6e6e9;
  --line-soft: #f0f0f2;
  --ink: #111418;
  --ink-2: #4a5058;
  --ink-3: #6b7280;
  --accent: #111418;
  --accent-hover: #000000;
  --accent-weak: #f1f1f3;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04);
}

body { font-size: 15px; }

/* 頂欄 ---------------------------------------------------------------- */
.topbar { background: rgba(255,255,255,.92); }
.topbar-inner { max-width: 1180px; padding: 13px 28px; }
.brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: #111418;
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0;
}

.brand-text strong { font-size: 17.5px; font-weight: 700; letter-spacing: .01em; }
.brand-text small { font-size: 13px; color: var(--ink-3); margin-top: 1px; }

.topbar-note {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--ink-2);
}

/* 版面 ---------------------------------------------------------------- */
.wrap { max-width: 1180px; padding: 40px 28px 72px; gap: 22px; }

.hero { margin-bottom: 4px; align-items: center; }
.hero h1 { font-size: 34px; line-height: 1.25; letter-spacing: -.015em; margin-bottom: 10px; }
.hero-sub { font-size: 15px; color: var(--ink-2); }

.hero-badge {
  background: #111418;
  border-color: #111418;
  color: #fff;
  font-size: 13.5px;
  padding: 9px 16px;
  gap: 8px;
}
.hero-badge::before { display: none; }   /* 改用 SVG 盾牌圖示 */
.hero-badge svg { flex: none; }

/* 步驟條 -------------------------------------------------------------- */
.stepper {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 22px;
  margin-bottom: 2px;
}

.stp {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 13.5px;
  color: var(--ink-3);
  white-space: nowrap;
}

.stp-n {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .02em;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  color: var(--ink-3);
  background: #fff;
}

.stp.is-on { color: var(--ink); font-weight: 600; }
.stp.is-on .stp-n { background: #111418; border-color: #111418; color: #fff; }
.stp.is-done .stp-n { background: #111418; border-color: #111418; color: #fff; }
.stp-line { flex: 1; height: 1px; background: var(--line); margin: 0 18px; min-width: 20px; }

/* 卡片 ---------------------------------------------------------------- */
.card {
  border-radius: 16px;
  border-color: var(--line);
  padding: 26px 28px;
  box-shadow: none;
}

.card-head {
  position: relative;
  margin-bottom: 20px;
  padding-right: 150px;
  min-height: 30px;
}

.card-head h2 { font-size: 20px; font-weight: 700; gap: 12px; margin-bottom: 7px; }
.card-head .sub { font-size: 13.5px; }

.step {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: #111418;
  color: #fff;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .01em;
}

.head-meta {
  position: absolute;
  right: 0;
  top: 4px;
  font-size: 13px;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: 10px;
}

/* 拖放區（水平）------------------------------------------------------- */
.drop {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 18px 20px;
  border-radius: 12px;
  border: 1.5px dashed #dcdce0;
  background: #fbfbfc;
}

.drop-main { display: flex; align-items: center; gap: 15px; flex: 1; min-width: 0; }

.drop-icon {
  width: 50px; height: 50px;
  border-radius: 11px;
  background: #fff;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  color: #111418;
  margin: 0;
  flex: none;
}

.drop-copy { min-width: 0; }
.drop-title { font-size: 14.5px; font-weight: 600; color: var(--ink); }
.drop-sub { font-size: 13px; color: var(--ink-3); margin-top: 3px; }

.drop-note {
  margin: 14px 0 0;
  font-size: 13px;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: 7px;
}

.drop-note::before {
  content: '';
  width: 13px; height: 13px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 7h16M4 12h16M4 17h10' stroke='black' stroke-width='2' stroke-linecap='round' fill='none'/%3E%3C/svg%3E") center/contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 7h16M4 12h16M4 17h10' stroke='black' stroke-width='2' stroke-linecap='round' fill='none'/%3E%3C/svg%3E") center/contain no-repeat;
  flex: none;
}

/* 按鈕 ---------------------------------------------------------------- */
.btn { border-radius: 10px; font-size: 14px; font-weight: 600; padding: 10px 18px; }

.btn-dark {
  background: #111418;
  border-color: #111418;
  color: #fff;
}
.btn-dark:hover { background: #000; border-color: #000; }
.btn-dark:disabled { background: #c9ccd2; border-color: #c9ccd2; color: #fff; opacity: 1; }

#pick { flex: none; }

/* 表單 ---------------------------------------------------------------- */
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.field { gap: 7px; }
.label { font-size: 13px; font-weight: 600; color: var(--ink); gap: 7px; }

.req, .opt {
  font-style: normal;
  font-size: 11.5px;
  font-weight: 500;
  padding: 1px 6px;
  border-radius: 5px;
  letter-spacing: .01em;
}
.req { color: #a4262c; background: #fbeceb; }
.req.soft { color: #6b7280; background: #f2f2f4; }
.opt { color: #6b7280; background: #f2f2f4; }

.field-help { font-size: 12.5px; color: var(--ink-3); line-height: 1.55; }

input[type="text"], select, textarea {
  border-radius: 9px;
  border-color: #dfe1e5;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--ink);
}

input[type="text"]:focus, select:focus, textarea:focus {
  border-color: #111418;
  box-shadow: 0 0 0 3px rgba(17,20,24,.08);
}

/* 經費代碼摘要 -------------------------------------------------------- */
.fund-summary {
  margin-top: 20px;
  border-radius: 12px;
  background: #f7f7f8;
  border: 1px solid var(--line-soft);
  padding: 14px 18px 16px;
}

.fund-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.fund-title { font-size: 13px; font-weight: 600; color: var(--ink); }
.fund-note { font-size: 12.5px; color: var(--ink-3); }

.fund-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.fund-cell { display: flex; flex-direction: column; gap: 5px; }
.fund-cell span { font-size: 11.5px; color: var(--ink-3); letter-spacing: .02em; }
.fund-cell b { font-size: 14px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }

/* 進階設定 ------------------------------------------------------------ */
.advanced { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line-soft); }
.advanced > summary { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.adv-note { color: var(--ink-3); font-weight: 400; }
.adv-grid { margin-top: 16px; }

.seg-row { display: flex; gap: 10px; flex-wrap: wrap; }
.seg { flex: 1 1 100px; display: flex; flex-direction: column; gap: 5px; }
.seg span { font-size: 11.5px; color: var(--ink-3); }
.seg input { width: 100%; }
.seg-ac input { border-color: #111418; background: #f7f7f8; font-weight: 600; }

.sheet-row { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 4px 0 2px; }

/* 行動區 -------------------------------------------------------------- */
.card-actions .card-head { padding-right: 190px; }
.card-actions .head-meta { top: 0; }

.actions { justify-content: space-between; }
.action-note { color: var(--ink-3); font-size: 13px; }

/* Modal --------------------------------------------------------------- */
.modal { border-radius: 18px; }
.modal-head h2 { font-size: 20px; }
.modal-actions .btn { min-width: 120px; }

/* 檔案卡 -------------------------------------------------------------- */
.fitem { border-radius: 12px; border-color: var(--line); }
.fitem:hover { border-color: #d5d7db; }

/* 頁尾 ---------------------------------------------------------------- */
.foot { border-top: 1px solid var(--line); padding-top: 20px; margin-top: 6px; }
.foot p { font-size: 13px; color: var(--ink-3); margin-bottom: 6px; }
.foot strong { color: var(--ink-2); }

/* 響應式 -------------------------------------------------------------- */
@media (max-width: 900px) {
  .wrap { padding: 28px 18px 56px; }
  .topbar-inner { padding: 12px 18px; }
  .hero h1 { font-size: 27px; }
}

@media (max-width: 640px) {
  .wrap { padding: 22px 14px 48px; }
  .hero h1 { font-size: 23px; }
  .stepper { padding: 11px 14px; }
  .stp { font-size: 12px; }
  .stp-line { margin: 0 8px; }
  .stp-n { width: 20px; height: 20px; font-size: 10.5px; }
  .card { padding: 20px 18px; }
  .card-head { padding-right: 0; }
  .head-meta { position: static; margin-top: 10px; }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .fund-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .drop { flex-direction: column; align-items: stretch; }
  .drop-main { align-items: flex-start; }
  #pick { width: 100%; justify-content: center; }
  .card-actions .card-head { padding-right: 0; }
}

/* 卡片 3：右上按鈕＋下方小字 */
.head-action { flex-direction: column; align-items: flex-end; gap: 7px; }
.head-hint { font-size: 12.5px; color: var(--ink-3); }
.card-actions .actions { justify-content: flex-end; margin-top: 4px; }
@media (max-width: 640px) {
  .head-action { align-items: stretch; }
  .card-actions .actions { justify-content: flex-start; }
}

/* 修正：舊 .drop 的 text-align:center 會讓新版的左對齊文字看起來偏中間 */
.drop { text-align: left; }
.drop-copy { text-align: left; }

/* 經費代碼摘要與下一個欄位列之間留白 */
.fund-summary { margin-bottom: 20px; }

/* ── Modal（2026-10-29 對齊 Figma：圖示徽章、X、勾選大格、分隔線）───── */
.modal-backdrop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.modal {
  position: relative;
  max-width: 660px;
  border-radius: 20px;
  padding: 30px 34px 24px;
  box-shadow: 0 24px 60px -28px rgba(16, 24, 40, .35);
}

.modal-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: none;
  background: transparent;
  color: #6b7280;
  border-radius: 8px;
  cursor: pointer;
}
.modal-close:hover { background: #f2f2f4; color: #111418; }

.modal-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: #242629;
  color: #fff;
  display: grid;
  place-items: center;
  margin-bottom: 20px;
}

.modal-head { margin-bottom: 20px; }
.modal-head h2 { font-size: 26px; line-height: 1.3; margin: 0 0 12px; letter-spacing: -.01em; }
.modal-head p { font-size: 14.5px; line-height: 1.75; color: var(--ink-2); margin: 0; }

.modal .ac-box { margin-bottom: 16px; }

.modal .check {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 16px 18px;
  border: 1px solid #e3e4e7;
  border-radius: 10px;
  background: #fff;
  font-size: 14.5px;
  color: var(--ink);
  cursor: pointer;
  margin-top: 4px;
}
.modal .check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #111418;
  flex: none;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.btn-outline {
  background: #fff;
  border-color: #dcdde1;
  color: var(--ink);
}
.btn-outline:hover { background: #f7f7f8; border-color: #c9cbd0; }

.modal-actions .btn-dark { display: inline-flex; align-items: center; gap: 8px; }
.modal-actions .btn-dark:disabled { background: #d7d8dc; border-color: #d7d8dc; color: #fff; }

.modal-hint {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  font-size: 13px;
  color: #6b7280;
}

@media (max-width: 640px) {
  .modal { padding: 24px 20px 18px; border-radius: 18px; }
  .modal-head h2 { font-size: 21px; }
  .modal-icon { width: 46px; height: 46px; margin-bottom: 16px; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn { width: 100%; justify-content: center; }
}

/* Modal：強制片語不斷行；遮罩上的提示改成淺色 */
.modal-head strong { white-space: nowrap; }
.modal-hint { color: rgba(255, 255, 255, .82); }
