:root {
  --bg: #0b0f0d;
  --surface: #141a17;
  --surface-2: #1c2420;
  --line: #26302b;
  --text: #eef3f0;
  --muted: #8b9a92;
  --accent: #22d36b;
  --accent-ink: #04140a;
  --accent-soft: rgba(34, 211, 107, .14);
  --warn: #f5b13d;
  --danger: #ff5c5c;
  --danger-soft: rgba(255, 92, 92, .14);
  --income: #22d36b;
  --expense: #eef3f0;
  --radius: 16px;
  --radius-sm: 10px;
  --gap: 12px;
  --pad: 16px;
  --tabs-h: 64px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); -webkit-font-smoothing: antialiased; }
body { padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 24px); min-height: 100vh; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: 12px var(--pad); background: linear-gradient(var(--bg) 70%, transparent); }
.top h1 { margin: 0; font-size: 17px; font-weight: 600; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface);
  font-size: 22px; line-height: 1; }
.icon-btn:disabled { opacity: .35; cursor: default; }

main { padding: 0 var(--pad); max-width: 640px; margin: 0 auto; display: grid; gap: var(--gap); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--pad); }
.card h2 { margin: 0 0 10px; font-size: 13px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.hero { background: radial-gradient(120% 120% at 100% 0, var(--accent-soft), transparent 60%), var(--surface); }
.big { font-size: 34px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.big small { font-size: 15px; font-weight: 500; color: var(--muted); margin-left: 4px; }
.sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); margin-top: 14px; }
.stat { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; }
.stat b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); }
.up { color: var(--danger); } .down { color: var(--accent); }
.pos { color: var(--income); }

.chart svg { width: 100%; height: 140px; display: block; }
.chart svg { overflow: visible; touch-action: pan-y; }
.chart-hit { fill: transparent; cursor: crosshair; }
.chart-hit:focus { outline: none; }
.chart-hit:focus-visible { fill: rgba(34, 211, 107, .08); }
.chart-guide { stroke: var(--text); stroke-width: 1; stroke-dasharray: 3 3; opacity: .42; pointer-events: none; }
.chart-point { stroke: var(--surface); stroke-width: 2; pointer-events: none; }
.chart-point-current { fill: var(--accent); }
.chart-point-previous { fill: var(--muted); }
.chart-info { min-height: 38px; display: flex; align-items: center; flex-wrap: wrap; gap: 7px 14px;
  padding: 8px 10px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: 12px; color: var(--muted); }
.chart-info b { color: var(--text); font-weight: 600; }
.chart-info span { white-space: nowrap; }
.chart-key { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; }
.chart-key.current { background: var(--accent); }
.chart-key.previous { background: var(--muted); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 5px; }

.alert { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--danger-soft); color: var(--text); font-size: 14px; }
.alert.warn { background: rgba(245, 177, 61, .14); }

.list { display: grid; grid-template-columns: minmax(0, 1fr); }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line);
  background: none; border-left: 0; border-right: 0; border-top: 0; width: 100%; text-align: left; }
.row:last-child { border-bottom: 0; }
.ico { width: 38px; height: 38px; flex: none; border-radius: 12px; background: var(--surface-2); display: grid; place-items: center; font-size: 18px; }
.row .main { flex: 1; min-width: 0; }
.row .t { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .s { font-size: 12px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .amt { font-family: var(--mono); font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }

.bar { height: 6px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.bar.warn > i { background: var(--warn); } .bar.over > i { background: var(--danger); }

.day { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin: 14px 2px 2px; text-transform: uppercase; letter-spacing: .04em; }

.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.chip { flex: none; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: 14px; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }

.search { width: 100%; padding: 11px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); }

.empty { text-align: center; color: var(--muted); padding: 32px 12px; font-size: 14px; line-height: 1.5; }
.empty b { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; }
.skel { border-radius: var(--radius); background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%);
  background-size: 200% 100%; animation: shimmer 1.2s infinite linear; }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skel { animation: none; } }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; padding: 0 18px;
  border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface-2); font-weight: 600; width: 100%; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--danger); }
.btn.ghost { background: none; }
.btn.sm { min-height: 34px; padding: 0 12px; width: auto; font-size: 13px; }
.btns { display: grid; gap: 8px; }
.btns.two { grid-template-columns: 1fr 1fr; }

.fab { position: fixed; right: 18px; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 16px); z-index: 6;
  width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink);
  font-size: 30px; line-height: 1; box-shadow: var(--shadow); }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
.tabs button { background: none; border: 0; color: var(--muted); font-size: 11px; display: grid; place-items: center; align-content: center; gap: 2px; }
.tabs button span { font-size: 20px; line-height: 1; }
.tabs button.active { color: var(--accent); }

.sheet-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 20; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-height: 88vh; overflow-y: auto;
  background: var(--surface); border-radius: 22px 22px 0 0; padding: 10px var(--pad) calc(var(--pad) + env(safe-area-inset-bottom));
  box-shadow: var(--shadow); max-width: 640px; margin: 0 auto; animation: up .22s cubic-bezier(.2, .8, .2, 1); }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }
.sheet .grip { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 12px; }
.sheet h3 { margin: 0 0 14px; font-size: 18px; }
.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 13px; color: var(--muted); }
.field input, .field select { width: 100%; padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface-2); }
.amount-input { font-size: 28px !important; font-weight: 700; font-family: var(--mono); }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); border-radius: var(--radius-sm); padding: 3px; margin-bottom: 12px; }
.seg button { border: 0; background: none; padding: 9px; border-radius: 8px; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); font-weight: 600; }
.cat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.cat-grid button { border: 1px solid var(--line); background: var(--surface-2); border-radius: var(--radius-sm); padding: 8px 2px; font-size: 11px; display: grid; gap: 2px; place-items: center; }
.cat-grid button span { font-size: 20px; }
.cat-grid button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }

.toast { position: fixed; left: 50%; bottom: calc(var(--tabs-h) + 90px); transform: translateX(-50%); z-index: 30;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px; box-shadow: var(--shadow); max-width: 90vw; }

.debt-tot { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--gap); }
.debt-tot h2 { text-transform: none; letter-spacing: 0; }
.row .btn.sm { flex: none; }
main > *, .split > * { min-width: 0; }
.muted { color: var(--muted); }
.settled { opacity: .5; }

@media (min-width: 900px) {
  main { max-width: 720px; }
  .sheet { bottom: auto; top: 50%; transform: translateY(-50%); border-radius: 22px; }
}

.kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.kv .stat b { font-size: 20px; }
.notice { font-size: 13px; color: var(--muted); line-height: 1.5; margin: 0 0 12px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; background: var(--surface-2); color: var(--muted); }
.badge.on { background: var(--accent-soft); color: var(--accent); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.switch-row input { width: 44px; height: 24px; accent-color: var(--accent); }
textarea { width: 100%; min-height: 110px; padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text); font: inherit; resize: vertical; }
