:root {
  --bg: #f4f5fb; --surface: #ffffff; --surface-2: #f0f2fa; --text: #1b1f3b; --muted: #6b7194;
  --border: #e3e6f3; --primary: #4f46e5; --primary-2: #7c3aed; --primary-text: #fff;
  --danger: #e11d48; --good: #059669; --warn: #d97706;
  --shadow: 0 1px 2px rgba(20,24,60,.05), 0 8px 24px rgba(20,24,60,.06);
  --radius: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1020; --surface: #171a30; --surface-2: #1e2240; --text: #e9ebff; --muted: #959bc4;
    --border: #2a2f55; --primary: #818cf8; --primary-2: #a78bfa; --primary-text: #0e1020;
    --danger: #fb7185; --good: #34d399; --warn: #fbbf24;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background-image: radial-gradient(900px 400px at 10% -10%, color-mix(in srgb, var(--primary) 14%, transparent), transparent),
                    radial-gradient(700px 400px at 100% 0%, color-mix(in srgb, var(--primary-2) 12%, transparent), transparent);
  background-attachment: fixed;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.3em; margin: .25rem 0; font-size: 14px; }
h1, h2, h3 { margin: 0 0 .4rem; line-height: 1.2; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.2rem 0; }
small { opacity: .75; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.2rem; }

/* form */
label, .field { display: block; font-size: 13px; color: var(--muted); margin: .7rem 0; font-weight: 500; }
input, select {
  display: block; width: 100%; margin-top: .3rem; padding: .7rem .85rem; font: inherit; font-size: 16px; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; outline: none;
}
input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent); }
.btn { font: inherit; font-weight: 600; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: .65rem 1rem; border-radius: 12px; cursor: pointer; transition: transform .06s, filter .15s; }
.btn:hover { filter: brightness(1.05); } .btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: var(--primary-text); border: 0; }
.btn.danger { color: var(--danger); } .btn.ghost { background: transparent; }
.btn.small { padding: .35rem .65rem; font-size: 14px; } .btn.block { width: 100%; margin-top: .6rem; }

/* login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: min(380px, 100%); padding: 2rem 1.6rem; text-align: center; }
.login-card label { text-align: left; }
.logo { font-size: 44px; }

/* layout */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 1rem; padding: .7rem 1.2rem;
  background: color-mix(in srgb, var(--surface) 85%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); }
.brand { font-weight: 800; font-size: 16px; white-space: nowrap; letter-spacing: -.02em; }
.tabs { display: flex; gap: .3rem; flex: 1; }
.tabs button { font: inherit; font-weight: 600; padding: .45rem .9rem; border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer; }
.tabs button.active { background: var(--surface-2); color: var(--text); }
.user { display: flex; align-items: center; gap: .4rem; color: var(--muted); font-weight: 600; }
.periodbar, .content { max-width: 1100px; margin: 0 auto; padding: 0 1.2rem; }
.periodbar { padding-top: 1.1rem; display: flex; flex-wrap: wrap; gap: .8rem 1.2rem; align-items: center; }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; }
.chip { font: inherit; font-weight: 600; padding: .45rem .85rem; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; }
.chip small { margin-left: .25rem; }
.chip.active { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: var(--primary-text); border-color: transparent; }
.monthnav { display: flex; align-items: center; gap: .4rem; min-width: 11rem; justify-content: center; }
.custom { display: flex; gap: .5rem; align-items: center; } .custom input { margin: 0; }
.content { padding-top: 1rem; padding-bottom: 6rem; }

/* dashboard */
.grid { display: grid; gap: 1rem; }
.stats { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.two { grid-template-columns: 1.1fr 1fr; margin-top: 1rem; }
@media (max-width: 1000px) { .two { grid-template-columns: 1fr; } .brand { display: none; } .topbar { padding: .5rem .8rem; } }
.stat .label { color: var(--muted); font-size: 13px; font-weight: 600; }
.stat .value { font-size: 28px; font-weight: 800; letter-spacing: -.03em; margin: .15rem 0; }
.stat.hero { background: linear-gradient(135deg, var(--primary), var(--primary-2)); border: 0; color: #fff; }
.stat.hero .label { color: rgba(255,255,255,.8); }
.delta { font-size: 13px; font-weight: 600; } .delta.up { color: var(--danger); } .delta.down { color: var(--good); }
.hero .delta { color: #fff; opacity: .95; }
.progress { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: .5rem; }
.progress > i { display: block; height: 100%; border-radius: 99px; background: var(--good); }
.progress.warn > i { background: var(--warn); } .progress.over > i { background: var(--danger); }
.card h3 { font-size: 15px; margin-bottom: .8rem; }
.chart-box { position: relative; height: 260px; }
.legend { list-style: none; margin: .8rem 0 0; padding: 0; display: grid; gap: .45rem; }
.legend li { display: flex; align-items: center; gap: .6rem; }
.dot { width: 12px; height: 12px; border-radius: 4px; flex: none; }
.legend .amt { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.legend .pct { color: var(--muted); width: 3.2rem; text-align: right; font-size: 13px; }
.people { display: grid; gap: .8rem; }
.person .bar { height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: .3rem; }
.person .bar i { display: block; height: 100%; border-radius: 99px; }
.person .top { display: flex; justify-content: space-between; font-weight: 600; }
.note { margin-top: .8rem; padding: .7rem .9rem; border-radius: 12px; background: var(--surface-2); color: var(--muted); font-size: 14px; }

/* liste */
.toolbar { display: flex; gap: .6rem; flex-wrap: wrap; margin-bottom: .8rem; }
.toolbar input, .toolbar select { margin: 0; width: auto; flex: 1 1 140px; }
.list { display: grid; gap: .5rem; }
.item { display: flex; align-items: center; gap: .8rem; padding: .7rem .9rem; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; cursor: pointer; text-align: left; font: inherit; color: inherit; width: 100%; }
.item:hover { border-color: var(--primary); }
.badge { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; flex: none; }
.item .main { flex: 1; min-width: 0; }
.item .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .s { color: var(--muted); font-size: 13px; }
.item .a { font-weight: 800; font-variant-numeric: tabular-nums; }
.dayhead { color: var(--muted); font-size: 13px; font-weight: 700; margin: 1rem 0 .1rem; display: flex; justify-content: space-between; }
.empty { text-align: center; color: var(--muted); padding: 2.5rem 1rem; }

/* fab + dialog */
.fab { position: fixed; right: max(1.2rem, env(safe-area-inset-right)); bottom: max(1.2rem, env(safe-area-inset-bottom)); width: 58px; height: 58px; border-radius: 50%;
  border: 0; font-size: 30px; line-height: 1; color: var(--primary-text); cursor: pointer; z-index: 30;
  background: linear-gradient(135deg, var(--primary), var(--primary-2)); box-shadow: 0 10px 28px color-mix(in srgb, var(--primary) 45%, transparent); }
dialog { border: 0; padding: 0; background: transparent; color: var(--text); width: min(460px, calc(100% - 1.5rem)); max-height: 92dvh; overflow: visible; }
dialog::backdrop { background: rgba(10,12,30,.55); backdrop-filter: blur(3px); }
dialog .card { max-height: 90dvh; overflow: auto; }
.actions { display: flex; gap: .5rem; align-items: center; margin-top: .8rem; } .spacer { flex: 1; }
.row { display: flex; gap: .8rem; } .row label { flex: 1; }
.catpick { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: .4rem; margin-top: .4rem; }
.catpick button { font: inherit; font-size: 13px; font-weight: 600; padding: .5rem .3rem; border-radius: 12px; border: 2px solid var(--border);
  background: var(--surface-2); color: var(--text); cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: .1rem; }
.catpick button span { font-size: 20px; }
.catpick button.sel { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 14%, var(--surface)); }
.toast { position: fixed; left: 50%; bottom: 5.5rem; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: .6rem 1rem; border-radius: 12px; font-weight: 600; transition: .25s; z-index: 50; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* passkey / banner */
.or { display: flex; align-items: center; gap: .8rem; color: var(--muted); font-size: 13px; margin: 1rem 0 .2rem; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.banner { max-width: 1100px; margin: 1rem auto 0; padding: .9rem 1.1rem; display: flex; gap: 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap;
  background: color-mix(in srgb, var(--primary) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--primary) 35%, var(--border)); border-radius: var(--radius); width: calc(100% - 2.4rem); }
.banner .actions { margin: 0; }
.plist { list-style: none; padding: 0; margin: 0 0 .8rem; display: grid; gap: .4rem; }
.plist li { display: flex; align-items: center; gap: .6rem; padding: .5rem .7rem; background: var(--surface-2); border-radius: 10px; }
.plist li span { flex: 1; } .plist small { display: block; }

/* diyalog: yatay taşma/kaydırma yok */
dialog .card { overflow-x: hidden; overscroll-behavior: contain; }
dialog form, dialog .card > * { max-width: 100%; }
dialog input, dialog select { min-width: 0; max-width: 100%; }
dialog input[type="date"] { -webkit-appearance: none; appearance: none; min-height: 2.9rem; }
.row label { min-width: 0; }
.catpick button { min-width: 0; overflow-wrap: anywhere; }
body { overflow-x: hidden; }

.version { font-size: 12px; margin: .8rem 0 0; }

/* grid taşmasını önle */
.grid > *, .two > * { min-width: 0; }
.chart-box canvas { max-width: 100%; }

/* form: kaydet/vazgeç hep görünsün, kategori butonları daha kompakt */
dialog .actions.sticky { position: sticky; bottom: -1.1rem; margin: .8rem -1.2rem -1.1rem; padding: .8rem 1.2rem 1.1rem; background: var(--surface); border-top: 1px solid var(--border); }
.catpick { grid-template-columns: repeat(3, 1fr); gap: .35rem; }
.catpick button { padding: .4rem .2rem; font-size: 12.5px; gap: 0; line-height: 1.25; }
.catpick button span { font-size: 18px; }
@media (min-width: 520px) { .catpick { grid-template-columns: repeat(4, 1fr); } }
dialog .card > .actions.sticky { max-width: none; }

/* ödeme yöntemi */
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: .35rem; margin-top: .4rem; }
.seg button { font: inherit; font-size: 14px; font-weight: 600; padding: .6rem .2rem; border-radius: 12px; border: 2px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; }
.seg button.sel { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 14%, var(--surface)); }
