:root {
  --bg: #f4f6f4;
  --panel: #ffffff;
  --ink: #18201c;
  --muted: #5f6b65;
  --line: #dfe5e1;
  --accent: #0b7a5c;
  --accent-ink: #ffffff;
  --accent-soft: #e2f3ec;
  --warn: #a8610b;
  --warn-soft: #fcf0dc;
  --bad: #b3261e;
  --bad-soft: #fbe5e3;
  --info: #2457a6;
  --info-soft: #e5edfa;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111513;
    --panel: #1a201d;
    --ink: #e8eeea;
    --muted: #98a59e;
    --line: #2c3530;
    --accent: #3fc79c;
    --accent-ink: #062018;
    --accent-soft: #163329;
    --warn: #e9a447;
    --warn-soft: #3a2a12;
    --bad: #f2867e;
    --bad-soft: #3d1c1a;
    --info: #86aef0;
    --info-soft: #1a2740;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 .75em; }
small, .muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

/* ---- Layout */
.top {
  position: sticky; top: 0; z-index: 5;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.top-inner {
  max-width: 1080px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.brand { font-weight: 750; font-size: 1.1rem; display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-size: .9rem; }
.top select { margin-left: auto; }
nav.tabs {
  max-width: 1080px; margin: 0 auto; padding: 0 16px;
  display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none;
}
nav.tabs a {
  padding: 10px 12px; text-decoration: none; color: var(--muted); white-space: nowrap;
  border-bottom: 2px solid transparent; font-weight: 550; font-size: .95rem;
}
nav.tabs a.on { color: var(--ink); border-color: var(--accent); }
main { max-width: 1080px; margin: 0 auto; padding: 20px 16px 64px; }

.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); min-width: 0;
}
.card + .card, .stack > * + * { margin-top: 16px; }
.grid > .card + .card, .grid-2 > .card + .card { margin-top: 0; }
.stat-label { color: var(--muted); font-size: .85rem; font-weight: 550; }
.stat { font-size: 1.8rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; flex-wrap: wrap; }

/* ---- Forms */
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.hint { font-weight: 400; color: var(--muted); font-size: .85rem; display: block; }
input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=month], select, textarea {
  width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); min-height: 42px;
}
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.top select { width: auto; min-height: 36px; padding: 4px 8px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; }
.check input { width: 20px; height: 20px; margin-top: 2px; flex: none; accent-color: var(--accent); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; min-height: 42px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel); cursor: pointer; font-weight: 600; text-decoration: none; color: var(--ink);
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--bad); }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: .88rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--panel); padding: 8px 14px; cursor: pointer; font-weight: 600; min-height: 40px; }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
.form-grid { display: grid; gap: 0 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

/* ---- Notices */
.note { border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; border: 1px solid transparent; }
.note > :last-child { margin-bottom: 0; }
.note.info { background: var(--info-soft); }
.note.warn { background: var(--warn-soft); }
.note.bad { background: var(--bad-soft); }
.note.good { background: var(--accent-soft); }
.badge { display: inline-block; font-size: .75rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }

/* ---- Tables & lists */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .82rem; }
td.amt, th.amt { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.total td { font-weight: 700; border-bottom: 0; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.date-chip { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 92px; display: inline-block; }

progress, meter { width: 100%; height: 10px; accent-color: var(--accent); }

/* ---- Setup steps */
.step { display: flex; gap: 12px; }
.step-dot {
  flex: none; width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--line);
  display: grid; place-items: center; font-weight: 700; font-size: .85rem; color: var(--muted);
}
.step.done .step-dot { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.step-body { flex: 1; min-width: 0; }
details { border-top: 1px solid var(--line); padding: 10px 0; }
details:first-of-type { border-top: 0; }
summary { cursor: pointer; font-weight: 650; }
details[open] summary { margin-bottom: 8px; }
pre { white-space: pre-wrap; word-break: break-word; font-size: .8rem; background: var(--bg); padding: 10px; border-radius: 8px; max-height: 360px; overflow: auto; }

/* ---- Auth */
.auth { max-width: 420px; margin: 8vh auto; padding: 0 16px; }
.auth .brand { justify-content: center; font-size: 1.5rem; margin-bottom: 8px; }

.toast {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 20;
  max-width: calc(100% - 32px); box-shadow: var(--shadow);
}
.hidden { display: none !important; }

@media (max-width: 560px) {
  .stat { font-size: 1.5rem; }
  .hide-sm { display: none; }
  .top select { margin-left: 0; }
}
td select { min-width: 150px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.file-btn { position: relative; }
.file-btn:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.receipt-preview { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.receipt-preview img { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); }
.receipt-pdf { width: 96px; height: 96px; border-radius: 8px; border: 1px solid var(--line); display: grid; place-items: center; font-weight: 700; color: var(--muted); }
