/* Prosperity Ledger. Printed matter: a cash book and a receipt. The page stays daylight in every scheme. */

:root {
  --ink: #1A1A1A;
  --ink-soft: #5B5B5B;
  --error: #BE3B27;
  --rule: var(--c-teal);
  --head: var(--c-moss);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: var(--c-cream);
    --ink: #1A1A1A;
    --ink-soft: #5B5B5B;
    --error: #BE3B27;
    color-scheme: light;
  }
}

*, *::before, *::after {
  box-sizing: border-box;
  border-radius: 0;
  box-shadow: none;
  background-image: none;
}
[hidden] { display: none !important; }

html { background: var(--c-cream); }
body {
  margin: 0;
  background: var(--c-cream);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
  -webkit-text-size-adjust: 100%;
}

.masthead, main { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.masthead { padding-top: 20px; }
.wordmark { display: block; width: 126px; height: auto; }
.title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  margin-top: 14px;
  padding-bottom: 6px;
  border-bottom: 3px double var(--ink);
}
h1 { margin: 0; font-size: 30px; line-height: 1.1; font-weight: 700; letter-spacing: -0.01em; }
.today { margin: 0; font-size: 15px; }

h2, h3, legend {
  margin: 0 0 8px;
  color: var(--head);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
p { margin: 0 0 8px; }
.caption { font-size: 13px; color: var(--ink-soft); }

/* Controls: plain bordered rectangles. */
button, input, select { font: inherit; color: var(--ink); }
button {
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--ink);
  background: var(--c-cream);
  font-size: 15px;
  text-align: left;
  cursor: pointer;
}
button:hover:not(:disabled) { text-decoration: underline; }
button:active:not(:disabled) { background: var(--ink); color: var(--c-cream); }
button:disabled { color: var(--ink-soft); border-color: var(--rule); cursor: default; }
input, select {
  height: 44px;
  width: 100%;
  padding: 0 10px;
  border: 1px solid var(--ink);
  background: var(--c-cream);
  font-size: 16px;
}
input:disabled, select:disabled { border-color: var(--rule); color: var(--ink-soft); }
:focus-visible { outline: 2px solid var(--head); outline-offset: 2px; }

/* Setup */
#setup { max-width: 680px; padding: 8px 0 40px; }
fieldset { margin: 0; padding: 16px 0 18px; border: 0; border-bottom: 1px solid var(--rule); }
legend { float: left; width: 100%; padding: 0; }
legend + * { clear: both; }
.names { list-style: none; margin: 0 0 12px; padding: 0; }
.names li { display: grid; grid-template-columns: 76px minmax(0, 1fr); align-items: center; gap: 10px; margin-bottom: 8px; }
.names label { font-size: 14px; color: var(--ink-soft); }
.names input, #start { max-width: 320px; }
.choice { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 8px; padding: 8px 0; cursor: pointer; }
input[type="radio"] {
  appearance: none;
  width: 20px;
  height: 20px;
  margin: 2px 0 0;
  padding: 0;
  border: 1px solid var(--ink);
  background: var(--c-cream);
}
input[type="radio"]:checked { background: var(--ink); }
#setup-form > p { margin: 14px 0 0; }
.open-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin-top: 20px; }
#open { font-weight: 700; border-width: 2px; padding: 0 20px; }
#open-missing { margin: 0; font-size: 14px; color: var(--ink-soft); }
.colophon { margin-top: 28px; font-size: 13px; color: var(--ink-soft); }

/* Notices */
#notice { margin: 14px 0 0; padding: 8px 0; border-bottom: 1px solid var(--rule); font-size: 14px; }
#banner { margin: 0; padding: 12px 0; border-bottom: 3px double var(--ink); font-size: 18px; font-weight: 700; }

/* Book screen */
#book { padding: 12px 0 0; }
.ending-line { font-size: 13px; color: var(--ink-soft); margin-bottom: 16px; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr); gap: 32px; }
@media (min-width: 900px) {
  .cols { grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr); gap: 44px; }
}
.col-left > * + * { margin-top: 14px; }

table { width: 100%; border-collapse: collapse; font-size: 15px; }
thead th {
  color: var(--head);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: left;
  vertical-align: bottom;
  padding: 6px 8px;
  border-bottom: 3px double var(--ink);
}
td, tbody th, tfoot th { padding: 8px; text-align: left; font-weight: 400; border-bottom: 1px solid var(--rule); vertical-align: middle; overflow-wrap: anywhere; }
tbody th { font-weight: 600; }
th + th, th + td, td + td { border-left: 1px solid var(--rule); }
tfoot td, tfoot th { border-top: 3px double var(--ink); border-bottom: 0; font-weight: 700; }
.num { text-align: right; white-space: nowrap; overflow-wrap: normal; }
thead th.num { white-space: normal; }
.status { font-size: 14px; }
.overdrawn { color: var(--error); }
button.out { min-height: 44px; min-width: 56px; margin-left: 8px; float: right; text-align: center; }
.figure-line { font-size: 14px; }
#worth-note { margin-top: 6px; }

.pay-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; align-items: end; }
.pay-grid label { display: grid; gap: 4px; font-size: 13px; color: var(--ink-soft); }
#record { font-weight: 700; text-align: center; }
@media (min-width: 560px) {
  .pay-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 0.8fr) auto; }
}
#amount { text-align: right; }
#form-error, #count-error { min-height: 20px; margin: 6px 0 0; font-size: 14px; }
.quick { display: flex; flex-wrap: wrap; gap: 8px; }
.quick button { flex: 1 1 auto; font-size: 14px; }

.count { border-top: 1px solid var(--rule); padding-top: 14px; }
#count-panel { margin-top: 14px; }
#count-table input { text-align: right; max-width: 160px; margin-left: auto; display: block; }
#count-table td { padding: 6px 8px; }
.count-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
#count-record { font-weight: 700; }

#lines {
  list-style: none;
  margin: 0;
  padding: 0;
  height: calc(14 * 1.6rem);
  overflow-y: auto;
  border: 1px solid var(--rule);
  font-size: 14px;
}
#lines:empty::before { content: "No lines yet."; display: block; padding: 8px 10px; color: var(--ink-soft); }
#lines li { display: grid; grid-template-columns: 46px minmax(0, 1fr); column-gap: 8px; padding: 5px 10px; border-bottom: 1px solid var(--rule); }
#lines .time, #receipt-lines .time { color: var(--ink-soft); white-space: nowrap; overflow-wrap: normal; }
.text { white-space: pre-line; overflow-wrap: anywhere; }
.struck { text-decoration: line-through; }
.struck-note { grid-column: 2; display: block; font-size: 13px; color: var(--ink-soft); }
.line-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

#foot { margin: 56px 0 28px; font-size: 11px; line-height: 1.4; color: var(--ink-soft); }

/* Receipt: built from the book at all times; on screen only once the book has closed. */
#receipt { display: none; max-width: 820px; margin: 0 auto; padding: 28px 16px 40px; }
body.closed #receipt { display: block; border-top: 1px dashed var(--ink-soft); }
#receipt .wordmark { width: 110px; margin-bottom: 10px; }
#receipt h2 { font-size: 22px; color: var(--ink); text-transform: none; letter-spacing: 0; margin-bottom: 6px; }
#receipt h3 { margin-top: 22px; }
#receipt table { font-size: 14px; margin: 8px 0; }
#r-result { font-weight: 700; }
#receipt-lines td.time { width: 1%; }
#receipt .small { font-size: 11px; color: var(--ink-soft); }
#r-method { margin-top: 18px; }
#receipt-foot { margin-top: 32px; }

@media (max-width: 480px) {
  table { font-size: 14px; }
  td, tbody th, tfoot th, thead th { padding-left: 5px; padding-right: 5px; }
  thead th { letter-spacing: 0.02em; font-size: 11px; }
  button.out { float: none; margin: 4px 0 0; display: block; }
}

@page { margin: 14mm; }
@media print {
  body > header, main { display: none !important; }
  #receipt { display: none; }
  body.has-book #receipt { display: block; max-width: none; margin: 0; padding: 0; border: 0; }
  #receipt, #receipt table, #receipt .status { font-size: 9pt; }
  #receipt h2 { font-size: 14pt; }
  #receipt .small { font-size: 7pt; }
  thead { display: table-header-group; }
  tr { break-inside: avoid; }
}
