/* Payroll practice: a wages ledger. Green ledger ruling, navy ink for the controls, slab-serif headings, tabular figures. */
:root {
  --bg: #e8efe9; --paper: #fff; --ink: #13241b; --muted: #3c4f44; --line: #c3d5c8; --line2: #7a9583; --rule: #2d7550;
  --accent: #1d3f73; --accent-ink: #fff; --hi: #e2f1de; --soft: #eef5ef; --given: #f4f8f4;
  --right: #17663a; --wrong: #a8231a; --close: #7a5300; --info: #1d3f73;
  --mk-right: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%2317663a' stroke-width='2.4'%3E%3Cpath d='M2.5 8.5l3.5 3.5 7.5-8'/%3E%3C/svg%3E");
  --mk-wrong: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23a8231a' stroke-width='2.4'%3E%3Cpath d='M3.5 3.5l9 9M12.5 3.5l-9 9'/%3E%3C/svg%3E");
  --mk-close: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%237a5300' stroke-width='2.4'%3E%3Cpath d='M8 2.5v7M8 13v.5'/%3E%3C/svg%3E");
  --mk-empty: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23a8231a' stroke-width='2'%3E%3Ccircle cx='8' cy='8' r='5.5'/%3E%3C/svg%3E");
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --slab: Rockwell, "Roboto Slab", "Zilla Slab", "DejaVu Serif", Georgia, serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --r: 2px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1913; --paper: #15231b; --ink: #e4eee7; --muted: #a8bcaf; --line: #2a3e31; --line2: #557260; --rule: #63c08b;
    --accent: #a3c2ff; --accent-ink: #0c182a; --hi: #1f3a28; --soft: #1b2c22; --given: #1a2a20;
    --right: #6fd394; --wrong: #ff8f80; --close: #f0c060; --info: #a3c2ff;
    --mk-right: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%236fd394' stroke-width='2.4'%3E%3Cpath d='M2.5 8.5l3.5 3.5 7.5-8'/%3E%3C/svg%3E");
    --mk-wrong: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23ff8f80' stroke-width='2.4'%3E%3Cpath d='M3.5 3.5l9 9M12.5 3.5l-9 9'/%3E%3C/svg%3E");
    --mk-close: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23f0c060' stroke-width='2.4'%3E%3Cpath d='M8 2.5v7M8 13v.5'/%3E%3C/svg%3E");
    --mk-empty: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23ff8f80' stroke-width='2'%3E%3Ccircle cx='8' cy='8' r='5.5'/%3E%3C/svg%3E");
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.55 var(--sans); }
a { color: var(--accent); }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 8px; background: var(--paper); padding: 8px 12px; z-index: 9; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--slab); line-height: 1.2; font-weight: 700; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

.hero { padding: 22px 0 4px; }
.hero h1 { font-size: clamp(1.5rem, 4.4vw, 2.25rem); margin: 0 0 6px; }
.lede { margin: 0 0 4px; max-width: 66ch; }

/* setup */
.setup { margin: 10px 0 12px; }
fieldset { border: 0; margin: 0 0 8px; padding: 0; min-width: 0; }
legend { font-weight: 650; margin-bottom: 4px; }
.chips, .steps-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip, .step { position: relative; }
.chip input, .step input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip span, .step span { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 6px 13px; border: 1px solid var(--line2); border-radius: var(--r); background: var(--paper); }
.step b { font-family: var(--mono); font-weight: 600; }
.chip input:checked + span, .step input:checked + span { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip input:focus-visible + span, .step input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.setrow { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; }
.inline { display: inline-flex; align-items: center; gap: 8px; }
select, input { font: inherit; font-size: 16px; color: var(--ink); background: var(--paper); border: 1px solid var(--line2); border-radius: var(--r); min-height: 44px; padding: 6px 8px; max-width: 100%; }
.btn { font: inherit; font-weight: 600; min-height: 44px; padding: 8px 16px; border-radius: var(--r); border: 1.5px solid var(--accent); background: var(--paper); color: var(--accent); cursor: pointer; display: inline-flex; align-items: center; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.small { min-height: 44px; padding: 6px 14px; }
.link { font: inherit; background: none; border: 0; padding: 8px 2px; color: var(--accent); text-decoration: underline; cursor: pointer; min-height: 44px; }
.note { padding: 10px 12px; background: var(--paper); border: 1px solid var(--wrong); border-radius: var(--r); margin: 8px 0; }
#store-note { overflow-wrap: anywhere; }
.note.info { border-color: var(--info); }

/* the sheet: a wages ledger page */
.sheet { background: var(--paper); border: 1px solid var(--line2); border-top: 3px double var(--rule); padding: 14px 18px; margin: 8px 0 18px; }
.sheet-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 2px 16px; border-bottom: 1px solid var(--rule); padding-bottom: 6px; }
.sheet-head h2 { margin: 0; font-size: 1.25rem; }
.code { font-family: var(--mono); letter-spacing: .06em; color: var(--accent); }
.lvname { font-family: var(--sans); font-weight: 400; font-size: 1rem; color: var(--muted); }
.score { margin: 0; color: var(--muted); }
.rules { margin: 6px 0; }
.rules summary, details.work summary, .recent summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 600; color: var(--accent); }
.rules ul { margin: 2px 0 8px; padding-left: 20px; max-width: 72ch; }
.qs { list-style: none; margin: 0; padding: 0; }
.q { padding: 12px 0 16px; border-bottom: 1px solid var(--line2); }
.q h3 { font-size: 1.15rem; margin: 4px 0 6px; display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: baseline; }
.q h3 .see { margin-left: auto; font: 600 1rem var(--sans); white-space: nowrap; padding: 10px 0; }
.qn { font-family: var(--mono); color: var(--rule); }
.scen, .task { margin: 0 0 8px; max-width: 72ch; }
.task { font-weight: 600; }
.terms { margin: 6px 0 10px; max-width: 72ch; }
.terms ul { margin: 0; padding-left: 20px; }
.tcap { font-weight: 650; margin: 0 0 2px; }

/* tables: facts, time card, piece work, register, pay slip */
.twrap { overflow-x: auto; max-width: 100%; }
.facts-wrap { max-width: 40rem; margin: 0 0 8px; }
table.dt, table.st { border-collapse: collapse; width: 100%; }
.dt th, .dt td { padding: 4px 10px 4px 0; border-bottom: 1px solid var(--line); text-align: left; font-weight: 400; vertical-align: top; }
.dt th[scope="row"] { color: var(--muted); width: 38%; min-width: 6.5rem; }
.st caption { text-align: left; padding-bottom: 4px; }
.st-t { font-family: var(--slab); font-weight: 700; font-size: 1.08rem; margin-right: 10px; }
.st-s { color: var(--muted); }
.st th, .st td { padding: 4px 6px; border-bottom: 1px solid var(--line); text-align: left; font-weight: 400; vertical-align: middle; }
.st thead th { font-weight: 600; border-bottom: 1.5px solid var(--rule); vertical-align: bottom; }
.st .amt { text-align: right; font-variant-numeric: tabular-nums; }
.st td.tm { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.st td.given { background: var(--given); }
.st th[scope="row"] { white-space: nowrap; }
.st tfoot th, .st tfoot td { border-top: 1.5px solid var(--rule); border-bottom: 3px double var(--rule); font-weight: 650; background: var(--hi); }
.dash { color: var(--muted); }
.forms { display: grid; gap: 16px; margin: 6px 0; }
.narrow { max-width: 30rem; }
.card, .piece, .slip { margin: 2px 0 8px; }

/* answer boxes */
.cell { width: 9.5rem; font-variant-numeric: tabular-nums; text-align: right; padding: 6px 6px; }
.answers { display: grid; gap: 6px; margin: 8px 0 4px; max-width: 40rem; }
.arow { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.arow .cell { width: 11rem; }
/* the register's seven columns fit as a table from about 1024 px: narrower boxes, still wide enough for a total */
.st.reg .cell { width: 7.75rem; }
.st.reg th, .st.reg td { padding: 4px 3px; }
.kv { font-variant-numeric: tabular-nums; font-weight: 650; }
.arow .kv { text-align: right; }
.cell.is-right { border-color: var(--right); box-shadow: inset 0 0 0 1px var(--right); }
.cell.is-wrong, .cell.is-unread, .cell.is-empty { border-color: var(--wrong); box-shadow: inset 0 0 0 1px var(--wrong); }
.cell.is-empty { border-style: dashed; }
.cell.is-close, .cell.is-own { border-color: var(--close); box-shadow: inset 0 0 0 1px var(--close); border-style: dashed; }
.cell:is(.is-right, .is-wrong, .is-unread, .is-close, .is-own, .is-empty) { background-repeat: no-repeat; background-position: 5px center; background-size: 15px; padding-left: 24px; }
.cell.is-right { background-image: var(--mk-right); }
.cell.is-wrong, .cell.is-unread { background-image: var(--mk-wrong); }
.cell.is-close, .cell.is-own { background-image: var(--mk-close); }
.cell.is-empty { background-image: var(--mk-empty); }

/* tables that do not fit (fit.js): each row a block, each value on its own line with its column name */
.twrap.rows table, .twrap.rows tbody, .twrap.rows thead, .twrap.rows tfoot, .twrap.rows tr, .twrap.rows caption { display: block; width: 100%; }
.twrap.rows thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.twrap.rows tr { border-bottom: 1.5px solid var(--line2); padding: 4px 0 6px; }
.twrap.rows th[scope="row"] { display: block; border: 0; padding: 2px 0; font-weight: 650; white-space: normal; overflow-wrap: anywhere; }
.twrap.rows td { display: flex; justify-content: space-between; align-items: center; gap: 8px; border: 0; padding: 2px 0; background: none; }
.twrap.rows td::before { content: attr(data-l); text-align: left; color: var(--muted); min-width: 0; overflow-wrap: anywhere; }
.twrap.rows td.nil { display: none; }
.twrap.rows tfoot tr { background: var(--hi); border-top: 1.5px solid var(--rule); border-bottom: 3px double var(--rule); }
.twrap.rows tfoot th, .twrap.rows tfoot td { border: 0; background: none; }
.twrap.rows .cell { flex: none; }
.twrap.rows.facts-wrap td::before, .twrap.rows .st.slip td::before { content: none; }
.twrap.rows.facts-wrap th[scope="row"] { width: auto; font-weight: 400; color: var(--muted); padding-bottom: 0; }
.twrap.rows.facts-wrap tr { border-bottom: 1px solid var(--line); padding: 2px 0 4px; }

/* feedback */
.fbwrap { margin: 8px 0 0; max-width: 72ch; }
.fb { margin: 4px 0; padding: 6px 10px; border: 1px solid var(--line2); border-radius: var(--r); background: var(--soft); }
.fb.right { border-color: var(--right); }
.fb.sum, .fb.wrong, .fb.unread, .fb.empty { border-color: var(--wrong); }
.fb.close, .fb.own { border-color: var(--close); }
.fblist { margin: 6px 0 0; padding-left: 1.8em; }
.fblist li.fb { margin: 4px 0; }
.qfoot { margin-top: 8px; }

/* the key */
details.work { margin-top: 8px; }
.keyfig { margin: 4px 0; }
.steps { margin: 6px 0 8px; padding-left: 20px; max-width: 72ch; }
.steps li { margin: 2px 0; font-variant-numeric: tabular-nums; }
.steps li.sh { list-style: none; margin: 10px 0 2px -20px; font-weight: 650; }

.sheet-foot { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin-top: 12px; }
.confirm { flex-basis: 100%; margin: 0; padding: 8px 10px; background: var(--soft); border: 1px solid var(--close); border-radius: var(--r); }
.save-hint { flex-basis: 100%; margin: 0; color: var(--muted); }
.share { margin: 0 0 22px; }
.print-row { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: end; }
.print-row label, .share-out label { display: grid; gap: 2px; }
.share-out input { width: 100%; font-family: var(--mono); }
.recent ul { list-style: none; padding: 0; margin: 4px 0; }
.recent li { display: flex; justify-content: space-between; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); padding: 4px 0; }
.recent small { display: block; color: var(--muted); font-size: 1rem; }
.hint { color: var(--muted); margin: 6px 0; }

/* content below the tool */
.content { max-width: 72ch; padding-bottom: 20px; }
.content h2 { font-size: 1.35rem; margin: 26px 0 8px; }
.faq details { border-bottom: 1px solid var(--line); }
.faq summary { cursor: pointer; padding: 10px 0; font-weight: 600; min-height: 44px; }
.faq p { margin: 0 0 12px; }
.sources { color: var(--muted); overflow-wrap: anywhere; }

footer { border-top: 1px solid var(--line2); padding: 16px 0 28px; color: var(--muted); font-size: 1rem; }
.indep { margin: 0 0 10px; }
.sb-footer p { margin: 6px 0; }
.sb-more { line-height: 1.8; }
.sb-footer a { color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: 16px; transform: translate(-50%, 140%); max-width: min(92vw, 520px); background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: var(--r); transition: transform .2s; z-index: 10; pointer-events: none; }
.toast.on { transform: translate(-50%, 0); }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
.print-root { display: none; }

@media (max-width: 560px) {
  body { font-size: 16px; }
  .sheet { padding: 10px 8px; }
  .hero { padding-top: 14px; }
  .hero h1 { font-size: 1.4rem; }
  .lede { display: none; }
  .chip span, .step span { padding: 6px 10px; }
  .steps-row { display: grid; grid-template-columns: 1fr 1fr; }
  .step span { width: 100%; height: 100%; }
}
/* on a phone the label stays beside its box; only the narrowest screens stack them */
@media (max-width: 420px) { .arow .cell { width: 9.5rem; } }
@media (max-width: 359px) {
  .arow { grid-template-columns: minmax(0, 1fr); }
  .arow .cell, .arow .kv { justify-self: end; }
}

@media print {
  :root { --ink: #000; --muted: #222; --line: #888; --line2: #444; --rule: #000; --paper: #fff; --bg: #fff; --accent: #000; --hi: #fff; --given: #fff; --soft: #fff; }
  @page { margin: 8mm 12mm; }
  body { background: #fff; color: #000; font: 10pt/1.25 var(--sans); }
  main, footer, .skip, .toast { display: none !important; }
  .print-root { display: block; }
  .psheet, .pkey { break-after: page; }
  .pkey:last-child, .psheet:last-child { break-after: auto; }
  table.pt { width: 100%; border-collapse: collapse; }
  .pt > thead .prun { color: #222; font-size: 10pt; padding-bottom: 4px; border-bottom: 0.5pt solid #888; }
  .ph h2 { margin: 4px 0 4px; font-size: 15pt; }
  .ph p { margin: 0 0 4px; }
  .pmeta { display: flex; justify-content: space-between; gap: 10px; margin: 8px 0; }
  .phrow { display: flex; align-items: baseline; gap: 12mm; margin: 0 0 6pt; }
  .phrow .pmeta { flex: 1; margin: 0; }
  .prules { margin: 0 0 6pt; padding-left: 14pt; columns: 2; column-gap: 8mm; }
  .prules li, .terms li { break-inside: avoid; }
  .terms ul { columns: 2; column-gap: 8mm; }
  .pq, .pk { list-style: none; margin: 0; padding: 0; }
  .pq > li { break-inside: avoid; padding: 3pt 0 5pt; border-top: 0.5pt solid #888; }
  .pq > li.pq-exam { break-inside: auto; padding-bottom: 0; }
  /* app.js marks the problem that starts each page, the same in every copy, so every copy prints the same length */
  .pq > li.pb { break-before: page; }
  .psheet .tcap { display: none; }
  .psheet .st.card caption { display: none; }
  .pk > li { padding: 4pt 0 8pt; border-top: 0.5pt solid #888; }
  .pqh h3, .pk h3 { font-size: 12pt; margin: 2pt 0 3pt; break-after: avoid; }
  .scen, .task { margin: 0 0 4pt; max-width: none; }
  .twrap { overflow: visible; }
  .facts-wrap { max-width: 130mm; break-inside: avoid; }
  .dt th, .dt td { padding: 1pt 6pt 1pt 0; border-bottom: 0.5pt solid #999; }
  .terms { break-inside: avoid; max-width: none; margin: 3pt 0 6pt; }
  .forms { display: block; }
  .forms > * { margin: 0 0 4pt; }
  .st { break-inside: avoid; }
  .st caption { padding-bottom: 2pt; }
  .st-t { font-size: 11pt; }
  .st th, .st td { padding: 1pt 4pt; border-bottom: 0.5pt solid #999; }
  .st thead th { border-bottom: 1pt solid #000; }
  .st tfoot th, .st tfoot td { border-top: 1pt solid #000; border-bottom: 2.5pt double #000; background: none; }
  .psheet .st tbody th, .psheet .st tbody td, .psheet .st tfoot th, .psheet .st tfoot td { height: 21pt; vertical-align: bottom; }
  .st.piece.across .amt { width: 13%; }
  /* every write-in column the same width; the given hours and rate narrower */
  .st.reg { table-layout: fixed; }
  .st.reg thead th:first-child { width: 30mm; }
  .st.reg.earn thead th:nth-child(2), .st.reg.earn thead th:nth-child(3) { width: 19mm; }
  .st.reg thead th { padding-left: 3mm; }
  .st.slip.pair { table-layout: fixed; }
  .st-g { display: block; margin-top: 1pt; }
  .st.slip caption { padding-bottom: 1pt; }
  .pq > li.pq-exam { padding-bottom: 0; }
  .st.slip.pair th[scope="row"] { white-space: normal; width: 34%; }
  .st.slip.pair .amt { width: 16%; }
  .st.card { width: auto; }
  .st.card th[scope="row"] { width: 24mm; }
  .st.card .tm { width: 19mm; }
  .st.card .amt { width: 30mm; }
  /* the facts as one run of text, not a table: it keeps two time cards to a page */
  .psheet .facts-wrap { max-width: none; margin: 0 0 3pt; }
  .psheet .facts-wrap :is(table, tbody) { display: block; }
  .psheet .facts-wrap :is(tr, th, td) { display: inline; padding: 0; border: 0; }
  .psheet .facts-wrap th { color: #000; }
  .psheet .facts-wrap th::after { content: ": "; }
  .psheet .facts-wrap tr + tr::before { content: " · "; }
  .narrow { max-width: 110mm; }
  .pblank { display: inline-block; width: 30mm; height: 15pt; }
  .st .pblank { display: block; width: auto; height: 0; }
  .answers { max-width: 140mm; gap: 0; margin: 4pt 0; break-inside: avoid; }
  .psheet .answers { display: grid; grid-template-columns: 1fr 1fr; column-gap: 10mm; max-width: none; }
  .psheet .arow { break-inside: avoid; }
  .arow { border-bottom: 0; padding: 0; grid-template-columns: minmax(0, 1fr) 32mm; }
  .arow .al { align-self: end; padding-bottom: 1pt; }
  .psheet .arow .pblank { width: 32mm; height: 21pt; border-bottom: 0.75pt solid #000; }
  .pkey .arow { border-bottom: 0.5pt solid #bbb; grid-template-columns: minmax(0, 1fr) auto; }
  .steps { margin: 4pt 0; max-width: none; columns: 1; }
  .steps li { break-inside: avoid; }
  .steps li.sh { margin-top: 5pt; break-after: avoid; }
  .keyfig { margin: 2pt 0 4pt; }
  * { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}
