/* 外貿驗證台 TradeProof — 設計系統
   原則：資料密集但不擁擠；狀態一眼可辨；事實、推測、未知用不同視覺語言。 */

:root {
  --bg: #f4f6f5;
  --panel: #ffffff;
  --panel-2: #f9fbfa;
  --ink: #12232a;
  --ink-2: #33464e;
  --muted: #6a7b82;
  --line: #e3e9e8;
  --line-2: #d3dcdb;
  --brand: #0f4c5c;
  --brand-ink: #e8f3f2;
  --brand-2: #157a7a;
  --accent: #10a39a;
  --accent-soft: #e2f5f3;
  --ok: #17803d;   --ok-soft: #e6f4ea;
  --warn: #a35a00; --warn-soft: #fdf1df;
  --bad: #b42318;  --bad-soft: #fdecea;
  --info: #1f5fbf; --info-soft: #e8f0fc;
  --violet: #6941c6; --violet-soft: #f1ecfd;
  --mark: #fff1b8;
  --shadow: 0 1px 2px rgba(16, 38, 45, .06), 0 1px 1px rgba(16, 38, 45, .03);
  --shadow-lg: 0 18px 50px rgba(10, 30, 36, .22);
  --radius: 10px;
  --radius-sm: 6px;
  --side: 236px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1517; --panel: #142024; --panel-2: #172529; --ink: #e6efee; --ink-2: #c4d2d2; --muted: #8aa0a3;
    --line: #23353a; --line-2: #2d434a; --brand: #0b3a46; --brand-ink: #d8eeec; --brand-2: #1d9a98; --accent: #2cc4b8; --accent-soft: #123a38;
    --ok: #4cc27a; --ok-soft: #12321f; --warn: #f0a63a; --warn-soft: #3a2a12; --bad: #f2776b; --bad-soft: #3b1714;
    --info: #79a8f2; --info-soft: #15284a; --violet: #b29cf5; --violet-soft: #2a2145; --mark: #5a4b12;
    --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1517; --panel: #142024; --panel-2: #172529; --ink: #e6efee; --ink-2: #c4d2d2; --muted: #8aa0a3;
  --line: #23353a; --line-2: #2d434a; --brand: #0b3a46; --brand-ink: #d8eeec; --brand-2: #1d9a98; --accent: #2cc4b8; --accent-soft: #123a38;
  --ok: #4cc27a; --ok-soft: #12321f; --warn: #f0a63a; --warn-soft: #3a2a12; --bad: #f2776b; --bad-soft: #3b1714;
  --info: #79a8f2; --info-soft: #15284a; --violet: #b29cf5; --violet-soft: #2a2145; --mark: #5a4b12;
  --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: .01em; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0 0 .6em; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.num, td.num, th.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.tabnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.stack > * + * { margin-top: 12px; }
.stack-sm > * + * { margin-top: 6px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.top { align-items: flex-start; }
.grow { flex: 1 1 auto; min-width: 0; }
.hidden { display: none !important; }
.ic { display: inline-block; vertical-align: -3px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
pre { white-space: pre-wrap; word-break: break-word; margin: 0; font: 13px/1.6 var(--font); }

/* ---------- 版面 ---------- */
.app { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--brand); color: var(--brand-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { padding: 18px 18px 14px; display: flex; gap: 10px; align-items: center; }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, #2cc4b8, #0b6b72); display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 14px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.18); }
.brand b { display: block; font-size: 15px; letter-spacing: .04em; }
.brand small { display: block; font-size: 10.5px; opacity: .65; letter-spacing: .14em; }
.nav { padding: 6px 10px; }
.nav .group { font-size: 10.5px; letter-spacing: .14em; opacity: .5; padding: 14px 10px 6px; }
.nav a { display: flex; gap: 10px; align-items: center; color: inherit; padding: 8px 10px; border-radius: 8px; opacity: .86; text-decoration: none; }
.nav a:hover { background: rgba(255,255,255,.07); opacity: 1; }
.nav a.on { background: rgba(255,255,255,.13); opacity: 1; box-shadow: inset 3px 0 0 #2cc4b8; }
.nav a .sub { display: block; font-size: 11px; opacity: .6; line-height: 1.3; }
.nav a .t { line-height: 1.25; }
.nav .cnt { margin-left: auto; font-size: 11px; background: rgba(255,255,255,.14); border-radius: 10px; padding: 0 7px; }
.side-foot { margin-top: auto; padding: 14px 16px 16px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; }
.side-foot .who { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.side-foot .role { opacity: .65; font-size: 11px; }
.meter-mini { height: 4px; border-radius: 4px; background: rgba(255,255,255,.12); overflow: hidden; margin-top: 6px; }
.meter-mini > i { display: block; height: 100%; background: #2cc4b8; }
.meter-mini.warn > i { background: #f0a63a; }
.meter-mini.bad > i { background: #f2776b; }

.main { min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); padding: 10px 26px; display: flex; gap: 14px; align-items: center; }
.crumbs { font-size: 12.5px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.crumbs a { color: var(--muted); }
.crumbs .sep { opacity: .5; }
.search-btn { margin-left: auto; display: flex; gap: 8px; align-items: center; border: 1px solid var(--line-2); background: var(--panel); color: var(--muted); border-radius: 8px; padding: 6px 10px; min-width: 240px; cursor: pointer; font: inherit; }
.kbd { font: 11px var(--mono); border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; color: var(--muted); background: var(--panel-2); }
.content { padding: 22px 26px 60px; max-width: 1480px; width: 100%; }
.page-head { display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .eyebrow { font-size: 12px; color: var(--muted); letter-spacing: .06em; margin-bottom: 4px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.page-head .lead { color: var(--ink-2); margin-top: 6px; max-width: 860px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- 卡片與格線 ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card-h { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.card-h h2, .card-h h3 { display: flex; gap: 8px; align-items: center; }
.card-h .hint { color: var(--muted); font-size: 12px; font-weight: 400; }
.card-b { padding: 14px 16px; }
.card-b.tight { padding: 0; overflow-x: auto; }
.card-f { padding: 10px 16px; border-top: 1px solid var(--line); background: var(--panel-2); border-radius: 0 0 var(--radius) var(--radius); }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1fr) 340px; }
.g-main-l { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.grid > .card + .card { margin-top: 0; }
@media (max-width: 1180px) { .g-main, .g-main-l, .g4 { grid-template-columns: minmax(0, 1fr); } .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; }
  .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content { padding: 16px; }
  .top { padding: 10px 16px; }
  .search-btn { min-width: 0; }
}

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.kpi .k { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.kpi .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; line-height: 1.2; }
.kpi .s { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.kpi.na .v { color: var(--muted); font-size: 15px; font-weight: 600; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--panel-2); white-space: nowrap; position: sticky; top: 0; }
table.t td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr:hover td { background: color-mix(in srgb, var(--accent-soft) 40%, transparent); }
table.t tr.dim td { opacity: .55; }
table.t .sub { display: block; color: var(--muted); font-size: 12px; }
table.kv { width: 100%; border-collapse: collapse; }
table.kv th { width: 34%; text-align: left; font-weight: 500; color: var(--muted); padding: 6px 0; vertical-align: top; font-size: 13px; }
table.kv td { padding: 6px 0; vertical-align: top; }
table.kv tr + tr th, table.kv tr + tr td { border-top: 1px dashed var(--line); }

/* ---------- 徽章 ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; padding: 1px 8px; border-radius: 999px; line-height: 1.6; white-space: nowrap; border: 1px solid transparent; }
.t-ok { background: var(--ok-soft); color: var(--ok); }
.t-warn { background: var(--warn-soft); color: var(--warn); }
.t-bad { background: var(--bad-soft); color: var(--bad); }
.t-info { background: var(--info-soft); color: var(--info); }
.t-muted { background: color-mix(in srgb, var(--muted) 14%, transparent); color: var(--ink-2); }
.t-example { background: var(--violet-soft); color: var(--violet); border-color: color-mix(in srgb, var(--violet) 30%, transparent); }
.t-ai { background: linear-gradient(90deg, var(--accent-soft), var(--info-soft)); color: var(--brand-2); }
.code { font: 600 11.5px var(--mono); color: var(--brand-2); letter-spacing: .02em; }
a.ref { text-decoration: none; }
a.ref:hover .code, a.ref:hover { text-decoration: underline; }

/* 觀察類型：事實／推測／未知／問題 */
.kind { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 650; padding: 1px 8px; border-radius: 4px; }
.kind-fact { background: var(--ok-soft); color: var(--ok); }
.kind-hypothesis { background: var(--warn-soft); color: var(--warn); border: 1px dashed color-mix(in srgb, var(--warn) 45%, transparent); }
.kind-unknown { background: color-mix(in srgb, var(--muted) 12%, transparent); color: var(--muted); border: 1px dotted var(--muted); }
.kind-question { background: var(--info-soft); color: var(--info); }

/* ---------- 按鈕 ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-2); background: var(--panel); color: var(--ink); padding: 6px 12px; border-radius: 8px; font: 600 13px var(--font); cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .12s, border-color .12s, transform .05s; }
.btn:hover { background: var(--panel-2); border-color: var(--muted); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.btn.primary:hover { background: color-mix(in srgb, var(--brand-2) 86%, #000); }
.btn.ai { background: linear-gradient(135deg, #0f6f78, #10a39a); border-color: transparent; color: #fff; }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line-2)); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--brand-2); }
.btn.ghost:hover { background: var(--accent-soft); }
.btn.sm { padding: 3px 9px; font-size: 12px; border-radius: 6px; }
.btn[disabled], .btn.disabled { opacity: .45; pointer-events: none; }
form.inline { display: inline; }

/* ---------- 表單 ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.form-grid.c1 { grid-template-columns: 1fr; }
.form-grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .wide { grid-column: 1 / -1; }
@media (max-width: 860px) { .form-grid, .form-grid.c3 { grid-template-columns: 1fr; } }
.fld label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
.fld .help { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.fld .err { font-size: 12px; color: var(--bad); margin-top: 3px; }
.fld.has-err input, .fld.has-err textarea, .fld.has-err select { border-color: var(--bad); }
input[type=text], input[type=email], input[type=url], input[type=number], input[type=date], input[type=datetime-local], input[type=password], input[type=search], select, textarea {
  width: 100%; border: 1px solid var(--line-2); background: var(--panel); color: var(--ink); border-radius: 7px; padding: 7px 10px; font: 14px var(--font); outline: none; transition: border-color .12s, box-shadow .12s;
}
textarea { min-height: 76px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--brand-2); vertical-align: -3px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500 !important; }
select[multiple] { min-height: 110px; }
.form-actions { display: flex; gap: 8px; margin-top: 16px; align-items: center; flex-wrap: wrap; }
.errorlist { color: var(--bad); margin: 0 0 8px; padding-left: 18px; font-size: 12.5px; }

/* ---------- 提示 ---------- */
.msgs { position: fixed; right: 18px; bottom: 18px; z-index: 60; display: flex; flex-direction: column; gap: 8px; max-width: 420px; }
.msg { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--brand-2); border-radius: 8px; box-shadow: var(--shadow-lg); padding: 10px 14px; font-size: 13px; display: flex; gap: 10px; align-items: flex-start; animation: slidein .2s ease-out; }
.msg.error { border-left-color: var(--bad); }
.msg.warning { border-left-color: var(--warn); }
.msg.success { border-left-color: var(--ok); }
.msg button { margin-left: auto; border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; }
@keyframes slidein { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.callout { border-radius: 8px; padding: 10px 14px; font-size: 13px; border: 1px solid; display: flex; gap: 10px; align-items: flex-start; }
.callout .ic { margin-top: 2px; }
.callout.info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 25%, transparent); color: var(--ink); }
.callout.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.callout.bad { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.callout.ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.callout.brand { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.callout b { font-weight: 650; }
.callout ul { margin: 4px 0 0; padding-left: 18px; }
.flags { margin: 6px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
.flags li { font-size: 12px; color: var(--warn); display: flex; gap: 6px; }
.flags li::before { content: "⚠"; }
.flags.bad li { color: var(--bad); }
.empty { text-align: center; padding: 28px 16px; color: var(--muted); }
.empty .big { font-size: 15px; color: var(--ink-2); font-weight: 600; margin-bottom: 4px; }

/* ---------- 頁籤 ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a, .tabs button { padding: 9px 14px; border: 0; background: none; color: var(--muted); font: 600 13px var(--font); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none; }
.tabs a.on, .tabs button.on { color: var(--brand-2); border-bottom-color: var(--brand-2); }
.tabs .cnt { font-size: 11px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 0 6px; margin-left: 4px; color: var(--muted); }

/* ---------- 證據卡 ---------- */
.evi { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--panel); }
.evi + .evi { margin-top: 8px; }
.evi blockquote { margin: 6px 0; padding: 4px 0 4px 12px; border-left: 3px solid var(--accent); color: var(--ink); font-size: 13.5px; }
.evi .meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 11.5px; color: var(--muted); }
.evi.blocked blockquote { border-left-color: var(--bad); text-decoration: line-through; opacity: .7; }
.evi.oppose { border-color: color-mix(in srgb, var(--bad) 30%, var(--line)); }
.evi.oppose blockquote { border-left-color: var(--bad); }
.source-text { font-size: 13.5px; line-height: 1.75; white-space: pre-wrap; word-break: break-word; max-height: 640px; overflow-y: auto; padding: 14px 16px; background: var(--panel-2); border-radius: 8px; border: 1px solid var(--line); }
mark { background: var(--mark); color: inherit; padding: 1px 0; border-radius: 2px; box-shadow: 0 0 0 1px color-mix(in srgb, var(--warn) 25%, transparent); }

/* ---------- 關卡 ---------- */
.gates { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 1100px) { .gates { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.gate { border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: var(--panel); position: relative; }
.gate .gh { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.gate .gc { font: 800 13px var(--mono); }
.gate.pass { border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); background: linear-gradient(180deg, var(--ok-soft), var(--panel) 60%); }
.gate.fail { border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.gate.pending { border-style: dashed; }
.gate ul { list-style: none; margin: 6px 0 0; padding: 0; font-size: 12px; }
.gate li { display: flex; gap: 6px; padding: 3px 0; align-items: flex-start; }
.gate li .d { color: var(--muted); display: block; font-size: 11.5px; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; margin-top: 6px; background: var(--muted); }
.dot.ok { background: var(--ok); } .dot.bad { background: var(--bad); } .dot.warn { background: var(--warn); }
.gate-strip { display: inline-flex; gap: 3px; align-items: center; }
.gate-strip i { width: 22px; height: 6px; border-radius: 3px; background: var(--line-2); }
.gate-strip i.on { background: var(--accent); }

/* ---------- 計量 ---------- */
.meter { height: 8px; background: var(--line); border-radius: 6px; overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--accent); border-radius: 6px; }
.meter.warn > i { background: var(--warn); }
.meter.bad > i { background: var(--bad); }
.score-row { display: grid; grid-template-columns: 120px 1fr 64px; gap: 10px; align-items: center; padding: 6px 0; }
.score-row + .score-row { border-top: 1px dashed var(--line); }
.pips { display: inline-flex; gap: 3px; }
.pips i { width: 14px; height: 14px; border-radius: 3px; background: var(--line); }
.pips i.on { background: var(--brand-2); }
.pips.unrated i { background: repeating-linear-gradient(45deg, var(--line), var(--line) 3px, transparent 3px, transparent 6px); }
.donut { --p: 0; width: 76px; height: 76px; border-radius: 50%; background: conic-gradient(var(--brand-2) calc(var(--p) * 1%), var(--line) 0); display: grid; place-items: center; flex: none; }
.donut > span { width: 58px; height: 58px; border-radius: 50%; background: var(--panel); display: grid; place-items: center; font: 700 15px var(--font); font-variant-numeric: tabular-nums; }

/* ---------- 漏斗 ---------- */
.funnel { display: flex; flex-direction: column; gap: 6px; }
.funnel .fr { display: grid; grid-template-columns: 90px 1fr 48px; gap: 10px; align-items: center; font-size: 12.5px; }
.funnel .bar { height: 22px; background: var(--line); border-radius: 5px; overflow: hidden; }
.funnel .bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand-2), var(--accent)); border-radius: 5px; }

/* ---------- 時間線 ---------- */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 4px; bottom: 4px; width: 2px; background: var(--line); }
.timeline li { position: relative; padding: 0 0 14px 26px; }
.timeline li::before { content: ""; position: absolute; left: 2px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--panel); border: 2px solid var(--brand-2); }
.timeline li.in::before { border-color: var(--info); background: var(--info-soft); }
.timeline li.out::before { border-color: var(--ok); background: var(--ok-soft); }
.timeline li.sys::before { border-color: var(--muted); }
.timeline .when { font-size: 11.5px; color: var(--muted); }
.timeline .body { margin-top: 4px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13px; white-space: pre-wrap; }

/* ---------- 差異 ---------- */
.diff td.old { color: var(--bad); text-decoration: line-through; }
.diff td.new { color: var(--ok); font-weight: 600; }

/* ---------- 三欄 ---------- */
.cols3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 1000px) { .cols3 { grid-template-columns: 1fr; } }
.col { border-radius: 10px; padding: 12px; border: 1px solid var(--line); background: var(--panel); }
.col h3 { font-size: 13px; margin-bottom: 8px; display: flex; gap: 6px; align-items: center; }
.col.fact { border-top: 3px solid var(--ok); }
.col.infer { border-top: 3px solid var(--warn); }
.col.ask { border-top: 3px solid var(--info); }
.col.ours { border-top: 3px solid var(--violet); }

/* ---------- 首頁 ---------- */
.home-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; }
@media (max-width: 1180px) { .home-grid { grid-template-columns: minmax(0, 1fr); } }
.q-card .qn { width: 24px; height: 24px; border-radius: 7px; background: var(--brand); color: #fff; display: grid; place-items: center; font: 700 12px var(--font); flex: none; }
.q-list { list-style: none; margin: 0; padding: 0; }
.q-list li { padding: 8px 0; display: flex; gap: 10px; align-items: flex-start; }
.q-list li + li { border-top: 1px solid var(--line); }
.q-list .what { flex: 1; min-width: 0; }
.q-list .what .sub { display: block; color: var(--muted); font-size: 12px; }
.rail .card-b { font-size: 13px; }
.rail-item { display: flex; justify-content: space-between; align-items: center; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.rail-item:last-child { border-bottom: 0; }
.rail-item .n { font: 700 15px var(--font); font-variant-numeric: tabular-nums; }
.rail-item .n.zero { color: var(--muted); font-weight: 500; }
.hero { background: linear-gradient(120deg, var(--brand) 0%, #0f6470 60%, #138a86 100%); color: #eaf6f5; border-radius: 14px; padding: 18px 22px; display: flex; gap: 18px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 18px; box-shadow: var(--shadow); }
.hero h1 { color: #fff; }
.hero p { margin: 4px 0 0; opacity: .82; max-width: 760px; }
.hero .btn { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.25); color: #fff; }
.hero .btn:hover { background: rgba(255,255,255,.2); }

/* ---------- 指令面板 ---------- */
.palette-bg { position: fixed; inset: 0; background: rgba(8, 20, 24, .45); z-index: 80; display: none; align-items: flex-start; justify-content: center; padding-top: 12vh; }
.palette-bg.on { display: flex; }
.palette { width: min(640px, 92vw); background: var(--panel); border-radius: 14px; box-shadow: var(--shadow-lg); overflow: hidden; border: 1px solid var(--line); }
.palette input { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 14px 18px; font-size: 16px; box-shadow: none !important; }
.palette .res { max-height: 52vh; overflow-y: auto; padding: 6px; }
.palette .it { display: flex; gap: 10px; align-items: center; padding: 8px 12px; border-radius: 8px; color: var(--ink); text-decoration: none; }
.palette .it.on, .palette .it:hover { background: var(--accent-soft); text-decoration: none; }
.palette .it .ty { font-size: 11px; color: var(--muted); min-width: 64px; }
.palette .foot { padding: 8px 14px; font-size: 11.5px; color: var(--muted); border-top: 1px solid var(--line); display: flex; gap: 14px; }

/* ---------- 任務進度 ---------- */
.job { display: flex; gap: 10px; align-items: center; }
.job .meter { flex: 1; }
.spin { width: 14px; height: 14px; border: 2px solid var(--line-2); border-top-color: var(--brand-2); border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 其他 ---------- */
details.more > summary { cursor: pointer; color: var(--brand-2); font-size: 12.5px; list-style: none; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: "▸ "; }
details.more[open] > summary::before { content: "▾ "; }
.pill { display: inline-flex; gap: 4px; align-items: center; border: 1px solid var(--line-2); border-radius: 999px; padding: 1px 9px; font-size: 12px; color: var(--ink-2); background: var(--panel); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.filterbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filterbar input, .filterbar select { width: auto; min-width: 160px; padding: 5px 9px; font-size: 13px; }
.filterbar input[type=checkbox] { min-width: 0; width: auto; padding: 0; }
.filterbar .check { white-space: nowrap; }
.formula { font: 14px var(--mono); background: var(--panel-2); border: 1px dashed var(--line-2); border-radius: 8px; padding: 10px 12px; }
.big-price { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
@media (max-width: 1000px) { .split { grid-template-columns: 1fr; } }
.sticky { position: sticky; top: 64px; }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.list-plain li:last-child { border-bottom: 0; }
.doc { background: #fff; color: #111; max-width: 820px; margin: 0 auto; padding: 40px 48px; border: 1px solid var(--line); border-radius: 6px; font-size: 13.5px; }
.doc h1 { font-size: 22px; margin-bottom: 4px; }
.doc table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.doc th, .doc td { border: 1px solid #ccd; padding: 6px 8px; text-align: left; vertical-align: top; }
.doc th { background: #f2f5f7; }
@media print {
  .side, .top, .no-print, .msgs { display: none !important; }
  .app { display: block; }
  .content { padding: 0; }
  .doc { border: 0; padding: 0; }
  body { background: #fff; }
}
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(1200px 600px at 20% -10%, #15606b 0%, transparent 60%), radial-gradient(900px 500px at 110% 110%, #0f766e 0%, transparent 55%), var(--brand); padding: 20px; }
.login { width: min(440px, 100%); background: var(--panel); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 28px; }
.login .brand { padding: 0 0 16px; color: var(--ink); }
.login .brand small { color: var(--muted); }
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.lane { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px; min-height: 120px; }
.lane h3 { font-size: 12.5px; color: var(--muted); display: flex; justify-content: space-between; margin-bottom: 8px; }
.lane .item { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13px; box-shadow: var(--shadow); }
.lane .item + .item { margin-top: 8px; }
.lane .item .sub { display: block; font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* 成本費用行編輯表 */
table.lines { min-width: 980px; }
table.lines td { padding: 6px 6px; }
table.lines select { min-width: 96px; padding: 5px 6px; font-size: 12.5px; }
table.lines input[type=text] { padding: 5px 7px; font-size: 12.5px; }
table.lines td:first-child input { min-width: 110px; }

/* 手機：側欄改成頂部橫向導航，待辦與內容優先 */
@media (max-width: 860px) {
  .side { flex-direction: row; flex-wrap: wrap; align-items: center; position: sticky; top: 0; z-index: 30; }
  .brand { padding: 10px 14px; flex: 1 1 auto; }
  .brand small { display: none; }
  .side-foot { margin: 0; padding: 6px 12px; border-top: 0; flex: none; }
  .side-foot .tiny, .side-foot .meter-mini, .side-foot .role, .side-foot .who > div:first-child { display: none; }
  .nav { order: 3; flex: 1 1 100%; display: flex; overflow-x: auto; gap: 4px; padding: 0 8px 8px; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav .group { display: none; }
  .nav a { flex: none; padding: 6px 10px; white-space: nowrap; font-size: 13px; }
  .nav a .sub { display: none; }
  .nav a.on { box-shadow: inset 0 -2px 0 #2cc4b8; }
  .top { position: static; }
  .search-btn span.grow, .search-btn .kbd { display: none; }
  .page-head h1 { font-size: 19px; }
  .hero { padding: 14px 16px; }
}
.deal-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 14px; counter-reset: deal; }
.deal-steps li { counter-increment: deal; font-size: 13px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); }
.deal-steps li::before { content: counter(deal) "."; color: var(--muted); margin-right: 6px; font-variant-numeric: tabular-nums; }
.deal-steps li a { color: var(--ink-2); text-decoration: none; }
.deal-steps li.done { background: var(--ok-soft); border-color: transparent; }
.deal-steps li.done a { color: var(--ok); }
.deal-steps li.now { border-color: var(--brand-2); box-shadow: 0 0 0 1px var(--brand-2) inset; }
.deal-steps li.now a { color: var(--brand-2); font-weight: 600; }
.bad-text { color: var(--bad); }
