:root {
  --accent: #0F7A5F;
  --bg: #F4F3EF;
  --card: #FFFFFF;
  --ink: #16181B;
  --muted: #5F646B;
  --line: #E2E0DA;
  --hair: #EEEDE8;
  --seg: #E7E6E1;
  --danger: #B42318;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); }
body {
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
.display { font-family: 'Space Grotesk', Inter, sans-serif; }
.num { font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.app {
  max-width: 480px; margin: 0 auto;
  height: 100dvh; position: relative; overflow: hidden;
  display: flex; flex-direction: column;
}
.scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.page { padding: calc(var(--sat) + 20px) 20px 24px; display: flex; flex-direction: column; gap: 16px; }
.page.with-tabs { padding-bottom: 104px; }
.page.fill { flex: 1; min-height: 0; }

h1.title { margin: 0; font-family: 'Space Grotesk', Inter, sans-serif; font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
h2.sub { margin: 0; font-size: 17px; font-weight: 600; }
.muted { color: var(--muted); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.icon-btn {
  width: 44px; height: 44px; flex-shrink: 0; padding: 0;
  border-radius: 22px; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  display: flex; align-items: center; justify-content: center;
}
.pill-btn {
  height: 44px; padding: 0 12px; border-radius: 22px; border: 1px solid var(--line);
  background: var(--card); font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; white-space: nowrap;
}
.card { background: var(--card); border-radius: 20px; }
.list { padding: 2px 16px; display: flex; flex-direction: column; }

/* hero */
.hero { background: var(--accent); color: #fff; border-radius: 24px; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.hero .big { font-family: 'Space Grotesk', Inter, sans-serif; font-size: 44px; font-weight: 700; letter-spacing: -0.03em; line-height: 1; }
.badge { font-size: 12px; font-weight: 600; background: rgba(0,0,0,0.22); padding: 4px 10px; border-radius: 999px; }
.bar { height: 8px; border-radius: 4px; background: rgba(255,255,255,0.28); overflow: hidden; }
.bar > div { height: 100%; border-radius: 4px; background: #fff; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat { background: var(--card); border-radius: 18px; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.stat .v { font-family: 'Space Grotesk', Inter, sans-serif; font-size: 22px; font-weight: 600; }

/* transaction rows */
.tx { display: flex; align-items: center; gap: 12px; padding: 12px 0; width: 100%; border: 0; background: none; text-align: left; }
.tx + .tx { border-top: 1px solid var(--hair); }
.cat-ico { width: 40px; height: 40px; flex-shrink: 0; border-radius: 12px; display: flex; align-items: center; justify-content: center; }
.tx .mid { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tx .name { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx .meta { font-size: 13px; color: var(--muted); }
.tx .amt { font-family: 'Space Grotesk', Inter, sans-serif; font-size: 15px; font-weight: 600; white-space: nowrap; }
.empty { text-align: center; padding: 28px 16px; color: var(--muted); font-size: 15px; line-height: 1.45; }

/* fabs + tabs */
.fabs { position: absolute; right: 20px; bottom: calc(var(--sab) + 84px); display: flex; gap: 12px; z-index: 5; }
.fab { width: 56px; height: 56px; border-radius: 28px; border: 0; color: #fff; display: flex; align-items: center; justify-content: center; box-shadow: 0 8px 20px rgba(22,24,27,0.25); }
.tabs {
  flex-shrink: 0; padding: 8px 24px calc(var(--sab) + 8px); background: var(--card); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(3, 1fr);
}
.tabs a { min-height: 48px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 11px; font-weight: 500; color: var(--muted); }
.tabs a.on { color: var(--accent); font-weight: 600; }

/* chips / segmented */
.chips { display: flex; gap: 8px; overflow-x: auto; margin: 0 -20px; padding: 2px 20px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { height: 44px; flex-shrink: 0; padding: 0 16px; border-radius: 22px; border: 1px solid var(--line); background: var(--card); font-size: 14px; font-weight: 600; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.chip.icon { padding: 0 14px 0 6px; }
.chip.icon .dot { width: 32px; height: 32px; border-radius: 16px; display: flex; align-items: center; justify-content: center; }
.chip.dark.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip.acc.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.dashed { border: 1px dashed #8A9097; background: transparent; padding: 0 16px 0 12px; gap: 6px; }
.seg { padding: 3px; display: grid; grid-template-columns: 1fr 1fr; background: var(--seg); border-radius: 22px; }
.seg button { height: 38px; border: 0; border-radius: 19px; background: transparent; font-size: 14px; font-weight: 600; }
.seg button.on { background: #fff; box-shadow: 0 1px 3px rgba(22,24,27,0.18); }
.seg.square { border-radius: 16px; padding: 4px; gap: 4px; }
.seg.square button { height: 44px; border-radius: 12px; }

/* inputs */
.field { height: 48px; padding: 0 14px; display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
.field input { flex: 1; min-width: 0; border: 0; background: transparent; font-size: 16px; outline: none; }
.field-label { font-size: 13px; font-weight: 600; color: var(--muted); }

/* add screen */
.add { padding: calc(var(--sat) + 16px) 20px calc(var(--sab) + 16px); display: flex; flex-direction: column; gap: 12px; height: 100%; }
.amount-out { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 0; }
.amount-out output { font-family: 'Space Grotesk', Inter, sans-serif; font-size: 56px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.05; }
.keypad { margin-top: auto; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.keypad button { height: 52px; border: 0; border-radius: 14px; background: #fff; font-family: 'Space Grotesk', Inter, sans-serif; font-size: 24px; font-weight: 600; display: flex; align-items: center; justify-content: center; }
.keypad button:active { background: var(--seg); }
.primary { height: 56px; flex-shrink: 0; border: 0; border-radius: 16px; background: var(--accent); color: #fff; font-size: 16px; font-weight: 600; display: flex; align-items: center; justify-content: center; width: 100%; }
.primary:disabled { opacity: 0.45; }
.ghost-danger { height: 44px; border: 0; background: transparent; color: var(--danger); font-size: 15px; font-weight: 600; }
.date-btn { position: relative; overflow: hidden; }
.date-btn input, .date-btn select { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; margin: 0; border: 0; -webkit-appearance: none; appearance: none; cursor: pointer; }

/* insights */
.share { display: flex; gap: 2px; height: 12px; border-radius: 6px; overflow: hidden; background: var(--hair); }
.week { height: 150px; display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.week > div { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; }
.week .b { width: 100%; max-width: 28px; border-radius: 6px; }
.track { height: 6px; border-radius: 3px; background: var(--hair); overflow: hidden; }
.track > div { height: 100%; border-radius: 3px; }

/* settings */
.set-row { min-height: 64px; padding: 12px 0; width: 100%; border: 0; background: transparent; display: flex; align-items: center; gap: 12px; text-align: left; }
.set-row + .set-row { border-top: 1px solid var(--hair); }
.set-row .mid { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.set-row .t { font-size: 15px; font-weight: 600; }
.set-row .s { font-size: 13px; color: var(--muted); }
.accents { display: flex; gap: 12px; }
.accents button { width: 44px; height: 44px; border-radius: 22px; border: 0; padding: 0; }
.accents button.on { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--ink); }

/* sheets / dialogs */
.scrim { position: fixed; inset: 0; z-index: 20; background: rgba(22,24,27,0.42); display: flex; flex-direction: column; justify-content: flex-end; }
.scrim.anim { animation: fade .15s ease; }
.sheet { width: 100%; max-width: 480px; margin: 0 auto; background: #fff; border-radius: 28px 28px 0 0; padding: 12px 20px calc(var(--sab) + 24px); display: flex; flex-direction: column; gap: 16px; max-height: 92dvh; overflow-y: auto; }
.sheet.anim { animation: up .2s ease; }
.grabber { align-self: center; width: 36px; height: 5px; border-radius: 3px; background: #D5D3CC; }
.swatches { display: grid; grid-template-columns: repeat(9, 1fr); }
.swatches button { height: 44px; border: 0; background: transparent; padding: 0; display: flex; align-items: center; justify-content: center; }
.swatches span { width: 28px; height: 28px; border-radius: 14px; }
.icons { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.icons button { height: 44px; border-radius: 12px; border: 2px solid transparent; background: var(--bg); padding: 0; display: flex; align-items: center; justify-content: center; }
.center-scrim { position: fixed; inset: 0; z-index: 30; padding: 0 32px; background: rgba(22,24,27,0.5); display: flex; align-items: center; justify-content: center; animation: fade .15s ease; }
.alert { width: 100%; max-width: 360px; background: #fff; border-radius: 24px; padding: 24px 20px 16px; display: flex; flex-direction: column; gap: 8px; }
.alert h2 { margin: 0; font-size: 18px; font-weight: 700; }
.alert p { margin: 0 0 8px; font-size: 14px; line-height: 1.45; color: var(--muted); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn-outline { height: 48px; border: 1px solid var(--line); border-radius: 14px; background: #fff; font-size: 15px; font-weight: 600; }
.btn-danger { height: 48px; border: 0; border-radius: 14px; background: var(--danger); color: #fff; font-size: 15px; font-weight: 600; }
.toast { position: fixed; left: 50%; bottom: calc(var(--sab) + 110px); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 14px; font-weight: 600; z-index: 40; animation: fade .2s ease; white-space: nowrap; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: .5; } }
