/* Box12TT — tokens follow DESIGN.md */
:root {
  --paper: #f7f8f6;
  --sheet: #ffffff;
  --ink: #1c1e21;
  --ink-2: #4d5560;
  --ink-3: #6b737d;
  --form-red: #c4122f;
  --form-red-soft: #f8e3e7;
  --greenbar: #e9f2e6;
  --rule: #d9ddd7;
  --rule-soft: #eceee9;
  --ok: #1f6f43;
  --ok-bg: #e6f2ea;
  --warn: #7a5100;
  --warn-bg: #fff3d1;
  --focus: #1d4ed8;
  --radius-s: 3px;
  --radius-m: 8px;
  --measure: 66ch;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --font: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 16px; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.6;
  font-variant-numeric: tabular-nums lining-nums;
  caret-color: var(--form-red);
}
::selection { background: var(--form-red-soft); color: var(--ink); }
a { color: var(--ink); text-decoration-color: var(--form-red); text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
a:hover { color: var(--form-red); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
svg { width: 1.15em; height: 1.15em; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }
img { max-width: 100%; }
* { scrollbar-color: #b9bfb6 transparent; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 24px; }
@media (max-width: 600px) { .wrap { padding: 0 16px; } }

/* header */
.site-head { border-bottom: 1px solid var(--rule); background: var(--sheet); }
.site-head .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px 20px; min-height: 60px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 800; font-size: 1.1rem; text-decoration: none; letter-spacing: -0.01em; }
.nav { display: flex; gap: 6px 22px; align-items: center; font-size: 0.95rem; flex-wrap: wrap; }
.nav a { text-decoration: none; color: var(--ink-2); }
.nav a:hover { color: var(--ink); text-decoration: underline; text-decoration-color: var(--form-red); }
.nav a.nav-cta { color: var(--ink); font-weight: 700; text-decoration: underline; text-decoration-color: var(--form-red); }
@media (max-width: 480px) { .nav a:not(.nav-cta):first-child { display: none; } }

/* type */
h1, h2, h3 { line-height: 1.12; letter-spacing: -0.02em; margin: 0 0 0.5em; text-wrap: balance; }
h1 { font-size: clamp(2.2rem, 4.6vw, 3.1rem); font-weight: 800; }
h2 { font-size: clamp(1.55rem, 3vw, 2.1rem); font-weight: 750; }
h3 { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.01em; }
p { margin: 0 0 1em; max-width: var(--measure); }
.lede { font-size: 1.22rem; line-height: 1.5; color: var(--ink-2); max-width: 44ch; }
.small { font-size: 0.875rem; color: var(--ink-2); }
.muted { color: var(--ink-3); font-weight: 400; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 9px 18px;
  border-radius: var(--radius-m); border: 2px solid var(--ink); background: var(--ink); color: #fff; font: inherit; font-size: 1rem;
  font-weight: 700; text-decoration: none; cursor: pointer; transition: background-color 160ms var(--ease-out), transform 160ms var(--ease-out); }
.btn:hover { background: #000; color: #fff; }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: var(--sheet); color: var(--ink); }
.btn.secondary:hover { background: var(--paper); color: var(--ink); }
.btn[disabled] { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn-lg { min-height: 52px; padding: 12px 24px; font-size: 1.05rem; }
.link-btn { font: inherit; background: none; border: 0; padding: 4px 0; color: var(--ink); cursor: pointer;
  text-decoration: underline; text-decoration-color: var(--form-red); text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
.link-btn:hover { color: var(--form-red); }
.link-btn[disabled] { opacity: 0.4; cursor: not-allowed; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 28px; }

/* hero */
.hero { padding: 80px 0 72px; }
.hero-grid { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 64px; align-items: center; }
.assure { display: flex; flex-wrap: wrap; gap: 8px 24px; margin-top: 22px; font-size: 0.92rem; color: var(--ink-2); }
.assure span { display: inline-flex; align-items: center; gap: 7px; }
.assure svg { color: var(--ok); }
@media (max-width: 880px) { .hero-grid { grid-template-columns: 1fr; gap: 44px; } .hero { padding: 48px 0 56px; } }

.w2 { background: var(--sheet); border: 1.5px solid var(--form-red); color: var(--form-red); font-size: 0.8rem; line-height: 1.3;
  box-shadow: 0 1px 2px rgba(28, 30, 33, 0.06), 0 12px 32px -12px rgba(28, 30, 33, 0.18); }
.w2-head { padding: 7px 12px; border-bottom: 1px solid var(--form-red); }
.box12 { display: grid; grid-template-columns: 34px 64px 1fr; }
.box12 > span { padding: 10px 12px; border-right: 1px solid var(--form-red); }
.box12 > span:last-child { border-right: 0; }
.box12 .code-lbl { font-size: 0.7rem; line-height: 1.15; }
.box12 .code { color: var(--ink); font-weight: 800; font-size: 1.3rem; }
.box12 .amt { color: var(--ink); font-weight: 800; font-size: clamp(1.8rem, 4vw, 2.4rem); text-align: right; letter-spacing: -0.02em; align-self: center; }
.calc-chain { margin: 18px 2px 0; padding: 0; list-style: none; font-size: 0.93rem; color: var(--ink-2); }
.calc-chain li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px dashed var(--rule); }
.calc-chain li:last-child { border-bottom: 0; color: var(--ink); font-weight: 700; }
.calc-chain b { color: var(--ink); }
@media (prefers-reduced-motion: no-preference) {
  .box12 .amt { animation: fill 1.1s steps(12, end) 0.25s backwards; }
  @keyframes fill { from { clip-path: inset(0 0 0 100%); } to { clip-path: inset(0 0 0 0); } }
}

/* sections */
section { padding: 64px 0; }
.band { background: var(--sheet); border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.two-col { display: grid; grid-template-columns: 0.9fr 1.1fr; gap: 48px; align-items: start; }
@media (max-width: 800px) { .two-col { grid-template-columns: 1fr; gap: 20px; } }
.mismatch { margin: 0 0 14px; padding: 0; list-style: none; border-top: 1px solid var(--rule); }
.mismatch li { display: flex; justify-content: space-between; gap: 16px; padding: 13px 0; border-bottom: 1px solid var(--rule); }
.mismatch b { white-space: nowrap; }

.price { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 28px; max-width: 880px; }
.price > div { padding: 28px; border: 1.5px solid var(--rule); border-radius: var(--radius-m); background: var(--sheet); display: flex; flex-direction: column; align-items: flex-start; }
.price .price-pro { border-color: var(--ink); }
.price .amount { font-size: 2.6rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1; margin: 4px 0 18px; }
.price .per { font-size: 1rem; font-weight: 600; color: var(--ink-2); letter-spacing: 0; }
.price .btn { margin-top: auto; }
.price .small { margin: 10px 0 0; }
.checks { list-style: none; padding: 0; margin: 0 0 24px; }
.checks li { position: relative; padding-left: 26px; margin: 7px 0; }
.checks li::before { content: ""; position: absolute; left: 3px; top: 0.42em; width: 11px; height: 6px; border-left: 2px solid var(--ok); border-bottom: 2px solid var(--ok); transform: rotate(-45deg); }
@media (max-width: 700px) { .price { grid-template-columns: 1fr; } }

.faq details { border-bottom: 1px solid var(--rule); padding: 15px 0; max-width: 72ch; }
.faq summary { cursor: pointer; font-weight: 700; }
.faq details p { margin: 10px 0 0; color: var(--ink-2); }

.site-foot { border-top: 1px solid var(--rule); padding: 28px 0 40px; font-size: 0.875rem; color: var(--ink-2); }
.site-foot .wrap { display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; }
.site-foot p { margin: 0; }

/* article pages */
.article { padding: 48px 0 72px; }
.article h1 { font-size: clamp(2rem, 4vw, 2.7rem); max-width: 24ch; }
.article h2 { font-size: 1.45rem; margin-top: 1.8em; }
.article p, .article li { max-width: var(--measure); }
.article table { border-collapse: collapse; margin: 16px 0 24px; font-size: 0.95rem; background: var(--sheet); }
.article th, .article td { border: 1px solid var(--rule); padding: 6px 10px; text-align: left; }
.article td.n, .article th.n { text-align: right; }
.callout { border: 1px solid var(--form-red); background: var(--sheet); padding: 14px 18px; margin: 20px 0; max-width: var(--measure); border-radius: var(--radius-s); }

/* ---------- calculator ---------- */
.tool { padding: 36px 0 72px; }
.tool-title { font-size: clamp(1.7rem, 3vw, 2.2rem); margin-bottom: 20px; }
#stage-upload { padding: 0; }

.dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center;
  min-height: 260px; padding: 32px 20px; border: 2px dashed #aeb5ab; border-radius: 14px; background: var(--sheet); cursor: pointer;
  transition: border-color 180ms var(--ease-out), background-color 180ms var(--ease-out); }
.dropzone:hover { border-color: var(--ink); }
.dropzone:focus-within { outline: 3px solid var(--focus); outline-offset: 3px; }
.dropzone.over { border-color: var(--form-red); background: #fdf6f7; }
.dz-icon { width: 40px; height: 40px; color: var(--form-red); margin-bottom: 6px; stroke-width: 1.5; }
.dz-main { font-size: 1.35rem; font-weight: 800; letter-spacing: -0.01em; }
.dz-sub { color: var(--ink-2); }
.dz-sub u { text-decoration-color: var(--form-red); text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
.dz-links { display: flex; flex-wrap: wrap; gap: 8px 28px; justify-content: center; margin: 16px auto 0; }

.options { max-width: 640px; margin: 18px auto 0; text-align: left; }
.options summary { cursor: pointer; color: var(--ink-2); font-size: 0.95rem; width: max-content; margin: 0 auto; }
.options-body { display: flex; flex-wrap: wrap; gap: 14px 28px; align-items: center; padding: 16px 0 0; justify-content: center; font-size: 0.95rem; }
.opt { display: inline-flex; gap: 8px; align-items: center; }
.opt-file { flex-wrap: wrap; }
.opt-file input { font: inherit; font-size: 0.875rem; }
.muted-link { font-size: 0.875rem; }
select, input[type=text] { font: inherit; padding: 8px 10px; border: 1px solid #9aa1a9; border-radius: var(--radius-s); background: #fff; color: var(--ink); }
input[type=checkbox] { accent-color: var(--ink); width: 17px; height: 17px; }

.msg { border-radius: var(--radius-m); padding: 12px 16px; margin: 16px 0; font-size: 0.95rem; }
.msg.error { background: var(--form-red-soft); color: #7a0b1d; }
.msg.warn { background: var(--warn-bg); color: var(--warn); }
.msg.ok-msg { background: var(--ok-bg); color: var(--ok); }
.msg ul { margin: 6px 0 0; padding-left: 1.2em; }

#results { padding: 0; }
.file-bar { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: baseline; justify-content: space-between; margin-bottom: 14px; color: var(--ink-2); font-size: 0.95rem; }

.totals { display: grid; grid-template-columns: 1.6fr 1fr 1fr; border: 1.5px solid var(--form-red); background: var(--sheet); margin-bottom: 18px; }
.totals > div { padding: 12px 16px 14px; border-right: 1px solid var(--form-red); display: flex; flex-direction: column; gap: 2px; }
.totals > div:last-child { border-right: 0; }
.totals .lbl { color: var(--form-red); font-size: 0.8rem; }
.totals .val { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.01em; }
.totals .total-main .val { font-size: 2.2rem; }
@media (max-width: 640px) {
  .totals { grid-template-columns: 1fr 1fr; }
  .totals .total-main { grid-column: 1 / -1; border-right: 0; border-bottom: 1px solid var(--form-red); }
}

.pass { border: 1.5px solid var(--ink); border-radius: var(--radius-m); padding: 16px 20px; background: var(--sheet); margin-bottom: 18px; }
.pass-text { margin: 0 0 12px; max-width: none; }
.pass-actions { display: flex; flex-wrap: wrap; gap: 10px 20px; align-items: center; }
.pass form { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.pass input { flex: 1 1 260px; }
.pass .small { margin: 8px 0 0; }
.pass .small:empty { display: none; }

.result-actions { display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: center; margin-bottom: 14px; }

.table-scroll { overflow-x: auto; border: 1px solid var(--rule); border-radius: var(--radius-m); background: var(--sheet); }
.table-scroll.inner { border-radius: var(--radius-s); }
table.ledger { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
table.ledger th { text-align: left; font-weight: 700; font-size: 0.85rem; color: var(--ink-2); padding: 10px 14px; border-bottom: 2px solid var(--ink); white-space: nowrap; }
table.ledger td { padding: 9px 14px; border-bottom: 1px solid var(--rule-soft); white-space: nowrap; }
table.ledger td.n, table.ledger th.n { text-align: right; }
table.ledger td.tt { font-weight: 700; }
#emp-table tbody tr.emp-row:nth-of-type(4n+1) { background: var(--greenbar); }
#emp-table tbody tr.emp-row:hover { background: #f1f5ef; }
table.ledger tr.locked td.tt { filter: blur(5px); user-select: none; }
table.ledger.detail { font-size: 0.85rem; }
table.ledger.detail th { border-bottom-width: 1px; padding: 7px 10px; }
table.ledger.detail td { padding: 6px 10px; }
table.ledger.detail tbody tr:nth-child(odd) { background: var(--paper); }
.row-toggle { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 600; background: none; border: 0; padding: 2px 0; color: var(--ink); cursor: pointer; text-align: left; }
.row-toggle svg { color: var(--ink-3); transition: transform 180ms var(--ease-out); }
.row-toggle[aria-expanded="true"] svg { transform: rotate(90deg); }
.row-toggle:hover span { text-decoration: underline; text-decoration-color: var(--form-red); text-underline-offset: 3px; }
tr.detail-row > td { background: var(--paper); padding: 10px 14px 14px; white-space: normal; }
.flag { display: inline-block; font-size: 0.78rem; padding: 1px 8px; border-radius: 999px; background: var(--warn-bg); color: var(--warn); margin: 1px 3px 1px 0; white-space: nowrap; }
.flag.err { background: var(--form-red-soft); color: #7a0b1d; }
.ok { color: var(--ok); font-size: 0.875rem; }
.hint { margin: 10px 0 0; }

.legend-box { margin-top: 24px; max-width: 72ch; }
.legend-box summary { cursor: pointer; font-weight: 700; }
.legend dt { font-weight: 700; margin-top: 10px; }
.legend dd { margin: 2px 0 0; color: var(--ink-2); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: var(--radius-m); font-weight: 600; box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.4); z-index: 10; }
@media (prefers-reduced-motion: no-preference) { .toast { animation: toast-in 220ms var(--ease-out); } @keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } } }

[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* print: audit trail */
.print-only { display: none; }
@media print {
  body { background: #fff; font-size: 10pt; }
  .site-head, .site-foot, .no-print, .legend-box summary { display: none !important; }
  .print-only { display: block; }
  .legend-box { display: block; }
  .table-scroll { overflow: visible; border: 0; }
  table.ledger { font-size: 8.5pt; }
  tr.detail-row, tr.detail-row[hidden] { display: table-row !important; }
  table.ledger tbody tr { break-inside: avoid; }
}

/* layout guards */
.hero-grid > * { min-width: 0; }
.hero-figure { margin: 0; }
@media (max-width: 560px) {
  .col-ot { display: none; }
  table.ledger th, table.ledger td { padding-left: 10px; padding-right: 10px; }
}
@media (max-width: 560px) { .pill-word { display: none; } }
