/* ==========================================================================
   Ev Bütçesi design system
   Neutral surfaces, one emerald accent, Inter, tabular figures for money.
   Light and dark are each tuned (not an automatic inversion).
   ========================================================================== */
:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --tile: #f1f3f5;          /* icon tiles, inputs, inset blocks */
  --text: #0f1419;
  --muted: #6b7280;
  --faint: #9ca3af;
  --line: #e7e9ec;
  --accent: #0e9f6e;
  --accent-strong: #0b7a55;
  --accent-soft: rgba(14, 159, 110, .11);
  --on-accent: #ffffff;
  --pos: #0e9f6e; --neg: #e5484d; --warn: #d97706;
  --hero-1: #10b981; --hero-2: #0b7a55; --hero-3: #064e3b;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 2px 8px rgba(16, 24, 40, .05);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, .14);
  --r-lg: 22px; --r-md: 16px; --r-sm: 12px;
  /* Categorical chart slots (validated CVD-safe order); --s-other = folded tail. */
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #6250d6; --s-other: #a8aca9;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0c0f; --card: #14171c; --tile: #1c2027; --text: #f3f4f6; --muted: #9aa3af; --faint: #6b7280; --line: #232830;
    --accent: #34d399; --accent-strong: #6ee7b7; --accent-soft: rgba(52, 211, 153, .13); --on-accent: #052e1f;
    --pos: #34d399; --neg: #f87171; --warn: #fbbf24;
    --hero-1: #059669; --hero-2: #065f46; --hero-3: #022c22;
    --shadow: none; --shadow-lg: 0 10px 30px rgba(0, 0, 0, .5);
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #9085e9; --s-other: #5c625e;
    color-scheme: dark;
  }
}

/* ---------- base ---------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* Browser pull-to-refresh is off (it fired inside sheets); app.js has its own, main screen only. */
html, body { overscroll-behavior-y: none; }
/* No zooming: double-tap zoom off (pinch is blocked in app.js for iOS). */
html { touch-action: manipulation; }
html, body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 16px/1.45 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv11", "ss01"; -webkit-font-smoothing: antialiased;
}
body { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
b, strong { font-weight: 650; }
small { font-size: 13px; }
h1 { font-size: 30px; line-height: 1.1; font-weight: 750; letter-spacing: -.025em; margin: 0; }
h2 { font-size: 15px; font-weight: 650; letter-spacing: -.01em; margin: 0 0 12px; color: var(--text); }
h3 { font-size: 12px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; margin: 22px 0 8px; color: var(--muted); }
.muted { color: var(--muted); }
.pos { color: var(--pos); } .neg { color: var(--neg); }
small.warn, span.warn { color: var(--warn); } small.over { color: var(--neg); }
.center { padding: 48px 20px; text-align: center; }
/* Money lines up in columns. */
.tx > span:last-child, .tx .r2, .line b, .card b, .hero-amt, .pf-value, .cattop, .items, .legend-list .pc, .amount { font-variant-numeric: tabular-nums; }

/* ---------- controls ---------- */
button, input, select, textarea { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
input, select, textarea {
  width: 100%; padding: 13px 14px; font-size: 16px; /* 16px: iOS won't zoom on focus */
  border: 1.5px solid transparent; border-radius: var(--r-sm); background: var(--tile); transition: border-color .15s, background .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); background: var(--card); }
input::placeholder { color: var(--faint); }
label { display: block; margin: 12px 0; font-size: 13px; font-weight: 550; color: var(--muted); }
label > input, label > select { margin-top: 6px; color: var(--text); font-weight: 400; }

.primary, .ghost, .danger {
  display: block; width: 100%; margin-top: 10px; padding: 14px 18px; border-radius: 14px;
  font-weight: 650; font-size: 15px; letter-spacing: -.01em; transition: transform .08s, filter .15s;
}
.primary:active, .ghost:active, .danger:active { transform: scale(.98); }
.primary { background: var(--accent); color: var(--on-accent); box-shadow: 0 4px 14px -4px color-mix(in srgb, var(--accent) 60%, transparent); }
.ghost { background: var(--accent-soft); color: var(--accent-strong); }
@media (prefers-color-scheme: dark) { .ghost { color: var(--accent); } }
.danger { background: color-mix(in srgb, var(--neg) 10%, transparent); color: var(--neg); }
.sm { padding: 10px 14px; font-size: 14px; border-radius: 12px; }
.link { color: var(--muted); margin-top: 20px; text-decoration: underline; }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }
.row .emoji { flex: 0 0 60px; text-align: center; font-size: 22px; }

/* Segmented control */
.seg { display: flex; gap: 2px; background: var(--tile); border-radius: 13px; padding: 3px; }
.seg label { flex: 1; margin: 0; }
.seg input, .chips input { position: absolute; opacity: 0; pointer-events: none; }
.seg span, .kind-seg button {
  display: block; width: 100%; text-align: center; padding: 9px 8px; border-radius: 10px;
  color: var(--muted); font-weight: 600; font-size: 14px; transition: background .15s, color .15s;
}
.seg input:checked + span, .kind-seg button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(16, 24, 40, .12); }
.kind-seg { margin: 16px 0 0; }

/* Chips (category picker) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.chips label { margin: 0; }
.chips span { display: block; padding: 8px 13px; border-radius: 99px; background: var(--tile); color: var(--text); font-size: 14px; font-weight: 500; border: 1.5px solid transparent; }
.chips input:checked + span { background: var(--accent-soft); color: var(--accent-strong); border-color: var(--accent); font-weight: 600; }
@media (prefers-color-scheme: dark) { .chips input:checked + span { color: var(--accent); } }
.chips .chip-add { padding: 8px 13px; border-radius: 99px; border: 1.5px dashed var(--faint); color: var(--muted); font-size: 14px; font-weight: 600; }

label.check { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 15px; font-weight: 500; }
label.check input { width: 22px; height: 22px; margin: 0; accent-color: var(--accent); flex: 0 0 22px; }

/* ---------- app chrome ---------- */
.demo { background: #fef3c7; color: #92400e; text-align: center; font-size: 12px; font-weight: 600; padding: 6px; }
header {
  padding: calc(18px + env(safe-area-inset-top)) 20px 10px; max-width: 640px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.monthnav { display: flex; align-items: center; gap: 2px; background: var(--card); border-radius: 99px; padding: 4px; box-shadow: var(--shadow); font-weight: 600; font-size: 14px; }
.monthnav span { padding: 0 6px; white-space: nowrap; }
.monthnav button { width: 30px; height: 30px; border-radius: 50%; font-size: 18px; line-height: 1; color: var(--text); display: grid; place-items: center; }
.monthnav button:active { background: var(--tile); }
main { padding: 0 16px 90px; max-width: 640px; margin: 0 auto; }
section { background: var(--card); border-radius: var(--r-lg); padding: 18px; margin: 14px 0; box-shadow: var(--shadow); }
.empty { text-align: center; color: var(--muted); padding: 48px 24px; }
.small-note { font-size: 12px; margin: 16px 4px; line-height: 1.5; color: var(--faint); }
.code { display: block; font-size: 13px; padding: 12px; background: var(--tile); border-radius: var(--r-sm); word-break: break-all; user-select: all; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* Bottom tab bar: translucent, line icons, active tint */
nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; justify-content: center;
  background: color-mix(in srgb, var(--card) 82%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
}
nav button { flex: 1; max-width: 120px; padding: 6px 0 4px; font-size: 10.5px; font-weight: 550; color: var(--faint); display: flex; flex-direction: column; align-items: center; gap: 3px; }
nav .ni { display: grid; place-items: center; width: 52px; height: 30px; border-radius: 99px; transition: background .2s; }
nav .ni svg { width: 22px; height: 22px; }
nav button.on { color: var(--text); font-weight: 650; }
nav button.on .ni { background: var(--accent-soft); color: var(--accent-strong); }
@media (prefers-color-scheme: dark) { nav button.on .ni { color: var(--accent); } }

.fab {
  position: fixed; right: 18px; bottom: calc(88px + env(safe-area-inset-bottom)); z-index: 6;
  width: 58px; height: 58px; border-radius: 20px; display: grid; place-items: center;
  background: linear-gradient(145deg, var(--hero-1), var(--hero-2)); color: #fff;
  box-shadow: 0 10px 24px -6px rgba(5, 150, 105, .55); transition: transform .1s;
}
.fab svg { width: 26px; height: 26px; }
.fab:active { transform: scale(.94); }

.toast {
  position: fixed; left: 50%; top: calc(14px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 40;
  background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 14px; font-size: 14px; font-weight: 550;
  max-width: 90vw; box-shadow: var(--shadow-lg); animation: toast-in .2s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -8px); } }

/* ---------- Özet ---------- */
.hero {
  position: relative; overflow: hidden; color: #fff; border-radius: 26px; padding: 22px 20px 18px;
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(255, 255, 255, .18), transparent 55%),
    linear-gradient(150deg, var(--hero-1) 0%, var(--hero-2) 55%, var(--hero-3) 100%);
  box-shadow: 0 16px 34px -14px rgba(6, 95, 70, .6);
}
.hero small { color: rgba(255, 255, 255, .78); font-weight: 550; }
.hero-amt { font-size: 38px; font-weight: 750; letter-spacing: -.03em; line-height: 1.15; margin: 4px 0 16px; }
.hero-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hero-pill {
  display: flex; align-items: center; gap: 10px; text-align: left; color: #fff; padding: 10px 12px; border-radius: 16px;
  background: rgba(255, 255, 255, .12); border: 1.5px solid transparent; transition: background .15s;
}
.hero-pill.sel { background: rgba(255, 255, 255, .22); border-color: rgba(255, 255, 255, .35); }
.hero-pill i { flex: 0 0 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; font-style: normal; background: rgba(255, 255, 255, .2); }
.hero-pill i svg { width: 16px; height: 16px; }
.hero-pill span { display: block; min-width: 0; }
.hero-pill small { display: block; font-size: 12px; }
.hero-pill b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }

.catrow { margin: 4px 0; }
button.catrow { display: block; width: 100%; text-align: left; padding: 10px 0; border-bottom: 1px solid var(--line); }
button.catrow:last-child { border-bottom: 0; }
.cattop { display: flex; justify-content: space-between; gap: 8px; align-items: center; font-size: 15px; }
.cattop > span:first-child { display: flex; align-items: center; gap: 10px; font-weight: 550; }
.bar { height: 6px; background: var(--tile); border-radius: 99px; overflow: hidden; margin: 8px 0 2px; }
.bar i { display: block; height: 100%; border-radius: 99px; background: var(--faint); }
.bar.ok i, .bar.inc i { background: var(--accent); }
.bar.warn i { background: var(--warn); } .bar.over i { background: var(--neg); }
.line { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); width: 100%; text-align: left; }
.line:last-child { border-bottom: 0; }

/* Legacy card grid (still used by some screens) */
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.card { background: var(--card); border-radius: var(--r-lg); padding: 16px; box-shadow: var(--shadow); text-align: left; }
.card small { color: var(--muted); display: block; }
.card b { font-size: 20px; }
.card.wide { grid-column: span 2; }
.card.wide b { font-size: 28px; letter-spacing: -.02em; }

/* ---------- lists (transactions, assets, debts, sheets) ---------- */
.list { background: var(--card); border-radius: var(--r-lg); box-shadow: var(--shadow); overflow: hidden; margin: 6px 0 14px; }
.day { display: flex; justify-content: space-between; font-size: 12px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin: 20px 6px 8px; }
.tx {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 12px 14px; background: transparent; position: relative;
}
.tx + .tx::before { content: ""; position: absolute; top: 0; left: 66px; right: 0; border-top: 1px solid var(--line); }
.list .tx:active, .sheet .tx:active { background: var(--tile); }
.tx .ico { flex: 0 0 40px; height: 40px; border-radius: 13px; background: var(--tile); display: grid; place-items: center; font-size: 19px; }
.tx .mid { flex: 1; min-width: 0; }
.tx .mid b, .tx .mid small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx .mid b { font-weight: 600; font-size: 15px; }
.tx .mid small { color: var(--muted); margin-top: 1px; }
.tx > span:last-child { font-weight: 650; white-space: nowrap; font-size: 15px; }
.tx .r2 { text-align: right; white-space: nowrap; }
.tx .r2 b, .tx .r2 small { display: block; }
.sheet .tx { padding-left: 4px; padding-right: 4px; }
.sheet .tx + .tx::before { left: 4px; }
.debt-list .tx { padding-left: 0; padding-right: 0; }
.debt-list .tx + .tx::before { left: 52px; }
.debt-list details summary { cursor: pointer; padding: 10px 0; font-size: 14px; }
.netline { margin-top: 6px; }

.goal { background: var(--card); border-radius: var(--r-lg); padding: 18px; margin: 14px 0; box-shadow: var(--shadow); }
.goal .cattop b { font-size: 16px; }
.goal .row { margin-top: 8px; }

/* ---------- sheets ---------- */
.overlay {
  position: fixed; inset: auto 0; top: var(--vvtop, 0px); height: var(--vvh, 100%); z-index: 10;
  background: rgba(8, 10, 14, .45); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  display: flex; align-items: flex-end; justify-content: center; animation: fade .18s;
}
.sheet {
  background: var(--card); width: 100%; max-width: 640px; max-height: calc(var(--vvh, 100vh) * 0.92); overflow-y: auto;
  overscroll-behavior: contain; border-radius: 28px 28px 0 0; padding: 8px 20px calc(18px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-lg); animation: up .26s cubic-bezier(.2, .8, .2, 1);
}
.grip-area { position: sticky; top: -8px; z-index: 2; margin: -8px -20px 6px; padding: 10px 0 12px; background: var(--card); touch-action: none; cursor: grab; }
.grip { width: 40px; height: 5px; border-radius: 4px; background: var(--line); margin: 0 auto; }
.sheet h2 { font-size: 21px; font-weight: 700; letter-spacing: -.02em; margin-bottom: 14px; }
/* Save / delete stay visible at the bottom while the sheet content scrolls. */
.sheet form > .row:last-child, .sheet .sticky-actions {
  position: sticky; bottom: calc(-18px - env(safe-area-inset-bottom)); z-index: 1;
  background: color-mix(in srgb, var(--card) 92%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  margin: 14px -20px calc(-18px - env(safe-area-inset-bottom));
  padding: 4px 20px calc(14px + env(safe-area-inset-bottom));
}
.amount {
  font-size: 40px; font-weight: 750; letter-spacing: -.03em; text-align: center;
  border: 0; background: transparent; margin: 12px 0 4px; padding: 10px;
}
.amount:focus { background: transparent; }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

.receipt-row { margin-bottom: 10px; }
.receipt-row .sm { margin-top: 0; }
.scan-status { font-size: 14px; margin: 6px 0 10px; padding: 10px 12px; background: var(--tile); border-radius: var(--r-sm); }
.det { margin: 12px 0; background: var(--tile); border-radius: var(--r-md); padding: 10px 14px; }
.det summary { cursor: pointer; font-weight: 650; padding: 4px 0; }
.det .line span { text-align: right; max-width: 65%; overflow-wrap: anywhere; }
.items { width: 100%; border-collapse: collapse; font-size: 14px; margin: 6px 0; }
.items td { padding: 6px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.items .q { color: var(--muted); white-space: nowrap; padding: 6px 8px; }
.items .r { text-align: right; white-space: nowrap; }
.items .sum td { font-weight: 650; border-bottom: 0; }
.sthead { background: var(--tile); border-radius: var(--r-md); padding: 12px 14px; margin: 10px 0; display: grid; gap: 4px; }
.receipt-img { display: block; width: 100%; border-radius: var(--r-md); background: #fff; }
.btnlink { display: block; text-align: center; text-decoration: none; }
.imp { border-bottom: 1px solid var(--line); padding: 10px 0; }
.imp.off { opacity: .5; }
.imp-top { display: flex; align-items: center; gap: 10px; margin: 0; color: var(--text); }
.imp-top input { width: 22px; height: 22px; flex: 0 0 22px; accent-color: var(--accent); }
.imp-top .mid { flex: 1; min-width: 0; }
.imp-top .mid b, .imp-top .mid small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.imp-top > span:last-child { font-weight: 650; white-space: nowrap; }
.imp select { margin-top: 8px; padding: 8px 10px; font-size: 16px; }
.wipe-list { margin: 4px 0 8px; padding-left: 20px; font-size: 14px; }
.wipe-list li { margin: 4px 0; }

/* ---------- charts ---------- */
.donut-wrap { display: flex; gap: 16px; align-items: center; }
.donut { flex: 0 0 140px; height: 140px; }
.donut-btn { flex: 0 0 140px; padding: 0; border-radius: 50%; }
.donut circle { fill: none; stroke-width: 18; transition: stroke-width .15s; cursor: pointer; }
.donut circle.on { stroke-width: 24; }
.donut text { fill: var(--text); text-anchor: middle; }
.donut .c1 { font-size: 8.5px; fill: var(--muted); font-weight: 550; }
.donut .c2 { font-size: 14px; font-weight: 750; letter-spacing: -.02em; }
.donut .c3 { font-size: 8px; fill: var(--accent); font-weight: 650; }
.legend-list { flex: 1; min-width: 0; display: grid; gap: 2px; }
.legend-list button { display: grid; grid-template-columns: 10px 1fr auto; gap: 9px; align-items: center; text-align: left; padding: 6px 6px; border-radius: 10px; font-size: 13.5px; }
.legend-list button.on, .legend-list button:active { background: var(--tile); }
.legend-list .sw { width: 10px; height: 10px; border-radius: 3px; }
.legend-list .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-list .pc { color: var(--muted); font-weight: 550; }

.pf-head { padding: 4px 4px 8px; }
.pf-value { font-size: 36px; font-weight: 750; letter-spacing: -.03em; line-height: 1.15; margin: 2px 0 4px; }
.live { color: var(--pos); font-size: 11px; font-weight: 650; }
.chart-wrap { margin: 6px -16px 0; }
.chart { display: block; width: 100%; height: 190px; touch-action: none; }
.chart path { vector-effect: non-scaling-stroke; fill: none; }
.chart .val { stroke-width: 2.5; stroke: var(--pos); stroke-linejoin: round; }
.chart.down .val { stroke: var(--neg); }
.chart .area { fill: var(--pos); opacity: .1; }
.chart.down .area { fill: var(--neg); }
.chart .cost { stroke: var(--faint); stroke-width: 1.5; stroke-dasharray: 4 4; }
.chart .cursor { stroke: var(--text); stroke-width: 1; vector-effect: non-scaling-stroke; opacity: .4; }
.ranges { display: flex; flex-wrap: wrap; gap: 4px; justify-content: space-between; margin: 10px 0 6px; background: var(--card); border-radius: 14px; padding: 4px; box-shadow: var(--shadow); }
.ranges button { flex: 1; padding: 7px 0; border-radius: 10px; font-size: 13px; color: var(--muted); font-weight: 650; }
.ranges button.on { background: var(--accent-soft); color: var(--accent-strong); }
@media (prefers-color-scheme: dark) { .ranges button.on { color: var(--accent); } }
.legend { display: block; text-align: center; font-size: 12px; margin-bottom: 4px; }
.lg-val, .lg-cost { display: inline-block; width: 14px; height: 0; border-top: 2.5px solid var(--pos); vertical-align: middle; margin: 0 3px 0 8px; }
.lg-cost { border-top: 1.5px dashed var(--faint); }

/* ---------- misc ---------- */
.auth { max-width: 400px; margin: 0 auto; padding: calc(56px + env(safe-area-inset-top)) 24px; text-align: center; }
.auth .logo {
  width: 76px; height: 76px; margin: 0 auto 18px; border-radius: 24px; display: grid; place-items: center; font-size: 38px;
  background: linear-gradient(150deg, var(--hero-1), var(--hero-3)); box-shadow: 0 14px 30px -12px rgba(6, 95, 70, .7);
}
.auth h1 { font-size: 28px; }
.auth form { text-align: left; margin-top: 26px; }
.auth input { margin-bottom: 10px; }
.auth h3 { text-align: left; }

/* Pull-to-refresh indicator (app.js). Sits above the top edge until pulled into view. */
.ptr {
  position: fixed; z-index: 30; left: 50%; top: calc(env(safe-area-inset-top) - 28px); width: 38px; height: 38px; margin-left: -19px;
  border-radius: 50%; background: var(--card); color: var(--accent); box-shadow: var(--shadow-lg);
  display: grid; place-items: center; font-size: 20px; font-weight: 700; opacity: 0; pointer-events: none;
  transition: transform .2s ease-out, opacity .2s;
}
.ptr.spin { animation: ptr-spin .8s linear infinite; }
@keyframes ptr-spin { from { rotate: 0deg; } to { rotate: 360deg; } }
/* Segmented controls that sit directly on the page background need their own track colour. */
.kind-seg { background: color-mix(in srgb, var(--text) 7%, transparent); }
.donut, .donut-btn { flex-basis: 128px; }
.donut { height: 128px; }
