/* Honesty Box: screen and print. Square corners everywhere, ink on white on cream. */

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

html { background: var(--bg); color: var(--ink); -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.45 var(--font-body); background: var(--bg); color: var(--ink); }
p, h2 { margin: 0; }

.banner { background: #fff; border-bottom: 1px solid var(--ink); color: var(--error); padding: 12px 16px; font-weight: var(--fw-bold); }

.desk { max-width: 1180px; margin: 0 auto; padding: 24px 16px 40px; display: flex; flex-direction: column; gap: 24px; }
.masthead { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; color: var(--ink-soft); font-variant-caps: all-small-caps; letter-spacing: .05em; font-size: 17px; }
.masthead span:first-child { color: var(--ink); font-weight: var(--fw-bold); }

.sheet { background: #fff; border: 1px solid var(--ink); padding: 24px; min-width: 0; }
.sheet h2 { font-size: 20px; font-weight: var(--fw-bold); margin-bottom: 16px; }
.sub { color: var(--ink-soft); margin: -12px 0 16px; }
.note { color: var(--ink-soft); font-size: 14px; margin-top: 12px; }
.lab { display: block; color: var(--ink-soft); font-variant-caps: all-small-caps; letter-spacing: .05em; font-size: 16px; line-height: 1.2; margin-bottom: 4px; }

/* The sign: a 210 x 275 sheet (A4 width, 235 mm of text height) scaled to its container. */
.sign-sheet { width: min(100%, 600px); align-self: center; padding: 0; container-type: inline-size; }
.sign { aspect-ratio: 210 / 275; padding: 9.524cqw; display: flex; flex-direction: column; overflow-wrap: anywhere; }
.sign p { line-height: 1.15; }
.sign-item { font-size: 6.048cqw; font-weight: var(--fw-bold); min-height: 1.15em; }
.sign-price { font-size: 12.095cqw; font-weight: var(--fw-bold); min-height: 1.15em; margin-top: 1.5cqw; }
.sign-unit { font-size: max(3.360cqw, 13px); font-weight: var(--fw-medium); min-height: 1.15em; margin-top: 1cqw; }
.sign-instr { font-size: max(2.688cqw, 12px); font-weight: var(--fw-medium); margin-top: 6cqw; }
.sign .blank { border-bottom: 1px solid var(--ink-soft); }
.sign-item.blank { width: 50%; }
.sign-price.blank { width: 70%; }
.sign-unit.blank { width: 40%; }
.sign-record { margin-top: auto; border-top: 1px solid var(--ink); padding-top: 2.5cqw; }
.sign .sign-line { font-size: max(2.016cqw, 11px); font-weight: var(--fw-bold); line-height: 1.3; }

/* Forms */
.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.field { display: block; min-width: 0; }
.field.wide, .actions.wide { grid-column: 1 / -1; }
input, select, button { font: inherit; color: var(--ink); }
input, select { width: 100%; min-height: 44px; padding: 8px 10px; background: #fff; border: 1px solid var(--ink); }
input:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.hint { display: block; color: var(--ink-soft); font-size: 13px; margin-top: 4px; }
.hint:empty { display: none; }
.select { position: relative; display: block; }
.select select { appearance: none; padding-right: 32px; }
.select::after { content: ""; position: absolute; right: 12px; top: 50%; margin-top: -3px; border: 6px solid transparent; border-top-color: var(--ink); border-bottom: 0; pointer-events: none; }

.actions { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-top: 16px; }
.grid .actions { margin-top: 0; }
.paper { width: 120px; }
button { min-height: 44px; padding: 8px 16px; background: #fff; border: 1px solid var(--ink); cursor: pointer; }
button:hover { text-decoration: underline; }
button.primary { background: var(--ink); color: #fff; font-weight: var(--fw-bold); }
button:disabled { color: var(--ink-soft); border-color: var(--ink-soft); cursor: default; text-decoration: none; }

.msg { margin-top: 16px; font-weight: var(--fw-bold); }
.msg:empty { display: none; }
.msg.refused { color: var(--error); }
.field .msg { margin-top: 6px; font-size: 15px; }

.file input[type=file] { border: 1px dashed var(--ink); padding: 6px 8px; font-size: 14px; }
.file input[type=file]:disabled { border-color: var(--ink-soft); color: var(--ink-soft); }
::file-selector-button { font: inherit; background: #fff; border: 1px solid var(--ink); padding: 4px 10px; margin-right: 10px; color: var(--ink); }

/* Ledger */
.empty { font-weight: var(--fw-bold); }
.table-wrap { position: relative; overflow-x: auto; border: 1px solid var(--ink); }
.ledger, .tally table { border-collapse: collapse; width: 100%; font-size: 14px; }
.ledger th, .ledger td { padding: 5px 8px; border-bottom: 1px solid var(--ink-soft); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; vertical-align: top; }
.ledger th { white-space: normal; font-weight: var(--fw-medium); color: var(--ink-soft); font-variant-caps: all-small-caps; letter-spacing: .04em; font-size: 15px; border-bottom-color: var(--ink); vertical-align: bottom; }
.ledger .t { text-align: left; }
.ledger td.t.note-cell { white-space: normal; min-width: 110px; max-width: 220px; color: var(--ink-soft); }
.ledger tfoot td { border-top: 1px solid var(--ink); border-bottom: 0; font-weight: var(--fw-bold); }
.ledger tr.struck td.num { text-decoration: line-through; color: var(--ink-soft); }
.ledger td.act { text-align: left; }
.ledger td.act button { min-height: 26px; padding: 0 8px; font-size: 13px; }
.ledger tr.strike-row td { text-align: left; white-space: normal; background: #fff; }
.strike-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.strike-form .field { flex: 1 1 220px; }
.strike-form .msg { flex-basis: 100%; margin-top: 0; }
.working { margin-top: 12px; font-variant-numeric: tabular-nums; font-weight: var(--fw-bold); }
.working:empty { display: none; }
.record { border-top: 1px solid var(--ink); margin-top: 20px; padding-top: 4px; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.tally { display: none; }
.foot { display: flex; align-items: center; justify-content: space-between; color: var(--ink-soft); font-size: 13px; }
.foot img { display: block; }

@media (max-width: 760px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
  .sheet { padding: 16px; }
  .ledger th, .ledger td { padding: 6px; }
}

/* Print: one sheet per mode, chosen by data-print on <html>. Default is the sign. */
@media print {
  @page { margin: 20mm; }
  html, body { background: #fff; }
  .desk { max-width: none; padding: 0; display: block; }
  .desk > *, .banner { display: none !important; }

  html:not([data-print=tally]):not([data-print=ledger]) .sign-sheet { display: block !important; width: 100%; border: 0; container-type: normal; }
  html:not([data-print=tally]):not([data-print=ledger]) .sign { aspect-ratio: auto; height: 225mm; padding: 0; }
  .sign-item { font-size: 36pt; }
  .sign-price { font-size: 72pt; margin-top: 5mm; }
  .sign-unit { font-size: 20pt; margin-top: 3mm; }
  .sign-instr { font-size: 16pt; margin-top: 18mm; }
  .sign-record { padding-top: 4mm; }
  .sign .sign-line { font-size: 12pt; }

  html[data-print=tally] .tally, html[data-print=ledger] .ledger-sheet { display: block !important; }
  html[data-print=tally] .foot, html[data-print=ledger] .foot { display: flex !important; margin-top: 6mm; font-size: 8pt; }
  .foot img { width: 26mm; height: auto; }

  .ledger-sheet { border: 0; padding: 0; }
  .ledger-sheet h2, .tally h2 { font-size: 14pt; margin-bottom: 2mm; }
  .ledger-sheet .sub, .tally .sub { margin: 0 0 4mm; font-size: 9pt; }
  .table-wrap { overflow: visible; border: 0; }
  .ledger { font-size: 8pt; }
  .ledger th { font-size: 8pt; }
  .ledger th, .ledger td { padding: 1.2mm 1.6mm; }
  .ledger td.t.note-cell { min-width: 0; max-width: 50mm; }
  .ledger .act, .record, .strike-row { display: none !important; }
  .working, .ledger-sheet .note { font-size: 8pt; margin-top: 2mm; }
  thead { display: table-header-group; }
  tr { break-inside: avoid; }

  .tally table { font-size: 8pt; table-layout: fixed; }
  .tally th { text-align: left; font-weight: var(--fw-bold); border: 1px solid var(--ink); padding: 1.5mm; vertical-align: bottom; }
  .tally td { border: 1px solid var(--ink); height: 7.6mm; }
  .tally th:nth-child(9) { width: 22%; }
  .tally th:nth-child(10) { width: 9%; }
}
