/* Cüzdan görünümü: açık gri-mavi zemin, beyaz yuvarlak kartlar, lacivert ana renk, kişisel harcamalar için kehribar. */
:root {
  --bg: #eef1f6;
  --surface: #ffffff;
  --surface-2: #f3f5f9;
  --text: #111827;
  --text-2: #6b7280;
  --border: #e5e7eb;
  --primary: #1e3a8a;
  --primary-soft: #dbeafe;
  --on-primary: #ffffff;
  --hero-muted: #c7d2fe;
  --ink: #111827;
  --on-ink: #ffffff;
  --personal: #fbbf24;
  --personal-soft: #fef3c7;
  --personal-ink: #92400e;
  --warn: #78350f;
  --warn-bg: #fef3c7;
  --warn-border: #f59e0b;
  --ok: #166534;
  --ok-bg: #dcfce7;
  --danger: #b91c1c;
  --danger-bg: #fee2e2;
  --radius: 18px;
  --radius-sm: 12px;
  --tabbar-h: 72px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #1a1d24;
    --surface-2: #232733;
    --text: #f3f4f6;
    --text-2: #9ca3af;
    --border: #2d3240;
    --primary: #3b5bdb;
    --primary-soft: #1e2a4f;
    --hero-muted: #c7d2fe;
    --ink: #f3f4f6;
    --on-ink: #111827;
    --personal-soft: #3a2e10;
    --personal-ink: #fcd34d;
    --warn: #fcd34d;
    --warn-bg: #3a2e10;
    --warn-border: #b45309;
    --ok: #86efac;
    --ok-bg: #12301d;
    --danger: #fca5a5;
    --danger-bg: #3b1515;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}

#app {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 14px) 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 28px);
}

h1 { font-size: 24px; font-weight: 800; letter-spacing: -0.3px; margin: 4px 0 12px; }
h2 { font-size: 15px; font-weight: 700; margin: 22px 0 10px; color: var(--text); }
a { color: var(--primary); }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.topbar .nav { display: flex; align-items: center; gap: 4px; }
.topbar .greet { font-size: 15px; font-weight: 600; color: var(--text-2); }
.icon-btn {
  border: 0; background: var(--surface); color: var(--text-2); font-size: 18px;
  min-width: 44px; height: 44px; border-radius: 22px; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn svg { width: 20px; height: 20px; }

/* Ay kartı */
.hero {
  border-radius: 24px; background: #1e3a8a; color: #ffffff; padding: 20px;
  display: flex; flex-direction: column; gap: 14px; margin-bottom: 12px;
}
.hero-top { display: flex; justify-content: space-between; align-items: center; }
.hero-month { font-size: 15px; font-weight: 700; color: var(--hero-muted); }
.hero-nav { display: flex; gap: 6px; }
.hero-nav a {
  width: 38px; height: 38px; border-radius: 19px; background: rgba(255, 255, 255, 0.14);
  color: #ffffff; text-decoration: none; display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.hero-label { font-size: 13px; color: var(--hero-muted); }
.hero-total { font-size: 38px; font-weight: 800; letter-spacing: -1px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.hero-change { font-size: 13px; font-weight: 600; color: var(--hero-muted); margin-left: 6px; }
.split { height: 10px; border-radius: 5px; background: rgba(255, 255, 255, 0.18); display: flex; overflow: hidden; }
.split .w { background: #ffffff; }
.split .p { background: var(--personal); }
.split-legend { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; flex-wrap: wrap; }
.swatch { display: inline-block; width: 8px; height: 8px; border-radius: 4px; margin-right: 4px; vertical-align: 1px; }
.swatch.w { background: #ffffff; }
.swatch.p { background: var(--personal); }

/* Kutucuklar */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.tile {
  background: var(--surface); border-radius: var(--radius); padding: 14px;
  display: flex; flex-direction: column; gap: 2px; color: var(--text); text-decoration: none; min-width: 0;
}
.tile .label { font-size: 12px; color: var(--text-2); }
.tile .value { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile.warn { background: var(--warn-bg); color: var(--warn); }
.tile.warn .label { color: var(--warn); }

/* Kategori çipleri */
.chips { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 12px; padding: 2px 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip-btn {
  flex: none; padding: 9px 14px; border-radius: 999px; border: 0; background: var(--surface); color: var(--text);
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; min-height: 38px;
}
.chip-btn.on { background: var(--ink); color: var(--on-ink); }

/* Eski kutucuk düzeni (rapor, gönder) aynı görünümde */
.metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.metric { background: var(--surface); border-radius: var(--radius); padding: 14px; min-width: 0; }
.metric .label { font-size: 12px; color: var(--text-2); }
.metric .value { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.metric .value.small { font-size: 16px; font-weight: 700; }
.up { color: var(--danger); }
.down { color: var(--ok); }

.bars { display: flex; flex-direction: column; gap: 10px; background: var(--surface); border-radius: var(--radius); padding: 14px; }
.bar-row { font-size: 14px; }
.bar-row .meta { display: flex; justify-content: space-between; gap: 8px; }
.bar-row .meta span:last-child { font-weight: 700; font-variant-numeric: tabular-nums; }
.bar { height: 8px; border-radius: 4px; background: var(--primary-soft); margin-top: 4px; }
.bar > div { height: 8px; border-radius: 4px; background: var(--primary); }

/* Listeler: ayrı yuvarlak kartlar */
.list { display: flex; flex-direction: column; gap: 8px; }
.item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface);
  border-radius: var(--radius); color: inherit; text-decoration: none; min-height: 64px;
}
.item img, .item .ph { width: 38px; height: 48px; object-fit: cover; border-radius: 8px; background: var(--surface-2); flex: none; }
.item .main { flex: 1; min-width: 0; }
.item .title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 700; font-size: 15px; }
.item .sub { font-size: 12px; color: var(--text-2); }
.item .amt { font-variant-numeric: tabular-nums; font-weight: 800; white-space: nowrap; font-size: 15px; }
.ricon {
  width: 42px; height: 42px; border-radius: 14px; flex: none;
  display: flex; align-items: center; justify-content: center; background: var(--primary-soft); color: var(--primary);
}
.ricon.p { background: var(--personal-soft); color: var(--personal-ink); }
.ricon svg { width: 20px; height: 20px; }

.chip { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.muted { background: var(--surface-2); color: var(--text-2); }

.empty { text-align: center; color: var(--text-2); padding: 32px 16px; background: var(--surface); border-radius: var(--radius); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 0 18px; border-radius: 16px;
  border: 0; background: var(--surface); color: var(--text);
  font: inherit; font-weight: 700; cursor: pointer; text-decoration: none; text-align: center;
}
.btn.primary { background: var(--ink); color: var(--on-ink); }
.btn.danger { color: var(--danger); }
.btn.ghost { background: none; color: var(--text-2); }
.btn.block { display: flex; width: 100%; }
.btn:active { transform: scale(0.98); }
.actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.actions > * { flex: 1; }

.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; background: var(--surface); border-radius: var(--radius); padding: 16px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field > span { font-size: 12px; font-weight: 600; color: var(--text-2); display: flex; justify-content: space-between; gap: 6px; }
h2.field { margin: 8px 0 0; }
input, select, textarea {
  font: inherit; font-size: 16px; color: var(--text); background: var(--surface-2);
  border: 1px solid transparent; border-radius: var(--radius-sm); padding: 10px 12px; width: 100%; min-height: 44px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); background: var(--surface); }
textarea { min-height: 120px; resize: vertical; }
.field.warn input, .field.warn select { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn); }
.hint { font-size: 12px; color: var(--text-2); }
.hint.bad { color: var(--danger); }
.hint.good { color: var(--ok); }

.segmented { display: flex; gap: 6px; background: var(--surface-2); border-radius: 999px; padding: 4px; }
.segmented button {
  flex: 1; border: 0; background: none; color: var(--text-2); font: inherit; font-weight: 700;
  padding: 10px; border-radius: 999px; cursor: pointer; min-height: 40px;
}
.segmented button.on { background: var(--ink); color: var(--on-ink); }

.vat-table { display: flex; flex-direction: column; gap: 6px; }
.vat-row { display: grid; grid-template-columns: 76px minmax(0, 1fr) minmax(0, 1fr) 36px; gap: 6px; align-items: center; }
.vat-head { font-size: 12px; color: var(--text-2); }

.preview { display: block; width: 100%; max-height: 260px; object-fit: contain; background: var(--surface); border-radius: var(--radius); margin-bottom: 8px; }
.preview.open { max-height: none; }

.notice { border-radius: 16px; padding: 12px 14px; font-size: 14px; margin: 0 0 12px; }
.notice a { color: inherit; font-weight: 700; }
.notice.warn { background: var(--warn-bg); color: var(--warn); }
.notice.ok { background: var(--ok-bg); color: var(--ok); }
.notice.bad { background: var(--danger-bg); color: var(--danger); }

details { margin-top: 16px; }
summary { color: var(--text-2); font-size: 14px; font-weight: 600; cursor: pointer; padding: 8px 0; }
pre.raw { white-space: pre-wrap; font-size: 12px; background: var(--surface-2); padding: 10px; border-radius: var(--radius-sm); }

.crop-host { display: flex; justify-content: center; }
.crop-canvas { touch-action: none; border-radius: var(--radius-sm); }

/* Alt menü */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: space-around; align-items: flex-start;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding: 10px 6px env(safe-area-inset-bottom);
  background: var(--surface); border-radius: 24px 24px 0 0;
  box-shadow: 0 -1px 0 var(--border);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; font-weight: 600; color: var(--text-2); text-decoration: none; min-height: 44px;
}
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a.on { color: var(--primary); font-weight: 800; }
.tabbar .shoot {
  width: 60px; height: 60px; margin-top: -28px; flex: none; border-radius: 20px;
  border: 4px solid var(--bg); background: var(--ink); color: var(--on-ink); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.tabbar .shoot svg { width: 26px; height: 26px; }
body.no-tabbar .tabbar { display: none; }

.sheet { position: fixed; inset: 0; z-index: 20; background: rgba(15, 17, 21, 0.45); display: flex; align-items: flex-end; }
.sheet[hidden] { display: none; }
.sheet-panel {
  width: 100%; background: var(--bg); border-radius: 24px 24px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px;
}

.busy { position: fixed; inset: 0; z-index: 30; background: rgba(15, 17, 21, 0.4); display: flex; align-items: center; justify-content: center; }
.busy[hidden] { display: none; }
.busy-box { background: var(--surface); padding: 22px 28px; border-radius: var(--radius); text-align: center; min-width: 190px; font-weight: 600; }
.busy-box p { margin: 12px 0 0; }
.spinner { width: 30px; height: 30px; margin: 0 auto; border: 3px solid var(--primary-soft); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.fx-box { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 12px; border-radius: 14px; background: var(--surface-2); }
.fx-box[hidden] { display: none; }
.fx-box input, .fx-box select { background: var(--surface); }

/* Rapor grafiği */
.trend { display: flex; gap: 4px; align-items: stretch; height: 150px; background: var(--surface); border-radius: var(--radius); padding: 14px 10px 10px; }
.tcol { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; text-decoration: none; min-width: 0; }
.tbar { flex: 1; width: 100%; display: flex; flex-direction: column-reverse; }
.tcol .tw { background: var(--primary); border-radius: 0 0 3px 3px; }
.tcol .tp { background: var(--personal); border-radius: 3px 3px 0 0; }
.tcol span { font-size: 10px; color: var(--text-2); }
.tcol.on span { color: var(--primary); font-weight: 800; }
.legend { display: flex; align-items: center; gap: 6px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.dot.tw { background: var(--primary); }
.dot.tp { background: var(--personal); margin-left: 8px; }

.m-link { flex-wrap: wrap; }
.m-actions { display: flex; gap: 6px; }
.m-preview pre.raw { max-height: 220px; overflow: auto; margin: 8px 0 0; }

/* Gelir */
.hero-flow { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; border-top: 1px solid rgba(255, 255, 255, 0.18); padding-top: 12px; }
.hero-flow > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.hero-num { font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }
.hero-num.neg { color: #fecaca; }
.ricon.in { background: var(--ok-bg); color: var(--ok); }
.item .amt.in { color: var(--ok); }
.tpair { flex: 1; width: 100%; display: flex; gap: 2px; }
.tpair .tbar { flex: 1; }
.tcol .ti { background: #16a34a; border-radius: 3px 3px 0 0; }
.dot.ti { background: #16a34a; margin-left: 8px; }
