:root {
  --bg: #f4f6f8; --panel: #ffffff; --ink: #1b2430; --muted: #5f6b7a; --line: #d9dee5; --accent: #1e5eff; --accent-ink: #ffffff;
  --ok: #1a7f4b; --warn: #b26a00; --bad: #b3261e; --soft: #eef3ff; --radius: 8px; --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 6px 12px; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.danger { color: var(--bad); border-color: var(--bad); }
button.link { border: 0; background: none; color: var(--accent); padding: 0; }
button:disabled { opacity: .5; cursor: default; }
button.working { opacity: .85; }
button.working::before { content: ""; display: inline-block; width: .75em; height: .75em; margin-right: 7px; vertical-align: -1px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
body.busy::before { content: ""; position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 100; background: linear-gradient(90deg, transparent, var(--accent), transparent) no-repeat; background-size: 35% 100%; animation: slide 1.1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes slide { from { background-position: -55% 0; } to { background-position: 155% 0; } }
@media (prefers-reduced-motion: reduce) { button.working::before, body.busy::before { animation-duration: 3s; } }
input, select, textarea { border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; background: #fff; min-width: 0; }
input.money { text-align: right; font-family: var(--mono); }
input:invalid { border-color: var(--bad); }
.top { display: flex; align-items: center; gap: 16px; height: 48px; padding: 0 16px; background: #111827; color: #fff; }
.top .brand { color: #fff; font-weight: 700; font-size: 16px; letter-spacing: .3px; }
.top-trust { flex: 1; display: flex; align-items: center; gap: 8px; }
.top-trust select { background: #1f2937; color: #fff; border-color: #374151; }
.top-user { display: flex; align-items: center; gap: 10px; font-size: 13px; color: #cbd5e1; }
.top-user button { background: #1f2937; color: #fff; border-color: #374151; }
.shell { display: flex; min-height: calc(100% - 48px); }
.side { width: 220px; flex: none; background: var(--panel); border-right: 1px solid var(--line); padding: 12px 0; }
.side a { display: block; padding: 7px 18px; color: var(--ink); }
.side a.active { background: var(--soft); color: var(--accent); font-weight: 600; border-right: 3px solid var(--accent); }
.side .group { padding: 12px 18px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.view { flex: 1; min-width: 0; padding: 20px 24px 60px; }
.loading { color: var(--muted); padding: 40px; text-align: center; }
h1 { font-size: 20px; margin: 0 0 14px; } h2 { font-size: 16px; margin: 20px 0 8px; } h3 { font-size: 14px; margin: 14px 0 6px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.stat .label { color: var(--muted); font-size: 12px; } .stat .value { font-size: 22px; font-family: var(--mono); }
.muted { color: var(--muted); } .small { font-size: 12px; } .right { text-align: right; } .mono { font-family: var(--mono); }
.ok { color: var(--ok); } .warn { color: var(--warn); } .bad { color: var(--bad); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; background: var(--soft); color: var(--accent); }
.pill.void { background: #fde8e6; color: var(--bad); } .pill.ok { background: #e3f5ea; color: var(--ok); } .pill.warn { background: #fff3df; color: var(--warn); }
table { width: 100%; border-collapse: collapse; background: var(--panel); }
th, td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: #fafbfc; position: sticky; top: 0; }
td.num, th.num { text-align: right; font-family: var(--mono); white-space: nowrap; }
tr.total td { font-weight: 700; border-top: 2px solid var(--ink); }
tr.section td { font-weight: 700; background: #fafbfc; }
tr.void td { color: var(--muted); text-decoration: line-through; }
tr.clickable { cursor: pointer; } tr.clickable:hover td { background: var(--soft); }
.table-wrap { overflow: auto; max-height: 70vh; border: 1px solid var(--line); border-radius: var(--radius); }
.indent1 { padding-left: 24px; } .indent2 { padding-left: 40px; }
form.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px 14px; }
form.grid label, .field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
form.grid label > *:not(span), .field > *:not(span) { font-size: 14px; color: var(--ink); }
.lines td { padding: 4px; } .lines input, .lines select { width: 100%; }
.actions { display: flex; gap: 8px; margin-top: 12px; align-items: center; }
.error { color: var(--bad); background: #fde8e6; border: 1px solid #f3b4b0; padding: 8px 10px; border-radius: 6px; margin: 8px 0; }
.notice { background: #fff8e6; border: 1px solid #f1d58a; padding: 8px 10px; border-radius: 6px; margin: 8px 0; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: #111827; color: #fff; padding: 10px 14px; border-radius: 6px; box-shadow: 0 6px 20px rgba(0,0,0,.2); max-width: 420px; }
.toast.bad { background: var(--bad); }
.modal { position: fixed; inset: 0; background: rgba(17,24,39,.45); display: flex; align-items: center; justify-content: center; z-index: 40; padding: 20px; }
.modal[hidden] { display: none; }
.modal .box { background: var(--panel); border-radius: var(--radius); padding: 18px 20px; width: min(760px, 100%); max-height: 90vh; overflow: auto; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs a { padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tree .acct { display: flex; justify-content: space-between; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 24px; text-align: center; color: var(--muted); }
.drop.over { border-color: var(--accent); background: var(--soft); }
.report-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.report-title { font-size: 18px; font-weight: 700; } .report-sub { color: var(--muted); }
.kbd { font-family: var(--mono); font-size: 12px; background: #eef1f5; padding: 1px 5px; border-radius: 4px; }
@media print { .top, .side, .actions, .toasts, .no-print { display: none !important; } .view { padding: 0; } .table-wrap { max-height: none; overflow: visible; border: 0; } th { position: static; } body { background: #fff; } }
@media (max-width: 800px) { .side { display: none; } .view { padding: 14px; } }

/* search row, top-bar refresh */
.field.grow { flex: 1; min-width: 240px; } .field.grow input { width: 100%; }
.top-trust button { background: #1f2937; color: #fff; border-color: #374151; }
.pre { white-space: pre-line; }

/* printed documents: only #printSheet shows while one is printing (see printSheet in app.js) */
#printSheet { display: none; }
.doc-sheet { font-size: 13px; color: #000; padding: 6px; }
.doc-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 22px; }
.doc-org { font-size: 20px; font-weight: 700; } .doc-kind { font-size: 18px; font-weight: 600; text-align: right; }
.doc-meta { width: 100%; margin-bottom: 14px; } .doc-meta td { vertical-align: top; border: 0; padding: 4px 0; }
.doc-lines, .ck-stub table { width: 100%; border-collapse: collapse; }
.doc-lines th, .doc-lines td { border-bottom: 1px solid #bbb; padding: 6px 4px; text-align: left; background: none; }
.doc-lines .num, .ck-stub .num, .doc-meta .num { text-align: right; } .doc-total td { font-weight: 700; border-top: 1px solid #000; }
.check-sheet { position: relative; width: 8.5in; height: 10.9in; overflow: hidden; font: 12px/1.3 Helvetica, Arial, sans-serif; color: #000; page: check; }
.check-sheet .ck { position: absolute; white-space: nowrap; transform: translate(var(--dx, 0mm), var(--dy, 0mm)); }
.ck-date { left: 6.9in; top: .62in; } .ck-payee { left: 1in; top: 1.12in; font-size: 13px; } .ck-amount { left: 6.9in; top: 1.12in; font-family: var(--mono); }
.ck-words { left: .35in; top: 1.5in; } .check-sheet .ck-address { left: 1in; top: 1.85in; white-space: pre-line; } .ck-memo { left: .7in; top: 2.85in; }
.ck-stub { position: absolute; left: .5in; right: .5in; font-size: 11px; } .ck-stub td { padding: 2px 4px; border: 0; background: none; }
.ck-stub-head { display: flex; justify-content: space-between; font-weight: 700; margin-bottom: 4px; }
@page check { size: letter; margin: 0; }
@media print { body.sheet > *:not(#printSheet) { display: none !important; } body.sheet #printSheet { display: block; } body.sheet { background: #fff; } }
