/* FinansTakip — kompakt tek sayfa, modern koyu tema */

:root {
  --bg: #0b0f19;
  --surface: rgba(255, 255, 255, .035);
  --surface-2: rgba(255, 255, 255, .06);
  --border: rgba(255, 255, 255, .08);
  --border-strong: rgba(255, 255, 255, .14);
  --text: #e9edf6;
  --text-dim: #8a94ab;
  --accent: #6366f1;
  --accent-2: #22d3ee;
  --green: #34d399;
  --green-dim: rgba(52, 211, 153, .12);
  --red: #f87171;
  --red-dim: rgba(248, 113, 113, .12);
  --amber: #fbbf24;
  --amber-dim: rgba(251, 191, 36, .12);
  --amber-border: rgba(251, 191, 36, .3);
  --elev-bg: #151b2b;
  --topbar-bg: rgba(11, 15, 25, .8);
  --input-bg: rgba(0, 0, 0, .25);
  --inset-bg: rgba(0, 0, 0, .18);
  --shadow-strong: 0 10px 30px rgba(0, 0, 0, .45);
  --shadow-modal: 0 24px 70px rgba(0, 0, 0, .5);
  --radius: 14px;
  --radius-sm: 9px;
  color-scheme: dark;
}

/* Acik tema — ☀️ dugmesi veya sistem tercihi ile */
:root[data-theme="light"] {
  --bg: #f3f5fa;
  --surface: #ffffff;
  --surface-2: rgba(15, 23, 42, .05);
  --border: rgba(15, 23, 42, .10);
  --border-strong: rgba(15, 23, 42, .18);
  --text: #16203a;
  --text-dim: #5c6880;
  --accent: #4f46e5;
  --accent-2: #0891b2;
  --green: #059669;
  --green-dim: rgba(5, 150, 105, .10);
  --red: #dc2626;
  --red-dim: rgba(220, 38, 38, .08);
  --amber: #b45309;
  --amber-dim: rgba(245, 158, 11, .15);
  --amber-border: rgba(180, 83, 9, .35);
  --elev-bg: #ffffff;
  --topbar-bg: rgba(255, 255, 255, .85);
  --input-bg: #ffffff;
  --inset-bg: rgba(15, 23, 42, .05);
  --shadow-strong: 0 10px 30px rgba(15, 23, 42, .16);
  --shadow-modal: 0 24px 70px rgba(15, 23, 42, .22);
  color-scheme: light;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background:
    radial-gradient(1100px 500px at 80% -10%, rgba(99, 102, 241, .13), transparent 60%),
    radial-gradient(900px 400px at 0% 110%, rgba(34, 211, 238, .07), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  font-size: 14.5px;
  line-height: 1.45;
  min-height: 100vh;
}

:root[data-theme="light"] body {
  background:
    radial-gradient(1100px 500px at 80% -10%, rgba(99, 102, 241, .07), transparent 60%),
    radial-gradient(900px 400px at 0% 110%, rgba(8, 145, 178, .05), transparent 60%),
    var(--bg);
}

/* ---------- login ---------- */

.login-body { display: flex; align-items: center; justify-content: center; padding: 20px; }

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px;
  text-align: center;
  backdrop-filter: blur(12px);
}
.login-logo { font-size: 40px; margin-bottom: 8px; }
.login-card h1 { font-size: 21px; margin-bottom: 6px; }
.login-sub { color: var(--text-dim); font-size: 13.5px; margin-bottom: 18px; }
.login-card form { text-align: left; }
.login-card label { display: block; font-size: 12.5px; color: var(--text-dim); margin: 12px 0 4px; }
.login-card input {
  width: 100%; padding: 11px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--input-bg);
  color: var(--text); font-size: 16px;
}
.login-card input:focus { outline: none; border-color: var(--accent); }
.login-card button {
  width: 100%; margin-top: 18px; padding: 12px; border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), #4f46e5);
  color: #fff; font-size: 14.5px; font-weight: 600; cursor: pointer;
}
.login-card button:hover { filter: brightness(1.1); }
.login-card button:disabled { opacity: .6; }
.login-err {
  margin-top: 14px; padding: 10px; border-radius: var(--radius-sm);
  background: var(--red-dim); color: var(--red); font-size: 13.5px;
}

/* ---------- topbar ---------- */

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 10px 16px;
  background: var(--topbar-bg);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 15.5px; white-space: nowrap; }
.topbar-actions { display: flex; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }

.grow { flex: 1; }

.profile-wrap { position: relative; }
.profile-wrap .row-menu { left: 0; right: auto; top: calc(100% + 4px); min-width: 170px; }
.profile-wrap .row-menu .sep { border-top: 1px solid var(--border); margin: 4px 0; }
.profile-wrap .row-menu .cur { font-weight: 700; }

/* ---------- chips / pills / buttons ---------- */

.btn-chip {
  padding: 7px 13px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  cursor: pointer; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-family: inherit; white-space: nowrap;
}
.btn-chip:hover { border-color: var(--border-strong); background: var(--surface-2); }
.btn-chip.accent { background: linear-gradient(135deg, var(--accent), #4f46e5); border-color: transparent; color: #fff; }
.btn-chip.accent:hover { filter: brightness(1.12); }
.btn-chip.income { color: var(--green); border-color: rgba(52, 211, 153, .35); background: var(--green-dim); }
.btn-chip.expense { color: var(--red); border-color: rgba(248, 113, 113, .35); background: var(--red-dim); }
.btn-chip.ghost { color: var(--text-dim); }

.pills { display: flex; gap: 5px; }
.pill {
  padding: 5px 12px; border-radius: 999px; font-size: 12px; font-weight: 600;
  cursor: pointer; border: 1px solid transparent; background: none;
  color: var(--text-dim); font-family: inherit;
}
.pill:hover { color: var(--text); }
.pill.active { background: var(--surface-2); border-color: var(--border); color: var(--text); }

/* ---------- özet şeridi ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 15px;
}
.stat .label { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-dim); margin-bottom: 3px; }
.stat .value { font-size: 19px; font-weight: 700; letter-spacing: -.01em; }
.stat .sub { font-size: 11.5px; color: var(--text-dim); margin-top: 2px; }
.stat.net { background: linear-gradient(135deg, rgba(99, 102, 241, .16), rgba(34, 211, 238, .07)); border-color: rgba(99, 102, 241, .3); }

.pos { color: var(--green); }
.neg { color: var(--red); }

/* ---------- vade uyarı şeridi ---------- */

#due-banner {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 9px 14px; margin-bottom: 12px;
  background: var(--amber-dim);
  border: 1px solid var(--amber-border);
  border-radius: var(--radius);
  font-size: 12.5px;
}
#due-banner[hidden] { display: none; }
.due-chip {
  padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--input-bg); border: 1px solid var(--border);
}
.due-chip.overdue { color: var(--red); border-color: rgba(248, 113, 113, .4); }
.due-chip.soon { color: var(--amber); }

/* ---------- panel / kolonlar ---------- */

main { padding: 14px; max-width: 1180px; margin: 0 auto; }

.columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 15px;
}

.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 10px; flex-wrap: wrap;
}
.panel-head.sub { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.panel-head h2 { font-size: 13px; letter-spacing: .05em; text-transform: uppercase; color: var(--text-dim); font-weight: 700; }
.count { color: var(--text-dim); font-weight: 400; }
.muted { color: var(--text-dim); font-weight: 400; font-size: .92em; }

/* ---------- borç/alacak satırları ---------- */

.debt-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 10px; align-items: center;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  position: relative;
}
.debt-row:hover { background: var(--surface-2); border-color: var(--border); }
.debt-row + .debt-row { margin-top: 2px; }

.badge {
  font-size: 10.5px; font-weight: 700; padding: 3px 8px;
  border-radius: 999px; white-space: nowrap; letter-spacing: .02em;
}
.badge-borc { background: var(--red-dim); color: var(--red); }
.badge-alacak { background: var(--green-dim); color: var(--green); }
.badge-closed { background: var(--surface-2); color: var(--text-dim); }

.debt-main { min-width: 0; }
.debt-person { font-weight: 600; font-size: 13.5px; }
.debt-meta { font-size: 11.5px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.debt-meta .overdue-txt { color: var(--red); font-weight: 600; }
.debt-meta .soon-txt { color: var(--amber); font-weight: 600; }

.debt-amount { font-weight: 700; font-size: 14px; white-space: nowrap; text-align: right; }
.debt-amount .of { display: block; font-size: 10.5px; color: var(--text-dim); font-weight: 400; }

.mini-progress {
  grid-column: 2 / -1;
  height: 3px; border-radius: 3px; background: var(--surface-2);
  overflow: hidden; margin-top: -3px;
}
.mini-progress > div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }

.debt-actions { display: flex; gap: 4px; }
.icon-btn {
  width: 28px; height: 28px; display: grid; place-items: center;
  border-radius: 7px; border: 1px solid transparent; background: none;
  color: var(--text-dim); cursor: pointer; font-size: 13px; font-family: inherit;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.icon-btn.pay { color: var(--green); }
.icon-btn.sm { width: 23px; height: 23px; font-size: 11px; border-radius: 6px; }
.icon-btn.danger:hover { color: var(--red); border-color: var(--red); }
.entry-actions { white-space: nowrap; }

/* satır menüsü */
.row-menu {
  position: absolute; right: 8px; top: calc(100% - 4px); z-index: 30;
  background: var(--elev-bg); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 4px; min-width: 130px;
  box-shadow: var(--shadow-strong);
}
.row-menu button {
  display: block; width: 100%; text-align: left; padding: 7px 10px;
  background: none; border: none; color: var(--text); font-size: 12.5px;
  border-radius: 6px; cursor: pointer; font-family: inherit;
}
.row-menu button:hover { background: var(--surface-2); }
.row-menu button.danger { color: var(--red); }

/* ---------- gelir/gider ---------- */

.month-nav { display: flex; align-items: center; gap: 4px; }
.mnav {
  width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-dim); cursor: pointer; font-size: 14px;
  font-family: inherit;
}
.mnav:hover { color: var(--text); border-color: var(--border-strong); }

.month-input {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 7px; color: var(--text); padding: 4px 7px; font-size: 12.5px;
  font-family: inherit;
}
.month-input:focus { outline: none; border-color: var(--accent); }

/* ---- Gelir/Gider: "Sade Defter" duzeni ---- */

.tx-totals { margin-bottom: 2px; }

.b-top {
  display: flex; align-items: flex-end; gap: 14px;
  border-bottom: 1px solid var(--border);
  padding: 2px 2px 12px;
}
.b-kalan .label {
  font-size: 10px; letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-dim); margin-bottom: 1px;
}
.b-kalan .value {
  font-size: 25px; font-weight: 800; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.b-side {
  margin-left: auto; text-align: right;
  font-size: 12.5px; color: var(--text-dim); line-height: 1.7;
  font-variant-numeric: tabular-nums;
}
.b-side b { font-weight: 600; }
.b-other { font-size: 11.5px; padding: 7px 2px 0; }

.b-sec {
  font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-dim); font-weight: 700; margin: 14px 2px 3px;
}
.b-sec.amber { color: var(--amber); }

.b-line {
  display: flex; gap: 10px; align-items: center;
  padding: 6px 2px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.b-line:hover { background: var(--surface-2); }
.b-date {
  color: var(--text-dim); font-size: 11.5px; min-width: 42px;
  font-variant-numeric: tabular-nums; flex-shrink: 0;
}
.b-cat { font-weight: 600; white-space: nowrap; }
.b-note {
  color: var(--text-dim); font-size: 11.5px; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.b-amt {
  margin-left: auto; font-weight: 700; font-size: 13px;
  white-space: nowrap; font-variant-numeric: tabular-nums;
}
.b-ok {
  font-size: 11px; font-weight: 700; color: var(--green);
  border: 1px solid rgba(52, 211, 153, .4); background: var(--green-dim);
  padding: 3px 9px; border-radius: 999px; cursor: pointer;
  font-family: inherit; white-space: nowrap; flex-shrink: 0;
}
.b-ok:hover { filter: brightness(1.15); }
.b-line .icon-btn.sm { flex-shrink: 0; opacity: .6; }
.b-line:hover .icon-btn.sm { opacity: 1; }

.btn-chip.sm { padding: 4px 10px; font-size: 11.5px; }
.pending-chk {
  display: flex; align-items: center; gap: 8px;
  margin: 12px 0 2px; font-size: 12.5px; color: var(--amber);
  cursor: pointer;
}
.overdue-txt { color: var(--red); font-weight: 600; }

/* detay modali notlari icin */
.tx-note { font-size: 11.5px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- aylık tablo ---------- */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th, td { padding: 7px 8px; text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th {
  color: var(--text-dim); font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
}
tbody tr { border-bottom: 1px solid rgba(255, 255, 255, .04); }
tbody tr:hover { background: var(--surface-2); }

/* ---------- form / modal ---------- */

button { font-family: inherit; }

select, input[type="text"], input[type="date"], input[type="password"] {
  background: var(--input-bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  padding: 9px 11px; font-size: 15px; font-family: inherit;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(4, 6, 12, .72);
  display: flex; align-items: center; justify-content: center; padding: 16px;
  backdrop-filter: blur(3px);
}
.modal-backdrop[hidden] { display: none; }

.modal {
  width: 100%; max-width: 420px; max-height: 88vh; overflow-y: auto;
  background: var(--elev-bg); border: 1px solid var(--border-strong);
  border-radius: var(--radius); padding: 22px;
  box-shadow: var(--shadow-modal);
}
.modal h3 { font-size: 16px; margin-bottom: 10px; }
.modal label { display: block; font-size: 12.5px; color: var(--text-dim); margin: 11px 0 4px; }
.modal input, .modal select { width: 100%; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.row2 { display: grid; grid-template-columns: 1fr 108px; gap: 10px; }

.seg { display: flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 4px; }
.seg-btn {
  flex: 1; padding: 9px; border: none; background: none;
  color: var(--text-dim); font-size: 13.5px; font-weight: 600; cursor: pointer;
}
.seg-btn.verdim.active { background: var(--green-dim); color: var(--green); }
.seg-btn.aldim.active { background: var(--red-dim); color: var(--red); }

.dir-hint { font-size: 11.5px; color: var(--text-dim); margin: 6px 2px 0; }

.debt-main[data-action], .debt-amount[data-action] { cursor: pointer; }
.due-chip[data-action] { cursor: pointer; }

/* ---------- işlem kaydı (audit) ---------- */

.modal-wide { max-width: 580px; }

.audit-row {
  display: flex; gap: 10px; align-items: baseline;
  padding: 7px 2px;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
}
.audit-row:last-child { border-bottom: none; }
.audit-ts { color: var(--text-dim); white-space: nowrap; min-width: 84px; font-size: 11.5px; }
.audit-txt { white-space: pre-line; word-break: break-word; }
.audit-txt.audit-del { color: var(--red); }
.audit-txt.audit-edit { color: var(--amber); }

/* ---------- boş durum & toast ---------- */

.empty { text-align: center; color: var(--text-dim); padding: 22px 10px; font-size: 13px; }

#toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--elev-bg); border: 1px solid var(--border-strong); color: var(--text);
  padding: 10px 18px; border-radius: 999px; font-size: 13px; z-index: 100;
  box-shadow: var(--shadow-strong); white-space: nowrap; max-width: 92vw;
  overflow: hidden; text-overflow: ellipsis;
}
#toast.err { border-color: var(--red); color: var(--red); }

/* ---------- responsive ---------- */

@media (max-width: 860px) {
  .columns { grid-template-columns: 1fr; }
  .brand span { display: none; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat .value { font-size: 16.5px; }
}

@media (max-width: 480px) {
  main { padding: 10px; }
  .btn-chip { padding: 7px 10px; font-size: 12px; }
  .debt-row { grid-template-columns: auto 1fr auto; }
  .debt-actions { grid-column: 1 / -1; justify-content: flex-end; }
}
