/* Fuud's Finans Sistemi: iOS sistem uygulaması dili (gruplu listeler, sistem yazı tipi, tek vurgu rengi).
   Kullanım sahnesi: telefonda, ayakta, gün ışığında; açık tema varsayılan, koyu tema sistemden. */

:root {
  --bg: #f2f2f7;
  --cell: #ffffff;
  --fill: #e5e5ea;
  --fill-2: #d1d1d6;
  --label: #111114;
  --label-2: #5f5f66;
  --label-3: #8a8a91;
  --sep: rgba(60, 60, 67, 0.22);
  --accent: #0a62d0;
  --accent-tint: rgba(10, 98, 208, 0.11);
  --accent-fill: #0a62d0;   /* dolu düğme zemini; beyaz yazıyla en az 4.5:1 */
  --on-accent: #ffffff;
  --in: #187a36;
  --in-tint: rgba(24, 122, 54, 0.12);
  --neg: #c4302b;
  --neg-tint: rgba(196, 48, 43, 0.11);
  --transfer-tint: rgba(10, 98, 208, 0.11);
  --bar-material: rgba(249, 249, 251, 0.86);

  --radius: 12px;
  --radius-lg: 16px;
  --gutter: 16px;
  --cell-pad: 16px;
  --tabbar-h: 52px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --t-large: 700 2rem/1.15 var(--font);       /* 32 */
  --t-title: 600 1.375rem/1.25 var(--font);   /* 22 */
  --t-body: 400 1.0625rem/1.35 var(--font);   /* 17 */
  --t-sub: 400 0.9375rem/1.3 var(--font);     /* 15 */
  --t-foot: 400 0.8125rem/1.3 var(--font);    /* 13 */

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --cell: #1c1c1e;
    --fill: #2c2c2e;
    --fill-2: #3a3a3c;
    --label: #f5f5f7;
    --label-2: #a1a1a8;
    --label-3: #7c7c83;
    --sep: rgba(84, 84, 88, 0.6);
    --accent: #4c9bff;
    --accent-tint: rgba(76, 155, 255, 0.16);
    --accent-fill: #0a68d8;
    --on-accent: #ffffff;
    --in: #3fd06b;
    --in-tint: rgba(63, 208, 107, 0.16);
    --neg: #ff6b63;
    --neg-tint: rgba(255, 107, 99, 0.16);
    --transfer-tint: rgba(76, 155, 255, 0.16);
    --bar-material: rgba(22, 22, 24, 0.86);
    color-scheme: dark;
  }
}

/* --- Temel --- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font: var(--t-body);
  color: var(--label);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  caret-color: var(--accent);
  scrollbar-color: var(--fill-2) transparent;
}
::selection { background: var(--accent-tint); color: inherit; }
a { color: var(--accent); text-underline-offset: 0.2em; }
a, button, select, input, summary, label { touch-action: manipulation; }
h1, h2, p { margin: 0; }
[hidden] { display: none !important; }
strong { font-weight: 600; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cell:focus-visible, .cell:focus-within:has(:focus-visible) { outline-offset: -2px; }
.cell :focus-visible { outline: none; }
.icon { width: 24px; height: 24px; flex: none; }

/* --- Sayfa iskeleti --- */

.content {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) max(var(--gutter), env(safe-area-inset-right))
    calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 32px) max(var(--gutter), env(safe-area-inset-left));
}

.page-head { padding: 8px 0 16px; }
.page-head-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.page-head h1, .page-title { font: var(--t-large); letter-spacing: -0.02em; text-wrap: balance; }
.page-title { padding: 8px 0 16px; }
.page-sub { font: var(--t-sub); color: var(--label-2); margin-top: 4px; }
.back {
  display: inline-flex; align-items: center; gap: 2px;
  min-height: 44px; margin-left: -8px; padding-right: 8px;
  font: var(--t-body); text-decoration: none;
}
.back .icon { width: 26px; height: 26px; }
.head-action {
  display: grid; place-items: center; flex: none;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--accent-tint); color: var(--accent);
}
.head-action:active { background: var(--fill); }

/* --- Gruplu liste --- */

.group { margin: 0 0 28px; }
.group-title {
  font: var(--t-foot); text-transform: uppercase; letter-spacing: 0.02em;
  color: var(--label-2); padding: 0 var(--cell-pad) 7px;
}
.group-footer {
  display: flex; flex-direction: column; gap: 2px;
  font: var(--t-foot); color: var(--label-2); padding: 7px var(--cell-pad) 0;
}
.group-footer.error { color: var(--neg); font-weight: 500; }
.cells {
  background: var(--cell);
  border-radius: var(--radius);
  overflow: hidden;
}
.cells > *, .cells > div > .cell { position: relative; }
/* Satır ayırıcı: içerik hizasından başlar, iOS gibi */
.cells > * + *::before, .cells > div:not([hidden]) ~ div:not([hidden]) > .cell::before {
  content: ""; position: absolute; top: 0; right: 0; left: var(--cell-pad);
  border-top: 0.5px solid var(--sep);
}
.cells > .cell:has(.badge) + *::before { left: calc(var(--cell-pad) + 44px); }
.cell {
  display: flex; align-items: center; gap: 12px;
  width: 100%; min-height: 50px;
  padding: 10px var(--cell-pad);
  color: var(--label); text-decoration: none;
  background: transparent; border: 0; font: var(--t-body); text-align: left;
}
a.cell, button.cell, label.cell { cursor: pointer; }
a.cell:active, button.cell:active, label.field:active { background: var(--fill); }
@media (hover: hover) {
  a.cell:hover, button.cell:hover { background: color-mix(in srgb, var(--fill) 50%, transparent); }
}
.cell-main { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.cell-label { overflow-wrap: anywhere; }
.cell-sub { font: var(--t-foot); color: var(--label-2); overflow-wrap: anywhere; }
.cell-value {
  display: flex; flex-direction: column; align-items: flex-end; gap: 1px;
  flex: none; max-width: 60%; text-align: right;
}
.chev { width: 16px; height: 16px; color: var(--label-3); flex: none; margin-right: -4px; stroke-width: 2.4; }
.cell.total { background: color-mix(in srgb, var(--fill) 35%, var(--cell)); }
.cell.selected { background: var(--accent-tint); }
.cell.accent { color: var(--accent); justify-content: center; }
.cell.destructive { color: var(--neg); justify-content: center; }
.archived .cells, .cell.archived { opacity: 0.6; }

/* Form hücreleri: etiket solda, değer sağda */
.field .cell-label { flex: none; }
.field select, .field input, .field textarea {
  flex: 1; min-width: 0;
  font: var(--t-body); color: var(--label-2);
  background: transparent; border: 0; padding: 0; margin: 0;
  text-align: right; text-align-last: right;
  appearance: none; -webkit-appearance: none;
  min-height: 30px;
}
.field input { color: var(--label); }
.field input::placeholder, .field textarea::placeholder { color: var(--label-2); opacity: 1; }
.field select { cursor: pointer; text-overflow: ellipsis; }
.field select:focus, .field input:focus, .field textarea:focus { outline: none; }
.field:focus-within { background: color-mix(in srgb, var(--accent-tint) 60%, transparent); }
.field input[type="date"] { display: flex; justify-content: flex-end; }
.field input[type="date"]::-webkit-date-and-time-value { text-align: right; }
.field input[type="date"]::-webkit-calendar-picker-indicator { opacity: 0.55; }
.field.note input, .field.note textarea { text-align: left; text-align-last: left; color: var(--label); }
.field textarea { resize: vertical; line-height: 1.35; padding: 4px 0; }
.field[aria-invalid="true"], .field:has([aria-invalid="true"]) .cell-label { color: var(--neg); }
.cell.add input { text-align: left; text-align-last: left; color: var(--label); }

/* --- Rozetler, tutarlar --- */

.badge {
  display: grid; place-items: center; flex: none;
  width: 32px; height: 32px; border-radius: 50%;
  color: var(--neg); background: var(--neg-tint);
}
.badge .icon { width: 18px; height: 18px; stroke-width: 2.1; }
.badge-gelir, .badge-tahsilat { color: var(--in); background: var(--in-tint); }
.badge-transfer, .badge-plain { color: var(--accent); background: var(--transfer-tint); }
.amt { font-variant-numeric: tabular-nums; white-space: nowrap; letter-spacing: -0.01em; }
.amt.in, .in { color: var(--in); }
.amt.neg, .neg { color: var(--neg); }
.muted { color: var(--label-2); }
.tag {
  display: inline-block; padding: 0 6px; border-radius: 6px;
  font-size: 0.75rem; font-weight: 600; line-height: 1.5;
  color: var(--neg); background: var(--neg-tint); vertical-align: 1px;
}

/* --- Düğmeler --- */

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 18px;
  font: 600 1.0625rem/1 var(--font); text-decoration: none;
  color: var(--accent); background: var(--accent-tint);
  border: 0; border-radius: var(--radius); cursor: pointer;
  transition: transform 120ms var(--ease-out), opacity 120ms;
  user-select: none; -webkit-user-select: none;
}
.button .icon { width: 20px; height: 20px; stroke-width: 2.2; }
.button.primary { color: var(--on-accent); background: var(--accent-fill); }
.button.block { display: flex; width: 100%; min-height: 52px; margin: 0 0 28px; }
.button:active { transform: scale(0.98); opacity: 0.85; }
.button[aria-busy="true"], .button:disabled { opacity: 0.45; cursor: progress; transform: none; }
.plain {
  font: var(--t-sub); font-weight: 600; color: var(--accent);
  background: none; border: 0; padding: 10px 4px; margin: -10px -4px; cursor: pointer;
  min-height: 44px; display: inline-flex; align-items: center; gap: 6px;
}
.plain.small { font-weight: 500; }
.link { font: var(--t-sub); text-decoration: none; display: inline-flex; align-items: center; min-height: 44px; }

/* --- Yeni kayıt ekranı --- */

.tx-form { padding-top: 4px; }
.nav-title { font: 600 1.0625rem/1.3 var(--font); text-align: center; padding: 2px 0 12px; }
.segmented {
  position: relative; display: grid; grid-template-columns: repeat(var(--n), 1fr);
  margin: 0 0 4px; padding: 2px; border: 0; border-radius: 10px; background: var(--fill);
}
.segmented label {
  position: relative; z-index: 1; display: grid; place-items: center;
  min-height: 40px; padding: 0 2px; border-radius: 8px; cursor: pointer;
  font: 500 0.875rem/1.1 var(--font); color: var(--label); text-align: center;
  user-select: none; -webkit-user-select: none;
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked) { font-weight: 600; }
.segmented label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; }
.segmented-thumb {
  position: absolute; z-index: 0; top: 2px; bottom: 2px; left: 2px;
  width: calc((100% - 4px) / var(--n)); border-radius: 8px;
  background: var(--cell); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
  transform: translateX(calc(var(--i, 0) * 100%));
  transition: transform 200ms var(--ease-out);
}
.segmented:has(label:nth-of-type(2) input:checked) { --i: 1; }
.segmented:has(label:nth-of-type(3) input:checked) { --i: 2; }
.segmented:has(label:nth-of-type(4) input:checked) { --i: 3; }
.segmented:has(label:nth-of-type(5) input:checked) { --i: 4; }

.amount {
  display: flex; align-items: baseline; justify-content: center; gap: 6px;
  padding: 26px 0 6px; cursor: text;
}
.amount input {
  width: 100%; min-width: 0; max-width: 100%; field-sizing: content;
  padding: 0; border: 0; background: transparent; color: var(--label);
  font: 600 3.5rem/1.05 var(--font); letter-spacing: -0.03em; text-align: right;
  font-variant-numeric: tabular-nums;
}
.amount input::placeholder { color: var(--label-3); opacity: 1; }
.amount input:focus { outline: none; }
.amount input[aria-invalid="true"] { color: var(--neg); }
.amount input[aria-invalid="true"]::placeholder { color: var(--neg); opacity: 0.55; }
.currency { font: 600 2rem/1 var(--font); color: var(--label-2); }
.amount-gap { height: 24px; }
.submit-spacer { display: none; }
.tx-form.kb-open .submit-spacer { display: block; }

/* Klavye açıkken (iOS ondalık tuş takımında Return yok) Kaydet klavyenin hemen üstünde durur */
.tx-form.kb-open .submit {
  position: fixed; z-index: 20; margin: 0;
  left: max(var(--gutter), env(safe-area-inset-left)); right: max(var(--gutter), env(safe-area-inset-right));
  bottom: calc(var(--kb, 0px) + 8px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}
.tx-form.kb-open .submit-spacer { height: 52px; margin-bottom: 28px; }
body:has(.tx-form.kb-open) .tabbar { visibility: hidden; }

.shortcut .chev { width: 18px; height: 18px; color: var(--accent); margin: 0; }

/* Kayıt onayı: üstte, içerik akışında */
.toast, .flash {
  display: flex; align-items: center; gap: 12px;
  margin: 0 0 16px; padding: 10px 12px 10px var(--cell-pad);
  background: var(--cell); border-radius: var(--radius);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.07);
  font: var(--t-sub);
  animation: drop-in 200ms var(--ease-out);
}
.toast p { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.toast p span { color: var(--label-2); font: var(--t-foot); }
.toast form { margin: 0; }
@keyframes drop-in { from { transform: translateY(-10px); } }

/* --- Hareketler --- */

.stepper {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin: -4px 0 6px;
}
.stepper-label { font: var(--t-title); letter-spacing: -0.01em; }
.step {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  color: var(--accent);
}
a.step:active { background: var(--fill); }
.totals {
  display: flex; flex-wrap: wrap; gap: 4px 18px;
  font: var(--t-sub); color: var(--label-2); margin: 0 0 14px;
}
.totals strong { font-variant-numeric: tabular-nums; color: var(--label); }
.totals strong.in { color: var(--in); }
.totals strong.neg { color: var(--neg); }

.filters { margin: 0 0 22px; }
.filters summary, .disclosure summary {
  display: flex; align-items: center; gap: 8px;
  min-height: 44px; list-style: none; cursor: pointer;
  font: var(--t-sub); font-weight: 600; color: var(--accent);
}
.filters summary::-webkit-details-marker, .disclosure summary::-webkit-details-marker { display: none; }
.disclose { width: 18px; height: 18px; stroke-width: 2.4; transition: transform 200ms var(--ease-out); }
.filters[open] .disclose, .disclosure[open] .disclose { transform: rotate(180deg); }
.filter-form { padding-top: 8px; }
.filter-form .group { margin-bottom: 12px; }
.row-actions { display: flex; align-items: center; gap: 16px; }
.pill {
  font: 600 0.75rem/1.5 var(--font); padding: 0 7px; border-radius: 99px;
  color: var(--on-accent); background: var(--accent-fill);
}
.tx-group { margin-bottom: 22px; }
.tx .cell-value .cell-sub { color: var(--label-2); }
/* Liste satırları iOS gibi tek satır; tam metin düzenleme ekranında */
.tx .cell-label, .tx .cell-main > .cell-sub, .shortcut .cell-label {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; overflow-wrap: normal;
}
/* Transferde hedef hesap ayırt edici bilgidir: başlık iki satıra kadar kırılabilir */
.tx-transfer .cell-label {
  white-space: normal; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
}
.section-title { font: var(--t-title); letter-spacing: -0.01em; margin: 8px 0 10px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 4px; }
.section-head .section-title { margin-bottom: 10px; }
.section-head .link { padding-right: 4px; }
.empty {
  padding: 28px var(--cell-pad); text-align: center;
  font: var(--t-sub); color: var(--label-2); text-wrap: balance;
}

/* --- Hesap ve cari detayı --- */

.balance-card {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  margin: 0 0 16px; padding: 22px var(--cell-pad);
  background: var(--cell); border-radius: var(--radius-lg); text-align: center;
  font: var(--t-foot); color: var(--label-2);
}
.balance-card strong {
  font: 700 2.25rem/1.1 var(--font); letter-spacing: -0.025em; color: var(--label);
  font-variant-numeric: tabular-nums;
}
.balance-card strong.in { color: var(--in); }
.balance-card strong.neg { color: var(--neg); }
.balance-card .contact a { color: var(--accent); }
.actions {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  margin: 0 0 24px;
}
.action {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 2px; border-radius: var(--radius);
  background: var(--cell); text-decoration: none;
  font: 500 0.8125rem/1.2 var(--font); color: var(--accent);
}
.action:active { background: var(--fill); }
.action-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--accent-tint); }
.action-icon .icon { width: 20px; height: 20px; stroke-width: 2.1; }
.note { font: var(--t-sub); color: var(--label-2); white-space: pre-line; padding: 0 var(--cell-pad) 20px; }
.disclosure { margin: 8px 0 20px; }
.disclosure > summary { padding: 0 4px; }
.disclosure[open] > summary { margin-bottom: 10px; }
.danger-zone { margin-top: 12px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.chips a {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; border-radius: 99px;
  font: 500 0.875rem/1 var(--font); color: var(--label); background: var(--fill); text-decoration: none;
}
.chips a[aria-current] { color: var(--on-accent); background: var(--accent-fill); font-weight: 600; }

.segmented-links {
  display: grid; grid-template-columns: repeat(3, 1fr);
  margin: 0 0 18px; padding: 2px; border-radius: 10px; background: var(--fill);
}
.segmented-links a {
  display: grid; place-items: center; min-height: 36px; border-radius: 8px;
  font: 500 0.875rem/1 var(--font); color: var(--label); text-decoration: none;
}
.segmented-links a[aria-current] { background: var(--cell); font-weight: 600; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1); }

/* --- Rapor --- */

.bar-cell .cell-main { gap: 6px; }
.bar {
  display: block; height: 4px; width: var(--w); border-radius: 2px;
  background: var(--neg); opacity: 0.55;
}
.bar.gelir { background: var(--in); }

/* --- Giriş --- */

.login { max-width: 420px; margin: 12vh auto 0; }
.login h1 { font: var(--t-large); letter-spacing: -0.02em; padding: 0 4px; }
.login .page-sub { padding: 0 4px 24px; }
.login .field .cell-label { width: 5.5em; }
.login .field input { text-align: left; text-align-last: left; }

/* --- Sekme çubuğu (telefon) --- */

.tabbar {
  position: fixed; z-index: 10; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: var(--bar-material);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--sep);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  height: var(--tabbar-h);
  font: 500 0.6875rem/1 var(--font); color: var(--label-2); text-decoration: none;
  user-select: none; -webkit-user-select: none;
}
.tabbar a[aria-current] { color: var(--accent); }
.tabbar a[aria-current] .icon { stroke-width: 2.2; }
.tabbar a:focus-visible { outline-offset: -4px; }

/* --- Kenar çubuğu (geniş ekran) --- */

.sidebar { display: none; }

@media (min-width: 900px) {
  .tabbar { display: none; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 10;
    display: flex; flex-direction: column; width: 260px;
    padding: 20px 12px 16px;
    background: var(--cell); border-right: 0.5px solid var(--sep);
  }
  .sidebar-brand {
    font: 700 1.25rem/1 var(--font); letter-spacing: -0.02em;
    color: var(--label); text-decoration: none; padding: 8px 12px 20px;
  }
  .sidebar ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
  .sidebar ul a {
    display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 0 12px;
    border-radius: 10px; color: var(--label); text-decoration: none; font: var(--t-sub);
  }
  .sidebar ul a .icon { color: var(--accent); width: 22px; height: 22px; }
  .sidebar ul a:hover { background: var(--fill); }
  .sidebar ul a[aria-current] { background: var(--accent-fill); color: var(--on-accent); font-weight: 600; }
  .sidebar ul a[aria-current] .icon { color: inherit; }
  .sidebar-user {
    margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 12px 12px 0; border-top: 0.5px solid var(--sep);
    font: var(--t-foot); color: var(--label-2);
  }
  .sidebar-user .plain { font: var(--t-foot); color: var(--label-2); }
  .sidebar-user .icon { width: 18px; height: 18px; }
  .sidebar ~ .content { padding: 40px 32px 64px calc(260px + 32px); max-width: calc(640px + 260px + 64px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
