:root {
  --bg: #f6f2ea;
  --surface: #fffdf8;
  --surface-2: #efe9dd;
  --ink: #23211e;
  --ink-2: #6b665d;
  --line: #e2dbcd;
  --accent: #b8432b;
  --accent-ink: #ffffff;
  --ok: #4f7d4e;
  --warn: #b8432b;
  --p-zorunlu: #3d5a80;
  --p-istek: #c4572f;
  --p-kultur: #4f7d4e;
  --p-beklenmedik: #b88a12;
  --p-gelir: #6b665d;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(35, 33, 30, .06), 0 4px 16px rgba(35, 33, 30, .05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1a18; --surface: #252320; --surface-2: #2e2b27; --ink: #f1ece2; --ink-2: #a8a195;
    --line: #3a3631; --accent: #e0694d; --p-zorunlu: #7d9cc7; --p-istek: #e27c55; --p-kultur: #86b585;
    --p-beklenmedik: #d9ae3c; --p-gelir: #a8a195; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1b1a18; --surface: #252320; --surface-2: #2e2b27; --ink: #f1ece2; --ink-2: #a8a195;
  --line: #3a3631; --accent: #e0694d; --p-zorunlu: #7d9cc7; --p-istek: #e27c55; --p-kultur: #86b585;
  --p-beklenmedik: #d9ae3c; --p-gelir: #a8a195; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { font-size: calc(16px * var(--scale, 1)); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font);
  line-height: 1.45; min-height: 100dvh; -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.boot { display: grid; place-items: center; height: 100dvh; font-family: var(--serif); font-size: 2.5rem; color: var(--ink-2); }

.wrap { max-width: 560px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 12px) 16px calc(96px + env(safe-area-inset-bottom)); }
.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0 14px; }
.top h1 { font-family: var(--serif); font-weight: 600; font-size: 1.5rem; margin: 0; }
.top .sub { color: var(--ink-2); font-size: .85rem; }
.period-nav { display: flex; align-items: center; gap: 4px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 12px; }
.card h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); margin: 0 0 10px; font-weight: 600; }
.muted { color: var(--ink-2); }
.small { font-size: .85rem; }
.num { font-variant-numeric: tabular-nums; }
.big { font-size: 2.2rem; font-weight: 650; letter-spacing: -.02em; line-height: 1.1; }
.neg { color: var(--warn); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stack > * + * { margin-top: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.meter { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 10px 0 4px; display: flex; }
.meter > span { display: block; height: 100%; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }

.pillars { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pillar { border-radius: 12px; padding: 12px; background: var(--surface-2); border-left: 4px solid var(--c); }
.pillar .name { font-size: .8rem; color: var(--ink-2); }
.pillar .val { font-weight: 650; font-size: 1.1rem; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 11px 2px; border-bottom: 1px solid var(--line); cursor: pointer; }
.list li:last-child { border-bottom: 0; }
.list .meta { flex: 1; min-width: 0; }
.list .meta .t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .meta .s { font-size: .8rem; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .amt { font-weight: 600; white-space: nowrap; }
.list .amt.in { color: var(--ok); }
.day-h { font-size: .8rem; color: var(--ink-2); margin: 14px 2px 2px; display: flex; justify-content: space-between; }
.thumb { width: 36px; height: 36px; border-radius: 8px; object-fit: cover; flex: none; }

.btn { appearance: none; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 10px 14px; cursor: pointer; min-height: 44px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.block { width: 100%; }
.btn.danger { color: var(--warn); }
.btn:disabled { opacity: .5; }
.icon-btn { appearance: none; border: 0; background: transparent; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; color: var(--ink); }
.icon-btn:active, .btn:active { transform: scale(.97); }

label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-size: .8rem; color: var(--ink-2); margin-bottom: 4px; }
input.i, select.i, textarea.i { width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 11px 12px; min-height: 44px; }
textarea.i { min-height: 90px; resize: vertical; }
input.i:focus, select.i:focus, textarea.i:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 8px 6px; border-radius: 9px; cursor: pointer; font-size: .9rem; min-height: 38px; }
.seg button.on { background: var(--surface); box-shadow: var(--shadow); font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 7px 12px; cursor: pointer; font-size: .9rem; min-height: 36px; }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.pchip { border-color: var(--c); }
.pchip.on { background: var(--c); border-color: var(--c); color: #fff; }

/* Tutar ekranı + hesap makinesi */
.amount-display { text-align: right; padding: 8px 4px 12px; }
.amount-display .expr { color: var(--ink-2); min-height: 1.3em; font-size: .95rem; word-break: break-all; }
.amount-display .val { font-size: 2.6rem; font-weight: 650; letter-spacing: -.02em; }
.keypad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.keypad button { border: 0; background: var(--surface); border-radius: 12px; min-height: 54px; font-size: 1.3rem; cursor: pointer; box-shadow: var(--shadow); border: 1px solid var(--line); }
.keypad button.op { background: var(--surface-2); }
.keypad button.ok { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-size: 1rem; font-weight: 600; }

/* Takvim */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .wd { font-size: .7rem; text-align: center; color: var(--ink-2); padding: 2px 0; }
.cal .d { background: var(--surface); border: 1px solid var(--line); border-radius: 9px; min-height: 58px; padding: 4px; font-size: .75rem; cursor: pointer; display: flex; flex-direction: column; gap: 2px; text-align: left; }
.cal .d.out { opacity: .35; }
.cal .d.today { border-color: var(--accent); }
.cal .d.sel { outline: 2px solid var(--ink); }
.cal .d .n { font-weight: 600; }
.cal .d .sum { font-size: .68rem; margin-top: auto; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal .d .dots { display: flex; gap: 2px; flex-wrap: wrap; }
.cal .d .dots .dot { width: 6px; height: 6px; }

/* Çubuk grafik */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding-top: 8px; }
.bars .b { flex: 1; display: flex; flex-direction: column-reverse; border-radius: 6px 6px 0 0; overflow: hidden; min-width: 0; background: var(--surface-2); }
.bars .b span { display: block; }
.bars-l { display: flex; gap: 6px; font-size: .65rem; color: var(--ink-2); margin-top: 4px; }
.bars-l span { flex: 1; text-align: center; overflow: hidden; }

/* Alt menü */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabbar nav { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); align-items: center; }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 6px; text-decoration: none; color: var(--ink-2); font-size: .68rem; min-height: 56px; justify-content: center; }
.tabbar a.on { color: var(--ink); font-weight: 600; }
.tabbar a.add { color: var(--accent-ink); }
.tabbar a.add .plus { width: 50px; height: 50px; border-radius: 50%; background: var(--accent); display: grid; place-items: center; box-shadow: 0 4px 14px rgba(184, 67, 43, .35); }
.tabbar svg { width: 22px; height: 22px; }

#toast { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: .9rem; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 20; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; }
.banner { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; font-size: .85rem; margin-bottom: 12px; }
.empty { text-align: center; color: var(--ink-2); padding: 24px 8px; }
.auth { max-width: 400px; margin: 0 auto; padding: 12vh 16px 40px; }
.auth .logo { font-family: var(--serif); font-size: 3rem; text-align: center; }
.receipt-full { width: 100%; border-radius: 12px; margin-top: 8px; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
