:root {
  --bg: #f4f2ee;
  --card: #ffffff;
  --ink: #1c1b19;
  --muted: #7a766f;
  --line: #e7e3dc;
  --accent: #1f6f54;
  --accent-ink: #ffffff;
  --accent-soft: #e3f0ea;
  --hero-a: #1f6f54;
  --hero-b: #144a39;
  --p1: #2f5d8a;
  --p2: #c0773a;
  --warn: #b4641a;
  --warn-soft: #fbeedd;
  --danger: #c0392b;
  --danger-soft: #fbe5e2;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 6px 20px rgba(0,0,0,.05);
  --radius: 20px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121211;
    --card: #1c1c1a;
    --ink: #f2efe9;
    --muted: #9a958c;
    --line: #2c2b28;
    --accent: #4cbf92;
    --accent-ink: #0d2a1f;
    --accent-soft: #1d3329;
    --hero-a: #1d5a45;
    --hero-b: #123528;
    --p1: #79a9db;
    --p2: #e5a067;
    --warn: #e9a25a;
    --warn-soft: #33281b;
    --danger: #ef7a6c;
    --danger-soft: #3a1f1c;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #121211;
  --card: #1c1c1a;
  --ink: #f2efe9;
  --muted: #9a958c;
  --line: #2c2b28;
  --accent: #4cbf92;
  --accent-ink: #0d2a1f;
  --accent-soft: #1d3329;
  --hero-a: #1d5a45;
  --hero-b: #123528;
  --p1: #79a9db;
  --p2: #e5a067;
  --warn: #e9a25a;
  --warn-soft: #33281b;
  --danger: #ef7a6c;
  --danger-soft: #3a1f1c;
  --shadow: none;
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
.muted { color: var(--muted); }
.vh { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* ---------- splash / login ---------- */
.splash { position: fixed; inset: 0; display: grid; place-items: center; }
.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.login {
  min-height: 100vh; display: grid; place-items: center;
  padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
}
.login-card {
  width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px;
  text-align: center;
}
.login-icon { width: 72px; height: 72px; border-radius: 18px; margin: 0 auto 8px; box-shadow: var(--shadow); }
.login-card h1 { font-size: 28px; letter-spacing: -.02em; }
.login-card p.muted { margin-bottom: 12px; }
.login-card input[type=password] {
  width: 100%; padding: 15px 16px; font-size: 17px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); outline: none;
}
.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.error { color: var(--danger); font-size: 14px; min-height: 20px; }
.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 18px; border-radius: 14px; font-weight: 600; font-size: 16px;
  transition: transform .1s, opacity .2s;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn:disabled { opacity: .6; }

/* ---------- app ---------- */
.app {
  max-width: 560px; margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(32px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 16px;
}
.top-actions { display: flex; gap: 8px; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; padding: 8px 4px 0; }
.topbar h1 { font-size: 32px; letter-spacing: -.03em; font-weight: 750; }
.eyebrow { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: var(--card); color: var(--muted); box-shadow: var(--shadow);
}

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }

/* hero */
.hero {
  border-radius: 24px; padding: 22px 20px 20px; color: #fff;
  background: linear-gradient(145deg, var(--hero-a), var(--hero-b));
  box-shadow: 0 10px 30px rgba(20, 74, 57, .25);
}
.hero .label { font-size: 14px; opacity: .8; font-weight: 500; }
.hero .big { font-size: 38px; font-weight: 750; letter-spacing: -.03em; margin: 2px 0 16px; }
.hero .big small { font-size: 22px; opacity: .8; font-weight: 600; }
.bar { height: 8px; border-radius: 99px; background: rgba(255,255,255,.18); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: inherit; background: #fff; transition: width .5s ease; }
.hero .bar-meta { display: flex; justify-content: space-between; font-size: 13px; opacity: .85; margin-top: 8px; }
.hero .stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 18px; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.15); }
.hero .stats div { min-width: 0; }
.hero .stats b { display: block; font-size: 16px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero .stats span { font-size: 12px; opacity: .75; }

/* next payment */
.next { display: flex; flex-direction: column; gap: 14px; }
.next-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.next .kicker { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.next .amt { font-size: 28px; font-weight: 750; letter-spacing: -.02em; margin-top: 4px; }
.next .meta { color: var(--muted); font-size: 15px; margin-top: 2px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  font-size: 13px; font-weight: 600; padding: 6px 10px; border-radius: 99px;
  background: var(--accent-soft); color: var(--accent);
}
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.danger { background: var(--danger-soft); color: var(--danger); }
.pill.done { background: var(--accent-soft); color: var(--accent); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.dot.p1 { background: var(--p1); } .dot.p2 { background: var(--p2); }
.next .btn { width: 100%; }
.alldone { text-align: center; padding: 28px 18px; }
.alldone .emoji { font-size: 40px; }
.alldone h3 { font-size: 20px; margin: 8px 0 4px; }

/* plans */
.plans { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.plan { display: flex; flex-direction: column; gap: 10px; padding: 16px; }
.plan-head { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 15px; }
.plan-ring { display: flex; align-items: center; gap: 12px; }
.ring { width: 58px; height: 58px; flex: none; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 6; }
.ring .track { stroke: var(--line); }
.ring .val { stroke-linecap: round; transition: stroke-dashoffset .5s ease; }
.ring-text b { display: block; font-size: 20px; font-weight: 750; }
.ring-text span { font-size: 12px; color: var(--muted); }
.plan dl { margin: 0; display: grid; gap: 4px; font-size: 13px; }
.plan dl div { display: flex; justify-content: space-between; gap: 6px; }
.plan dt { color: var(--muted); }
.plan dd { margin: 0; font-weight: 600; text-align: right; }
.plan.finished { opacity: .7; }

/* timeline */
.section-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 4px 10px; }
.section-head h2 { font-size: 20px; letter-spacing: -.02em; }
.past-toggle {
  width: 100%; padding: 12px; border-radius: 14px; color: var(--muted); font-size: 14px; font-weight: 600;
  border: 1px dashed var(--line); margin-bottom: 12px;
}
.month { padding: 6px 0; margin-bottom: 12px; overflow: hidden; }
.month.current { outline: 2px solid var(--accent); outline-offset: -2px; }
.month-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px 6px; gap: 8px; }
.month-head h3 { font-size: 16px; font-weight: 700; }
.month-head .sum { font-size: 14px; color: var(--muted); font-weight: 600; }
.month-head .left { display: flex; align-items: center; gap: 8px; }
.month-head .pill { padding: 3px 8px; font-size: 11px; }

.row { position: relative; display: flex; align-items: center; gap: 8px; padding: 6px 16px 6px 8px; }
.row + .row::before { content: ""; position: absolute; top: 0; left: 60px; right: 16px; border-top: 1px solid var(--line); }
.check {
  width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 50%;
}
.check span {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line);
  display: grid; place-items: center; transition: all .2s ease;
}
.check svg { width: 16px; height: 16px; opacity: 0; transform: scale(.5); transition: all .2s ease; }
.row.is-paid .check span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.row.is-paid .check svg { opacity: 1; transform: scale(1); }
.row.is-overdue .check span { border-color: var(--danger); }
.row.is-soon .check span { border-color: var(--warn); }
.check:active span { transform: scale(.88); }
.row-main { flex: 1; min-width: 0; }
.row-title { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 15px; }
.row-title .n { color: var(--muted); font-weight: 500; font-size: 13px; }
.row-sub { font-size: 13px; color: var(--muted); margin-top: 1px; }
.row-sub.overdue { color: var(--danger); font-weight: 600; }
.row-sub.soon { color: var(--warn); font-weight: 600; }
.row-sub.ok { color: var(--accent); }
.row-amt { font-weight: 650; font-size: 15px; white-space: nowrap; }
.row.is-paid .row-amt { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line); }

.toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom));
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 99px;
  font-size: 14px; font-weight: 600; transition: all .25s ease; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 360px) {
  .plans { grid-template-columns: 1fr; }
  .hero .big { font-size: 32px; }
}

/* ---------- son ödeme aralığı ---------- */
.window {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg); border-radius: 14px; padding: 12px 14px;
}
.window > div { display: flex; flex-direction: column; min-width: 0; }
.window > div:last-of-type { text-align: right; }
.window span { font-size: 12px; color: var(--muted); }
.window b { font-size: 15px; font-weight: 650; }
.window > i { flex: 1; height: 2px; border-radius: 2px; background: linear-gradient(90deg, var(--line), var(--accent)); position: relative; }
.window > i::after { content: ""; position: absolute; right: -2px; top: -4px; border: 5px solid transparent; border-left: 7px solid var(--accent); border-right: 0; }
.window.single { justify-content: space-between; }
.window.single > div:last-of-type { text-align: left; }
.window em { font-style: normal; font-size: 12px; font-weight: 600; color: var(--warn); background: var(--warn-soft); padding: 4px 8px; border-radius: 99px; white-space: nowrap; }
.next .meta b { color: var(--ink); font-weight: 650; }

.plan-head small { display: block; font-size: 12px; font-weight: 500; color: var(--muted); }
.plan-head .dot { align-self: flex-start; margin-top: 6px; }

/* ---------- bildirim kartı ---------- */
.notif { display: flex; gap: 14px; align-items: flex-start; }
.notif-icon { width: 40px; height: 40px; flex: none; border-radius: 12px; display: grid; place-items: center; background: var(--warn-soft); color: var(--warn); }
.notif.on .notif-icon { background: var(--accent-soft); color: var(--accent); }
.notif-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.notif-main b { font-size: 15px; }
.notif-main p { font-size: 14px; color: var(--muted); }
.notif-main .btn { margin-top: 8px; align-self: flex-start; }
.notif-actions { display: flex; gap: 8px; margin-top: 8px; }
.notif-actions .btn { margin-top: 0; }
.btn.sm { padding: 10px 14px; font-size: 14px; border-radius: 12px; }
.btn.ghost { background: var(--bg); color: var(--ink); border: 1px solid var(--line); }
