:root {
  --bg: #f4f5f2;
  --surface: #ffffff;
  --surface-2: #eef0ec;
  --text: #1b1f1d;
  --muted: #66706b;
  --line: #dfe3dd;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --accent-soft: #d8efe9;
  --pos: #12804a;
  --neg: #c2410c;
  --warn-bg: #fff4d6;
  --warn-ink: #7a5300;
  --danger: #b91c1c;
  --radius: 14px;
  --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: #121514;
    --surface: #1b1f1d;
    --surface-2: #252a27;
    --text: #e8ebe9;
    --muted: #97a19c;
    --line: #2f3532;
    --accent: #2dd4bf;
    --accent-ink: #062b27;
    --accent-soft: #163a35;
    --pos: #4ade80;
    --neg: #fb923c;
    --warn-bg: #3a2f12;
    --warn-ink: #f5d27a;
    --danger: #f87171;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { padding: 40px; text-align: center; color: var(--muted); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.right { text-align: right; }
.row { display: flex; align-items: center; gap: 8px; }
.row.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.hidden { display: none !important; }

/* ---- üst çubuk */
.top {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  display: flex; align-items: center; gap: 10px;
}
.top h1 { font-size: 18px; margin: 0; flex: 1; font-weight: 650; letter-spacing: -.01em; }
.top .back { font-size: 22px; line-height: 1; padding: 4px 8px 4px 0; color: var(--text); }
.iconbtn { background: none; border: 0; padding: 6px; border-radius: 10px; cursor: pointer; color: var(--muted); font-size: 14px; }
.iconbtn:hover { background: var(--surface-2); }

main { max-width: 720px; margin: 0 auto; padding: 14px 16px 24px; }

/* ---- alt menü */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--surface); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); font-size: 11px; padding: 4px 0; border-radius: 10px; }
.nav a svg { width: 22px; height: 22px; }
.nav a.on { color: var(--accent); font-weight: 600; }
.nav a.add { color: var(--accent-ink); }
.nav a.add span.plus {
  width: 46px; height: 46px; margin-top: -18px; border-radius: 50%;
  background: var(--accent); display: grid; place-items: center; box-shadow: 0 4px 14px rgba(15,118,110,.35);
}
.nav a.add span.plus svg { width: 26px; height: 26px; }
@media (min-width: 900px) {
  body { padding-bottom: 0; padding-left: 200px; }
  .nav { top: 0; right: auto; width: 200px; grid-template-columns: 1fr; align-content: start; gap: 4px; border-top: 0; border-right: 1px solid var(--line); padding: 70px 10px 10px; }
  .nav a { flex-direction: row; gap: 10px; font-size: 14px; padding: 9px 12px; }
  .nav a.on { background: var(--accent-soft); }
  .nav a.add { order: -1; background: var(--accent); color: var(--accent-ink); margin-bottom: 10px; }
  .nav a.add span.plus { width: auto; height: auto; margin: 0; background: none; box-shadow: none; }
  .nav a.add span.plus svg { width: 20px; height: 20px; }
  .top { padding-left: 24px; }
}

/* ---- kartlar */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 14px; }
.card h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 10px; font-weight: 600; }
.card h2 .row { justify-content: space-between; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush h2 { padding: 14px 14px 0; }
.hero { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hero .stat { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.hero .stat .lbl { font-size: 12px; color: var(--muted); }
.hero .stat .val { font-size: 20px; font-weight: 650; margin-top: 2px; }
.stats3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stats3 .stat { background: var(--surface-2); border-radius: 12px; padding: 8px 10px; }
.stats3 .lbl { font-size: 12px; color: var(--muted); }
.stats3 .val { font-weight: 650; font-size: 16px; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list li.click { cursor: pointer; }
.list li.click:hover { background: var(--surface-2); }
.list .t { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .s { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .amt { text-align: right; font-weight: 600; }
.badge { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 99px; background: var(--surface-2); color: var(--muted); font-weight: 600; vertical-align: 1px; }
.badge.acc { background: var(--accent-soft); color: var(--accent); }
.badge.warn { background: var(--warn-bg); color: var(--warn-ink); }
.ico { width: 34px; height: 34px; flex: none; border-radius: 10px; display: grid; place-items: center; font-size: 15px; font-weight: 700; }
.ico.expense { background: color-mix(in srgb, var(--neg) 14%, transparent); color: var(--neg); }
.ico.income { background: color-mix(in srgb, var(--pos) 14%, transparent); color: var(--pos); }
.ico.transfer { background: var(--accent-soft); color: var(--accent); }

.pair { display: flex; align-items: center; gap: 8px; padding: 9px 0; border-top: 1px solid var(--line); }
.pair:first-child { border-top: 0; }
.pair .arrow { color: var(--muted); }
.empty { color: var(--muted); padding: 6px 0; font-size: 14px; }
.list .empty { padding: 14px; }

/* ---- form */
.field { margin-bottom: 14px; }
.field > label, .lbl2 { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input:not([type]), select, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { min-height: 70px; resize: vertical; }
.amount-input { font-size: 28px !important; font-weight: 650; padding: 10px 12px !important; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 7px 13px; cursor: pointer; font-size: 14px;
  user-select: none; -webkit-tap-highlight-color: transparent;
}
.chip small { color: var(--muted); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip.on small { color: inherit; opacity: .8; }
.chip:disabled { opacity: .5; cursor: default; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 3px; margin-bottom: 16px; }
.seg button { border: 0; background: none; padding: 9px 6px; border-radius: 9px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); border-radius: 11px; padding: 10px 16px; cursor: pointer; font-weight: 600; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; padding: 13px; font-size: 16px; }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 9px; }
.btn:disabled { opacity: .55; cursor: default; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.preview { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; font-size: 14px; margin-bottom: 14px; }
.preview .pair { padding: 5px 0; border-color: transparent; }
.note { background: var(--warn-bg); color: var(--warn-ink); border-radius: 12px; padding: 10px 12px; font-size: 14px; margin-bottom: 14px; }
.err { color: var(--danger); font-size: 14px; margin: 8px 0; min-height: 1em; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.filters select, .filters input { padding: 8px 10px; font-size: 14px; }

table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: right; font-weight: 600; color: var(--muted); font-size: 12px; padding: 6px 4px; border-bottom: 1px solid var(--line); }
table.t th:first-child, table.t td:first-child { text-align: left; }
table.t td { text-align: right; padding: 8px 4px; border-bottom: 1px solid var(--line); }
table.t tr:last-child td { border-bottom: 0; }
.scroll-x { overflow-x: auto; }

.login { max-width: 360px; margin: 12vh auto 0; padding: 0 16px; }
.login .logo { width: 56px; height: 56px; margin-bottom: 14px; }
.login h1 { margin: 0 0 18px; font-size: 24px; }

#toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none;
  transition: .2s; z-index: 50; max-width: calc(100% - 32px);
}
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.bad { background: var(--danger); color: #fff; }

details.hist summary { cursor: pointer; color: var(--muted); font-size: 13px; }
details.hist ul { padding-left: 18px; font-size: 13px; color: var(--muted); }
