/* 帳房：方案 B（中性 ERP 風）。主題色只改 --accent 一組，版面不動。 */
:root {
  --bg: #ffffff;
  --surface: #f5f7fa;
  --ink: #1f2933;
  --muted: #7b8794;
  --line: #e4e7eb;
  --accent: #3e5c76;
  --accent-soft: #e7edf2;
  --accent-ink: #ffffff;
  --flag: #fff3b0;
  --danger: #b4443c;
  --ok: #3d7a4f;
  --radius: 6px;
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", "Heiti TC", sans-serif;
  font-size: 15px;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); line-height: 1.55; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

header.top { display: flex; align-items: center; gap: 20px; padding: 10px 24px; border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
header.top .brand { font-weight: 700; letter-spacing: .08em; }
header.top .store { color: var(--muted); }
header.top nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
header.top nav a { padding: 6px 12px; border-radius: var(--radius); color: var(--ink); }
header.top nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; text-decoration: none; }
main { padding: 24px; max-width: 1240px; margin: 0 auto; }
h1 { font-size: 20px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 24px 0 8px; }

.btn { border: 1px solid var(--line); background: var(--bg); padding: 7px 16px; border-radius: var(--radius); cursor: pointer; }
.btn:hover { background: var(--surface); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { border-color: transparent; color: var(--accent); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.small { padding: 3px 10px; font-size: 13px; }

input, select, textarea { border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 9px; background: var(--bg); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input.flag, select.flag, textarea.flag { background: var(--flag); }
input[type=checkbox] { width: auto; }
label.field { display: block; font-size: 13px; color: var(--muted); }
label.field > :last-child { margin-top: 3px; color: var(--ink); }

.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; background: var(--bg); }
.bar { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; margin-bottom: 16px; }
.bar > * { min-width: 120px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 13px; color: var(--muted); font-weight: 500; background: var(--surface); }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: var(--surface); }
.tag { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: var(--surface); color: var(--muted); }
.tag.ok { background: #e3f1e8; color: var(--ok); }
.tag.warn { background: var(--flag); color: #6a5a00; }

.notice { padding: 10px 14px; border-radius: var(--radius); background: var(--accent-soft); margin-bottom: 14px; }
.notice.err { background: #f8e4e2; color: var(--danger); }
.notice.warn { background: var(--flag); }

/* 判讀確認頁：左原圖、右欄位 */
.split { display: grid; grid-template-columns: minmax(300px, 5fr) 7fr; gap: 20px; align-items: start; }
.viewer { position: sticky; top: 64px; }
.viewer .stage { border: 1px solid var(--line); border-radius: var(--radius); height: calc(100vh - 220px); min-height: 360px; overflow: auto; background: var(--surface); }
.viewer .stage img { width: 100%; display: block; cursor: zoom-in; }
.viewer .stage img.zoom { width: 220%; cursor: zoom-out; }
.viewer .stage iframe { width: 100%; height: 100%; border: 0; }
.viewer .thumbs { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.viewer .thumbs button { border: 1px solid var(--line); background: var(--bg); border-radius: var(--radius); padding: 3px 10px; cursor: pointer; }
.viewer .thumbs button.on { border-color: var(--accent); color: var(--accent); }
.items td { padding: 4px; }
.items input, .items select { padding: 4px 6px; }
.items .w-name { min-width: 150px; }
.items .w-num { width: 82px; }
.actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; position: sticky; bottom: 0; background: var(--bg); padding: 10px 0; border-top: 1px solid var(--line); }
.dropzone { border: 2px dashed var(--line); border-radius: var(--radius); padding: 36px; text-align: center; color: var(--muted); }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }

.center { max-width: 380px; margin: 14vh auto; text-align: center; }
.center h1 { font-size: 26px; letter-spacing: .12em; }

@media (max-width: 860px) {
  main { padding: 14px; }
  .split { grid-template-columns: 1fr; }
  .viewer { position: static; }
  .viewer .stage { height: 320px; }
}

/* 品項表：類型欄與刪除鈕不要被擠壓 */
.items th { white-space: nowrap; }
.items td:first-child select { min-width: 76px; }
.items td:last-child { white-space: nowrap; }
.items .w-num { min-width: 78px; }

.tag { white-space: nowrap; }
@media (max-width: 860px) {
  header.top { gap: 8px 12px; padding: 8px 14px; }
  header.top nav { order: 10; flex: 1 0 100%; flex-wrap: nowrap; overflow-x: auto; }
  header.top nav a { white-space: nowrap; }
}
input.bad { border-color: #c0392b; background: #fdecea; }

/* 客戶對帳單 */
.st-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.statement { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.st-company { margin: 0; font-size: 18px; text-align: center; } .st-title { margin: 2px 0 8px; font-size: 22px; text-align: center; }
.st-meta { font-size: 13px; margin: 0 0 10px; }
.st-table th, .st-table td { padding: 5px 6px; font-size: 13px; }
.st-table tr.doc-head td { border-top: 1px solid var(--line); font-weight: 600; }
.st-table tr.doc-items > td { padding: 0 6px 6px 18px; border: 0; }
.st-table table.inner th, .st-table table.inner td { padding: 2px 6px; font-size: 12px; background: transparent; border: 0; }
.doc-note { font-size: 12px; color: var(--muted); padding: 2px 6px; }
.st-table tr.prev td, .st-table tr.sum td { background: var(--accent-soft); font-weight: 600; }
@media (max-width: 1100px) { .st-layout { grid-template-columns: 1fr; } }
@media print {
  header.top, .no-print, .st-side { display: none !important; }
  body { background: #fff; } main { max-width: none; padding: 0; }
  .st-layout { display: block; } .statement { border: 0; padding: 0; }
  .st-table thead { display: table-header-group; } .st-table tr { break-inside: avoid; }
  .st-table th, .st-table td { font-size: 11px; padding: 3px 4px; }
}
