/* ---- typeface: Heebo, self-hosted (Hebrew by Oded Ezer, Latin from Roboto; figures are tabular) ---- */
@font-face {
  font-family: "Heebo"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url(/fonts/heebo-hebrew.woff2) format("woff2");
  unicode-range: U+0307-0308, U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F;
}
@font-face {
  font-family: "Heebo"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url(/fonts/heebo-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---- colours (light only) ----
   The drawer was adapted from a shadcn/Tailwind component. Its tokens map onto ours like this:
   --background -> --paper, --card/--popover -> --surface, --foreground -> --ink, --muted-foreground -> --muted,
   --border/--input -> --line, --primary/--ring -> --leaf, --destructive -> --brick, --radius -> 12px. */
:root {
  color-scheme: light;
  --paper: #F7F6F2;
  --surface: #FFFFFF;
  --ink: #1B1F2A;
  --on-ink: #F7F6F2;
  --on-ink-muted: #C9D3E0;
  --muted: #5B6472;
  --line: #E3E1DB;
  --pressed: #ECEAE4;
  --leaf: #1E6F5C;
  --leaf-soft: #E4F1EC;
  --slate: #2F4F73;
  --slate-2: #4B6E99;
  --mist: #6E8DB8;
  --brick: #B5443A;
  --brick-soft: #F6E4E2;
  --on-accent: #FFFFFF;
  --scrim: rgba(27, 31, 42, 0.5);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 24px 64px -28px rgba(0, 0, 0, 0.45);
  --ease: cubic-bezier(0.23, 1, 0.32, 1);
}

/* ---- base ---- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.45 "Heebo", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body.has-drawer { overflow: hidden; }
a { color: var(--leaf); }
h1 { font-size: 22px; font-weight: 700; margin: 0 0 12px; letter-spacing: -0.01em; }
h2 { font-size: 13px; font-weight: 600; margin: 0; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.card h2 { text-transform: none; letter-spacing: 0; font-size: 17px; color: var(--ink); margin-bottom: 12px; }
h3 { font-size: 17px; font-weight: 600; margin: 0; }
p { margin: 0 0 12px; }
small { color: var(--muted); font-weight: 400; }
strong { font-weight: 600; }
.amt { font-variant-numeric: tabular-nums; white-space: nowrap; unicode-bidi: isolate; }
.amt.out { color: var(--brick); }
.amt.in { color: var(--leaf); }
.amt.masked { letter-spacing: 0.05em; }
svg { display: inline-block; vertical-align: middle; }

/* ---- the dark top bar: brand, links, and the month ---- */
.top { background: var(--ink); color: var(--on-ink); padding: 12px 16px 18px; }
.top-row { display: flex; justify-content: space-between; align-items: center; max-width: 600px; margin: 0 auto; }
.brand { font-weight: 700; font-size: 18px; color: var(--on-ink); text-decoration: none; }
.top nav { display: flex; gap: 18px; }
.top nav a { text-decoration: none; padding: 8px 0; font-size: 15px; color: var(--on-ink-muted); }
.top-month { max-width: 600px; margin: 14px auto 0; }
.month { font-size: 30px; font-weight: 800; margin: 0; color: var(--on-ink); letter-spacing: -0.01em; line-height: 1.15; }
.today { margin: 4px 0 0; font-size: 14px; color: var(--on-ink-muted); font-variant-numeric: tabular-nums; }
main { max-width: 600px; margin: 0 auto; padding: 20px 16px calc(96px + env(safe-area-inset-bottom)); }

/* ---- dashboard: the hero with its pie, the month bar, the two buttons ---- */
.hero { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 0 0 14px; }
.hero-main { min-width: 0; }
.hero-label { color: var(--muted); font-size: 15px; margin: 0 0 2px; }
.hero-amount { font-size: 40px; font-weight: 700; line-height: 1.15; margin: 0; letter-spacing: -0.02em; }
.hero.short .hero-amount { color: var(--brick); }
.hero.unset .hero-label { font-size: 17px; color: var(--ink); font-weight: 600; }
.hero-total { color: var(--muted); font-size: 15px; margin: 6px 0 0; }
.hero-total .amt { font-weight: 600; }
.pie { width: 92px; height: 92px; flex: none; }
.pie-left { stroke: var(--leaf); }
.pie-out { stroke: var(--brick); }
.pie-text { font-size: 8px; font-weight: 700; fill: var(--ink); font-variant-numeric: tabular-nums; }

.bar { height: 14px; border-radius: 7px; overflow: hidden; background: var(--line); }
.bar svg { display: block; width: 100%; height: 100%; }
[dir="rtl"] .bar svg { transform: scaleX(-1); }
.track { fill: var(--line); }
.gap { fill: var(--paper); }
.mark { fill: var(--ink); }
.seg-0 { fill: var(--slate); background: var(--slate); }
.seg-1 { fill: var(--mist); background: var(--mist); }
.seg-2 { fill: var(--slate-2); background: var(--slate-2); }
.seg-left { fill: var(--leaf); background: var(--leaf); }
.seg-over { fill: var(--brick); background: var(--brick); }
.legend { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 14px; color: var(--muted); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend .amt { color: var(--ink); font-weight: 500; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }

.status { font-size: 15px; margin: 18px 0 0; padding: 0 0 18px; border-bottom: 1px solid var(--line); }
.hero.unset + .actions { margin-top: 8px; }

.actions { display: flex; gap: 10px; margin: 18px 0 22px; }
.actions .btn { flex: 1; }

/* ---- timeline ---- */
h2.section-head { margin: 0 0 6px; }
.day { padding: 10px 0 12px; }
.day + .day { border-top: 1px solid var(--line); }
.day h3 { display: flex; align-items: center; gap: 10px; min-height: 32px; }
.day h3 .total { margin-inline-start: auto; font-weight: 600; }
.day h3 .mark { width: 22px; height: 22px; border-radius: 50%; background: var(--leaf-soft); color: var(--leaf); display: inline-grid; place-items: center; flex: none; }
.day h3 .mark svg { width: 14px; height: 14px; }
.day.done h3 .day-name, .day.done h3 .total { color: var(--muted); }
.day.done .row .amt.out { opacity: 0.75; }
.day-note { margin-inline-start: auto; color: var(--muted); font-weight: 400; font-size: 14px; }
.day.empty { padding: 6px 0; }
.day.empty h3 { min-height: 28px; font-size: 15px; }
.day.empty .day-name { color: var(--muted); font-weight: 500; }
.tag { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--leaf); background: var(--leaf-soft); padding: 2px 8px; border-radius: 999px; }
.day.next { background: var(--surface); border: 1px solid var(--line); border-inline-start: 4px solid var(--leaf); border-radius: 12px; padding: 10px 14px 6px; margin: 8px 0; }
.day.next + .day { border-top: 0; }

.rows { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 6px 4px;
  color: inherit; text-decoration: none; border-radius: 10px;
}
.row + .row { border-top: 1px solid var(--line); border-radius: 0 0 10px 10px; }
.row:active { background: var(--pressed); }
.row-name { flex: 1; overflow-wrap: anywhere; display: inline-flex; align-items: center; gap: 8px; }
.row .amt { font-weight: 600; }
.row .meta { font-size: 12px; }
.chev { width: 18px; height: 18px; color: var(--muted); flex: none; }
[dir="rtl"] .chev { transform: scaleX(-1); }
.row.income .ico { color: var(--leaf); width: 18px; height: 18px; }

.empty { text-align: center; padding: 20px 16px 8px; }
.empty h3 { margin-bottom: 6px; }
.empty p { color: var(--muted); margin-bottom: 0; }

/* ---- buttons ---- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 48px; padding: 12px 16px;
  border: 0; border-radius: 12px; cursor: pointer; font: inherit; font-weight: 600; text-align: center; text-decoration: none;
  background: var(--leaf); color: var(--on-accent);
}
.btn svg { width: 18px; height: 18px; }
.btn:active { filter: brightness(0.92); }
.btn.secondary, .btn.google { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.btn.google { gap: 12px; }
.btn.google .g { width: 20px; height: 20px; flex: none; }
.btn.danger { background: var(--brick); color: #fff; }
.btn.quiet { background: transparent; color: var(--ink); min-height: 44px; margin-top: 4px; }
.btn.quiet:active { background: var(--pressed); filter: none; }
.btn.quiet.danger { color: var(--brick); }
button.link { background: none; border: 0; padding: 10px 0; font: inherit; color: var(--leaf); cursor: pointer; text-decoration: underline; }

/* ---- forms ---- */
form { margin: 0; }
label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 14px; }
input, select {
  display: block; width: 100%; margin-top: 6px; padding: 12px 14px;
  font: inherit; font-size: 16px; /* 16px stops iOS zooming into the field */
  color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 10px;
}
input:focus-visible, select:focus-visible, .btn:focus-visible, a:focus-visible, button:focus-visible { outline: 2px solid var(--leaf); outline-offset: 2px; }
input.code { font-size: 24px; letter-spacing: 0.35em; text-align: center; }
/* Emails, passwords, codes and amounts are typed left-to-right in both languages. */
input[type="email"], input[type="password"], input[type="number"], input.code, input.amount { direction: ltr; }
[dir="rtl"] input[type="email"], [dir="rtl"] input[type="password"] { text-align: right; }
.money { display: flex; align-items: center; margin-top: 6px; direction: ltr; }
.money .cur { color: var(--muted); font-size: 18px; padding: 0 4px 0 14px; border: 1px solid var(--line); border-right: 0; border-radius: 10px 0 0 10px; background: var(--paper); align-self: stretch; display: flex; align-items: center; }
.money input { margin: 0; border-radius: 0 10px 10px 0; font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
fieldset.days { border: 0; padding: 0; margin: 0 0 18px; }
fieldset.days legend { font-size: 14px; font-weight: 600; padding: 0; margin-bottom: 6px; }
.segmented { display: flex; gap: 8px; }
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.segmented label, .segmented button {
  flex: 1; margin: 0; min-height: 48px; display: flex; align-items: center; justify-content: center; cursor: pointer;
  font: inherit; font-size: 16px; font-weight: 600; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 12px;
}
.segmented input:checked + label, .segmented button.on { background: var(--leaf-soft); border-color: var(--leaf); color: var(--leaf); }
.segmented input:focus-visible + label { outline: 2px solid var(--leaf); outline-offset: 2px; }
.segmented label:active, .segmented button:active { background: var(--pressed); }
.other-day { display: none; margin-top: 10px; }
.days:has(#day-other:checked) .other-day { display: block; }
.other-day label { margin-bottom: 0; }
.check { display: flex; align-items: center; gap: 12px; min-height: 44px; font-size: 16px; font-weight: 500; margin-bottom: 4px; }
.check input { width: 22px; height: 22px; margin: 0; accent-color: var(--leaf); flex: none; }
.settings .btn { margin-top: 12px; }

/* ---- signed-out pages and account ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 20px; margin-bottom: 14px; }
.narrow { max-width: 420px; margin-left: auto; margin-right: auto; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; margin: 14px 0; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; margin: 14px 0 0; font-size: 15px; }
.links.center { justify-content: center; }
.row-links { display: flex; justify-content: space-between; margin-top: 8px; }
.alert, .notice { padding: 10px 12px; border-radius: 10px; font-size: 15px; margin-bottom: 14px; }
.alert { color: var(--brick); background: var(--brick-soft); }
.notice { color: var(--leaf); background: var(--leaf-soft); }

/* ---- the drawer (bottom sheet) ---- */
.drawer-backdrop { position: fixed; inset: 0; z-index: 100; background: var(--scrim); animation: backdrop-in 300ms var(--ease) both; }
.drawer-backdrop[data-ending-style] { transition: opacity 250ms var(--ease); opacity: 0; }
.drawer-viewport { position: fixed; inset: 0; z-index: 101; display: flex; align-items: flex-end; justify-content: center; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); pointer-events: none; }
.drawer {
  pointer-events: auto; position: relative; isolation: isolate; display: flex; flex-direction: column;
  width: min(100%, 26rem); max-height: min(88vh, 40rem);
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden;
  translate: 0 var(--swipe-y, 0px);
  animation: drawer-in 500ms var(--ease) both;
}
.drawer.settling { transition: translate 400ms var(--ease); }
.drawer.dragging { transition: none; }
.drawer[data-ending-style] { transition: translate 250ms var(--ease), opacity 250ms var(--ease); translate: 0 105%; }
.drawer-grip { flex: none; touch-action: none; cursor: grab; }
.drawer-handle { display: flex; justify-content: center; padding: 12px 16px 8px; }
.drawer-handle span { width: 40px; height: 6px; border-radius: 999px; background: var(--muted); opacity: 0.35; }
.drawer-head { padding: 0 48px 14px 20px; border-bottom: 1px solid var(--line); }
[dir="rtl"] .drawer-head { padding: 0 20px 14px 48px; }
.drawer-title { font-size: 17px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.drawer-desc { font-size: 13px; color: var(--muted); margin: 4px 0 0; }
.drawer-body { min-height: 0; flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 18px 20px 20px; }
.drawer-body .btn { margin-top: 4px; }
.drawer-close {
  position: absolute; top: 12px; inset-inline-end: 12px; width: 32px; height: 32px; display: grid; place-items: center;
  border-radius: 10px; color: var(--muted); border: 1px solid transparent; text-decoration: none;
}
.drawer-close svg { width: 16px; height: 16px; }
.drawer-close:hover, .drawer-close:active { border-color: var(--line); background: var(--pressed); color: var(--ink); }
@keyframes drawer-in { from { translate: 0 105%; } to { translate: 0 0; } }
@keyframes backdrop-in { from { opacity: 0; } to { opacity: 1; } }

/* ---- the save confirmation ---- */
.toast {
  position: fixed; z-index: 50; inset-inline: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); max-width: 320px; margin: 0 auto;
  padding: 10px 16px; border-radius: 12px; text-align: center; font-weight: 600; font-size: 15px;
  background: var(--ink); color: var(--paper); box-shadow: var(--shadow);
  animation: toast 3.2s var(--ease) both;
}
@keyframes toast { 0% { opacity: 0; translate: 0 8px; } 8% { opacity: 1; translate: 0 0; } 85% { opacity: 1; } 100% { opacity: 0; visibility: hidden; } }

@media (prefers-reduced-motion: reduce) {
  .drawer, .drawer-backdrop, .toast { animation: none; }
  .drawer[data-ending-style], .drawer-backdrop[data-ending-style], .drawer.settling { transition: none; }
}

/* ---- phones: the two buttons stay at the bottom of the screen ---- */
@media (max-width: 639px) {
  .actions { position: fixed; z-index: 5; inset-inline: 16px; bottom: calc(14px + env(safe-area-inset-bottom)); margin: 0; }
  .actions .btn { box-shadow: var(--shadow); }
  .status { margin-bottom: 8px; }
}

/* ---- wider screens ---- */
@media (min-width: 640px) {
  main { padding-bottom: 40px; }
  .hero-amount { font-size: 44px; }
  .month { font-size: 34px; }
  .actions { justify-content: flex-start; }
  .actions .btn { flex: 0 0 auto; width: auto; min-width: 200px; }
  .drawer-viewport { align-items: center; }
  .drawer { animation-name: dialog-in; animation-duration: 300ms; }
  .drawer[data-ending-style] { translate: 0 0; opacity: 0; }
  .toast { inset-inline: auto 24px; bottom: auto; top: 20px; }
}
@keyframes dialog-in { from { opacity: 0; scale: 0.985; } to { opacity: 1; scale: 1; } }
