:root {
  --bg: #f5f7f6; --surface: #ffffff; --surface-2: #eef2f1; --ink: #17211f; --muted: #5a6865;
  --line: #dbe3e1; --primary: #0f7b6c; --primary-ink: #ffffff; --primary-soft: #dcf1ec;
  --side: #10302b; --side-ink: #d5e9e4; --side-active: #1d4a42;
  --danger: #b4232a; --danger-soft: #fde8e8; --warn: #8a5300; --warn-soft: #fff1d6; --ok: #146c36; --ok-soft: #dcf4e4;
  --focus: #0b5ed7; --radius: 10px; --shadow: 0 1px 2px rgba(23, 33, 31, .05), 0 4px 14px rgba(23, 33, 31, .05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1513; --surface: #16201e; --surface-2: #1d2a27; --ink: #e5eeec; --muted: #9db0ab;
    --line: #2a3a36; --primary: #4fc7b2; --primary-ink: #062520; --primary-soft: #173c35;
    --side: #0a1210; --side-ink: #c9dcd7; --side-active: #1d3631;
    --danger: #ff8d86; --danger-soft: #3a1714; --warn: #ffcf7a; --warn-soft: #362a10; --ok: #7be3a0; --ok-soft: #12301f;
    --focus: #8ab4ff; --shadow: none;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.4rem; } h2 { font-size: 1.1rem; } h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
a { color: var(--primary); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--surface); padding: .5rem 1rem; z-index: 99; }
.skip:focus { left: 8px; top: 8px; }
.loading, .pad { padding: 2rem; color: var(--muted); }
.muted { color: var(--muted); } .small { font-size: .875rem; }
.error { color: var(--danger); font-weight: 600; margin: 0; }
.error:empty { display: none; }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; } .row.end { justify-content: flex-end; }
.stack > * + * { margin-top: 1rem; }
.grow { flex: 1 1 0; min-width: 0; }

/* layout: a dark sidebar like most accounting apps, a top strip on phones */
.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); padding: 1rem .75rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: .55rem; color: inherit; text-decoration: none; font-weight: 700; font-size: 1.1rem; padding: .25rem .5rem 1rem; }
.brand img { width: 30px; height: 30px; }
.side .org { font-size: .85rem; opacity: .8; padding: 0 .5rem 1rem; overflow-wrap: anywhere; }
.side h4 { font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; opacity: .6; margin: 1rem .5rem .35rem; }
.side a.nav { display: block; color: var(--side-ink); text-decoration: none; padding: .45rem .6rem; border-radius: 8px; font-weight: 500; }
.side a.nav:hover { background: var(--side-active); }
.side a.nav.active { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 #4fc7b2; }
.side .soon { display: block; padding: .3rem .6rem; font-size: .88rem; opacity: .45; }
.main { min-width: 0; }
.topline { display: flex; justify-content: flex-end; align-items: center; gap: .75rem; padding: .6rem 1.5rem; border-bottom: 1px solid var(--line); background: var(--surface); font-size: .9rem; }
.topline .menu-btn { display: none; margin-right: auto; }
main { max-width: 1100px; padding: 1.5rem 1.5rem 4rem; }
@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 30; left: 0; top: 0; width: 260px; transform: translateX(-100%); transition: transform .2s; }
  .shell.menu-open .side { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35); }
  .topline { padding: .5rem 1rem; }
  .topline .menu-btn { display: inline-flex; }
  main { padding: 1rem 1rem 4rem; }
}

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; }
.narrow { max-width: 680px; }
.auth { max-width: 440px; margin: 7vh auto; padding: 0 1rem; }
.auth .brand { justify-content: center; font-size: 1.5rem; color: var(--ink); }
.auth .brand img { width: 42px; height: 42px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }

/* forms */
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .3rem; }
.hint { font-weight: 400; color: var(--muted); font-size: .85rem; }
input, select, textarea { width: 100%; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .65rem; min-height: 40px; }
textarea { min-height: 80px; resize: vertical; }
input[type=checkbox] { width: auto; min-height: 0; }
.check { display: flex; gap: .5rem; align-items: center; font-weight: 500; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .9rem; }
button, .btn { font: inherit; font-weight: 600; border: 1px solid transparent; border-radius: 8px; padding: .45rem 1rem; min-height: 40px; cursor: pointer; background: var(--primary); color: var(--primary-ink); text-decoration: none; display: inline-flex; align-items: center; gap: .4rem; white-space: nowrap; }
button:disabled { opacity: .6; cursor: default; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-link { background: none; border: 0; color: var(--primary); padding: 0; min-height: 0; font-weight: 600; }
.btn-sm { min-height: 32px; padding: .2rem .65rem; font-size: .88rem; }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .55rem .75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
tr.group td { background: var(--surface-2); font-weight: 700; }
tr.total td { font-weight: 700; border-top: 2px solid var(--ink); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.archived td { color: var(--muted); }
.lines td { padding: .35rem .4rem; }
.lines input, .lines select { min-height: 36px; }
.lines td.num input { text-align: right; }
.lines .acct { min-width: 220px; }
.lines .amt { width: 130px; }

.pill { display: inline-block; font-size: .78rem; font-weight: 600; padding: .1rem .55rem; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-bad { background: var(--danger-soft); color: var(--danger); }
.note { border-left: 4px solid var(--primary); background: var(--primary-soft); padding: .75rem 1rem; border-radius: 0 8px 8px 0; }
.note.warn { border-color: var(--warn); background: var(--warn-soft); }
.stat { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { display: flex; gap: .6rem; align-items: baseline; padding: .4rem 0; border-bottom: 1px solid var(--line); }
.checklist li:last-child { border-bottom: 0; }
.tick { width: 1.3rem; height: 1.3rem; border-radius: 50%; display: inline-grid; place-items: center; font-size: .8rem; font-weight: 700; flex: none; background: var(--surface-2); color: var(--muted); }
.tick.done { background: var(--ok-soft); color: var(--ok); }
.secret { font-family: ui-monospace, Consolas, monospace; background: var(--surface-2); padding: .2rem .45rem; border-radius: 6px; user-select: all; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(30px); background: var(--ink); color: var(--bg); padding: .6rem 1rem; border-radius: 8px; opacity: 0; transition: .2s; pointer-events: none; z-index: 50; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translateX(-50%); }
.self-end { align-self: flex-end; }
input.search { max-width: 320px; }
