:root {
  --verdict: var(--c-earth);
  --rule: 1px solid var(--ink-soft);
  --frame: 1.5px solid var(--ink);
}
[data-theme="dark"] { --verdict: var(--ink); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --verdict: var(--ink); }
}

*, *::before, *::after { box-sizing: border-box; border-radius: 0; }

html { background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
}

.page { max-width: 46rem; margin: 0 auto; padding: 24px 16px 48px; }

:focus-visible { outline: 2px solid var(--verdict); outline-offset: 2px; }

h1, h2, h3, h4 { margin: 0; line-height: 1.2; }
p { margin: 0; }

.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; border-bottom: var(--frame); padding-bottom: 12px; }
h1 { color: var(--verdict); font-size: 2rem; font-weight: var(--fw-bold); letter-spacing: -0.01em; }
.sub { color: var(--ink-soft); font-size: 0.875rem; text-transform: uppercase; letter-spacing: 0.08em; margin-top: 4px; }
.label { flex: none; display: block; background: var(--c-cream); border: var(--frame); padding: 6px 8px 2px; }
.label img { display: block; width: 126px; height: auto; }

.intro { margin: 20px 0; max-width: 40rem; }
.note { font-size: 0.875rem; color: var(--ink); }
.note:empty { display: none; }
#nostore { margin-top: 12px; border: var(--rule); padding: 6px 10px; }

/* Boxed form fields: label small above, value below. */
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: var(--rule); border-left: var(--rule); }
.fields .field { border-right: var(--rule); border-bottom: var(--rule); padding: 6px 10px 8px; min-width: 0; }
.field label, .flabel { display: block; font-size: 0.75rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.06em; }
.fval { display: block; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.fields.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (min-width: 40rem) {
  .fields { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

input, button { font: inherit; color: inherit; border-radius: 0; }
input[type="text"], input[type="date"], input[type="month"] {
  width: 100%; min-width: 0; background: transparent; border: 0; border-bottom: var(--rule); padding: 2px 0; color: var(--ink);
}
.field input { border-bottom: 0; padding: 0; }
input[type="checkbox"] { width: 18px; height: 18px; margin: 0; accent-color: var(--ink); }

button {
  background: var(--bg); color: var(--ink); border: var(--frame); padding: 8px 14px; cursor: pointer; line-height: 1.2;
}
button:disabled { color: var(--ink-soft); border-color: var(--ink-soft); cursor: default; }
button.primary { background: var(--c-earth); color: var(--c-cream); border: 1.5px solid var(--ink); font-weight: var(--fw-bold); }
button.link { background: none; border: 0; padding: 0 2px; font-size: 0.8125rem; color: var(--ink-soft); text-decoration: underline; text-underline-offset: 2px; }

.form { border: var(--frame); padding: 16px; }
#draft-started { margin-top: 8px; }

.rows { list-style: none; margin: 16px 0 0; padding: 0; border-top: var(--rule); }
.row { display: grid; grid-template-columns: 2.25rem minmax(0, 1fr) auto; grid-template-areas: "num text text" ". tick remove"; align-items: center; gap: 4px 10px; padding: 8px 0; border-bottom: var(--rule); }
.row .num { grid-area: num; font-variant-numeric: tabular-nums; color: var(--ink-soft); text-align: right; }
.row input[type="text"] { grid-area: text; border-bottom: 1px dotted var(--ink-soft); }
.row .tick { grid-area: tick; display: inline-flex; align-items: center; gap: 6px; font-size: 0.875rem; }
.row .link { grid-area: remove; justify-self: end; }
@media (min-width: 40rem) {
  .row { grid-template-columns: 2.25rem minmax(0, 1fr) auto auto; grid-template-areas: "num text tick remove"; }
}

.tally { margin-top: 12px; font-variant-numeric: tabular-nums; }
.actions, .buttons { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
#form-error, #refile { margin-top: 10px; }

.rule { border: var(--frame); padding: 12px 16px; margin-top: 16px; }

/* The notice: one voice for every verdict. */
.notice-wrap:empty { display: none; }
.notice { border: var(--frame); border-left: 4px solid var(--c-mustard); padding: 14px 16px; margin-top: 16px; }
.notice h2 { font-size: 0.9375rem; letter-spacing: 0.08em; white-space: pre-wrap; font-weight: var(--fw-bold); }
.notice h2:focus { outline: 2px solid var(--verdict); outline-offset: 2px; }
.notice .meta { white-space: pre-wrap; font-variant-numeric: tabular-nums; margin-top: 4px; }
.notice .verdict { margin-top: 1.5em; }
.notice .word { color: var(--verdict); font-weight: var(--fw-bold); font-size: 1em; }
.notice .basis { margin-top: 2px; }

section.ledger, section.monthly { margin-top: 40px; }
section.ledger h2, section.monthly h2 { font-size: 1.25rem; margin-bottom: 10px; padding-bottom: 6px; border-bottom: var(--frame); }
#show-all { margin-top: 10px; }
#copies-foot { margin-top: 10px; color: var(--ink-soft); }

.scroll { overflow-x: auto; max-width: 100%; border: var(--rule); }
.table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; font-size: 0.9375rem; }
.table th { text-align: left; font-weight: var(--fw-medium); font-size: 0.75rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.06em; border-bottom: var(--rule); padding: 6px 10px; white-space: nowrap; }
.table td { padding: 5px 10px; border-bottom: var(--rule); white-space: nowrap; vertical-align: top; }
.table .num { text-align: right; }
.table tr.filing td { border-bottom: 0; }
.table tr.lines-row td { padding-top: 0; padding-bottom: 6px; font-size: 0.8125rem; white-space: normal; }
.table tr:last-child td { border-bottom: 0; }
.table td.remark { min-width: 9rem; }
summary { cursor: pointer; color: var(--ink-soft); width: max-content; }
details ol { margin: 4px 0 2px; padding-left: 2.25rem; }
details li { white-space: normal; }
details .mark { display: inline-block; min-width: 3.75rem; color: var(--ink-soft); }

.controls { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; align-items: end; }
.controls .field { border: var(--rule); padding: 6px 10px 8px; max-width: 14rem; }
.controls .buttons { margin-top: 0; }
@media (min-width: 40rem) { .controls { grid-template-columns: 14rem minmax(0, 1fr); } }
.load-status p:empty { display: none; }
.load-status { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.sheet { border: var(--frame); padding: 16px; margin-top: 16px; }
.sheet-title { font-size: 1rem; margin-bottom: 12px; }
.sheet h4 { font-size: 0.75rem; font-weight: var(--fw-medium); text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-soft); margin: 16px 0 6px; }
.sheet .fields .fval { font-size: 1.25rem; }
.dist td.barcell { width: 100%; height: 24px; padding-top: 6px; padding-bottom: 6px; }
.bar { display: block; height: 0; border-top: 12px solid var(--ink); }
#s-none, #s-variation { margin-top: 16px; }
.sheet-notes { margin-top: 16px; border-top: var(--rule); padding-top: 10px; font-size: 0.875rem; }
.sheet-notes p + p { margin-top: 6px; }
.printed { display: none; }
.sheet-mark { display: block; width: 105px; height: auto; margin-top: 18px; background: var(--c-cream); border: var(--frame); padding: 4px 6px 1px; box-sizing: content-box; }

.foot { margin-top: 40px; padding-top: 12px; border-top: var(--frame); font-size: 0.875rem; color: var(--ink-soft); }
.foot p + p { margin-top: 6px; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media print {
  @page { margin: 14mm; }
  :root, :root:not([data-theme="light"]), [data-theme="dark"] { --bg: #FCF0DD; --verdict: #530E36; --ink: #1A1A1A; --ink-soft: #5B5B5B; }
  html, body { background: #fff; color: #1A1A1A; }
  .page { max-width: none; padding: 0; }
  .page > *:not(#monthly), #monthly > *:not(#sheet) { display: none !important; }
  #monthly { margin: 0; }
  .sheet { margin: 0; border-color: #1A1A1A; }
  .scroll { overflow: visible; }
  .fields { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .printed { display: block; margin-top: 16px; font-size: 0.8125rem; }
  body { font-size: 10.5pt; }
  tr, .field, .sheet-notes { break-inside: avoid; }
}
