/* Defter: tek sistem, nötr arayüz, tek vurgu rengi */
:root {
  --bg: #ffffff;
  --surface: #f4f4f4;
  --surface-2: #ebebeb;
  --ink: #111111;
  --muted: #5c5c5c;
  --line: rgba(17, 17, 17, 0.13);
  --line-strong: rgba(17, 17, 17, 0.24);
  --accent: #1a4be0;
  --accent-hover: #143bb5;
  --on-accent: #ffffff;
  --neg: #b42318;
  --warn: #9a5b00;
  --pos: #1d7a3f;
  --focus: #1a4be0;
  --scrim: rgba(17, 17, 17, 0.32);

  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 8px;

  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 64px;

  --nav: 64px;
  --gut: 32px;
  --tab: 0px;

  --t-h1: 28px;
  --t-fig: 44px;
  --t-stat: 22px;
  --t-body: 16px;
  --t-small: 14px;
  --t-label: 13px;

  --font: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141414; --surface: #1d1d1d; --surface-2: #262626; --ink: #f1f1ef; --muted: #a6a6a2;
    --line: rgba(241, 241, 239, 0.12); --line-strong: rgba(241, 241, 239, 0.24);
    --accent: #6f8fff; --accent-hover: #8aa4ff; --on-accent: #0c1433;
    --neg: #ff8a7a; --warn: #e8b05c; --pos: #6fcf8f; --focus: #8aa4ff; --scrim: rgba(0, 0, 0, 0.55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141414; --surface: #1d1d1d; --surface-2: #262626; --ink: #f1f1ef; --muted: #a6a6a2;
  --line: rgba(241, 241, 239, 0.12); --line-strong: rgba(241, 241, 239, 0.24);
  --accent: #6f8fff; --accent-hover: #8aa4ff; --on-accent: #0c1433;
  --neg: #ff8a7a; --warn: #e8b05c; --pos: #6fcf8f; --focus: #8aa4ff; --scrim: rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 400 var(--t-body)/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
  padding-bottom: var(--tab);
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: var(--t-h1); font-weight: 500; letter-spacing: -0.02em; line-height: 1.2; }
h2 { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.3; }
h3 { font-size: var(--t-body); font-weight: 600; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: var(--gut); top: -100px; background: var(--bg); padding: var(--s-2) var(--s-3); z-index: 30; border: 1px solid var(--line-strong); border-radius: var(--r-md); }
.skip-link:focus { top: 12px; }

.wrap { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 var(--gut); }

/* ---------- Üst çubuk ---------- */
.top {
  position: fixed; inset: 0 0 auto 0; height: var(--nav); z-index: 10;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.top__in { height: 100%; display: flex; align-items: center; gap: var(--s-5); }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-size: 19px; font-weight: 600; letter-spacing: -0.02em; white-space: nowrap; }
.mark { width: 26px; height: 26px; border-radius: var(--r-md); background: var(--ink); color: var(--bg); display: grid; place-items: center; font-size: 15px; font-weight: 600; }
.nav { display: flex; gap: var(--s-1); flex: 1; }
.nav a {
  position: relative; display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 var(--s-3);
  color: var(--muted); font-size: 15px; font-weight: 500; border-radius: var(--r-md); white-space: nowrap;
  transition: color .15s, background-color .15s;
}
.nav a:hover { color: var(--ink); background: var(--surface); }
.nav a[aria-current="page"] { color: var(--ink); }
.nav a[aria-current="page"]::after { content: ""; position: absolute; left: var(--s-3); right: var(--s-3); bottom: -12px; height: 2px; background: var(--ink); }
.count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--surface-2); color: var(--ink); font-size: 12px; font-weight: 600; display: inline-grid; place-items: center; }
.count[hidden], [hidden] { display: none !important; }
.top__right { display: flex; align-items: center; gap: var(--s-3); margin-left: auto; }

.month { display: flex; align-items: center; border: 1px solid var(--line-strong); border-radius: var(--r-md); height: 44px; }
.month button { width: 40px; height: 42px; border: 0; background: none; cursor: pointer; display: grid; place-items: center; color: var(--ink); border-radius: var(--r-md); }
.month button:hover { background: var(--surface); }
.month__label { min-width: 116px; text-align: center; font-weight: 500; font-size: 15px; padding: 0 var(--s-1); border: 0; background: none; cursor: pointer; height: 42px; }
.month__label:hover { background: var(--surface); }

/* ---------- Butonlar ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  height: 44px; padding: 0 var(--s-5); border-radius: var(--r-md); border: 1px solid transparent;
  font-size: 15px; font-weight: 500; cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background-color .15s, border-color .15s, color .15s, transform .08s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn--primary { background: var(--accent); color: var(--on-accent); }
.btn--primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn--secondary { background: var(--bg); border-color: var(--line-strong); color: var(--ink); }
.btn--secondary:hover:not(:disabled) { background: var(--surface); border-color: var(--ink); }
.btn--danger { background: var(--bg); border-color: var(--line-strong); color: var(--neg); }
.btn--danger:hover:not(:disabled) { border-color: var(--neg); }
.btn--sm { height: 36px; padding: 0 var(--s-3); font-size: 14px; }
.btn--icon { width: 36px; padding: 0; }
.btn--done { background: var(--surface); color: var(--pos); border-color: transparent; }
.btn--done:hover:not(:disabled) { background: var(--surface-2); }
.btn-row { display: flex; gap: var(--s-3); flex-wrap: wrap; }
.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-weight: 500; font-size: 14px; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }
.icon { width: 20px; height: 20px; flex: none; }
.icon--sm { width: 16px; height: 16px; }

/* ---------- Sayfa ---------- */
.main { padding-top: calc(var(--nav) + var(--s-6)); padding-bottom: var(--s-8); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; margin-bottom: var(--s-5); }
.page-head p { margin-top: var(--s-1); color: var(--muted); }

.grid { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: var(--s-5); align-items: start; }
.stack { display: grid; gap: var(--s-5); min-width: 0; }

.card { background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-lg); min-width: 0; }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-4) var(--s-5); }
.card__head p { font-size: var(--t-small); color: var(--muted); }
.card__body { padding: 0 var(--s-5) var(--s-5); }
.card__foot { padding: var(--s-3) var(--s-5); border-top: 1px solid var(--line); }

/* Özet şeridi */
.hero { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: var(--s-5); align-items: end; margin-bottom: var(--s-6); }
.hero__label { font-size: var(--t-small); color: var(--muted); font-weight: 500; }
.figure { font-size: var(--t-fig); font-weight: 500; letter-spacing: -0.035em; line-height: 1.1; margin-top: var(--s-1); }
.figure.is-neg { color: var(--neg); }
.hero__sub { margin-top: var(--s-2); color: var(--muted); font-size: var(--t-small); }
.ledger { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0; border-top: 1px solid var(--line); }
.ledger > div { padding: var(--s-3) var(--s-4) 0 0; }
.ledger > div + div { padding-left: var(--s-4); border-left: 1px solid var(--line); }
.ledger dt { font-size: var(--t-label); color: var(--muted); font-weight: 500; }
.ledger dd { margin: 2px 0 0; font-size: var(--t-stat); font-weight: 500; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ledger .is-neg { color: var(--neg); }

/* Satır listeleri */
.rows { list-style: none; margin: 0; padding: 0; }
.row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: var(--s-4);
  padding: var(--s-3) var(--s-5); border-top: 1px solid var(--line); min-height: 64px;
}
button.row { width: 100%; background: none; border: 0; border-top: 1px solid var(--line); text-align: left; font: inherit; color: inherit; grid-template-columns: minmax(0, 1fr) auto; }
.row--click { cursor: pointer; transition: background-color .15s; }
.row--click:hover { background: var(--surface); }
.row__title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__meta { font-size: var(--t-small); color: var(--muted); display: flex; flex-wrap: wrap; gap: 2px var(--s-2); margin-top: 2px; }
.row__meta > * + *::before { content: "·"; margin-right: var(--s-2); color: var(--muted); }
.row__amt { font-weight: 500; text-align: right; white-space: nowrap; }
.row__amt small { display: block; font-size: var(--t-label); color: var(--muted); font-weight: 400; }
.row__act { display: flex; gap: var(--s-2); justify-content: flex-end; }
.row.is-paid .row__title, .row.is-paid .row__amt { color: var(--muted); }
.amt-in { color: var(--pos); }
.sub-row { grid-template-columns: minmax(0, 1fr) auto auto; padding-left: var(--s-7); min-height: 56px; }

.group + .group { margin-top: var(--s-5); }
.group__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); padding: var(--s-4) var(--s-5); flex-wrap: wrap; }
.group__head h2 { display: flex; align-items: baseline; gap: var(--s-2); }
.group__head h2 .muted { font-weight: 400; font-size: var(--t-small); }
.group__sum { font-size: var(--t-small); color: var(--muted); }
.group__sum b { color: var(--ink); font-weight: 600; }

.status { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.st-overdue, .st-today { color: var(--neg); }
.st-tomorrow, .st-urgent { color: var(--warn); }
.st-soon { color: var(--ink); }
.st-planned { color: var(--muted); }
.st-paid, .st-done { color: var(--pos); }
.st-missing { color: var(--accent); }

.tag { font-size: var(--t-label); color: var(--muted); font-weight: 400; margin-left: var(--s-2); }

.empty { padding: var(--s-6) var(--s-5); text-align: center; color: var(--muted); border-top: 1px solid var(--line); }
.empty p + .btn, .empty p + .btn-row { margin-top: var(--s-4); }
.empty .btn-row { justify-content: center; }

/* Kategoriler */
.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-4); }
.bar__top { display: flex; justify-content: space-between; gap: var(--s-3); font-size: var(--t-small); }
.bar__top span:first-child { font-weight: 500; }
.bar__track { height: 6px; border-radius: 3px; background: var(--surface-2); margin-top: 6px; overflow: hidden; }
.bar__fill { height: 100%; background: var(--ink); border-radius: 3px; }
.bars li:first-child .bar__fill { background: var(--accent); }

.kv { margin: 0; display: grid; gap: 0; }
.kv > div { display: flex; justify-content: space-between; gap: var(--s-3); padding: var(--s-3) 0; border-top: 1px solid var(--line); }
.kv > div:first-child { border-top: 0; padding-top: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; text-align: right; }

/* Filtreler */
.toolbar { display: flex; gap: var(--s-3); flex-wrap: wrap; align-items: center; margin-bottom: var(--s-5); }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r-md); padding: 3px; gap: 2px; flex-wrap: wrap; background: var(--bg); }
.seg button {
  height: 34px; padding: 0 var(--s-3); border: 0; border-radius: var(--r-sm); background: none; cursor: pointer;
  font-size: 14px; font-weight: 500; color: var(--muted); white-space: nowrap; transition: background-color .15s, color .15s;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.seg--full { display: flex; }
.seg--full button { flex: 1; }

/* Form */
.field { display: grid; gap: 6px; }
.field + .field, .field + .field-row, .field-row + .field, .field-row + .field-row, .seg + .field, .field + .seg, .hint + .field { margin-top: var(--s-4); }
.field label, .field .label { font-size: var(--t-small); font-weight: 500; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); align-items: start; }
.field-row > .field + .field { margin-top: 0; }
.seg + input[type=hidden] + .field, .seg + input[type=hidden] + .field-row, .seg + input[type=hidden] + [data-fields] { margin-top: var(--s-4); }
.field[data-field] + .field:not([data-field]) { margin-top: var(--s-4); }
.input, select.input, textarea.input {
  width: 100%; height: 48px; padding: 0 var(--s-3); border: 1px solid var(--line-strong); border-radius: var(--r-md);
  background: var(--bg); font-size: 16px; transition: border-color .15s;
}
textarea.input { height: auto; min-height: 76px; padding: var(--s-3); resize: vertical; }
.input:hover { border-color: var(--muted); }
.input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 1px var(--focus); }
.input--search { height: 44px; max-width: 280px; }
.hint { font-size: var(--t-small); color: var(--muted); }
.check { display: flex; align-items: center; gap: var(--s-2); font-size: 15px; min-height: 44px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.preview { margin-top: var(--s-4); padding: var(--s-3) var(--s-4); background: var(--surface); border-radius: var(--r-md); font-size: 15px; }
.preview b { font-weight: 600; }
.form-actions { display: flex; gap: var(--s-3); flex-wrap: wrap; margin-top: var(--s-5); }
.form-error { color: var(--neg); font-size: var(--t-small); margin-top: var(--s-3); min-height: 0; }
.chips { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.chip { height: 34px; padding: 0 var(--s-3); border: 1px solid var(--line-strong); background: var(--bg); border-radius: var(--r-md); cursor: pointer; font-size: 14px; transition: border-color .15s, background-color .15s; }
.chip:hover { border-color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.quick .seg { margin-bottom: var(--s-4); }

/* ---------- Panel (dialog) ---------- */
dialog.sheet {
  border: 0; padding: 0; margin: 0 0 0 auto; height: 100dvh; max-height: 100dvh; width: min(460px, 100vw); max-width: 100vw;
  background: var(--bg); color: var(--ink); border-left: 1px solid var(--line);
}
dialog.sheet::backdrop { background: var(--scrim); }
dialog.sheet[open] { animation: sheet-in .22s cubic-bezier(.2, .8, .2, 1); display: flex; flex-direction: column; }
@keyframes sheet-in { from { transform: translateX(24px); opacity: 0; } }
.sheet__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--line); }
.sheet__head p { color: var(--muted); font-size: var(--t-small); margin-top: 2px; }
.sheet__close { width: 44px; height: 44px; border: 0; background: none; border-radius: var(--r-md); cursor: pointer; display: grid; place-items: center; color: var(--ink); margin-right: -10px; }
.sheet__close:hover { background: var(--surface); }
.sheet__body { padding: var(--s-5); overflow-y: auto; flex: 1; }
.sheet__danger { margin-top: var(--s-6); padding-top: var(--s-5); border-top: 1px solid var(--line); display: grid; gap: var(--s-3); }
.sheet__danger p { font-size: var(--t-small); color: var(--muted); }

dialog.confirm { border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s-5); width: min(420px, calc(100vw - 32px)); background: var(--bg); color: var(--ink); }
dialog.confirm::backdrop { background: var(--scrim); }
dialog.confirm p { margin-top: var(--s-2); color: var(--muted); }

.menu-list { list-style: none; margin: 0; padding: 0; }
.menu-list button {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); min-height: 56px;
  padding: var(--s-2) 0; border: 0; border-top: 1px solid var(--line); background: none; cursor: pointer; text-align: left;
}
.menu-list li:first-child button { border-top: 0; }
.menu-list button:hover .menu-list__t { color: var(--accent); }
.menu-list__t { font-weight: 500; transition: color .15s; }
.menu-list__d { display: block; font-size: var(--t-small); color: var(--muted); }
.menu-group + .menu-group { margin-top: var(--s-5); }
.menu-group h3 { font-size: var(--t-label); color: var(--muted); font-weight: 500; margin-bottom: var(--s-1); }

/* Bildirim */
.toasts { position: fixed; left: 50%; bottom: calc(var(--tab) + 24px); transform: translateX(-50%); display: grid; gap: var(--s-2); z-index: 40; width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--ink); color: var(--bg); padding: var(--s-3) var(--s-4); border-radius: var(--r-md); font-size: 15px; animation: toast-in .2s ease-out; }
.toast--err { background: var(--neg); color: #fff; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

/* Giriş */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: var(--s-5) var(--s-4); }
.auth__box { width: min(400px, 100%); }
.auth__box .brand { margin-bottom: var(--s-6); }
.auth__box h1 { margin-bottom: var(--s-2); }
.auth__box > p { color: var(--muted); margin-bottom: var(--s-5); }
.auth__box .btn { width: 100%; margin-top: var(--s-5); height: 48px; }

/* Alt sekme çubuğu (telefon) */
.tabbar { display: none; }
.loading { padding: var(--s-8) 0; text-align: center; color: var(--muted); }

@media (max-width: 1080px) {
  .nav a { padding: 0 var(--s-2); }
  .hero { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  :root { --gut: 16px; --nav: 56px; --t-fig: 38px; --t-stat: 18px; --tab: calc(64px + env(safe-area-inset-bottom)); }
  .nav { display: none; }
  .brand__name { display: none; }
  .grid { grid-template-columns: 1fr; }
  .main { padding-top: calc(var(--nav) + var(--s-5)); }
  .top__in { gap: var(--s-3); }
  .top__right { flex: 1; justify-content: flex-end; }
  .month { flex: 1; max-width: 260px; }
  .month__label { flex: 1; min-width: 0; }
  .add-label { display: none; }
  .btn--add { width: 44px; padding: 0; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; inset: auto 0 0 0; z-index: 10;
    height: var(--tab); padding-bottom: env(safe-area-inset-bottom); background: var(--bg); border-top: 1px solid var(--line);
  }
  .tabbar a { display: grid; place-items: center; align-content: center; gap: 2px; color: var(--muted); font-size: 12px; font-weight: 500; position: relative; }
  .tabbar a[aria-current="page"] { color: var(--ink); }
  .tabbar .count { position: absolute; top: 6px; left: calc(50% + 6px); height: 18px; min-width: 18px; font-size: 11px; background: var(--ink); color: var(--bg); }
  dialog.sheet { margin: auto 0 0 0; width: 100vw; height: auto; max-height: 92dvh; border-left: 0; border-top: 1px solid var(--line); border-radius: var(--r-lg) var(--r-lg) 0 0; }
  dialog.sheet[open] { animation-name: sheet-up; }
  @keyframes sheet-up { from { transform: translateY(32px); opacity: 0; } }
  .sheet__body { padding-bottom: calc(var(--s-5) + env(safe-area-inset-bottom)); }
}
@media (max-width: 640px) {
  .ledger { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ledger > div:nth-child(3) { border-left: 0; padding-left: 0; }
  .ledger > div:nth-child(n+3) { border-top: 1px solid var(--line); margin-top: var(--s-3); }
  .row { grid-template-columns: minmax(0, 1fr) auto; padding: var(--s-3) var(--s-4); }
  .row__act { grid-column: 1 / -1; justify-content: flex-start; }
  .row__act:empty { display: none; }
  .sub-row { padding-left: var(--s-6); }
  .card__head, .group__head { padding: var(--s-4); }
  .card__body { padding: 0 var(--s-4) var(--s-4); }
  .empty { padding: var(--s-5) var(--s-4); }
  .input--search { max-width: none; flex: 1 1 100%; }
  .field-row { grid-template-columns: 1fr; }
  .form-actions .btn { flex: 1 1 100%; }
  .page-head .btn-row { width: 100%; }
  .page-head .btn-row .btn { flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
