/* Brightkept Budget: calm, warm, high-contrast where it matters. */

:root {
  --bg: #FAF8F4;
  --surface: #FFFFFF;
  --surface-2: #F3F0EA;
  --line: #E6E1D8;
  --ink: #2F3437;
  --muted: #646B70;
  --faint: #8C9296;
  --sage: #8FA68A;
  --sage-ink: #4E6A48;      /* text/buttons on light: 5.6:1 on white */
  --sage-50: #EDF2EB;
  --sage-100: #DCE7D8;
  --terra: #D08C6A;
  --terra-ink: #9C5634;
  --terra-50: #FBEEE6;
  --amber-50: #FBF3E2;
  --amber-ink: #8A5E12;
  --focus: #3D6FB6;
  --shadow: 0 1px 2px rgba(47, 52, 55, .06), 0 4px 16px rgba(47, 52, 55, .06);
  --radius: 18px;
  --radius-sm: 12px;
  --font: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --fs: 16px;
  --tabs-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #161A1B;
  --surface: #1F2426;
  --surface-2: #283033;
  --line: #333B3E;
  --ink: #ECEDEA;
  --muted: #AEB4B0;
  --faint: #8A918E;
  --sage: #9DB897;
  --sage-ink: #A8C7A1;
  --sage-50: #233026;
  --sage-100: #2E3F31;
  --terra: #E3A283;
  --terra-ink: #F0B497;
  --terra-50: #3A2A22;
  --amber-50: #3A3120;
  --amber-ink: #E9C27A;
  --focus: #8DB4F0;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

:root[data-text="large"] { --fs: 18.5px; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; overflow-x: hidden; background: var(--bg); color: var(--ink);
  font: 400 var(--fs)/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--sage-ink); }
img { max-width: 100%; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: .875em; }
.tiny { font-size: .78em; }
.center { text-align: center; }
.right { text-align: right; }
.hide { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 8px; }

/* ---------- layout ---------- */
.app { min-height: 100vh; min-height: 100dvh; }
.side { display: none; }
.main { padding-bottom: calc(var(--tabs-h) + var(--safe-b) + 16px); }
.view { max-width: 640px; margin: 0 auto; padding: calc(12px + var(--safe-t)) 16px 24px; outline: none; }
.view.wide { max-width: 1080px; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(var(--n, 5), 1fr);
  height: calc(var(--tabs-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 0; background: none; color: var(--muted); font-size: 11.5px; font-weight: 600; text-decoration: none;
  min-height: 44px;
}
.tab svg { width: 24px; height: 24px; }
.tab[aria-current="page"] { color: var(--sage-ink); }
.tab[aria-current="page"] svg { stroke-width: 2.4; }

@media (min-width: 960px) {
  .app { display: grid; grid-template-columns: 232px 1fr; }
  .side {
    display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh;
    padding: 24px 14px; border-right: 1px solid var(--line); background: var(--surface);
  }
  .brand { display: flex; align-items: center; gap: 10px; font-weight: 750; padding: 0 8px; }
  .brand img { border-radius: 9px; }
  .side-nav { display: flex; flex-direction: column; gap: 2px; }
  .side-nav a {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px;
    color: var(--muted); text-decoration: none; font-weight: 600;
  }
  .side-nav a svg { width: 21px; height: 21px; }
  .side-nav a:hover { background: var(--surface-2); color: var(--ink); }
  .side-nav a[aria-current="page"] { background: var(--sage-50); color: var(--sage-ink); }
  .side-nav hr { border: 0; border-top: 1px solid var(--line); margin: 10px 8px; }
  .tabs { display: none; }
  .main { padding-bottom: 32px; }
  .view { padding-top: 28px; }
}

/* ---------- headings ---------- */
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 4px 2px 14px; }
.top h1 { font-size: 1.55em; line-height: 1.15; margin: 0; letter-spacing: -.01em; }
.top .sub { color: var(--muted); font-size: .9em; margin-top: 2px; }
h2 { font-size: 1.05em; margin: 0 0 10px; letter-spacing: -.005em; }
h3 { font-size: 1em; margin: 0 0 6px; }
.section-title { display: flex; justify-content: space-between; align-items: baseline; margin: 22px 4px 10px; }
.section-title h2 { margin: 0; }

/* ---------- cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px;
}
.card.tight { padding: 6px 0; }
.card.soft { background: var(--surface-2); box-shadow: none; }
.card.sage { background: var(--sage-50); border-color: var(--sage-100); box-shadow: none; }
.card.terra { background: var(--terra-50); border-color: color-mix(in srgb, var(--terra) 35%, transparent); box-shadow: none; }
.card.amber { background: var(--amber-50); border-color: color-mix(in srgb, var(--amber-ink) 25%, transparent); box-shadow: none; }
.grid2 { display: grid; gap: 0 14px; grid-template-columns: minmax(0, 1fr); }
.grid2 > * { min-width: 0; }
@media (min-width: 960px) {
  .grid2 { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); align-items: start; }
}

/* ---------- hero number ---------- */
.hero { text-align: center; padding: 22px 16px 18px; }
.hero .label { color: var(--muted); font-weight: 650; letter-spacing: .01em; }
.hero .big {
  font-size: clamp(48px, 15vw, 68px); font-weight: 800; line-height: 1.05; letter-spacing: -.03em;
  margin: 6px 0 4px; font-variant-numeric: tabular-nums;
}
.hero .big .cents { font-size: .45em; letter-spacing: 0; vertical-align: .9em; margin-left: 2px; }
.hero .big.neg { color: var(--terra-ink); }
.hero .line { color: var(--muted); }
.hero .line b { color: var(--ink); }
.pill-status {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; padding: 6px 12px;
  border-radius: 999px; font-size: .88em; font-weight: 650; background: var(--sage-50); color: var(--sage-ink);
}
.pill-status.warn { background: var(--terra-50); color: var(--terra-ink); }
.pill-status.amber { background: var(--amber-50); color: var(--amber-ink); }

.breakdown { margin-top: 14px; text-align: left; border-top: 1px dashed var(--line); padding-top: 12px; }
.breakdown .row { padding: 6px 2px; min-height: 0; border: 0; }
.breakdown .row.total { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 10px; font-weight: 750; }

/* ---------- rows / lists ---------- */
.list { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 10px 16px;
  border-top: 1px solid var(--line); background: none; border-left: 0; border-right: 0; border-bottom: 0;
  width: 100%; text-align: left; color: inherit; text-decoration: none;
}
.list > .row:first-child, .card > .row:first-child { border-top: 0; }
button.row:hover, a.row:hover { background: var(--surface-2); }
.row .grow { flex: 1; min-width: 0; }
.row .title { display: block; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .meta { display: block; color: var(--muted); font-size: .85em; }
.row .amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row .amt.in { color: var(--sage-ink); }
.row.done .title, .row.done .amt { color: var(--faint); text-decoration: line-through; }
.emoji {
  width: 38px; height: 38px; flex: none; border-radius: 12px; display: grid; place-items: center;
  background: var(--surface-2); font-size: 20px;
}
.chev { color: var(--faint); flex: none; }
.empty { padding: 18px 16px; color: var(--muted); text-align: center; }

.badge {
  display: inline-block; font-size: .72em; font-weight: 700; padding: 2px 7px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); vertical-align: 1px; margin-left: 4px; letter-spacing: .02em;
}
.badge.sage { background: var(--sage-50); color: var(--sage-ink); }
.badge.terra { background: var(--terra-50); color: var(--terra-ink); }
.badge.amber { background: var(--amber-50); color: var(--amber-ink); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 10px 18px; border-radius: 14px; border: 1px solid transparent;
  background: var(--sage-ink); color: #fff; font-weight: 700; text-decoration: none; letter-spacing: .005em;
}
:root[data-theme="dark"] .btn:not(.ghost):not(.soft):not(.link):not(.terra) { color: #13201a; }
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn.block { width: 100%; }
.btn.ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn.soft { background: var(--sage-50); color: var(--sage-ink); }
.btn.terra { background: var(--terra-ink); color: #fff; }
:root[data-theme="dark"] .btn.terra { color: #2a160c; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: .9em; border-radius: 11px; }
.btn.link { background: none; color: var(--sage-ink); padding: 6px 4px; min-height: 36px; }
.btn svg { width: 18px; height: 18px; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; }
.btns.stack { flex-direction: column; }
.btns.end { justify-content: flex-end; }
.iconbtn {
  width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
.iconbtn svg { width: 20px; height: 20px; }
.tick {
  width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 50%;
  border: 2px solid var(--line); background: var(--surface); color: transparent;
}
.tick svg { width: 20px; height: 20px; }
.tick.on { background: var(--sage-ink); border-color: var(--sage-ink); color: #fff; }
.tick:hover { border-color: var(--sage); }

/* ---------- forms ---------- */
.field { display: block; margin-bottom: 14px; }
.field > span, .label { display: block; font-weight: 650; margin-bottom: 6px; font-size: .95em; }
.hint { display: block; color: var(--muted); font-size: .84em; margin-top: 5px; font-weight: 400; }
.input, select.input, textarea.input {
  width: 100%; min-height: 48px; padding: 11px 14px; border-radius: 13px; border: 1.5px solid var(--line);
  background: var(--surface); outline: none; -webkit-appearance: none; appearance: none;
}
select.input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%23646B70' stroke-width='2'%3E%3Cpath d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px;
}
textarea.input { min-height: 96px; resize: vertical; }
.input:focus { border-color: var(--sage); box-shadow: 0 0 0 3px color-mix(in srgb, var(--sage) 30%, transparent); }
.input.money { font-size: 1.6em; font-weight: 750; text-align: center; font-variant-numeric: tabular-nums; }
.money-wrap { position: relative; }
.money-wrap .sym { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--faint); font-weight: 700; font-size: 1.1em; pointer-events: none; }
.money-wrap .input { padding-left: 34px; }
.inline { display: flex; gap: 10px; }
.inline > * { flex: 1; min-width: 0; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line); }
.switch:first-child { border-top: 0; }
.switch .text { flex: 1; }
.switch input { appearance: none; -webkit-appearance: none; width: 50px; height: 30px; border-radius: 99px; background: var(--line); position: relative; flex: none; transition: background .15s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked { background: var(--sage-ink); }
.switch input:checked::after { transform: translateX(20px); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: none; flex-wrap: wrap; }
.chips.scroll { flex-wrap: nowrap; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 7px 13px;
  border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface); font-weight: 600; font-size: .92em;
}
.chip[aria-pressed="true"] { border-color: var(--sage-ink); background: var(--sage-50); color: var(--sage-ink); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 14px; }
.seg button { border: 0; background: none; min-height: 40px; border-radius: 10px; font-weight: 650; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* ---------- quick log ---------- */
.quick .amount-row { display: flex; gap: 10px; align-items: stretch; }
.quick .amount-row .money-wrap { flex: 1; }
.quick .amount-row .btn { min-width: 96px; }
.quick .quick-amts { margin-top: 10px; }
.quick .cats { margin-top: 10px; }
.quick .more-link { margin-top: 4px; }

/* ---------- progress ---------- */
.bar { height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: inherit; background: var(--sage); }
.bar.terra > i { background: var(--terra); }
.bar.thin { height: 6px; }

/* ---------- calendar ---------- */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .dow { text-align: center; font-size: .75em; color: var(--faint); font-weight: 700; padding-bottom: 4px; }
.cal .day {
  aspect-ratio: 1 / 1.05; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding: 5px 2px 3px;
  font-size: .82em; min-width: 0;
}
.cal .day.out { visibility: hidden; }
.cal .day.today { border-color: var(--sage-ink); box-shadow: inset 0 0 0 1px var(--sage-ink); }
.cal .day .n { font-weight: 700; }
.cal .day .dots { display: flex; gap: 3px; margin-top: 3px; min-height: 7px; }
.cal .day .dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--terra); }
.cal .day .dots i.pay { background: var(--sage-ink); }
.cal .day .s { margin-top: auto; font-size: .78em; color: var(--muted); font-variant-numeric: tabular-nums; max-width: 100%; overflow: hidden; text-overflow: clip; white-space: nowrap; }
.legend { display: flex; gap: 16px; justify-content: center; font-size: .82em; color: var(--muted); margin-top: 10px; }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--terra); margin-right: 5px; }
.legend i.pay { background: var(--sage-ink); }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.tile .k { font-size: .78em; color: var(--muted); font-weight: 650; }
.tile .v { font-size: 1.15em; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: 2px; }

/* ---------- sheet ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(20, 24, 26, .38); z-index: 40; animation: fade .18s ease; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 92vh; max-height: 92dvh; overflow: auto;
  background: var(--bg); border-radius: 22px 22px 0 0; padding: 8px 18px calc(22px + var(--safe-b));
  box-shadow: 0 -8px 40px rgba(0, 0, 0, .18); animation: up .22s cubic-bezier(.2, .8, .2, 1);
  overscroll-behavior: contain;
}
.sheet .grab { width: 40px; height: 5px; border-radius: 9px; background: var(--line); margin: 4px auto 12px; }
.sheet .sheet-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.sheet .sheet-top h2 { margin: 0; font-size: 1.2em; }
@media (min-width: 700px) {
  .sheet { left: 50%; right: auto; bottom: auto; top: 50%; transform: translate(-50%, -50%); width: min(520px, 92vw); border-radius: 22px; padding-bottom: 22px; animation: pop .18s ease; }
  .sheet .grab { display: none; }
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translate(-50%, -47%); } }
@keyframes fade { from { opacity: 0; } }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabs-h) + var(--safe-b) + 14px); transform: translate(-50%, 20px);
  z-index: 60; background: var(--ink); color: var(--bg); border-radius: 14px; padding: 10px 10px 10px 16px;
  display: flex; align-items: center; gap: 12px; font-weight: 600; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); box-shadow: 0 8px 30px rgba(0,0,0,.2);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast button { border: 0; background: color-mix(in srgb, var(--bg) 18%, transparent); color: var(--bg); font-weight: 750; border-radius: 10px; padding: 8px 12px; }
@media (min-width: 960px) { .toast { bottom: 24px; } }

/* ---------- banner ---------- */
.banner { background: var(--amber-50); color: var(--amber-ink); font-size: .88em; padding: 9px 16px; text-align: center; font-weight: 600; }
.banner a { color: inherit; }

/* ---------- misc ---------- */
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; }
.kv .v { font-weight: 700; font-variant-numeric: tabular-nums; }
.stack > * + * { margin-top: 10px; }
.steps { display: flex; gap: 6px; justify-content: center; margin: 4px 0 18px; }
.steps i { width: 26px; height: 6px; border-radius: 9px; background: var(--line); }
.steps i.on { background: var(--sage-ink); }
.welcome { text-align: center; padding: 26px 8px 8px; }
.welcome img { width: 76px; height: 76px; border-radius: 20px; box-shadow: var(--shadow); }
.welcome h1 { font-size: 1.7em; line-height: 1.15; margin: 18px 0 8px; letter-spacing: -.015em; }
.welcome p { color: var(--muted); margin: 0 auto 22px; max-width: 30em; }
.note-ios { text-align: left; }
.wins { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.win { border: 1px solid var(--line); border-radius: 16px; padding: 14px; background: var(--surface); text-align: center; }
.win .e { font-size: 30px; }
.win .t { font-weight: 700; margin-top: 4px; }
.win.locked { opacity: .5; filter: grayscale(1); }
.cmp { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cmp .opt { border: 1.5px solid var(--line); border-radius: 16px; padding: 14px; background: var(--surface); }
.cmp .opt.best { border-color: var(--sage-ink); background: var(--sage-50); }
.cmp .opt .when { font-size: 1.25em; font-weight: 800; margin: 4px 0; }
input[type="range"] { width: 100%; accent-color: var(--sage-ink); }
.drop { border: 2px dashed var(--line); border-radius: 18px; padding: 22px; text-align: center; background: var(--surface); }
.drop.over { border-color: var(--sage-ink); background: var(--sage-50); }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 70; overflow: hidden; }
.confetti i { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 3px; animation: fall 1.6s ease-in forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(540deg); opacity: .9; } }
details.more summary { cursor: pointer; color: var(--sage-ink); font-weight: 650; list-style: none; padding: 6px 0; }
details.more summary::-webkit-details-marker { display: none; }
.timeline .row { min-height: 44px; }
.timeline .row .left { font-variant-numeric: tabular-nums; color: var(--muted); }

:root[data-motion="reduce"] *, :root[data-motion="reduce"] *::before, :root[data-motion="reduce"] *::after { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
@media print {
  .tabs, .side, .toast, #sheet-root, .banner, .btn, .iconbtn { display: none !important; }
  .main { padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
}

/* Listing screenshots only (?shot=1): leave room for a phone's status bar and home bar. */
@media (max-width: 959px) { :root[data-shot] { --safe-t: 46px; --safe-b: 18px; } }
