:root {
  --bg: #ffffff;
  --card: #ffffff;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #86868b;
  --sep: rgba(60, 60, 67, .14);
  --fill: rgba(118, 118, 128, .12);
  --accent: #0071e3;
  --green: #248a3d;
  --red: #d70015;
  --sheet-bg: #ffffff;
  --shadow: 0 0 0 1px #e8e8ed;
  --line: #e8e8ed;
  --side-bg: #fbfbfd;
  --side-w: 260px;
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

* { 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: 17px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "Segoe UI", Roboto, Arial, sans-serif;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
button, input, textarea, select { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Yerleşim ---------- */
.page {
  max-width: 720px;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 12px) 16px calc(var(--safe-bottom) + 24px);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
.page > main { flex: 1; }

.navbar {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 44px; gap: 8px;
}
.nav-btn {
  border: 0; background: none; color: var(--accent);
  font-size: 17px; padding: 8px 4px; display: inline-flex; align-items: center; gap: 2px;
}
.nav-btn svg { width: 22px; height: 22px; }
.nav-btn:active { opacity: .5; }
.icon-btn {
  border: 0; background: var(--fill); color: var(--accent);
  width: 34px; height: 34px; border-radius: 50%;
  display: inline-grid; place-items: center;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:active { opacity: .6; }

.large-title {
  font-size: 34px; font-weight: 700; letter-spacing: -0.025em; line-height: 1.15;
  margin: 4px 0 16px;
}

/* ---------- Özet ---------- */
.summary {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 20px; margin-bottom: 20px;
}
.summary .label { font-size: 13px; color: var(--text-3); font-weight: 500; }
.summary .value { font-size: 34px; font-weight: 600; letter-spacing: -0.02em; margin-top: 2px; }
.summary .sub { font-size: 15px; color: var(--text-2); margin-top: 2px; }
.summary-split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; padding-top: 14px; border-top: .5px solid var(--sep); }
.summary-split .value { font-size: 17px; font-weight: 600; }

/* ---------- Arama ---------- */
.search {
  position: relative; margin-bottom: 16px;
}
.search input {
  width: 100%; border: 0; outline: 0;
  background: var(--fill); border-radius: 10px;
  padding: 9px 12px 9px 34px; font-size: 17px;
}
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--text-3); }

/* ---------- Gruplu liste ---------- */
.section-title {
  font-size: 13px; color: var(--text-3); text-transform: uppercase; letter-spacing: .02em;
  margin: 22px 16px 6px;
}
.list {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden;
}
.row {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left; border: 0; background: none;
  padding: 12px 16px; min-height: 56px; position: relative;
}
.row + .row::before {
  content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: .5px solid var(--sep);
}
button.row:active { background: var(--fill); }
.row .main { flex: 1; min-width: 0; }
.row .title { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .subtitle { font-size: 14px; color: var(--text-3); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .end { text-align: right; flex-shrink: 0; }
.row .amount { font-size: 17px; font-weight: 500; }
.row .chev { color: var(--text-3); opacity: .6; width: 8px; flex-shrink: 0; }
.amount.pay { color: var(--green); }
.amount.zero { color: var(--text-3); font-weight: 400; }

.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-size: 15px; font-weight: 600;
  background: var(--fill); color: var(--text-2);
}
.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--text); opacity: .85; }
.dot.pay { background: var(--green); opacity: 1; }

.empty { text-align: center; color: var(--text-3); padding: 40px 20px; font-size: 15px; }
.empty strong { display: block; color: var(--text); font-size: 17px; font-weight: 600; margin-bottom: 4px; }

/* ---------- Butonlar ---------- */
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 4px; }
.btn {
  border: 0; border-radius: 12px; padding: 13px 16px; font-size: 17px; font-weight: 600;
  background: var(--accent); color: #fff; width: 100%;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn svg { width: 18px; height: 18px; }
.btn.secondary { background: var(--card); color: var(--accent); box-shadow: var(--shadow); }
.btn.tinted { background: var(--fill); color: var(--accent); }
.btn.danger { background: none; color: var(--red); font-weight: 400; }
.btn:active { opacity: .7; }
.btn:disabled { opacity: .4; }

/* ---------- Segment ---------- */
.segment {
  display: flex; background: var(--fill); border-radius: 9px; padding: 2px; margin: 22px 0 10px;
}
.segment button {
  flex: 1; border: 0; background: none; border-radius: 7px; padding: 6px 8px; font-size: 13px; font-weight: 500;
}
.segment button.on { background: var(--card); box-shadow: 0 1px 3px rgba(0,0,0,.12), 0 1px 1px rgba(0,0,0,.04); font-weight: 600; }

/* ---------- Giriş ---------- */
.login {
  min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(var(--safe-top) + 24px) 24px calc(var(--safe-bottom) + 24px);
}
.login-box { width: 100%; max-width: 340px; text-align: center; }
.login-box img { width: 72px; height: 72px; border-radius: 17px; margin-bottom: 18px; }
.login-box h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 4px; }
.login-box p { color: var(--text-3); margin: 0 0 28px; font-size: 15px; }
.login-box .fields { text-align: left; }
.login-box .btn { margin-top: 18px; }
.login-error { color: var(--red); font-size: 14px; min-height: 20px; margin-top: 10px; }

/* ---------- Formlar ---------- */
.fields { background: var(--card); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
.field { display: flex; align-items: center; padding: 0 16px; min-height: 48px; position: relative; gap: 12px; }
.field + .field::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: .5px solid var(--sep); }
.field label { width: 96px; flex-shrink: 0; font-size: 17px; }
.field input, .field textarea {
  flex: 1; min-width: 0; border: 0; outline: 0; background: none; padding: 13px 0; font-size: 17px;
}
.field input::placeholder, .field textarea::placeholder { color: var(--text-3); opacity: .8; }
.field textarea { resize: none; min-height: 44px; }
.field input[type=date] { -webkit-appearance: none; appearance: none; text-align: left; min-height: 48px; }
.field input[type=date]::-webkit-date-and-time-value { text-align: left; }
.field .req { color: var(--text-3); font-size: 13px; }
.form-hint { font-size: 13px; color: var(--text-3); margin: 8px 16px 18px; }
.form-hint.calc { color: var(--accent); }
.field-group + .field-group { margin-top: 22px; }

/* ---------- Sheet (alt panel) ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.32); z-index: 40;
  opacity: 0; transition: opacity .25s ease;
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  background: var(--sheet-bg);
  border-radius: 14px 14px 0 0;
  max-height: calc(100dvh - var(--safe-top) - 24px);
  overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: 0 16px calc(var(--safe-bottom) + 20px);
  transform: translateY(100%); transition: transform .32s cubic-bezier(.32,.72,0,1);
}
.sheet.open { transform: none; }
.sheet-backdrop.open { opacity: 1; }
@media (min-width: 640px) {
  .sheet {
    left: 50%; right: auto; bottom: auto; top: 50%; width: 480px;
    border-radius: 16px; max-height: 86vh;
    transform: translate(-50%, -46%) scale(.98); opacity: 0;
    transition: transform .25s ease, opacity .2s ease;
  }
  .sheet.open { transform: translate(-50%, -50%); opacity: 1; }
}
.sheet-head {
  position: sticky; top: 0; z-index: 1; background: var(--sheet-bg);
  display: grid; grid-template-columns: 1fr; align-items: center;
  min-height: 56px; margin: 0 -16px 8px; padding: 0 16px;
}
.sheet-head h2 { font-size: 17px; font-weight: 600; margin: 0; text-align: center; }
.sheet-head .nav-btn:last-child { justify-self: end; font-weight: 600; }
.sheet-head .nav-btn:first-child { justify-self: start; }
.sheet-type { display: flex; background: var(--fill); border-radius: 9px; padding: 2px; margin-bottom: 18px; }
.sheet-type button { flex: 1; border: 0; background: none; border-radius: 7px; padding: 7px; font-size: 14px; font-weight: 500; }
.sheet-type button.on { background: var(--card); box-shadow: 0 1px 3px rgba(0,0,0,.12); font-weight: 600; }

/* ---------- Detay ---------- */
.detail-head { text-align: center; margin: 8px 0 22px; }
.detail-head .avatar { width: 64px; height: 64px; font-size: 24px; margin: 0 auto 12px; }
.detail-head h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; margin: 0; }
.detail-head .meta { color: var(--text-3); font-size: 14px; margin-top: 2px; }

.month { font-size: 13px; color: var(--text-3); text-transform: uppercase; letter-spacing: .02em; margin: 20px 16px 6px; display: flex; justify-content: space-between; }

/* ---------- Altbilgi ---------- */
.footer { text-align: center; color: var(--text-3); font-size: 12px; padding: 36px 0 4px; }
.footer b { font-weight: 600; color: var(--text-2); }

/* ---------- Bildirim ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 24px); z-index: 60;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: rgba(29,29,31,.92); color: #fff; padding: 10px 18px; border-radius: 22px; font-size: 15px;
  transition: all .25s ease; -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  max-width: calc(100vw - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

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

@media (prefers-reduced-motion: reduce) {
  .sheet, .sheet-backdrop, #toast { transition: none; }
}

/* ---------- Beyaz tema ayarları ---------- */
.summary { background: #f5f5f7; box-shadow: none; }
.btn.secondary { background: #f5f5f7; box-shadow: none; }
.segment { background: #f5f5f7; }
.segment button.on, .sheet-type button.on { background: #fff; }
.sheet { box-shadow: 0 -8px 40px rgba(0,0,0,.12); }
.sheet-type { background: #f5f5f7; }
.search input { background: #f5f5f7; }

/* ---------- Kabuk + sol menü ---------- */
body.auth .sidebar, body.auth .side-backdrop { display: none; }
.sidebar {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 50;
  width: var(--side-w); background: var(--side-bg); border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: calc(var(--safe-top) + 18px) 12px calc(var(--safe-bottom) + 14px);
  transform: translateX(-100%); transition: transform .3s cubic-bezier(.32,.72,0,1);
}
.sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.15); }
.side-backdrop { position: fixed; inset: 0; z-index: 49; background: rgba(0,0,0,.25); opacity: 0; pointer-events: none; transition: opacity .25s; }
.side-backdrop.open { opacity: 1; pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; }
.brand img { width: 34px; height: 34px; border-radius: 8px; }
.brand b { display: block; font-size: 15px; font-weight: 600; line-height: 1.2; }
.brand span { display: block; font-size: 12px; color: var(--text-3); }
.side-new { margin: 0 4px 14px; padding: 9px 12px; font-size: 15px; border-radius: 9px; }
.side-nav a, .side-list a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  color: var(--text); text-decoration: none; font-size: 15px;
}
.side-nav a svg { width: 18px; height: 18px; color: var(--text-2); }
.side-nav a:hover, .side-list a:hover { background: rgba(0,0,0,.04); }
.side-nav a.on, .side-list a.on { background: rgba(0,113,227,.09); color: var(--accent); font-weight: 500; }
.side-nav a.on svg { color: var(--accent); }
.side-label { font-size: 11px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; padding: 18px 10px 6px; }
.side-list { flex: 1; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.side-list a { font-size: 14px; justify-content: space-between; padding: 7px 10px; }
.side-list a span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-list a span:last-child { color: var(--text-3); font-size: 13px; font-variant-numeric: tabular-nums; flex-shrink: 0; }
.side-list a.on span:last-child { color: var(--accent); }
.side-foot { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 8px; }
.side-foot button { border: 0; background: none; color: var(--text-2); font-size: 14px; padding: 8px 10px; width: 100%; text-align: left; border-radius: 8px; }
.side-foot button:hover { background: rgba(0,0,0,.04); color: var(--red); }
.menu-btn { background: #f5f5f7; color: var(--text); }

@media (min-width: 900px) {
  .sidebar { transform: none; transition: none; }
  .sidebar.open { box-shadow: none; }
  .side-backdrop { display: none; }
  body:not(.auth) #app { margin-left: var(--side-w); }
  .menu-btn { display: none !important; }
  .page { padding-top: 28px; max-width: 760px; }
  .sheet { left: calc(50% + var(--side-w) / 2); }
}

/* ---------- Alt butonlar + kalın yazı ---------- */
.sheet-head h2 { font-size: 18px; font-weight: 700; }
.sheet-head::before { content: ""; position: absolute; top: 7px; left: 50%; width: 36px; height: 5px; margin-left: -18px; border-radius: 3px; background: #d1d1d6; }
@media (min-width: 640px) { .sheet-head::before { display: none; } }
.sheet { padding-bottom: 0; }
.sheet-foot {
  position: sticky; bottom: 0; z-index: 1; background: var(--sheet-bg);
  display: grid; grid-template-columns: 1fr 2fr; gap: 10px;
  margin: 22px -16px 0; padding: 12px 16px calc(var(--safe-bottom) + 14px);
  border-top: 1px solid var(--line);
}
.sheet-foot .btn { padding: 15px 16px; font-size: 17px; font-weight: 700; }
.sheet-foot .btn.tinted { background: #f2f2f7; color: var(--text); }
.btn.danger { font-weight: 600; }

body { font-weight: 500; }
.row .title, .side-list a span:first-child { font-weight: 600; }
.row .subtitle, .form-hint, .summary .sub, .detail-head .meta { font-weight: 500; color: var(--text-2); }
.row .amount { font-weight: 700; }
.summary .label, .side-label, .section-title, .month { font-weight: 600; }
.summary .value { font-weight: 700; }
.summary-split .value { font-weight: 700; }
.field label { font-weight: 600; }
.field input, .field textarea { font-weight: 500; }
.segment button, .sheet-type button { font-weight: 600; }
.segment button.on, .sheet-type button.on { font-weight: 700; }
.nav-btn { font-weight: 500; }
.side-nav a { font-weight: 600; }
.brand b { font-weight: 700; }
.footer { font-weight: 500; }
.footer b { font-weight: 700; }

.footer .quote { margin: 0 auto; max-width: 420px; font-size: 14px; line-height: 1.5; color: var(--text-2); font-weight: 500; font-style: italic; text-wrap: balance; }
.footer .quote-src { display: block; margin-top: 4px; font-size: 12px; color: var(--text-3); font-weight: 600; }
