:root {
  --bg: #eef2f1;
  --panel: #ffffff;
  --ink: #1c2b2d;
  --muted: #5f6f70;
  --line: #d3dbd9;
  --line-soft: #e6ecea;
  --accent: #24596e;
  --accent-hover: #1b4656;
  --strip: #18323b;
  --strip-ink: #f3efe4;
  --strip-muted: #9fb3b5;
  --kraft: #e9d9b4;
  --warn: #9a3b2f;
  --ok: #2f7a52;
  --m-LCPC: #2f7a52;
  --m-CL: #3a52a3;
  --m-YFY: #b07a16;
  --radius: 6px;
  font-family: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; font-size: 15px; line-height: 1.55; }
button, input, select, textarea { font: inherit; color: inherit; }
.num, td.n, input.n { font-variant-numeric: tabular-nums; text-align: right; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- 按鈕 ---------- */
.btn { border: 1px solid var(--line); background: var(--panel); padding: 6px 14px; border-radius: var(--radius); cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.primary:disabled { background: #9fb0b3; border-color: #9fb0b3; cursor: default; }
.btn.danger { color: var(--warn); }
.btn.danger:hover { border-color: var(--warn); }
.btn.small { padding: 2px 9px; font-size: 13px; }
.btn.link { border: 0; background: none; color: var(--accent); padding: 2px 4px; text-decoration: underline; text-underline-offset: 3px; }
.icon-btn { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 2px 6px; border-radius: 4px; font-size: 16px; line-height: 1; }
.icon-btn:hover { color: var(--warn); background: #f6e9e6; }

/* ---------- 登入 ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--strip); }
.login form { width: min(360px, 100%); background: var(--panel); border-radius: 10px; padding: 32px 28px; display: grid; gap: 14px; }
.login h1 { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: .02em; }
.login p.sub { margin: -8px 0 6px; color: var(--muted); font-size: 14px; }
.field { display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
.field input, .field select, .field textarea { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; background: #fff; color: var(--ink); }
.pw-wrap { position: relative; }
.pw-wrap input { width: 100%; padding-right: 42px; }
.pw-eye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); border: 0; background: none; cursor: pointer; color: var(--muted); padding: 6px; }
.err { color: var(--warn); font-size: 14px; min-height: 1.4em; margin: 0; }

/* ---------- 頂部 ---------- */
.top { display: flex; align-items: center; gap: 20px; padding: 0 20px; height: 56px; background: var(--strip); color: var(--strip-ink); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand b { font-size: 18px; letter-spacing: .03em; }
.brand small { color: var(--strip-muted); font-size: 13px; }
.nav { display: flex; gap: 2px; margin-left: 12px; }
.nav button { background: none; border: 0; color: var(--strip-muted); padding: 16px 14px; cursor: pointer; border-bottom: 3px solid transparent; }
.nav button.on { color: var(--strip-ink); border-bottom-color: var(--kraft); }
.nav button:hover { color: var(--strip-ink); }
.top .spacer { flex: 1; }
.top .who { color: var(--strip-muted); font-size: 14px; }
.top .btn { background: transparent; color: var(--strip-ink); border-color: #3d5961; }

/* ---------- 結清版面 ---------- */
.layout { display: grid; grid-template-columns: 250px 1fr; min-height: calc(100vh - 56px); }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 16px 14px; display: flex; flex-direction: column; gap: 12px; position: sticky; top: 56px; height: calc(100vh - 56px); overflow: hidden; }
.mill-switch { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.mill-switch button { border: 1px solid var(--line); background: #fff; padding: 7px 2px; cursor: pointer; border-radius: 4px; font-weight: 500; box-shadow: inset 0 -3px 0 var(--mc); }
.mill-switch button:hover { border-color: var(--mc); }
.mill-switch button.on { color: #fff; background: var(--mc); border-color: var(--mc); }
.month-list { overflow-y: auto; flex: 1; margin: 0 -14px; padding: 0 14px; }
.month-list h4 { margin: 14px 0 4px; font-size: 13px; color: var(--muted); font-weight: 500; position: sticky; top: 0; background: var(--panel); padding: 2px 0; }
.mrow { display: grid; grid-template-columns: 44px 1fr 16px; align-items: center; width: 100%; border: 0; background: none; padding: 6px 8px; border-radius: 4px; cursor: pointer; text-align: left; gap: 6px; }
.mrow:hover { background: var(--line-soft); }
.mrow.on { background: #dfe9ec; box-shadow: inset 3px 0 0 var(--accent); }
.mrow .m { font-weight: 500; }
.mrow .v { font-variant-numeric: tabular-nums; text-align: right; font-size: 14px; color: var(--muted); }
.mrow.on .v { color: var(--ink); }
.lock { width: 12px; height: 12px; color: var(--muted); }
.side-foot { border-top: 1px solid var(--line-soft); padding-top: 8px; font-size: 13px; }

.main { padding: 20px 24px 60px; min-width: 0; }
.empty { color: var(--muted); padding: 60px 0; text-align: center; }

/* ---------- 結清單 ---------- */
.sheet-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 14px; }
.sheet-head h2 { margin: 0; font-size: 22px; display: flex; align-items: center; gap: 10px; }
.sheet-head h2 .mill-dot { width: 10px; height: 22px; border-radius: 2px; display: inline-block; }
.tag { font-size: 12px; padding: 1px 8px; border-radius: 10px; border: 1px solid var(--line); color: var(--muted); font-weight: 400; }
.tag.lock-tag { border-color: #c9b98f; color: #7a6326; background: #faf4e4; }
.tag.dirty { border-color: var(--warn); color: var(--warn); }
.sheet-head .actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: 6px; }

/* 結清帶：本頁的主角 */
.strip { background: var(--strip); color: var(--strip-ink); border-radius: 8px; display: grid; grid-template-columns: minmax(230px, 300px) 1fr; overflow: hidden; margin-bottom: 18px; }
.strip .hero { padding: 18px 22px; border-right: 1px solid #2c4952; background: repeating-linear-gradient(0deg, transparent 0 13px, rgba(233, 217, 180, .05) 13px 14px); }
.strip .hero .lbl { color: var(--kraft); font-size: 14px; }
.strip .hero .big { font-size: 46px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -.01em; margin: 4px 0 6px; }
.strip .hero .big small { font-size: 16px; font-weight: 400; color: var(--strip-muted); margin-left: 4px; }
.strip .hero .formula { color: var(--strip-muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.strip .hero .rec { margin-top: 8px; font-size: 13px; color: var(--kraft); }
.figs { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.fig { padding: 12px 16px; border-bottom: 1px solid #2c4952; border-right: 1px solid #2c4952; }
.fig .lbl { color: var(--strip-muted); font-size: 13px; }
.fig .val { font-size: 19px; font-variant-numeric: tabular-nums; font-weight: 500; }
.fig .sub { font-size: 12px; color: var(--strip-muted); font-variant-numeric: tabular-nums; }
.fig .sub.rec { color: var(--kraft); }
.fig .sub.diff { color: #f0a58f; }

.block { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; margin-bottom: 18px; }
.block > header { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line-soft); }
.block > header h3 { margin: 0; font-size: 16px; }
.block > header .hint { color: var(--muted); font-size: 13px; }
.block > header .btn { margin-left: auto; }
.block > header .head-btns { margin-left: auto; display: flex; gap: 6px; }
.block > header .head-btns .btn { margin-left: 0; }
tr.fold-row td { padding: 0; border-bottom: 1px solid var(--line-soft); }
.fold-btn { width: 100%; border: 0; background: #f7f9f8; color: var(--accent); text-align: left; padding: 8px 12px; cursor: pointer; font-size: 14px; }
.fold-btn:hover { background: #eaf1f2; }
.fold-btn .caret { display: inline-block; width: 18px; }
.icon-btn.star:hover { color: #9a7a1e; background: #faf4e4; }
.pick-list { display: grid; gap: 6px; }
.pick { display: grid; gap: 2px; text-align: left; border: 1px solid var(--line); background: #fff; border-radius: var(--radius); padding: 9px 12px; cursor: pointer; }
.pick:hover { border-color: var(--accent); background: #f4f8f9; }
.pick b { font-weight: 500; }
.pick span { font-size: 13px; color: var(--muted); }
.block .body { padding: 14px; }

.head-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px 16px; align-items: end; }
.head-grid input, .head-grid textarea { width: 100%; min-width: 0; }
.head-grid .wide { grid-column: 1 / -1; }
.head-grid textarea { min-height: 54px; resize: vertical; }

.tbl-wrap { overflow-x: auto; }
table.grid { border-collapse: collapse; width: 100%; font-size: 14px; }
table.grid th { font-weight: 500; color: var(--muted); text-align: left; padding: 6px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #f7f9f8; position: sticky; top: 0; }
table.grid th.n { text-align: right; }
table.grid td { padding: 3px 4px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; white-space: nowrap; }
table.grid td.n { padding-right: 8px; }
table.grid tr.zero td { color: #93a09f; }
table.grid tr.zero td input { color: #7d8b8a; }
table.grid tfoot td { font-weight: 500; border-top: 1px solid var(--line); border-bottom: 0; padding-top: 7px; }
table.grid input, table.grid select { border: 1px solid transparent; background: transparent; border-radius: 4px; padding: 4px 6px; width: 100%; min-width: 0; }
table.grid input:hover, table.grid select:hover { border-color: var(--line); }
table.grid input:focus, table.grid select:focus { border-color: var(--accent); background: #fff; outline: none; }
table.grid input:disabled, table.grid select:disabled { color: inherit; border-color: transparent; -webkit-appearance: none; appearance: none; }
td.settled { font-weight: 700; color: var(--accent); }
td.calc { color: var(--muted); }
.w-code { width: 112px; } .w-paper { width: 176px; } .w-kind { width: 66px; } .w-mode { width: 122px; }
.w-off { width: 72px; } .w-price { width: 84px; } .w-wt { width: 92px; } .w-note { min-width: 160px; }
.row-tools { white-space: nowrap; }
.chk { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); }

.tiers { display: flex; flex-wrap: wrap; gap: 8px; }
.tiers span { border: 1px solid var(--line); border-radius: 4px; padding: 3px 10px; font-size: 13px; background: #fbfaf6; }
.tiers b { font-variant-numeric: tabular-nums; margin-left: 6px; }

/* ---------- 走勢 ---------- */
.trend { max-width: 1200px; margin: 0 auto; padding: 20px 24px 60px; }
.trend h2 { font-size: 20px; margin: 4px 0 12px; }
.ctrls { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 12px; }
.ctrls .field { min-width: 140px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 6px 12px; cursor: pointer; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent); color: #fff; }
.chart { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 8px 4px; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .tip { position: absolute; pointer-events: none; background: var(--strip); color: var(--strip-ink); font-size: 13px; padding: 6px 10px; border-radius: 6px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--muted); padding: 4px 8px 6px; }
.legend i { display: inline-block; width: 18px; height: 3px; vertical-align: middle; margin-right: 6px; border-radius: 2px; }
.legend i.dash { background: repeating-linear-gradient(90deg, currentColor 0 4px, transparent 4px 7px) !important; height: 2px; }
.section-gap { height: 26px; }

/* ---------- 帳號 ---------- */
.page { max-width: 900px; margin: 0 auto; padding: 20px 24px 60px; }
.page h2 { font-size: 20px; }
.form-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }

/* ---------- 視窗 ---------- */
.modal { position: fixed; inset: 0; background: rgba(16, 30, 34, .55); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal-box { background: var(--panel); border-radius: 10px; width: min(1100px, 100%); max-height: calc(100vh - 40px); overflow: auto; padding: 18px 20px; }
.modal-box.narrow { width: min(440px, 100%); }
.modal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.modal-head h3 { margin: 0; font-size: 18px; }
.modal-head .x { margin-left: auto; }
.raw-tbl { border-collapse: collapse; font-size: 13px; }
.raw-tbl td { border: 1px solid var(--line-soft); padding: 2px 6px; white-space: pre-wrap; max-width: 380px; vertical-align: top; }
.raw-tbl td.n { white-space: nowrap; }
.raw-tbl td.rn { color: var(--muted); background: #f7f9f8; text-align: right; }
.rev-list { list-style: none; margin: 0; padding: 0; }
.rev-list li { display: grid; grid-template-columns: 170px 1fr 110px auto; gap: 10px; padding: 7px 4px; border-bottom: 1px solid var(--line-soft); align-items: center; font-size: 14px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--strip); color: var(--strip-ink); padding: 10px 18px; border-radius: 8px; z-index: 60; }
.toast.bad { background: var(--warn); }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: static; height: auto; max-height: 300px; }
  .strip { grid-template-columns: 1fr; }
  .strip .hero { border-right: 0; border-bottom: 1px solid #2c4952; }
  .nav button { padding: 16px 8px; }
  .brand small { display: none; }
  .main { padding: 14px; }
  .rev-list li { grid-template-columns: 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
#items-tbl { min-width: 1320px; }
#items-tbl select[data-f="kind"] { min-width: 58px; }
#items-tbl select[data-f="mode"] { min-width: 112px; }

.radio-set { border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 12px 10px; margin: 0; }
.radio-set .radios { display: flex; gap: 28px; flex-wrap: wrap; }
.radio-set legend { color: var(--muted); font-size: 14px; padding: 0 4px; }
.radio-set label { display: flex; align-items: baseline; gap: 6px; cursor: pointer; font-size: 16px; }
.radio-set small { color: var(--muted); font-size: 12px; }
tr.nomatch td { background: #fbf1ee; }
.seg { flex-wrap: wrap; }

.wide-page { max-width: 1400px; }
.search { border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 10px; width: 260px; background: #fff; }
table.clickable tbody tr { cursor: pointer; }
table.clickable tbody tr:hover td { background: #f1f6f7; }
table.grid td.small { font-size: 13px; color: var(--muted); }
td.late { color: var(--warn); font-weight: 700; }
.order-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 16px; }
.order-form .span2 { grid-column: 1 / -1; }
.order-form input, .order-form select, .order-form textarea { width: 100%; min-width: 0; }
.order-form .inline { display: flex; gap: 6px; }
.order-form .inline select { flex: 1; }
.cost-box { margin-top: 14px; background: var(--strip); color: var(--strip-ink); border-radius: 8px; padding: 12px 16px; display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px 18px; }
.cost-box span { display: block; color: var(--strip-muted); font-size: 13px; }
.cost-box b { font-size: 18px; font-weight: 500; font-variant-numeric: tabular-nums; }
.cost-box b.big { font-size: 26px; font-weight: 700; color: var(--kraft); }
.cost-box .err { color: #f0a58f; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-list { list-style: none; margin: 0; padding: 0; }
.file-list li { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line-soft); flex-wrap: wrap; }
.file-list li a:first-child { font-weight: 500; color: var(--accent); }
.file-list .hint { color: var(--muted); font-size: 12px; flex: 1; }
.modal-foot { display: flex; gap: 8px; margin-top: 14px; align-items: center; }
.master-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 0 18px; }
.master-list { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow-y: auto; }
.master-list li { display: flex; align-items: center; gap: 6px; padding: 5px 0; border-bottom: 1px solid var(--line-soft); }
.master-list li > span:first-child { flex: 1; }
.master-list .hint { color: var(--muted); font-size: 12px; }
.form-row input, .form-row select { border: 1px solid var(--line); border-radius: var(--radius); padding: 7px 9px; background: #fff; }
#mill-tbl input[type=color] { width: 44px; height: 30px; padding: 2px; }

table.grid tr.group-row td { background: #eef3f2; color: var(--ink); font-weight: 500; padding: 7px 8px; border-top: 1px solid var(--line); cursor: default; }
table.clickable tbody tr.group-row:hover td { background: #eef3f2; }

.fx-box { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: #f8faf9; }
.fx-head { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; margin-bottom: 8px; }
.fx-head label { display: flex; gap: 5px; align-items: center; cursor: pointer; }
.fx-auto { display: grid; gap: 4px; justify-items: start; }
.fx-val { font-size: 15px; font-variant-numeric: tabular-nums; }
.fx-val b { font-size: 20px; color: var(--accent); }
.fx-box .hint { color: var(--muted); font-size: 12px; }
.fx-box .err { margin: 4px 0; }
.fx-manual { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px 14px; }
.fx-manual .fx-note { grid-column: span 2; }
.order-form input[type=radio], .order-form input[type=checkbox] { width: auto; }
.fx-head label { white-space: nowrap; }

.fx-manual .fx-date { grid-column: span 2; }
.fx-manual .fx-date .inline { display: flex; gap: 6px; }
.fx-manual .fx-date input { flex: 1; min-width: 0; }
.fx-manual .fx-note { grid-column: 1 / -1; }

.fx-ref { font-size: 14px; margin: 0 0 8px; font-variant-numeric: tabular-nums; }
.fx-ref b { color: var(--accent); }
a.btn { color: inherit; text-decoration: none; display: inline-flex; align-items: center; }

.perm-chip { display: inline-block; font-size: 12px; padding: 1px 8px; margin: 1px 3px 1px 0; border-radius: 10px; background: #eef3f2; color: var(--muted); border: 1px solid var(--line); }
.perm-chip.full { background: #e3eef1; color: var(--accent); border-color: #b9cfd6; }
.perm-cell { white-space: normal !important; max-width: 380px; }
.perm-box { margin-top: 14px; border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: #f8faf9; }
.perm-quick { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.perm-grid fieldset { border: 1px solid var(--line); border-radius: 6px; margin: 0; padding: 6px 12px 10px; background: #fff; display: grid; gap: 6px; align-content: start; }
.perm-grid legend { font-weight: 500; padding: 0 4px; }
.perm-grid .chk { font-size: 14px; color: var(--ink); align-items: flex-start; }

.sys-warn { background: var(--warn); color: #fff; padding: 10px 20px; font-size: 14px; line-height: 1.5; }
.sys-warn b { text-decoration: underline; }

.arr-cell { white-space: nowrap; }
.arr-input { border: 1px solid var(--line); border-radius: 4px; padding: 2px 6px; font-size: 13px; background: #fff; width: 132px; }
.arr-input:hover, .arr-input:focus { border-color: var(--accent); outline: none; }
.arr-input.late-input { border-color: #e2b7ad; }
.arr-cell .late { margin-left: 6px; font-size: 12px; }

.fee-input { border: 1px solid var(--line); border-radius: 4px; padding: 2px 6px; font-size: 13px; background: #fff; width: 70px; text-align: right; }
.fee-input:hover, .fee-input:focus { border-color: var(--accent); outline: none; }
table.grid input.fee-input, table.grid input.arr-input { border: 1px solid var(--line); background: #fff; padding: 2px 6px; }
table.grid input.fee-input { width: 70px; }
table.grid input.arr-input { width: 136px; }
table.grid input.fee-input:focus, table.grid input.arr-input:focus { border-color: var(--accent); }
table.grid input.arr-input.late-input { border-color: #e2b7ad; }

.sub-h { font-size: 16px; margin: 16px 0 8px; }

.pick-row { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; flex-wrap: wrap; }
.pick-row select { border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 8px; background: #fff; }
.pick-row select[data-k=src] { width: 200px; }
.pick-row select[data-k=type] { flex: 1; min-width: 260px; }
.pick-dot { width: 12px; height: 12px; border-radius: 3px; flex: none; }

.f-err { color: var(--warn); font-size: 12px; white-space: normal; }
.help h4 { margin: 14px 0 6px; }
.help code { background: #f2f5f4; padding: 1px 5px; border-radius: 3px; font-size: 13px; }
#disc-tbl select { min-width: 140px; }

.master-grid > .block { min-width: 0; }
.master-grid .field input, .master-grid .field select { width: 100%; min-width: 0; box-sizing: border-box; }
.master-grid .block .body { overflow: hidden; }

.mrow.pv-row { grid-template-columns: 1fr auto auto; }
.tag.now-tag { border-color: #9cc7b0; color: #2f7a52; background: #eef7f1; }
span.up { color: #b23a3a; font-weight: 500; }
span.down { color: #2f7a52; font-weight: 500; }
.master-grid .block .body[style*="display:grid"] { grid-template-columns: minmax(0, 1fr); }
.master-grid .btn { white-space: normal; text-align: center; justify-content: center; }

.pi-same { color: var(--muted); font-size: 13px; padding-left: 12px; border-left: 2px solid var(--line); }
table.grid tr.pi-first td { border-bottom-color: transparent; }
table.grid tr.pi-cont td { border-top: 0; }

b.erp { font-family: ui-monospace, Consolas, monospace; font-weight: 600; letter-spacing: .02em; }
input.suggested { background: #fbf6e8 !important; }

table.grid tr.year-row td { background: var(--strip); color: var(--strip-ink); font-size: 16px; font-weight: 700; padding: 9px 10px; cursor: default; }
table.grid tr.year-row td span { font-size: 13px; font-weight: 400; color: var(--strip-muted); }
table.clickable tbody tr.year-row:hover td { background: var(--strip); }
table.grid tr.done-month td { box-shadow: inset 4px 0 0 var(--accent); }

.sup-line { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.sup-line.month { display: inline-flex; margin: 0 0 0 14px; vertical-align: middle; }
.sup-chip { font-size: 13px; font-weight: 400; padding: 1px 9px; border-radius: 10px; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.25); }
.sup-chip b { font-weight: 700; margin-left: 2px; }
.sup-chip small { margin-left: 5px; opacity: .75; font-size: 11px; }
tr.group-row .sup-chip { background: #fff; border-color: var(--line); color: var(--ink); }

tr.pv-inactive td { background: #fafbfa; color: var(--muted); }
tr.pv-inactive td input:not([type=checkbox]), tr.pv-inactive td select { color: var(--muted); }

table.grid input.f-input { min-width: 170px; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }

.paste-box { width: 100%; min-height: 320px; border: 1px solid var(--line); border-radius: 6px; padding: 10px; font-family: ui-monospace, Consolas, monospace; font-size: 13px; resize: vertical; }

.fail-list { max-height: 260px; overflow: auto; font-size: 13px; color: var(--warn); padding-left: 20px; }

.tier-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.tier-card { border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; background: #fbfcfb; }
.tier-rule { font-weight: 700; color: var(--accent); font-size: 14px; }
.tier-val { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.3; }
.tier-val small { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 6px; }
.tier-names { font-size: 12px; color: var(--ink); margin-top: 2px; }
.tier-sub { font-size: 11px; color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; }

/* ---------- 訂紙計算器／配紙寬計算器 ---------- */
.cs-row { grid-template-columns: 1fr; gap: 0; padding: 6px 8px; }
.cs-row .cs-l1 { display: flex; justify-content: space-between; gap: 8px; }
.cs-row .cs-l1 b { font-weight: 500; }
.cs-row .cs-l2 { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-row .cs-date { font-variant-numeric: tabular-nums; margin-right: 6px; color: var(--ink); }
.side select.search { padding: 6px 8px; }
.sheet-head h2 .cs-sub { font-size: 15px; font-weight: 400; color: var(--muted); margin-left: 4px; }
.cs-strip { grid-template-columns: minmax(220px, 280px) 1fr; }
.cs-strip .fig .val small { font-size: 12px; color: var(--strip-muted); font-weight: 400; }
.cs-wrap { max-height: calc(100vh - 140px); overflow: auto; }
table.cs-grid { width: auto; min-width: 100%; }
table.cs-grid th.sc, table.cs-grid td.sc { position: sticky; left: 0; background: #f7f9f8; z-index: 2; min-width: 74px; font-weight: 500; }
table.cs-grid thead th.sc { z-index: 3; }
table.cs-grid th small { display: block; font-size: 11px; font-weight: 400; }
table.cs-grid th.g-head { vertical-align: bottom; padding: 4px 3px 6px; min-width: 92px; text-align: center; white-space: normal; }
table.cs-grid th.g-head input { width: 100%; text-align: center; border: 1px solid var(--line); background: #fff; padding: 3px 4px; font-weight: 500; color: var(--ink); }
table.cs-grid th.g-head input.g-code { font-weight: 400; font-size: 12px; margin-top: 2px; color: var(--muted); }
table.cs-grid th.g-head input:disabled { border-color: transparent; background: transparent; }
.g-tools { display: flex; justify-content: center; gap: 0; margin-bottom: 2px; }
.g-tools .icon-btn { font-size: 15px; padding: 0 5px; }
.fsc-chk { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; color: #2f7a52; font-weight: 500; margin-bottom: 2px; cursor: pointer; }
.fsc-chk input { width: auto !important; }
table.cs-grid td.q-cell { padding: 1px 2px; }
table.cs-grid input.q { min-width: 56px; text-align: center; }
table.cs-grid input.w-in { font-weight: 700; text-align: center; }
table.cs-grid tbody tr.has-q td { background: #fbf8ee; }
table.cs-grid tbody tr.has-q td.sc { background: #f3ecd6; }
table.cs-grid tfoot tr.f-factor td input { text-align: center; color: var(--accent); }
table.cs-grid tfoot tr.f-kg td { color: var(--accent); font-weight: 700; }
table.cs-grid tfoot td { background: #f7f9f8; }
table.cs-grid tfoot td.sc { background: #eef3f2; }
table.cs-grid td.tot { font-weight: 700; }
table.cs-grid tr.bad-row td { background: #fbf1ee; }
table.cs-grid input.sets { color: var(--accent); }
.st { font-size: 13px; white-space: nowrap; }
.st.ok { color: var(--ok); }
.st.bad { color: var(--warn); font-weight: 500; }
.st.more { color: #9a6a0e; font-weight: 500; }
.range-in { display: flex; align-items: center; gap: 4px; }
.range-in input { flex: 1; min-width: 0; }
.field-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.block > header .head-btns select { border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 6px; background: #fff; max-width: 320px; }
.block > header .head-btns .chk { margin-right: 6px; }
.tag.fsc-tag { border-color: #9cc7b0; color: #2f7a52; background: #eef7f1; }
#dw { width: auto; min-width: 480px; }
#dw .need-body th { background: #f7f9f8; }
@media (max-width: 860px) { .cs-strip { grid-template-columns: 1fr; } .block > header { flex-wrap: wrap; } }
.hide-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding: 7px 14px; background: #f7f9f8; border-bottom: 1px solid var(--line-soft); font-size: 13px; color: var(--muted); }
table.cs-grid th.is-hidden, table.cs-grid td.is-hidden, table.cs-grid tr.is-hidden td { opacity: .45; }
table.cs-grid th.is-hidden { background: repeating-linear-gradient(135deg, #f7f9f8 0 6px, #eceff0 6px 12px); }
table.cs-grid .icon-btn.eye { display: inline-flex; align-items: center; padding: 2px 4px; }
table.cs-grid .icon-btn.eye:hover { color: var(--accent); background: #e3eef1; }
table.cs-grid td.row-tools { white-space: nowrap; }
#cs-main textarea { overflow: hidden; resize: none; min-height: 38px; line-height: 1.5; }
#og { min-width: 0; }
#og th.g-head { width: 104px; }
#cs-main .block > header { flex-wrap: wrap; }
#cs-main .block > header h3 { white-space: nowrap; }
.pick-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 13px; }
.pick-bar .pk-n { color: var(--muted); flex: 1; }
.pick-bar .btn.danger:disabled { opacity: .5; cursor: default; }
.cs-row.picking { grid-template-columns: 20px 1fr; column-gap: 6px; }
.cs-row.picking .cs-chk { grid-row: 1 / span 2; align-self: center; margin: 0; pointer-events: none; }
.cs-row.picked { background: #fbf1ee; }
.w-cell { display: flex; align-items: center; gap: 2px; }
.w-cell .w-in { width: 64px; flex: none; }
.w-tools { display: inline-flex; align-items: center; gap: 0; white-space: nowrap; }
.w-tools .icon-btn { font-size: 14px; padding: 2px 4px; }
.hide-chk { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; color: var(--muted); cursor: pointer; margin-right: 2px; font-weight: 400; }
.hide-chk input { width: auto !important; margin: 0; }
.g-chks { display: flex; justify-content: center; gap: 8px; margin-bottom: 2px; }
.g-chks .fsc-chk { margin-bottom: 0; }
.hide-chk, .fsc-chk { white-space: nowrap; }
.g-chks { gap: 5px; }
#og th.g-head { min-width: 108px; }
/* 訂紙表欄位縮窄 */
#og th.g-head { min-width: 0; width: 86px; max-width: 86px; padding: 3px 2px 5px; }
#og th.g-head input { font-size: 13px; padding: 2px 3px; }
#og .g-tools { gap: 0; }
#og .g-tools .icon-btn { padding: 0 3px; font-size: 14px; }
#og .g-tools .hide-chk { margin: 0 2px; font-size: 11px; }
.g-fsc { font-size: 10px; color: #2f7a52; font-weight: 700; line-height: 1.2; }
#og input.q { min-width: 0; width: 100%; padding: 4px 2px; }
#og td.q-cell { max-width: 86px; }
.pick-bar .pk-hint { font-size: 12px; color: var(--muted); }
/* 輸入格看得到框線、置中，比較好找填入點 */
table.cs-grid td.q-cell { padding: 3px 4px; text-align: center; }
table.cs-grid input.q, table.cs-grid input.w-in, #dg input[data-rnote] { border: 1px solid #c9d3d1 !important; background: #fff !important; text-align: center; border-radius: 4px; }
table.cs-grid input.q:hover { border-color: var(--accent) !important; }
table.cs-grid input.q:focus, table.cs-grid input.w-in:focus { border-color: var(--accent) !important; box-shadow: 0 0 0 2px rgba(36, 89, 110, .18); outline: none; }
table.cs-grid input.q:disabled, table.cs-grid input.w-in:disabled { border-color: transparent !important; background: transparent !important; }
table.cs-grid tbody tr.has-q td input.q { background: #fffdf6 !important; }
table.cs-grid tfoot tr.f-factor td input { border: 1px solid #c9d3d1; background: #fff; }
/* 配紙寬表格：不撐滿、欄位置中 */
#dg { width: auto; min-width: 0; margin: 0 auto; }
#dg th, #dg td { text-align: center; }
#dg input.q { width: 88px; }
#dg input.sets { width: 64px; }
#dg td.tot { padding: 0 12px; }
#dg input[data-rnote] { width: 150px; text-align: left; }
#dg .row-tools { padding-left: 10px; }
