/* Para (money.pivony.com). Açık/koyu tema işletim sistemini izler. */
:root {
  color-scheme: light dark;
  --bg: #f4f4f7;
  --surface: #ffffff;
  --soft: #eeeef3;
  --text: #1d1d1f;
  --muted: #62666e;
  --line: #dcdce3;
  --line-strong: #c3c3cd;
  --shadow: 0 1px 2px rgba(16, 16, 24, 0.07), 0 2px 6px rgba(16, 16, 24, 0.04);
  --danger: #b42318;
  --warn: #b54708;
  --ok: #067647;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --series-1: #2a78d6; /* gelir */
  --series-2: #eb6834; /* gider */
  --radius: 12px;
  --radius-sm: 8px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f0f13;
    --surface: #1e1e25;
    --soft: #2a2a33;
    --text: #ececf1;
    --muted: #9c9ea8;
    --line: #2c2c36;
    --line-strong: #3d3d4a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
    --danger: #ff8a7a;
    --warn: #f5b062;
    --ok: #5fd39a;
    --accent: #2dd4bf;
    --accent-ink: #10141a;
    --series-1: #3987e5;
    --series-2: #d95926;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font);
  font-variant-numeric: tabular-nums;
}
h1, h2 { margin: 0; }
p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.spacer { flex: 1; }

/* Üst çubuk */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 17px; display: inline-flex; align-items: center; gap: 8px; }
.brand-mark {
  display: inline-grid; place-items: center;
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--accent); color: var(--accent-ink); font-weight: 700;
}
.month { display: inline-flex; align-items: center; gap: 2px; margin-left: 8px; }
.month-label {
  min-width: 128px; padding: 6px 8px; text-align: center; font-weight: 600;
  background: none; border: 0; border-radius: var(--radius-sm); cursor: pointer;
}
.icon-btn {
  width: 34px; height: 34px; font-size: 20px; line-height: 1;
  background: none; border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer;
}
.icon-btn:hover, .month-label:hover { background: var(--soft); }
.logout { margin: 0; }
.sync { font-size: 12px; color: var(--muted); white-space: nowrap; }
.sync[data-state="offline"] { color: var(--warn); font-weight: 600; }

.btn {
  padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface);
  cursor: pointer; font-weight: 600; white-space: nowrap;
}
.btn:hover { background: var(--soft); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn.ghost { border-color: transparent; background: none; color: var(--muted); }
.btn.danger { color: var(--danger); border-color: var(--line); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.block { width: 100%; padding: 11px; }
.btn-gap { width: 52px; }
.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-weight: 600; text-align: left; }
.link:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Sekmeler */
.tabs {
  display: flex; gap: 4px; padding: 8px 16px 0; overflow-x: auto;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.tabs button {
  padding: 8px 12px; background: none; border: 0; border-bottom: 2px solid transparent;
  color: var(--muted); font-weight: 600; cursor: pointer; white-space: nowrap;
}
.tabs button:hover { color: var(--text); }
.tabs button[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }

/* İçerik */
.view { max-width: 1120px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; display: grid; gap: 10px; align-content: start; min-width: 0;
}
.card h2 { font-size: 15px; font-weight: 650; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 16px; display: grid; gap: 2px;
}
.tile-label { color: var(--muted); font-size: 13px; }
.tile-value { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.tile-value[data-tone="ok"] { color: var(--ok); }
.tile-value[data-tone="bad"] { color: var(--danger); }
.tile-sub { color: var(--muted); font-size: 12px; }
.empty { color: var(--muted); padding: 10px 0; }
.notice {
  padding: 10px 14px; border: 1px solid var(--warn); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
}
.more { justify-self: start; font-size: 13px; }
.totals { color: var(--muted); font-size: 13px; padding-top: 8px; border-top: 1px solid var(--line); }

/* Satırlar */
.row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 9px 8px; margin: 0 -8px; width: calc(100% + 16px);
  background: none; border: 0; border-radius: var(--radius-sm); text-align: left;
}
button.row { cursor: pointer; }
button.row:hover { background: var(--soft); }
.row + .row { border-top: 1px solid var(--line); border-top-left-radius: 0; border-top-right-radius: 0; }
.row-main { flex: 1; min-width: 0; display: grid; gap: 1px; }
.row-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta, .row-date { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.amount { font-weight: 650; white-space: nowrap; }
.amount[data-type="gelir"] { color: var(--ok); }
.amount[data-type="transfer"] { color: var(--muted); }
.badge {
  font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--line-strong); color: var(--muted); white-space: nowrap;
}
.badge[data-state="islendi"] { color: var(--ok); border-color: var(--ok); }
.badge[data-state="gecikti"] { color: var(--danger); border-color: var(--danger); }

/* Filtreler */
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filters input { flex: 1 1 220px; }
input[type="text"], input[type="search"], input[type="date"], input[type="password"], select {
  padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); min-width: 0;
}

/* Grafik */
.chart-wrap { display: grid; gap: 6px; }
.chart { width: 100%; height: auto; display: block; }
.chart .s1, .dot.s1 { fill: var(--series-1); background: var(--series-1); }
.chart .s2, .dot.s2 { fill: var(--series-2); background: var(--series-2); }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { stroke: var(--line-strong); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; }
.chart .hit { fill: transparent; }
.chart .bar-group { cursor: pointer; outline: none; }
.chart .bar-group:hover .hit, .chart .bar-group:focus-visible .hit { fill: var(--soft); }
.chart .bar-group.current .month-tick { fill: var(--text); font-weight: 700; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); }
.legend span, .tip span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.tip {
  position: absolute; z-index: 20; pointer-events: none;
  display: grid; gap: 2px; padding: 8px 10px; font-size: 12.5px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}

/* Kategori çubukları ve bütçe */
.catbar { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; }
.catbar-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.catbar-val { color: var(--muted); font-size: 13px; white-space: nowrap; }
.catbar .meter { grid-column: 1 / -1; }
.meter { display: block; height: 8px; border-radius: 4px; background: var(--soft); overflow: hidden; }
.meter-fill { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.meter-fill[data-over] { background: var(--danger); }
.budget-head, .budget-row {
  display: grid; grid-template-columns: minmax(110px, 1.3fr) minmax(90px, 1fr) 120px minmax(80px, 1.2fr) minmax(110px, 1fr);
  gap: 10px; align-items: center;
}
.budget-head { color: var(--muted); font-size: 12px; padding-bottom: 4px; border-bottom: 1px solid var(--line); }
.budget-row { padding: 4px 0; }
.budget-name { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.budget-input { width: 100%; text-align: right; }
.budget-left { font-size: 13px; color: var(--muted); text-align: right; white-space: nowrap; }
.budget-left[data-tone="bad"] { color: var(--danger); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; }
.chip:hover { background: var(--soft); }
.card > .btn { justify-self: start; }
.view > .btn { justify-self: start; }

/* Form penceresi */
.dlg {
  width: min(460px, calc(100vw - 24px)); padding: 0; border: 1px solid var(--line-strong);
  border-radius: var(--radius); background: var(--surface); color: var(--text);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.3);
}
.dlg::backdrop { background: rgba(10, 10, 16, 0.5); }
.dlg form { padding: 18px; display: grid; gap: 14px; }
.dlg h2 { font-size: 17px; }
.form-body { display: grid; gap: 12px; }
.field { display: grid; gap: 4px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--muted); }
.field.check { display: flex; align-items: center; gap: 8px; }
.field.check > span { font-weight: 500; color: var(--text); }
.field.inline { grid-template-columns: 1fr 150px; align-items: center; }
.field.inline input, .field.inline select { text-align: right; }
.form-error, .alert { color: var(--danger); font-weight: 600; font-size: 14px; }
.form-actions { display: flex; gap: 8px; align-items: center; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 30;
  max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: var(--radius-sm);
  background: var(--text); color: var(--bg); font-weight: 600; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

/* Giriş sayfası */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login {
  width: min(380px, 100%); display: grid; gap: 14px; padding: 24px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.login h1 { font-size: 22px; display: flex; align-items: center; gap: 10px; }
.login form { display: grid; gap: 14px; }
.captcha { min-height: 78px; overflow: hidden; }

/* Telefon: bu blok dosyanın sonunda kalmalı (üstteki kuralları ezer). */
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  .month { margin-left: 0; order: 3; width: 100%; justify-content: space-between; }
  .month-label { flex: 1; }
  .sync { display: none; }
  .sync[data-state="offline"] { display: inline; order: 4; }
  .tabs { padding: 4px 8px 0; }
  .view { padding: 12px; gap: 12px; }
  .grid2 { grid-template-columns: 1fr; gap: 12px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .tile { padding: 10px 12px; }
  .tile-value { font-size: 17px; }
  .row-date { display: none; }
  .budget-head { display: none; }
  .budget-row { grid-template-columns: 1fr 110px; gap: 4px 10px; padding: 8px 0; border-top: 1px solid var(--line); }
  .budget-row .budget-spent { display: none; }
  .budget-row .meter { grid-column: 1 / -1; }
  .budget-row .budget-left { grid-column: 1 / -1; text-align: left; }
  .field.inline { grid-template-columns: 1fr 120px; }
  .rec { flex-wrap: wrap; }
  .rec .row-main { flex-basis: 100%; }
}
