/* Money — a carbon-copy docket book: ruled ledger paper, carbon-blue ink, perforated invoice dockets. */
:root {
  --paper: #fbfcfe; --sheet: #ffffff; --rule: #d7e3f1; --carbon: #23439b; --ink: #18202d; --soft: #5b6676;
  --in: #0d7448; --out: #b3312a; --warn: #fff4d6;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --paper: #0f1522; --sheet: #172033; --rule: #2a3854; --carbon: #9db4ff; --ink: #e8edf6; --soft: #a3aec2; --in: #4fd39a; --out: #ff8a80; --warn: #3a3214; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif; font-variant-numeric: tabular-nums;
  /* faint ledger ruling */
  background-image: linear-gradient(var(--rule) 1px, transparent 1px); background-size: 100% 34px; background-attachment: fixed;
}
main { max-width: 34rem; margin: 0 auto; padding: calc(env(safe-area-inset-top, 0px) + 20px) 16px calc(96px + var(--safe-b)); outline: none; }
h1 { font-size: 2rem; line-height: 1.1; margin: 0 0 16px; letter-spacing: -0.02em; }
h2 { font-size: 1.1rem; margin: 28px 0 8px; }
a { color: var(--carbon); }
.hint { color: var(--soft); font-size: .95rem; }
.warn { background: var(--warn); padding: 10px 12px; border-radius: 8px; }
.back { margin: 0 0 8px; } .back a { text-decoration: none; font-weight: 600; }

/* ledger table */
.ledger { width: 100%; border-collapse: collapse; background: var(--sheet); border: 1.5px solid var(--carbon); }
.ledger th, .ledger td { padding: 10px 8px; text-align: right; border-bottom: 1px solid var(--rule); font-size: .95rem; }
.ledger thead th { color: var(--carbon); font-weight: 600; border-bottom: 1.5px solid var(--carbon); }
.ledger tbody th { text-align: left; font-weight: 500; color: var(--soft); }
.ledger td + td { border-left: 1px solid var(--rule); }
.in { color: var(--in); } .out { color: var(--out); }

.goal { margin-top: 18px; } .goal p { margin: 0 0 6px; }
.bar { height: 14px; border: 1.5px solid var(--carbon); background: var(--sheet); }
.bar i { display: block; height: 100%; background: var(--in); transition: width .5s cubic-bezier(.2,.8,.2,1); }

/* buttons */
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 0; }
.actions.small { gap: 20px; margin-top: 12px; } .actions.small a { font-weight: 600; text-decoration: none; padding: 8px 0; }
.btn { appearance: none; border: 0; border-radius: 12px; min-height: 48px; padding: 12px 18px; font: inherit; font-size: 1rem; font-weight: 600; line-height: 1.2;
  background: var(--carbon); color: var(--sheet); text-decoration: none; display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  transition: transform .12s ease; flex: 1 1 auto; }
.btn:active { transform: scale(.97); }
.btn.ghost { background: transparent; color: var(--carbon); box-shadow: inset 0 0 0 1.5px var(--carbon); }
.btn.in { background: var(--in); }
.link { appearance: none; background: none; border: 0; font: inherit; color: var(--carbon); padding: 12px 0; cursor: pointer; text-decoration: underline; }
.danger { color: var(--out); }
:focus-visible { outline: 3px solid var(--carbon); outline-offset: 2px; }

/* lists */
.list { list-style: none; margin: 0; padding: 0; background: var(--sheet); border-top: 1px solid var(--rule); }
.list a { display: flex; justify-content: space-between; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--rule); color: inherit; text-decoration: none; min-height: 48px; }
.list small { display: block; color: var(--soft); font-size: .85rem; }
.list .amt { white-space: nowrap; font-weight: 600; align-self: center; }
.late { color: var(--out); font-style: normal; font-weight: 700; }
.cam { display: inline-block; width: 14px; height: 11px; margin-right: 6px; border: 1.5px solid var(--soft); border-radius: 3px; vertical-align: -1px; }

/* forms */
.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 4px; font-weight: 600; font-size: .95rem; }
.form input, .form select { font: inherit; font-size: 17px; line-height: 1.3; color: var(--ink); background: var(--sheet); border: 1.5px solid var(--rule); border-radius: 10px; padding: 12px; min-height: 48px; width: 100%; }
.form input:focus { border-color: var(--carbon); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--carbon) 25%, transparent); }
.form [aria-invalid="true"] { border-color: var(--out); }
fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 6px; } legend { font-weight: 600; font-size: .95rem; margin-bottom: 6px; }
.form .pick { display: flex; align-items: center; gap: 10px; font-weight: 400; background: var(--sheet); border: 1.5px solid var(--rule); border-radius: 10px; padding: 12px; min-height: 48px; }
.pick input { width: 22px; height: 22px; min-height: 0; accent-color: var(--carbon); margin: 0; }
.custom { display: grid; gap: 14px; } .custom[hidden] { display: none; }
.shot { margin: 0 0 14px; } .shot img { width: 100%; max-height: 50vh; object-fit: contain; background: var(--sheet); border: 1px solid var(--rule); border-radius: 10px; }

/* the docket: one bold thing */
.docket { position: relative; background: #fff; color: #18202d; padding: 28px 20px 76px; margin: 4px 0 0;
  border: 1.5px solid #23439b; border-top: 0; font-size: 15.5px;
  -webkit-mask: radial-gradient(circle 5px at 9px 0, transparent 98%, #000) -9px 0 / 18px 100% repeat-x; mask: radial-gradient(circle 5px at 9px 0, transparent 98%, #000) -9px 0 / 18px 100% repeat-x; }
.docket header { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 1.5px solid #23439b; padding-bottom: 8px; margin-bottom: 12px; }
.docket h1 { margin: 0; font-size: 1.4rem; color: #23439b; }
.docket .no { margin: 0; font: 700 2.1rem/1 ui-serif, "New York", Georgia, serif; color: #b3312a; letter-spacing: .02em; }
.docket dl { display: grid; grid-template-columns: 4.2em 1fr; gap: 6px 10px; margin: 0 0 14px; }
.docket dt { color: #23439b; font-weight: 600; } .docket dd { margin: 0; }
.lines { width: 100%; border-collapse: collapse; margin: 6px 0 12px; }
.lines td { padding: 9px 0; border-bottom: 1px solid #d7e3f1; vertical-align: top; } .lines td + td { text-align: right; white-space: nowrap; padding-left: 12px; }
.lines .total td { font-weight: 700; border-bottom: 2px solid #23439b; }
.docket mark { background: #fff4d6; }
.paidstamp { position: absolute; right: 18px; bottom: 20px; margin: 0; transform: rotate(-9deg); border: 3px solid #0d7448; color: #0d7448; border-radius: 8px; padding: 4px 10px; font: 800 1.15rem/1.1 ui-serif, Georgia, serif; text-transform: uppercase; opacity: .85; }

/* tab bar */
.tabs { position: fixed; inset: auto 0 0; display: flex; background: color-mix(in srgb, var(--paper) 88%, transparent); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border-top: 1px solid var(--rule); padding-bottom: var(--safe-b); }
.tabs a { flex: 1; display: grid; justify-items: center; gap: 2px; padding: 8px 0 6px; font-size: .72rem; font-weight: 600; color: var(--soft); text-decoration: none; min-height: 52px; }
.tabs svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs a[aria-current] { color: var(--carbon); }

.toast { position: fixed; left: 16px; right: 16px; bottom: calc(76px + var(--safe-b)); margin: auto; max-width: 30rem; background: var(--ink); color: var(--paper); padding: 12px 16px; border-radius: 12px;
  opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; pointer-events: none; text-align: center; }
.toast.on { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; } }
@media print {
  body { background: #fff; } .tabs, .noprint, .back, .toast { display: none !important; }
  main { padding: 0; max-width: none; } .docket { -webkit-mask: none; mask: none; border: 0; font-size: 12pt; }
}
