:root {
  --bg: #f6f6f3;
  --panel: #ffffff;
  --ink: #1c1d1f;
  --ink-2: #5b5e63;
  --ink-3: #8a8d92;
  --line: #e4e3de;
  --line-2: #efeeea;
  --accent: #1f5c4a;
  --accent-ink: #ffffff;
  --accent-soft: #e3efe9;
  --warn: #9a5b00;
  --warn-soft: #fbf0dc;
  --bad: #a3271f;
  --bad-soft: #fbe7e5;
  --good: #1f6b3a;
  --good-soft: #e2f2e7;
  --shadow: 0 1px 2px rgba(20, 20, 15, .05), 0 2px 8px rgba(20, 20, 15, .04);
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141515;
    --panel: #1c1d1e;
    --ink: #ececea;
    --ink-2: #a6a8ab;
    --ink-3: #74777b;
    --line: #2d2f30;
    --line-2: #252728;
    --accent: #5fb89a;
    --accent-ink: #0f1a16;
    --accent-soft: #1d3029;
    --warn: #e2a547;
    --warn-soft: #33281a;
    --bad: #ef7d73;
    --bad-soft: #3a201e;
    --good: #6cc48b;
    --good-soft: #1b2e22;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { padding: 48px; color: var(--ink-3); }

/* Layout */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px; background: var(--bg); overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand img { width: 28px; height: 28px; }
.brand b { font-size: 15px; letter-spacing: -.01em; }
.brand .ver { color: var(--ink-3); font-size: 12px; font-weight: 500; margin-left: 2px; }
.company { font-size: 12px; color: var(--ink-3); padding: 0 8px 10px; text-transform: uppercase; letter-spacing: .06em; }
.navgroup { font-size: 11.5px; font-weight: 700; color: var(--ink); text-transform: uppercase; letter-spacing: .09em; margin-top: 12px; padding: 14px 10px 6px; border-top: 1px solid var(--line); }
.nav a.sub { padding-left: 20px; font-weight: 400; }
.nav a.sub.on { font-weight: 500; }
.nav a { display: block; padding: 7px 10px; border-radius: 7px; color: var(--ink-2); font-weight: 500; }
.nav a:hover { background: var(--line-2); text-decoration: none; color: var(--ink); }
.nav a.on { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
.side .who { margin-top: auto; padding: 10px; font-size: 12px; color: var(--ink-3); border-top: 1px solid var(--line); }
.side .who button { margin-top: 6px; }
.main { padding: 28px 36px 60px; min-width: 0; max-width: 1240px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
h1 { font-size: 24px; letter-spacing: -.02em; margin: 0; font-weight: 650; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 600; }
.sub { color: var(--ink-2); margin-top: 4px; }

/* Panels and tables */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel.pad { padding: 18px 20px; }
.stack { display: grid; gap: 16px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-3); padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--panel); position: sticky; top: 0; }
td { padding: 8px 12px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover td { background: var(--line-2); }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--ink-3); }
.nowrap { white-space: nowrap; }
.small { font-size: 12px; }
.memo { color: var(--ink-2); max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
tr.group td { background: var(--bg); font-weight: 600; font-size: 12px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .05em; padding-top: 14px; }
tr.total td { font-weight: 650; border-top: 1px solid var(--line); }
.indent-1 { padding-left: 28px !important; }
.indent-2 { padding-left: 44px !important; }
.tablewrap { overflow-x: auto; }

/* Tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.tile { padding: 16px 18px; }
.tile .k { font-size: 12px; color: var(--ink-3); font-weight: 600; }
.tile .v { font-size: 24px; font-weight: 650; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }

/* Badges */
.badge { display: inline-block; padding: 1px 8px; border-radius: 20px; font-size: 11.5px; font-weight: 600; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.acc { background: var(--accent-soft); color: var(--accent); }

/* Forms */
.bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
input[type=text], input[type=password], input[type=date], input[type=search], select, textarea {
  background: var(--panel); border: 1px solid var(--line); border-radius: 7px; padding: 7px 10px; min-height: 34px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input.amt { text-align: right; font-variant-numeric: tabular-nums; width: 120px; }
input.grow, select.grow { flex: 1; min-width: 160px; }
label.f { display: grid; gap: 5px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.form { display: grid; gap: 14px; max-width: 420px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
button { cursor: pointer; border-radius: 7px; border: 1px solid var(--line); background: var(--panel); padding: 7px 14px; min-height: 34px; font-weight: 550; }
button:hover { border-color: var(--ink-3); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
a.button { display: inline-flex; align-items: center; text-decoration: none; cursor: pointer; border-radius: 7px; border: 1px solid var(--line); background: var(--panel); padding: 7px 14px; min-height: 34px; font-weight: 550; color: inherit; }
a.button.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--bad); }
button.link { border: 0; background: none; padding: 0; min-height: 0; color: var(--accent); }
button:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.msg { padding: 10px 14px; border-radius: 8px; font-weight: 500; }
.msg.bad { background: var(--bad-soft); color: var(--bad); }
.msg.good { background: var(--good-soft); color: var(--good); }
.msg.warn { background: var(--warn-soft); color: var(--warn); }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; color: var(--ink-3); font-size: 12px; border-top: 1px solid var(--line); }
.pager .btns { display: flex; gap: 6px; }

/* Journal entry grid */
.je td { padding: 6px 6px; border-bottom: 0; }
.je select { width: 100%; }
.je input.memo-in { width: 100%; }
.je .x { color: var(--ink-3); border: 0; background: none; min-height: 0; padding: 4px 8px; }
.diff { font-weight: 650; }
.diff.ok { color: var(--good); }
.diff.no { color: var(--bad); }

/* Detail */
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 16px; }
.kv dt { color: var(--ink-3); font-size: 12px; font-weight: 600; padding-top: 1px; }
.kv dd { margin: 0; }

/* Auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth .panel { width: 100%; max-width: 400px; padding: 28px; }
.auth .brand { padding: 0 0 18px; }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 0 8px 0 0; }
  .company, .side .who { display: none; }
  .nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .navgroup { display: none; }
  .main { padding: 20px 16px 48px; }
}

/* Reports */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs a { padding: 8px 12px; color: var(--ink-2); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--accent); }
.btnlink { display: inline-flex; align-items: center; border-radius: 7px; border: 1px solid var(--line); background: var(--panel); padding: 7px 14px; min-height: 34px; font-weight: 550; color: var(--ink); }
.btnlink:hover { border-color: var(--ink-3); text-decoration: none; }
.bar label.f { min-width: 0; }
.bar > button { align-self: flex-end; }
.report { overflow: hidden; }
.report .basis { padding: 10px 14px; font-size: 12px; color: var(--ink-3); border-top: 1px solid var(--line); }
.print-head { display: none; }
table.stmt td { padding: 6px 12px; border-bottom: 0; }
table.stmt td.num a { color: inherit; }
table.stmt td.num a:hover { color: var(--accent); }
table.stmt tr.k-section td { font-weight: 650; padding-top: 14px; }
table.stmt tr.k-group td, table.stmt tr.k-parent td:first-child { font-weight: 600; }
table.stmt tr.k-subtotal td, table.stmt tr.k-total td { font-weight: 600; }
table.stmt tr.k-subtotal td.num, table.stmt tr.k-total td.num { border-top: 1px solid var(--line); }
table.stmt tr.k-grand td { font-weight: 700; border-top: 1px solid var(--ink-3); background: var(--bg); }
table.stmt tr.gap td { height: 6px; padding: 0; }
.report.wide table.stmt { font-size: 12.5px; }
.report.wide table.stmt th, .report.wide table.stmt td { padding-left: 8px; padding-right: 8px; }
table.stmt tbody tr:not(.k-section):not(.k-grand):not(.gap):not(.lines):hover td { background: var(--line-2); }
table.gl tr.acct td { border-bottom: 1px solid var(--line-2); }
table.gl .chev { display: inline-block; width: 14px; color: var(--ink-3); }
table.gl tr.lines > td { padding: 0 0 8px 26px; background: var(--bg); }
table.inner { table-layout: fixed; width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; font-size: 12.5px; }
table.inner th { position: static; }

@media print {
  @page { margin: 0.55in 0.5in; }
  :root { --bg: #fff; --panel: #fff; --ink: #000; --ink-2: #222; --ink-3: #555; --line: #bbb; --line-2: #eee; --accent: #000; }
  html, body { background: #fff; font-size: 10.5px; }
  .side, .no-print, .tabs, #rf, .head, .chev { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; max-width: none; }
  .panel { border: 0; box-shadow: none; border-radius: 0; }
  .print-head { display: block; text-align: center; margin-bottom: 14px; }
  .ph-co { font-size: 11px; color: #444; }
  .ph-title { font-size: 17px; font-weight: 700; margin: 2px 0; }
  .ph-period { font-size: 11px; }
  .tablewrap { overflow: visible; }
  th { position: static; background: #fff; }
  thead { display: table-header-group; }
  tr { break-inside: avoid; }
  table.stmt td { padding: 2.5px 8px; }
  table.stmt tr.k-grand td { background: #fff; border-top: 1px solid #000; }
  table.stmt td.num a { text-decoration: none; }
  table.gl tr.lines[hidden] { display: none; }
  .report .basis { border-top: 0; padding: 10px 0 0; text-align: center; }
}

td.ellip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.inner td { padding: 6px 8px; }
table.inner th { padding: 8px; }
.btnlink.primary-link { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btnlink.primary-link:hover { filter: brightness(1.08); }
label.chk { display: inline-flex; gap: 8px; align-items: center; font-weight: 500; color: var(--ink-2); }
textarea { width: 100%; resize: vertical; }
.form .row > label.f { flex: 1; }
a.tile.tlink { color: var(--ink); display: block; }
a.tile.tlink:hover { text-decoration: none; border-color: var(--ink-3); }
a.tile.tlink.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
details > summary { cursor: pointer; }
table.review td { vertical-align: middle; }

/* ---------- charts ---------- */
:root { --s1: #2a78d6; --s2: #eb6834; }
@media (prefers-color-scheme: dark) { :root { --s1: #3987e5; --s2: #d95926; } }
.chart { position: relative; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .ax { font-size: 11px; fill: var(--ink-3); font-variant-numeric: tabular-nums; }
.chart .grid { stroke: var(--line-2); stroke-width: 1; }
.chart .base { stroke: var(--line); stroke-width: 1; }
.chart .hit { fill: transparent; }
.chart .hit.on { fill: var(--ink); fill-opacity: .04; }
.chart .cross { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--ink-2); margin-bottom: 6px; }
.chart .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.chart .tip { position: absolute; top: 0; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 8px; padding: 8px 10px; font-size: 12.5px; pointer-events: none; white-space: nowrap; z-index: 2; }
.chart .tip div { margin-top: 2px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 12px; }
.budget input { width: 96px; text-align: right; padding: 4px 6px; font-variant-numeric: tabular-nums; }
.budget td, .budget th { padding: 4px 6px; }
.budget td:first-child { white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
@media print { .chart .tip { display: none; } }
.chart .legend .sw.dash { background: none; border-top: 2px dashed; border-radius: 0; height: 0; width: 16px; vertical-align: 3px; }

/* Check deposits */
.dropzone { display: block; text-align: center; padding: 34px 20px; border: 2px dashed var(--line); cursor: pointer; box-shadow: none; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.checkgrid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1000px) { .checkgrid { grid-template-columns: 1fr; } }
.checkgrid > .panel:first-child { position: sticky; top: 16px; }
img.checkimg { display: block; width: 100%; height: auto; border-radius: 6px; background: var(--line-2); }
.suggest { display: grid; gap: 8px; }
button.sugg { text-align: left; display: block; width: 100%; padding: 10px 12px; font-weight: 400; }
button.sugg.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.msg.warn { margin-bottom: 12px; }

/* Customers money bar (1.74) */
.moneybar { display: flex; gap: 4px; padding: 18px 20px 20px; margin-bottom: 16px; }
.mb-seg { flex: 1 1 0; min-width: 150px; display: flex; flex-direction: column; gap: 2px; color: var(--ink); text-decoration: none; border-radius: 8px; padding: 6px 6px 0; }
.mb-seg:hover { text-decoration: none; background: var(--line-2); }
.mb-seg.on { background: var(--accent-soft); }
.mb-amt { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.mb-lbl { font-size: 13px; color: var(--ink-3); margin-bottom: 10px; }
.mb-strip { height: 14px; border-radius: 4px; margin-top: auto; margin-bottom: 6px; }
.mb-overdue .mb-strip { background: #e8862e; }
.mb-open .mb-strip { background: #cfd3d8; }
.mb-paid .mb-strip { background: #4f9e37; }
@media (prefers-color-scheme: dark) { .mb-open .mb-strip { background: #555b61; } }
@media (max-width: 700px) { .moneybar { flex-direction: column; } .mb-seg { flex-grow: 1 !important; } }

/* Sortable column headings (1.77) */
th.sortable a { color: inherit; text-decoration: none; display: inline-block; }
th.sortable a:hover { color: var(--ink); text-decoration: none; }
th.sortable.on a { color: var(--ink); }

/* Resizable columns (1.77) */
th { position: sticky; }
th .colrz { position: absolute; top: 0; right: -3px; width: 7px; height: 100%; cursor: col-resize; z-index: 2; }
th .colrz::after { content: ''; position: absolute; top: 25%; bottom: 25%; left: 3px; width: 1px; background: var(--line); }
th:hover .colrz::after, th .colrz:hover::after { background: var(--ink-3); }
table.rzfixed { table-layout: fixed; }
table.rzfixed th, table.rzfixed td { overflow: hidden; text-overflow: ellipsis; }
body.rz-dragging, body.rz-dragging * { cursor: col-resize !important; user-select: none !important; }
@media print { th .colrz { display: none; } }

/* Match payments (1.78) */
table.matchtbl td:nth-child(2) { min-width: 170px; }
table.matchtbl td.acts { white-space: nowrap; }
table.matchtbl td.acts .link { display: block; padding: 1px 0; text-align: left; }
table.pick { width: auto; min-width: 560px; }
table.pick td, table.pick th { padding: 6px 12px; }
table.matchtbl td:nth-child(3) { max-width: 180px; }

/* Business at a glance (1.81) */
:root { --s3: #2e8b57; --c1: #2a78d6; --c2: #1f9e89; --c3: #7a4fd6; --c4: #eb6834; --c5: #9aa0a6; }
@media (prefers-color-scheme: dark) { :root { --s3: #4caf78; --c1: #3987e5; --c2: #2bb39c; --c3: #9a77e8; --c4: #d95926; --c5: #6f757b; } }
.gl-title { margin: 0 0 10px; font-size: 17px; }
.gl-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 12px; }
.gl-grid1 { grid-template-columns: 1fr; margin-top: 12px; }
.gl-card { padding: 16px 18px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.gl-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.gl-h h3 { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); }
.gl-period { font-size: 12.5px; padding: 3px 6px; }
.gl-big { font-size: 28px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.gl-pill { font-size: 12px; font-weight: 600; background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 2px 8px; vertical-align: 5px; }
.gl-chg { font-weight: 650; } .gl-chg.good { color: var(--good); } .gl-chg.bad { color: var(--bad); } .gl-chg.flat { color: var(--ink-3); font-weight: 500; }
.bad-ink { color: var(--bad); display: block; } .acc-ink { color: var(--accent); }
.gl-list { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.gl-item { display: block; color: var(--ink); padding: 8px 10px; border-radius: 8px; background: var(--line-2); font-size: 13.5px; line-height: 1.35; }
.gl-item:hover { text-decoration: none; background: var(--accent-soft); }
.gl-item .small { display: block; margin-top: 2px; }
.gl-banks { display: flex; flex-direction: column; flex: 1; }
.gl-bank { color: var(--ink); padding: 8px 0; border-bottom: 1px solid var(--line-2); }
.gl-bank:hover { text-decoration: none; } .gl-bank:hover b { color: var(--accent); }
.gl-bank-top { display: flex; justify-content: space-between; gap: 10px; font-variant-numeric: tabular-nums; }
.gl-pl { display: flex; flex-direction: column; gap: 10px; margin: 6px 0 2px; flex: 1; }
.gl-pl-row { display: grid; grid-template-columns: 96px 1fr; gap: 10px; align-items: center; font-variant-numeric: tabular-nums; }
.gl-bar { height: 22px; background: var(--line-2); border-radius: 4px; overflow: hidden; }
.gl-bar span { display: block; height: 100%; border-radius: 4px; } .gl-bar .inc { background: var(--s3); } .gl-bar .exp { background: var(--s1); }
.gl-exp { display: flex; flex-direction: column; align-items: stretch; gap: 10px; flex: 1; }
.gl-donut { width: 104px; height: 104px; align-self: center; }
.gl-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; min-width: 0; }
.gl-legend li { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto 44px; gap: 6px; align-items: center; font-variant-numeric: tabular-nums; }
.gl-legend .sw { width: 10px; height: 10px; border-radius: 3px; }
.gl-legend .gl-ln { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gl-legend .gl-chg { font-size: 11.5px; text-align: right; }
.gl-cash-top { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; background: transparent; padding: 6px 12px; font-size: 13px; }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.gl-cleg { justify-content: center; margin-top: 4px; }
.sw.hatch { background: repeating-linear-gradient(45deg, var(--s3) 0 2px, var(--panel) 2px 5px); border: 1px solid var(--s3); }
.glance { margin-bottom: 4px; }
