:root {
  --bg: #110d0a;
  --bg-2: #1b1510;
  --card: #231c16;
  --card-2: #2c241c;
  --line: rgba(243, 214, 170, 0.12);
  --gold: #e4b54a;
  --gold-2: #f0d48a;
  --brass: #a57c32;
  --cream: #f6ead2;
  --ink: #f8f0e0;
  --muted: #9c8d78;
  --mint: #8fceb0;
  --mint-dim: #2b4a3c;
  --rose: #e08a7a;
  --rose-dim: #4a2a24;
  --sky: #8bb8c9;
  --warn: #e0a35a;
  --provisional: #c4a37a;
  --hit: 48px;
  --radius: 22px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
[hidden] { display: none !important; }

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; overflow-x: hidden; }
html, body { min-height: 100%; }
body {
  font-family: Outfit, "Avenir Next", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(1200px 700px at 10% -10%, rgba(228, 181, 74, 0.14), transparent 55%),
    radial-gradient(900px 600px at 110% 10%, rgba(139, 184, 201, 0.08), transparent 50%),
    radial-gradient(800px 500px at 50% 120%, rgba(224, 138, 122, 0.07), transparent 50%),
    url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.045'/%3E%3C/svg%3E");
}

button, input, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
button, .tappable, .file-btn { touch-action: manipulation; }
img { max-width: 100%; display: block; }

.app, .gate { position: relative; z-index: 1; min-width: 0; }

/* ——— Gate ——— */
.gate {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 28px 16px calc(28px + var(--safe-bot));
}
.gate-card {
  width: min(420px, 100%);
  background: linear-gradient(180deg, #2a221b, #1c1712);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 32px 26px 26px;
  box-shadow: 0 30px 80px rgba(0,0,0,.45);
}
.mark {
  width: 64px; height: 64px;
  border-radius: 20px;
  display: grid; place-items: center;
  background: radial-gradient(circle at 30% 25%, #f0d48a, #c4922e 60%, #6b4a16);
  color: #2a1c08;
  font-family: Fraunces, Georgia, serif;
  font-weight: 650;
  font-size: 30px;
  margin-bottom: 18px;
  box-shadow: 0 8px 24px rgba(228,181,74,.25);
}
.gate h1 {
  font-family: Fraunces, Georgia, serif;
  font-size: 30px;
  letter-spacing: -0.03em;
  margin-bottom: 6px;
}
.gate .lede { color: var(--muted); font-size: 14.5px; line-height: 1.5; margin-bottom: 22px; }
.err { color: var(--rose); font-size: 13px; text-align: center; min-height: 20px; margin-top: 10px; }
.btn {
  height: 48px;
  min-height: var(--hit);
  border-radius: 14px;
  background: linear-gradient(180deg, #f0d48a, #c4922e);
  color: #2a1c08;
  font-weight: 650;
  padding: 0 16px;
}
.linkish {
  color: var(--gold-2);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-size: 13px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.google-btn {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  margin: 8px 0 18px;
  min-height: 48px;
  width: 100%;
  overflow: hidden;
}
.google-btn > div,
.google-btn iframe { margin: 0 auto; max-width: 100%; }
.btn.google-todo { width: 100%; opacity: .7; }

@media (max-width: 400px) {
  .gate { padding: 16px 12px calc(16px + var(--safe-bot)); }
  .gate-card { padding: 24px 16px 20px; border-radius: 22px; }
  .gate h1 { font-size: 26px; }
  .mark { width: 56px; height: 56px; font-size: 26px; border-radius: 16px; }
}

/* ——— App chrome ——— */
.app { min-height: 100dvh; }
.top {
  position: sticky;
  top: 0;
  z-index: 4;
  padding: calc(10px + var(--safe-top)) 16px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: rgba(17,13,10,.78);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand .mark { width: 40px; height: 40px; font-size: 20px; border-radius: 13px; margin: 0; flex-shrink: 0; }
.brand b { display: block; font-size: 15px; letter-spacing: .01em; }
.brand small {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 52vw;
}
.top-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.ghost {
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--cream);
  font-size: 13px;
}

/* ——— Dashboard ——— */
.dash {
  width: min(840px, 100%);
  margin: 0 auto;
  padding: 8px 16px calc(36px + var(--safe-bot));
  min-width: 0;
}

.hero {
  padding: 18px 4px 8px;
}
.kicker {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .14em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.hero-num {
  font-family: Fraunces, Georgia, serif;
  font-size: clamp(48px, 14vw, 80px);
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--gold-2);
  font-variant-numeric: tabular-nums;
}
.hero-num.tight { color: var(--rose); }
.hero-sub {
  margin-top: 10px;
  font-size: 15px;
  line-height: 1.45;
  color: var(--cream);
}
.hero-note {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.5;
}

.section { margin-top: 22px; min-width: 0; }
h2.display {
  font-family: Fraunces, Georgia, serif;
  font-size: 26px;
  letter-spacing: -0.03em;
  margin-bottom: 6px;
}
.sub { color: var(--muted); font-size: 14px; line-height: 1.5; margin-bottom: 14px; }

.card {
  background: linear-gradient(180deg, rgba(255,255,255,.03), transparent 40%), var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  min-width: 0;
}
.card h3 { font-size: 15px; margin-bottom: 8px; }

.row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  min-width: 0;
}
.row:first-of-type { border-top: 0; }
.row > div:first-child { min-width: 0; }
.row .who { font-size: 14.5px; overflow-wrap: anywhere; }
.row .meta { color: var(--muted); font-size: 12px; margin-top: 2px; overflow-wrap: anywhere; }
.row .amt { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; flex-shrink: 0; }
.row.tappable { min-height: var(--hit); align-items: center; padding: 10px 0; }
.neg { color: var(--rose); }
.pos { color: var(--mint); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px; border-radius: 999px;
  font-size: 11px; letter-spacing: .04em; text-transform: uppercase;
  background: #2c241c; color: var(--muted); border: 1px solid var(--line);
}
.chip.live { color: var(--mint); background: var(--mint-dim); border-color: transparent; }
.chip.assumed { color: var(--sky); }
.chip.provisional, .chip.live-estimate { color: var(--provisional); border-style: dashed; }
.chip.card { color: var(--sky); }
.chip.payday { color: var(--mint); background: var(--mint-dim); border-color: transparent; }

.tappable {
  cursor: pointer;
  border-radius: 16px;
  transition: transform .12s ease, background .12s ease;
  min-height: 44px;
}
.tappable:active { transform: scale(.985); }

/* ——— Chart ——— */
.chart-card { padding: 14px 10px 10px; }
.chart-wrap {
  position: relative;
  width: 100%;
  min-width: 0;
}
.chart-wrap svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 280px;
}
.chart-tip {
  position: absolute;
  pointer-events: none;
  background: #2a221b;
  border: 1px solid var(--line);
  color: var(--cream);
  font-size: 12.5px;
  padding: 7px 10px;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
  transform: translate(-50%, calc(-100% - 10px));
  white-space: nowrap;
  opacity: 0;
}
.chart-tip.on { opacity: 1; }
.chart-tip b { display: block; font-family: Fraunces, Georgia, serif; font-size: 16px; color: var(--gold-2); }
.hit-day { cursor: pointer; }

/* ——— Bars / cats ——— */
.bar {
  height: 10px; border-radius: 999px; background: #3a3126; overflow: hidden; margin-top: 8px;
}
.bar > i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #c4922e, #f0d48a); }
.bar.over > i { background: linear-gradient(90deg, #9a4036, #e08a7a); }

.day-head {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  margin: 14px 0 4px;
}
.day-head:first-child { margin-top: 0; }

.foot-note { color: var(--muted); font-size: 12px; line-height: 1.45; margin-top: 8px; }

/* ——— Sheet ——— */
.overlay {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(0,0,0,.55);
  opacity: 0; pointer-events: none; transition: .2s ease;
}
.overlay.on { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21;
  max-height: min(86vh, 720px);
  overflow: auto;
  background: #1c1712;
  border-radius: 24px 24px 0 0;
  border: 1px solid var(--line);
  padding: 12px 18px calc(22px + var(--safe-bot));
  transform: translateY(110%);
  transition: transform .28s cubic-bezier(.2,.8,.2,1);
  min-width: 0;
}
.sheet.on { transform: none; }
.grab { width: 42px; height: 4px; border-radius: 99px; background: #4a4034; margin: 4px auto 14px; }
.sheet h3 { font-family: Fraunces, Georgia, serif; font-size: 24px; margin-bottom: 4px; overflow-wrap: anywhere; }
.sheet .big {
  font-family: Fraunces, Georgia, serif;
  font-size: clamp(28px, 8vw, 36px);
  margin: 8px 0 14px;
}
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 8px 10px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { font-weight: 500; overflow-wrap: anywhere; min-width: 0; }

.drop {
  border: 1.5px dashed rgba(228,181,74,.35);
  border-radius: 20px;
  padding: 22px 16px;
  text-align: center;
  background: rgba(228,181,74,.04);
  margin-bottom: 12px;
}
.drop p { color: var(--muted); font-size: 13px; margin: 8px 0 14px; }
.actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.file-btn {
  position: relative; overflow: hidden;
  padding: 12px 16px; border-radius: 14px;
  background: #2c241c; border: 1px solid var(--line); min-height: var(--hit);
}
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.receipt {
  display: grid; grid-template-columns: 72px 1fr auto; gap: 12px; align-items: center;
  min-width: 0;
}
.receipt img, .receipt .ph {
  width: 72px; height: 72px; object-fit: cover; border-radius: 12px; background: #2c241c;
}
.receipt .ph { display: grid; place-items: center; color: var(--muted); font-size: 11px; }
.notes { width: 100%; min-height: 70px; border-radius: 12px; border: 1px solid var(--line); background: #2c241c; padding: 10px; resize: vertical; }

@media (max-width: 430px) {
  .receipt { grid-template-columns: 56px 1fr; }
  .receipt img, .receipt .ph { width: 56px; height: 56px; }
  .receipt .file-btn { grid-column: 1 / -1; justify-self: start; width: max-content; }
  .kv { grid-template-columns: minmax(84px, 96px) minmax(0, 1fr); }
  .hero-num { font-size: clamp(44px, 16vw, 64px); }
}

@media (min-width: 880px) {
  .top { padding: calc(14px + var(--safe-top)) 28px 12px; }
  .dash { padding: 12px 28px 56px; }
  h2.display { font-size: 30px; }
  .brand small { max-width: 40vw; }
  .chart-wrap svg { max-height: 320px; }
  .sheet {
    left: 50%;
    right: auto;
    bottom: auto;
    top: 50%;
    width: min(520px, calc(100vw - 48px));
    max-height: min(80vh, 720px);
    border-radius: 24px;
    padding: 22px 24px 28px;
    transform: translate(-50%, -46%) scale(.98);
  }
  .sheet.on { transform: translate(-50%, -50%); }
  .grab { display: none; }
}

@media (min-width: 1024px) {
  .dash { width: min(920px, 100%); padding: 16px 36px 64px; }
  .hero-num { font-size: 84px; }
}
