:root {
  --bg: #f6f4ef;
  --card: #ffffff;
  --ink: #1f2623;
  --muted: #6b726e;
  --line: #e3e0d8;
  --brand: #2f5d50;
  --brand-ink: #ffffff;
  --brand-soft: #e4eee9;
  --good: #2e7d4f;
  --good-soft: #e3f3e8;
  --warn: #9a6400;
  --warn-soft: #fff3d6;
  --bad: #b3261e;
  --bad-soft: #fde7e5;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 1px 8px rgba(0, 0, 0, .04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141816; --card: #1c2220; --ink: #e8ebe9; --muted: #9aa39e; --line: #2c3431;
    --brand: #7fb8a4; --brand-ink: #10231c; --brand-soft: #22332d;
    --good: #7cc99a; --good-soft: #1d3326; --warn: #e6b45c; --warn-soft: #3a2f17; --bad: #f08a82; --bad-soft: #3d1f1d;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); }
button, input, select, textarea { font: inherit; color: inherit; }
.num, td.num, th.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.neg { color: var(--bad); }
.pos { color: var(--good); }

/* shell */
header.top { position: sticky; top: 0; z-index: 10; background: var(--card); border-bottom: 1px solid var(--line); }
.top-inner { max-width: 1180px; margin: 0 auto; display: flex; align-items: center; gap: 16px; padding: 10px 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; text-decoration: none; color: var(--ink); white-space: nowrap; }
.brand img { width: 28px; height: 28px; border-radius: 6px; object-fit: contain; background: #fff; }
nav.tabs { display: flex; gap: 2px; overflow-x: auto; flex: 1; scrollbar-width: none; }
nav.tabs::-webkit-scrollbar { display: none; }
nav.tabs a { padding: 7px 11px; border-radius: 8px; text-decoration: none; color: var(--muted); white-space: nowrap; font-weight: 500; }
nav.tabs a.on { background: var(--brand-soft); color: var(--ink); }
.who { color: var(--muted); font-size: 13px; white-space: nowrap; }
main { max-width: 1180px; margin: 0 auto; padding: 20px 16px 80px; }
h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 10px; }
.sub { color: var(--muted); margin: 0 0 18px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > h2 { padding: 14px 16px 0; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: 2px; }

/* controls */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--card); padding: 7px 12px; border-radius: 8px; cursor: pointer; font-weight: 550; text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.good { background: var(--good); border-color: var(--good); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.small { padding: 4px 9px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: default; }
input[type=text], input[type=search], input[type=email], input[type=date], input[type=number], input[type=month], input:not([type]), select, textarea {
  border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 7px 9px; min-width: 0; max-width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
label.field { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
label.field > * { color: var(--ink); font-size: 15px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg a, .seg button { padding: 6px 11px; text-decoration: none; color: var(--muted); border: 0; background: none; cursor: pointer; }
.seg .on { background: var(--brand-soft); color: var(--ink); font-weight: 550; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: var(--card); position: sticky; top: 0; }
tr.group td { background: var(--bg); font-weight: 650; }
tr.total td { font-weight: 700; border-top: 2px solid var(--ink); }
tr.sub td { font-weight: 600; }
td.desc { max-width: 420px; }
td.desc .d { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* pills */
.pill { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--bg); color: var(--muted); font-weight: 600; white-space: nowrap; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.brand { background: var(--brand-soft); color: var(--brand); }

/* coding cards (mobile-first) */
.txlist { display: grid; gap: 10px; }
.tx { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: grid; gap: 8px; box-shadow: var(--shadow); }
.tx.done { background: var(--good-soft); border-color: var(--good); }
.tx .top { display: flex; gap: 10px; align-items: baseline; }
.tx .merchant { font-weight: 650; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx .amt { font-weight: 650; font-variant-numeric: tabular-nums; }
.tx .meta { color: var(--muted); font-size: 13px; display: flex; gap: 8px; flex-wrap: wrap; }
.tx select { width: 100%; }
.tx .suggest { display: flex; gap: 8px; align-items: center; background: var(--brand-soft); border-radius: 8px; padding: 7px 10px; font-size: 13px; }
.tx .suggest .why { color: var(--muted); }
.tx .suggest .what { font-weight: 600; flex: 1; min-width: 0; }
.tx .note { width: 100%; }
.bulkbar { position: sticky; top: 58px; z-index: 5; background: var(--good-soft); border: 1px solid var(--good); color: var(--ink); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* checklist */
.check { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.check:last-child { border-bottom: 0; }
.check .box { width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--line); flex: none; display: grid; place-items: center; margin-top: 1px; }
.check.done .box { background: var(--good); border-color: var(--good); color: #fff; }
.check .body { flex: 1; min-width: 0; }
.check .title { font-weight: 600; }
.check .detail { color: var(--muted); font-size: 13px; }
.blockers { margin: 0; padding-left: 18px; }
.blockers li { margin: 2px 0; }

/* misc */
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.2); z-index: 100; max-width: calc(100% - 32px); }
.toast.bad { background: var(--bad); color: #fff; }
dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; background: var(--card); color: var(--ink); width: min(560px, calc(100% - 32px)); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog .dh { padding: 16px 18px 0; font-weight: 650; font-size: 17px; }
dialog .db { padding: 14px 18px; display: grid; gap: 12px; }
dialog .df { padding: 0 18px 16px; display: flex; gap: 8px; justify-content: flex-end; }
.bar { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; min-width: 60px; }
.bar > i { display: block; height: 100%; background: var(--good); }
.bar.over > i { background: var(--bad); }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.copy { display: flex; gap: 8px; }
.copy input { flex: 1; }

/* auth pages */
.auth { max-width: 420px; margin: 12vh auto; padding: 0 16px; text-align: center; }
.auth img { width: 64px; height: 64px; border-radius: 12px; background: #fff; object-fit: contain; }
.auth .card { text-align: left; margin-top: 18px; }

@media (max-width: 720px) {
  .top-inner { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  nav.tabs { order: 3; flex-basis: 100%; }
  .who { margin-left: auto; }
  main { padding: 14px 12px 80px; }
  .hide-sm { display: none; }
  .bulkbar { top: 96px; }
  th, td { padding: 7px 6px; }
}

/* transactions: confirmed rows go light green; a pre-filled suggestion reads as a draft */
table.txt tr.confirmed td { background: var(--good-soft); }
table.txt tr.confirmed td:first-child { box-shadow: inset 3px 0 0 var(--good); }
select.suggested { font-style: italic; border-style: dashed; border-color: var(--brand); }
.confirm-cell { white-space: nowrap; width: 1%; }
.confirm-cell .ok { color: var(--good); font-weight: 650; font-size: 13px; }

/* start-a-month drop zone */
.drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 26px 16px; text-align: center; background: var(--card); cursor: pointer; }
.drop.over { border-color: var(--brand); background: var(--brand-soft); }
.drop input { display: none; }
.filelist { margin: 10px 0 0; padding: 0; list-style: none; font-size: 14px; }
.filelist li { padding: 4px 0; }

/* financial statements: print like a document */
.fs { max-width: 820px; }
.fs h2.fs-title { text-align: center; font-size: 18px; margin: 0; }
.fs .fs-sub { text-align: center; color: var(--muted); margin: 2px 0 14px; font-size: 13px; }
.fs table td, .fs table th { padding: 5px 10px; }
.fs tr.indent td:first-child { padding-left: 26px; }
@media print {
  header.top, .noprint { display: none !important; }
  body { background: #fff; color: #000; }
  main { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 0; page-break-inside: avoid; }
  .fs { max-width: none; }
  .fs .pagebreak { page-break-before: always; }
}

/* ---------- transactions list: table on a computer, stacked cards on a phone ---------- */
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.filters input[type=search] { width: 180px; }
.sm-only { display: none; }
table.txt td.c-code { min-width: 230px; }
table.txt td.c-code select { width: 100%; }
table.txt .why { font-size: 12px; color: var(--muted); margin-top: 3px; }
table.txt td.c-note input { width: 150px; font-size: 13px; padding: 5px 7px; }
table.txt td.c-confirm { white-space: nowrap; width: 1%; }
table.txt td.c-confirm .btn { padding: 5px 12px; font-size: 13px; }
table.txt td.c-confirm .ok { color: var(--good); font-weight: 650; font-size: 13px; }
.donebar { margin-bottom: 12px; }

@media (max-width: 720px) {
  input, select, textarea { font-size: 16px !important; }       /* stops iOS zooming into fields */
  .filters .seg { max-width: 100%; }
  .seg.scroll { overflow-x: auto; scrollbar-width: none; }
  .seg.scroll::-webkit-scrollbar { display: none; }
  .seg a { white-space: nowrap; padding: 8px 12px; }
  .filters select, .filters input[type=search] { flex: 1 1 140px; width: auto; }
  .bulkbar { top: 96px; padding: 10px 12px; }
  .bulkbar .btn, .donebar .btn { width: 100%; justify-content: center; padding: 11px; }
  .donebar { flex-direction: column; align-items: stretch; gap: 8px; }

  .sm-only { display: inline; }
  .card.flush:has(table.txt) { background: transparent; border: 0; box-shadow: none; overflow: visible; }
  table.txt, table.txt tbody { display: block; }
  table.txt thead { display: none; }
  table.txt tr {
    display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px 8px;
    grid-template-areas: "desc desc amt" "code code code" "note confirm more";
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; box-shadow: var(--shadow);
  }
  table.txt tr.confirmed { background: var(--good-soft); border-color: var(--good); box-shadow: inset 4px 0 0 var(--good); }
  table.txt tr.confirmed td, table.txt tr.confirmed td:first-child { background: transparent; box-shadow: none; }
  table.txt td { display: block; padding: 0; border: 0; min-width: 0; }
  table.txt td.c-date, table.txt td.c-who { display: none; }
  table.txt td.c-desc { grid-area: desc; max-width: none; }
  table.txt td.c-desc .d { font-weight: 650; white-space: normal; }
  table.txt td.c-amt { grid-area: amt; font-weight: 650; font-size: 16px; }
  table.txt td.c-code { grid-area: code; min-width: 0; }
  table.txt td.c-code select { padding: 10px; }
  table.txt td.c-note { grid-area: note; }
  table.txt td.c-note input { width: 100%; padding: 9px 10px; }
  table.txt td.c-confirm { grid-area: confirm; width: auto; align-self: center; }
  table.txt td.c-confirm .btn { padding: 10px 16px; font-size: 15px; }
  table.txt td.c-more { grid-area: more; align-self: center; }
  table.txt td.c-more .btn { padding: 10px 12px; }
  table.txt td.c-more:empty, table.txt td.c-note:empty { display: none; }
  table.txt tr td.empty { grid-column: 1 / -1; }
}
.reviewbar { margin-bottom: 12px; }
.reviewbar.ready { border-color: var(--good); background: var(--good-soft); }
@media (max-width: 720px) { .reviewbar { flex-direction: column; align-items: stretch; } .reviewbar .btn { justify-content: center; padding: 11px; } }

/* questions passed back to finance */
table.txt tr.question td { background: var(--warn-soft); }
table.txt tr.question td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.qbox { font-size: 12.5px; margin-top: 5px; padding: 6px 8px; border-radius: 7px; background: var(--warn-soft); color: var(--ink); line-height: 1.4; }
.qbox.done { background: var(--brand-soft); }
.flaglink { display: inline-block; font-size: 12.5px; margin-top: 5px; color: var(--warn); }
@media (max-width: 720px) {
  table.txt tr.question { background: var(--warn-soft); border-color: var(--warn); box-shadow: inset 4px 0 0 var(--warn); }
  table.txt tr.question td, table.txt tr.question td:first-child { background: transparent; box-shadow: none; }
  .flaglink { font-size: 14px; padding: 4px 0; }
}
