:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface-2: #efeee9;
  --surface-3: #e6e4dd;
  --text: #1c1c1a;
  --muted: #6d6b65;
  --border: #e2e0d9;
  --accent: #2f6f4f;
  --accent-text: #ffffff;
  --accent-soft: #e2eee7;
  --danger: #b4441f;
  --danger-soft: #f8e5de;
  --warn: #8a6d1f;
  --warn-soft: #f5eed8;
  --info: #2b6cb0;
  --info-soft: #e3edf8;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 6px 20px rgba(0,0,0,.05);
  --radius: 14px;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141513;
    --surface: #1d1e1c;
    --surface-2: #262825;
    --surface-3: #30322e;
    --text: #ecebe6;
    --muted: #9b9992;
    --border: #31332f;
    --accent: #5fb38a;
    --accent-text: #0e1912;
    --accent-soft: #1e3328;
    --danger: #ea8a68;
    --danger-soft: #3a241c;
    --warn: #dcbb5e;
    --warn-soft: #35301c;
    --info: #7fb2ea;
    --info-soft: #1d2a3a;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100dvh;
}
h1, h2, h3 { margin: 0; letter-spacing: -.01em; line-height: 1.25; }
h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0 0 10px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.tiny { font-size: 12px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.hp { position: absolute; left: -9999px; top: auto; width: 1px; height: 1px; overflow: hidden; }

/* ---------- butonlar ---------- */
.btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: 11px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-size: 15px; font-weight: 600;
  cursor: pointer; text-decoration: none; white-space: nowrap; user-select: none;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 9px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; pointer-events: none; }
.icon-btn {
  appearance: none; border: 0; background: transparent; color: var(--muted); width: 44px; height: 44px;
  display: grid; place-items: center; border-radius: 50%; cursor: pointer; flex: none;
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn svg, .btn svg { width: 20px; height: 20px; }
.link-btn { appearance: none; border: 0; background: none; color: var(--accent); font: inherit; font-weight: 600; padding: 4px 0; cursor: pointer; }

/* ---------- form ---------- */
label.field { display: grid; gap: 6px; font-size: 14px; font-weight: 600; }
label.field small, .hint { color: var(--muted); font-weight: 400; font-size: 13px; }
input, select, textarea {
  font: inherit; font-size: 16px; /* iOS'ta yakınlaştırmayı önler */
  color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 11px; padding: 11px 12px; width: 100%; min-height: 46px;
}
textarea { resize: vertical; min-height: 80px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input[type="checkbox"] { width: 22px; height: 22px; min-height: 0; accent-color: var(--accent); flex: none; margin: 0; }
.check-row { display: flex; align-items: flex-start; gap: 10px; font-size: 15px; cursor: pointer; }
.check-row small { display: block; color: var(--muted); font-size: 13px; }
.form { display: grid; gap: 14px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row-amount { display: grid; grid-template-columns: 1fr 110px; gap: 10px; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 52px; }
.pw-wrap .icon-btn { position: absolute; right: 2px; top: 1px; }
.error-box { background: var(--danger-soft); color: var(--danger); padding: 10px 12px; border-radius: 10px; font-size: 14px; }
.info-box { background: var(--info-soft); color: var(--info); padding: 10px 12px; border-radius: 10px; font-size: 14px; }
.ok-box { background: var(--accent-soft); color: var(--accent); padding: 10px 12px; border-radius: 10px; font-size: 14px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-opt {
  appearance: none; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  min-height: 38px; padding: 0 14px; border-radius: 99px; font: inherit; font-size: 14px; cursor: pointer;
}
.chip-opt.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 4px; }
.segmented button {
  appearance: none; border: 0; background: transparent; min-height: 40px; border-radius: 9px; font: inherit;
  font-size: 14.5px; font-weight: 600; color: var(--muted); cursor: pointer;
}
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

.captcha { display: flex; gap: 8px; align-items: center; }
.captcha img { height: 52px; width: auto; border-radius: 10px; border: 1px solid var(--border); background: #f4f2ec; flex: none; max-width: 60%; }
.captcha input { text-transform: uppercase; letter-spacing: .15em; }

/* ---------- giriş ekranları ---------- */
.auth-wrap { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: 24px 16px calc(24px + var(--safe-b)); max-width: 440px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.brand-logo { width: 42px; height: 42px; border-radius: 12px; background: var(--accent); display: grid; place-items: center; color: var(--accent-text); flex: none; }
.brand-logo svg { width: 24px; height: 24px; }
.brand b { font-size: 20px; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 22px 18px; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 22px; margin-bottom: 4px; }
.auth-foot { text-align: center; margin-top: 18px; font-size: 15px; color: var(--muted); }

.center-page { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card.narrow { max-width: 420px; width: 100%; }
.card.narrow h1 { font-size: 21px; margin: 6px 0 10px; }
.card.narrow .btn { margin-top: 10px; }
.brand-mark { color: var(--accent); font-weight: 700; }

/* ---------- uygulama iskeleti ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 12px 10px 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.topbar h1 { font-size: 21px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .back { margin-left: -10px; }
.page { max-width: 760px; margin: 0 auto; padding: 4px 16px calc(var(--nav-h) + 96px + var(--safe-b)); }

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
}
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); text-decoration: none; font-size: 11.5px; font-weight: 600;
}
.bottom-nav a svg { width: 24px; height: 24px; }
.bottom-nav a.on { color: var(--accent); }
@media (min-width: 900px) {
  .bottom-nav { left: 50%; right: auto; transform: translateX(-50%); width: 560px; bottom: 14px; border: 1px solid var(--border); border-radius: 18px; height: var(--nav-h); padding: 0; box-shadow: var(--shadow); }
}

.fab {
  position: fixed; z-index: 7; right: 16px; bottom: calc(var(--nav-h) + 16px + var(--safe-b));
  width: 58px; height: 58px; border-radius: 18px; border: 0; background: var(--accent); color: var(--accent-text);
  display: grid; place-items: center; box-shadow: 0 6px 20px rgba(0,0,0,.18); cursor: pointer;
}
.fab svg { width: 28px; height: 28px; }
.fab:active { transform: scale(.95); }
@media (min-width: 900px) { .fab { right: calc(50% - 380px); bottom: 100px; } }

/* ---------- özet kartları ---------- */
.greet { margin: 2px 0 14px; color: var(--muted); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); min-width: 0; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 20px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat .sub { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat.alert .value { color: var(--danger); }
@media (min-width: 640px) { .stats { grid-template-columns: repeat(4, 1fr); } }

/* ---------- listeler ---------- */
.group { margin-bottom: 20px; }
.group-head { display: flex; justify-content: space-between; align-items: baseline; margin: 0 4px 8px; gap: 8px; }
.group-head h3 { font-size: 12.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.group-head.overdue h3 { color: var(--danger); }
.group-head.today h3 { color: var(--warn); }
.list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--border); cursor: pointer; min-height: 64px; }
.row:first-child { border-top: 0; }
.row:active { background: var(--surface-2); }
.row .body { flex: 1; min-width: 0; }
.row .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .meta { color: var(--muted); font-size: 13px; display: flex; flex-wrap: wrap; gap: 2px 10px; margin-top: 1px; }
.row .right { text-align: right; flex: none; max-width: 45%; }
.row .amount { font-weight: 700; font-variant-numeric: tabular-nums; }
.row .when { font-size: 13px; color: var(--muted); white-space: nowrap; }
.row .when.overdue { color: var(--danger); font-weight: 600; }
.row .when.soon { color: var(--warn); font-weight: 600; }
.row.inactive { opacity: .6; }
.row .chev { color: var(--muted); flex: none; }
.row .chev svg { width: 18px; height: 18px; }

.done-btn {
  flex: none; width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--border);
  background: var(--surface); color: transparent; cursor: pointer; display: grid; place-items: center; padding: 0;
}
.done-btn svg { width: 18px; height: 18px; }
.done-btn:active, .done-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.tag { display: inline-flex; align-items: center; gap: 5px; }
.tag i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.badge { display: inline-flex; align-items: center; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.green { background: var(--accent-soft); color: var(--accent); }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.yellow { background: var(--warn-soft); color: var(--warn); }
.badge.blue { background: var(--info-soft); color: var(--info); }

.empty { text-align: center; padding: 36px 20px; color: var(--muted); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }
.empty h2 { color: var(--text); margin-bottom: 8px; }
.empty .actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
.empty ul { text-align: left; display: inline-block; margin: 8px 0 0; padding-left: 20px; }

.search { margin-bottom: 14px; }

/* ---------- notlar / listeler ---------- */
.notes { display: grid; gap: 12px; }
@media (min-width: 640px) { .notes { grid-template-columns: 1fr 1fr; } }
.note { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.note-head { display: flex; align-items: flex-start; gap: 8px; cursor: pointer; }
.note-head h3 { flex: 1; font-size: 16px; }
.note p { color: var(--muted); font-size: 14px; white-space: pre-wrap; margin: 6px 0 0; overflow-wrap: anywhere; }
.checklist { list-style: none; margin: 8px 0 0; padding: 0; }
.checklist li { display: flex; align-items: center; gap: 10px; padding: 6px 0; min-height: 40px; font-size: 15px; }
.checklist li.done span { text-decoration: line-through; color: var(--muted); }
.checklist li span { flex: 1; overflow-wrap: anywhere; }
.progress { height: 4px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.progress i { display: block; height: 100%; background: var(--accent); }

/* düzenleme formundaki liste */
.edit-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.edit-list li { display: flex; align-items: center; gap: 8px; }
.edit-list li input[type="text"] { min-height: 42px; padding: 8px 10px; }
.add-line { display: flex; gap: 8px; }

/* ---------- takvim ---------- */
.cal-head { display: flex; align-items: center; gap: 4px; margin-bottom: 10px; }
.cal-head h2 { flex: 1; text-align: center; text-transform: capitalize; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-dow { text-align: center; font-size: 12px; color: var(--muted); font-weight: 700; padding: 4px 0; }
.cal-day {
  appearance: none; border: 1px solid transparent; background: var(--surface); border-radius: 11px; min-height: 52px;
  padding: 6px 2px 4px; display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; font: inherit; color: var(--text);
}
.cal-day.other { background: transparent; color: var(--muted); opacity: .55; }
.cal-day.today .num { background: var(--accent); color: var(--accent-text); }
.cal-day.sel { border-color: var(--accent); }
.cal-day .num { font-size: 14px; font-weight: 600; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; }
.cal-day .dots { display: flex; gap: 3px; flex-wrap: wrap; justify-content: center; max-width: 100%; }
.cal-day .dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.cal-day .dots b { font-size: 10px; color: var(--muted); line-height: 6px; }
.cal-list { margin-top: 16px; }
.cal-total { margin-top: 10px; text-align: right; }

/* ---------- hesap / admin ---------- */
.section { margin-bottom: 18px; }
.section > h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 4px 8px; font-weight: 700; }
.section .card { display: grid; gap: 14px; }
.kv { display: flex; justify-content: space-between; gap: 12px; font-size: 15px; }
.kv span:first-child { color: var(--muted); }
.kv span:last-child { text-align: right; overflow-wrap: anywhere; }
.email-row { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-top: 1px solid var(--border); flex-wrap: wrap; }
.email-row:first-child { border-top: 0; padding-top: 0; }
.email-row .addr { flex: 1; min-width: 160px; overflow-wrap: anywhere; font-weight: 600; }
.email-row .acts { display: flex; gap: 4px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.switch { position: relative; width: 52px; height: 32px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; background: var(--surface-3); border-radius: 99px; transition: .2s; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: .2s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); }
details.card > summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; align-items: center; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after { content: "›"; font-size: 22px; color: var(--muted); transition: .2s; }
details.card[open] > summary::after { transform: rotate(90deg); }
details.card[open] > summary { margin-bottom: 14px; }
details.card:not([open]) { gap: 0; }

.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; flex: none; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.admin-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.admin-head .avatar { width: 52px; height: 52px; font-size: 20px; }
.admin-head h2 { font-size: 20px; }
.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 380px) { .btn-grid { grid-template-columns: 1fr; } }
.scroll-chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px 14px; padding: 0 16px; }
.scroll-chips::-webkit-scrollbar { display: none; }
.scroll-chips .chip-opt { flex: none; }

/* ---------- alt sayfa (sheet) ---------- */
dialog.sheet {
  border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 100%; max-height: 94dvh;
  border-radius: 20px 20px 0 0; background: var(--surface); color: var(--text); overflow: hidden;
  display: flex; flex-direction: column;
}
dialog.sheet:not([open]) { display: none; }
dialog.sheet::backdrop { background: rgba(15,15,13,.5); }
dialog.sheet[open] { animation: up .22s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 10px 8px 10px 18px; border-bottom: 1px solid var(--border); flex: none; }
.sheet-head h2 { flex: 1; }
.sheet-body { overflow-y: auto; padding: 16px 18px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.sheet-foot { display: flex; gap: 8px; padding: 12px 18px calc(12px + var(--safe-b)); border-top: 1px solid var(--border); flex: none; flex-wrap: wrap; }
.sheet-foot .btn { flex: 1; }
.sheet-handle { width: 40px; height: 5px; border-radius: 99px; background: var(--surface-3); margin: 8px auto 0; flex: none; }
@media (min-width: 640px) {
  dialog.sheet { margin: auto; max-width: 540px; border-radius: 20px; max-height: 88dvh; }
  .sheet-handle { display: none; }
}
dialog.sheet.small-sheet { max-width: 420px; }
@media (min-width: 640px) { dialog.sheet.small-sheet { max-width: 420px; } }

.more { display: grid; gap: 14px; padding-top: 4px; }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 90px + var(--safe-b)); transform: translateX(-50%) translateY(16px); opacity: 0;
  background: var(--text); color: var(--bg); padding: 12px 16px; border-radius: 12px; font-size: 14.5px;
  transition: .2s; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); z-index: 50; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.error { background: var(--danger); color: #fff; }
.auth-wrap ~ #toast, body.no-nav #toast { bottom: calc(24px + var(--safe-b)); }

.spinner { width: 28px; height: 28px; border: 3px solid var(--surface-3); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin: 60px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* yasal metin sayfası */
.doc { max-width: 720px; margin: 0 auto; padding: 24px 16px 48px; }
.doc h1 { margin-bottom: 16px; }
.doc h2 { margin: 24px 0 8px; font-size: 17px; }
.doc p, .doc li { color: var(--text); font-size: 15px; }

.link-btn.small { font-size: 13.5px; }
