:root {
  --bg: #f3f4ef; --surface: #ffffff; --ink: #1b221f; --muted: #5f6a64; --line: #d9ddd4;
  --accent: #1f5f4a; --accent-soft: #e2ece6; --warn: #9a5b00; --warn-soft: #f7ead3;
  --info: #3b5a8a; --info-soft: #e3e9f3; --danger: #a3332b;
  --font-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121614; --surface: #1a201d; --ink: #e7ebe6; --muted: #9aa59f; --line: #2c3430;
    --accent: #6fc3a2; --accent-soft: #1f3129; --warn: #e3ac55; --warn-soft: #33281a;
    --info: #8fb0e3; --info-soft: #1e2736; --danger: #f08a80; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font-body); -webkit-text-size-adjust: 100%; }
img { max-width: 100%; }
.wrap {
  max-width: 1040px; margin: 0 auto; display: grid; gap: 22px;
  padding: max(20px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) calc(48px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.eyebrow { font: 600 12px/1 var(--font-body); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
h1 { font: 800 clamp(28px, 6vw, 40px)/1.05 var(--font-display); margin: 4px 0; }
h2 { font: 600 20px/1.2 var(--font-display); margin: 0; }
h3 { font: 600 15px/1.3 var(--font-body); margin: 0; }
p { margin: 0; }
.sync { color: var(--muted); font-size: 13px; }
.status { color: var(--warn); font-size: 14px; }
.top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; }
.top-actions { display: flex; gap: 8px; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); display: grid; gap: 14px; }
.login-card label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: grid; gap: 10px; align-content: start; min-width: 0; }
.notice { border-color: var(--accent); }
.notice .button { justify-self: start; }
.notice.warn { border-color: var(--warn); background: var(--warn-soft); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 760px) { .grid2 { grid-template-columns: 1fr; } }

.balance { display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.balance > div { padding: 16px 18px; display: grid; gap: 4px; align-content: start; min-width: 0; }
.balance > div + div { border-left: 1px solid var(--line); }
.balance .label { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.balance .num { font: 500 22px/1.2 var(--font-mono); font-variant-numeric: tabular-nums; }
.balance .owed { background: var(--accent-soft); }
.balance .owed .num { font: 800 34px/1.1 var(--font-display); color: var(--accent); font-variant-numeric: tabular-nums; }
.balance .sub { font-size: 12px; color: var(--muted); }
@media (max-width: 760px) {
  .balance { grid-template-columns: 1fr 1fr; }
  .balance .owed { grid-column: 1 / -1; }
  .balance > div + div { border-left: 0; border-top: 1px solid var(--line); }
  .balance > div:nth-child(odd):not(.owed) { border-left: 1px solid var(--line); }
}

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; border-radius: 0; color: var(--muted); padding: 10px 14px; font: 600 15px var(--font-body); white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.tabs .badge { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px; background: var(--warn); color: var(--surface); font-size: 12px; line-height: 18px; text-align: center; }
.panel { display: grid; gap: 18px; }
.head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.head .meta, .meta { color: var(--muted); font-size: 13px; }
.tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tools select { width: auto; }

/* rows: list items that work on phones and desktops */
.rows { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.row { display: grid; grid-template-columns: 92px 1fr auto; gap: 4px 14px; padding: 12px 16px; border-top: 1px solid var(--line); align-items: start; }
.row:first-child { border-top: 0; }
.row .date { color: var(--muted); font-size: 13px; white-space: nowrap; padding-top: 2px; }
.row .body { min-width: 0; display: grid; gap: 2px; }
.row .title { font-weight: 500; overflow-wrap: anywhere; }
.row .small, .small { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.row .money { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; display: grid; gap: 2px; justify-items: end; }
.row .acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
@media (max-width: 560px) {
  .row { grid-template-columns: 1fr auto; }
  .row .date { grid-column: 1 / -1; padding: 0; }
}
.list { display: grid; gap: 0; }
.list .li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.list .li:first-child { border-top: 0; }
.list .li > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.list .li > span:last-child { font-family: var(--font-mono); white-space: nowrap; flex: none; }
.empty { padding: 20px 16px; color: var(--muted); text-align: center; }

.plus { color: var(--accent); }
.minus { color: var(--danger); }
.none { color: var(--muted); }
.sku { display: inline-block; font: 500 12px/1 var(--font-mono); padding: 4px 7px; border-radius: 5px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; white-space: nowrap; margin-right: 6px; }
.pill.ok { background: var(--accent-soft); color: var(--accent); }
.pill.wait { background: var(--warn-soft); color: var(--warn); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.mute { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }

/* listing cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.lcard { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: grid; grid-template-rows: auto 1fr; color: inherit; text-decoration: none; }
.lcard .ph { aspect-ratio: 4 / 3; background: var(--bg); display: grid; place-items: center; overflow: hidden; }
.lcard .ph img { width: 100%; height: 100%; object-fit: contain; }
.lcard .info { padding: 12px 14px; display: grid; gap: 6px; align-content: start; }
.lcard .t { font-weight: 500; font-size: 14px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.lcard .p { font: 600 18px var(--font-mono); }
.lcard .stats { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12px; color: var(--muted); }
@media (max-width: 480px) { .cards { grid-template-columns: 1fr 1fr; gap: 10px; } .lcard .p { font-size: 16px; } }

form.entry { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
form.entry label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); min-width: 0; }
form.entry .span2 { grid-column: span 2; }
form.entry .span4 { grid-column: 1 / -1; }
@media (max-width: 760px) { form.entry { grid-template-columns: 1fr 1fr; } form.entry .span2 { grid-column: 1 / -1; } }
.hint { font-size: 13px; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
input, select { font: 16px var(--font-body); color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; width: 100%; }
input[type="file"] { padding: 6px; font-size: 14px; }
button, .button { font: 600 14px var(--font-body); border-radius: 8px; padding: 9px 14px; cursor: pointer; border: 1px solid transparent; text-decoration: none; display: inline-block; text-align: center; }
button:disabled { opacity: .6; cursor: default; }
.primary { background: var(--accent); color: var(--surface); }
.secondary { background: var(--surface); border-color: var(--line); color: var(--ink); }
.ghost { background: none; border-color: var(--line); color: var(--ink); padding: 5px 10px; font-size: 13px; }
.danger { background: none; border-color: var(--line); color: var(--danger); padding: 5px 10px; font-size: 13px; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.formmsg { font-size: 13px; color: var(--danger); }
.formmsg.ok { color: var(--accent); }
.formmsg:empty { display: none; }

.taxgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.card dl { margin: 0; display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; }
.card dt { color: var(--muted); }
.card dd { margin: 0; text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.card dt.total, .card dd.total { font-weight: 600; color: var(--ink); border-top: 1px solid var(--line); padding-top: 6px; }
.totals { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.totals div { display: grid; gap: 2px; }
.totals b { font: 600 18px var(--font-mono); }
.note, footer { color: var(--muted); font-size: 13px; max-width: 75ch; }
.review-item { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); }
.review-item:first-of-type { border-top: 0; }
