/* 版面概念：像一張正式的勞報單紙本——藍黑墨水、細格線、簽名處用印泥紅 */
:root {
  color-scheme: light;
  --paper: #F7F8FA;
  --sheet: #FFFFFF;
  --ink: #18202E;
  --muted: #5B6474;
  --line: #D9DDE4;
  --soft: #EEF1F5;
  --stamp: #C2302A;
  --stamp-soft: #FBEDEC;
  --ok: #2B7A52;
  --ok-soft: #E7F4ED;
  --warn: #9A6A00;
  --warn-soft: #FFF5DB;
  --focus: #3B6FD8;
  --f-body: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  --f-doc: "Noto Serif TC", "PMingLiU", "Songti TC", serif;
  --r: 10px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--f-body); font-size: 16px; line-height: 1.6;
  padding: env(safe-area-inset-top, 0px) max(16px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(16px, env(safe-area-inset-left, 0px));
}
h1, h2, h3 { line-height: 1.3; text-wrap: balance; margin: 0; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.sheet { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }

label.f { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 500; min-width: 0; }
label.f .hint { font-weight: 400; color: var(--muted); font-size: 12.5px; }
.req::after { content: " *"; color: var(--stamp); }
input[type=text], input[type=tel], input[type=email], input[type=date], input[type=number], input[type=password], select, textarea {
  font: inherit; font-size: 16px; color: var(--ink); background: var(--sheet);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; width: 100%; min-width: 0;
}
textarea { min-height: 72px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 2px;
}
input[aria-invalid=true] { border-color: var(--stamp); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.check input { width: 20px; height: 20px; margin-top: 2px; flex: none; accent-color: var(--ink); }

.btn {
  font: inherit; font-size: 15px; font-weight: 500; cursor: pointer;
  border: 1px solid var(--line); background: var(--sheet); color: var(--ink);
  border-radius: 8px; padding: 9px 16px; display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
}
.btn:hover { background: var(--soft); }
.btn.primary { background: var(--ink); color: var(--sheet); border-color: var(--ink); }
.btn.primary:hover { opacity: .9; }
.btn.danger { color: var(--stamp); }
.btn.big { width: 100%; justify-content: center; padding: 14px; font-size: 17px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.pill { display: inline-block; font-size: 12.5px; font-weight: 500; padding: 2px 10px; border-radius: 99px; white-space: nowrap; }
.pill.pending { background: var(--warn-soft); color: var(--warn); }
.pill.signed { background: var(--ok-soft); color: var(--ok); }
.pill.void { background: var(--soft); color: var(--muted); text-decoration: line-through; }

.amounts { width: 100%; border-collapse: collapse; }
.amounts td { padding: 8px 0; border-bottom: 1px dashed var(--line); }
.amounts td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.amounts tr.net td { border-bottom: 0; padding-top: 12px; font-weight: 700; font-size: 20px; }
.amounts tr.net td:last-child { color: var(--stamp); }
.cn-amount { font-family: var(--f-doc); color: var(--muted); font-size: 14px; text-align: right; }

.err { background: var(--stamp-soft); color: var(--stamp); border-radius: 8px; padding: 10px 14px; font-size: 14px; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  background: var(--ink); color: var(--sheet); padding: 10px 18px; border-radius: 99px; font-size: 14px; z-index: 50; }

/* ---------- 列印用勞報單（依現行紙本簽收單格式） ---------- */
.doc { font-family: var(--f-body); color: #111; background: #fff; width: 100%; max-width: 760px; margin: 0 auto; padding: 28px 32px; border: 1px solid #ccc; }
.doc .co { text-align: center; font-size: 20px; margin-bottom: 6px; }
.doc h1 { text-align: center; font-size: 21px; font-weight: 700; margin-bottom: 18px; }
.doc table.slip { width: 100%; border-collapse: collapse; border: 2px solid #111; font-size: 14px; table-layout: fixed; }
.doc .slip td, .doc .slip th { border: 1px solid #555; padding: 8px 10px; vertical-align: middle; overflow-wrap: anywhere; }
.doc .slip tr.sep td { border-bottom: 2px solid #111; }
.doc .slip tr.hd th { text-align: center; font-weight: 700; line-height: 1.35; }
.doc .slip tr.vals td { text-align: center; font-variant-numeric: tabular-nums; }
.doc .slip th { font-weight: 700; text-align: center; }
.doc .slip .calcline { font-size: 11px; color: #555; margin-top: 2px; }
.doc .slip .sig { height: 96px; position: relative; }
.doc .slip .sig img { max-height: 84px; max-width: 60%; display: block; }
.doc .slip .sig .when { position: absolute; right: 10px; bottom: 6px; font-size: 11px; color: #555; }
.doc .slip .bank div { line-height: 1.9; }
.doc .foot { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-top: 10px; font-size: 11.5px; }
.doc .foot ol { margin: 0; padding-left: 18px; line-height: 1.6; }
.doc .checker { font-size: 16px; font-weight: 700; white-space: nowrap; }
@media (max-width: 560px) { .doc:not(.render) { padding: 14px 10px; } .doc:not(.render) .slip { font-size: 12px; } .doc:not(.render) .slip td, .doc:not(.render) .slip th { padding: 5px 4px; } .doc:not(.render) .foot { flex-direction: column; align-items: flex-start; } }
