:root {
  --bg: #f4f5f3; --card: #fff; --text: #1d2321; --muted: #6b7471; --line: #e3e6e3;
  --accent: #1f6f5c; --accent-soft: #e2f1ec; --danger: #b3261e; --warn: #9a6200; --warn-soft: #fff4dc;
  --radius: 14px; --nav-h: 64px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #121614; --card: #1c2220; --text: #e8ecea; --muted: #97a19d; --line: #2b3330;
    --accent: #5cc4a5; --accent-soft: #1d3a31; --danger: #ff8a80; --warn: #f2c063; --warn-soft: #3a2f16; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); -webkit-text-size-adjust: 100%; }
body { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px); }
.top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px; background: var(--bg); border-bottom: 1px solid var(--line); }
.top h1 { font-size: 20px; margin: 0; }
#who { font-size: 13px; color: var(--muted); }
main { max-width: 640px; margin: 0 auto; padding: 16px; }
.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.card h2 { font-size: 16px; margin: 0 0 12px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
input, select, textarea { width: 100%; font-size: 17px; padding: 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--text); font-family: inherit; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
textarea { min-height: 70px; resize: vertical; }
.row { display: flex; gap: 10px; } .row > * { flex: 1; min-width: 0; }
button { font: inherit; cursor: pointer; }
.btn { display: block; width: 100%; margin-top: 16px; padding: 14px; font-size: 17px; font-weight: 600; border: 0; border-radius: 12px;
  background: var(--accent); color: #fff; }
.btn.secondary { background: var(--accent-soft); color: var(--accent); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn.small { display: inline-block; width: auto; padding: 8px 12px; font-size: 14px; margin: 0; }
.seg { display: flex; background: var(--bg); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 10px 6px; border-radius: 8px; color: var(--muted); font-size: 15px; }
.seg button.on { background: var(--card); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.1); }
.big-km { text-align: center; font-size: 34px; font-weight: 700; margin: 14px 0 0; color: var(--accent); }
.big-km small { display: block; font-size: 13px; font-weight: 400; color: var(--muted); }
.hint { font-size: 13px; padding: 8px 10px; border-radius: 8px; margin-top: 8px; background: var(--warn-soft); color: var(--warn); }
.muted { color: var(--muted); } .center { text-align: center; }
.item { display: flex; justify-content: space-between; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item .l { min-width: 0; } .item .r { text-align: right; white-space: nowrap; }
.item .t { font-weight: 600; } .item .s { font-size: 13px; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.item.click { cursor: pointer; }
.pill { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); margin-left: 4px; }
.pill.gray { background: var(--line); color: var(--muted); }
.amount { font-weight: 700; font-variant-numeric: tabular-nums; }
.pos { color: var(--accent); } .neg { color: var(--danger); }
table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 4px; border-bottom: 1px solid var(--line); text-align: right; }
th:first-child, td:first-child { text-align: left; }
th { font-size: 12px; color: var(--muted); font-weight: 500; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--bg); border-radius: 10px; padding: 10px; }
.stat b { display: block; font-size: 18px; } .stat span { font-size: 12px; color: var(--muted); }
.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); }
.tabs button { flex: 1; height: var(--nav-h); border: 0; background: none; color: var(--muted); font-size: 11px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.tabs button span { font-size: 20px; line-height: 1; }
.tabs button.on { color: var(--accent); font-weight: 600; }
#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 14px); z-index: 20;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 99px; font-size: 14px; max-width: 90vw; }
#toast.err { background: var(--danger); color: #fff; }
.check { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-size: 15px; color: var(--text); }
.check input { width: 22px; height: 22px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chips button { border: 1px solid var(--line); background: var(--card); color: var(--text); padding: 6px 10px; border-radius: 99px; font-size: 13px; }
details summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.chips button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.item summary .s { font-weight: 400; }
.item summary .pill:first-child { margin-left: 0; }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
