@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Manrope:wght@500;600;700;800&display=swap');

:root {
  color-scheme: light;
  --ink: #1d2b23;
  --muted: #7a847b;
  --paper: #f5f4ed;
  --card: #fffefa;
  --green: #173b2d;
  --green-soft: #e7eee7;
  --gold: #d7a84b;
  --line: #e9e8df;
  --red: #b84b3d;
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--paper); }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid #d7a84b88; outline-offset: 2px; }
.shell { width: min(100% - 32px, 760px); margin: 0 auto; padding: 30px 0 60px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 26px; }
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark { width: 42px; height: 42px; border-radius: 15px; display: grid; place-items: center; background: var(--green); color: #fffefa; font-size: 22px; }
.brand-name { margin: 0; font: 800 19px/1.1 'Manrope', sans-serif; letter-spacing: -.04em; }
.brand-caption { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.home-code { border: 1px solid var(--line); color: var(--muted); background: transparent; border-radius: 999px; padding: 9px 13px; font-size: 12px; font-weight: 700; letter-spacing: .07em; }
.install-button { border: 0; border-radius: 999px; background: #e8d6aa; color: #453719; padding: 10px 13px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.install-button[hidden] { display: none; }
.welcome { max-width: 610px; margin: 7vh auto 0; }
.welcome h1 { margin: 0; font: 800 clamp(34px, 7vw, 54px)/1.05 'Manrope', sans-serif; letter-spacing: -.06em; }
.welcome .lead { color: var(--muted); font-size: 16px; line-height: 1.65; max-width: 490px; margin: 16px 0 28px; }
.welcome-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 22px; box-shadow: 0 10px 30px #31452a08; }
.panel h2 { margin: 0 0 17px; font: 700 17px 'Manrope', sans-serif; letter-spacing: -.03em; }
.field { display: grid; gap: 7px; margin: 13px 0; }
.field label, .dialog label { font-size: 12px; color: var(--muted); font-weight: 700; }
.field input, .field select, .dialog input { width: 100%; height: 46px; border: 1px solid var(--line); border-radius: 12px; padding: 0 13px; color: var(--ink); background: #fff; }
.button { min-height: 44px; border: 0; border-radius: 13px; padding: 0 16px; font-weight: 700; transition: transform .15s, background .15s; }
.button:active { transform: scale(.98); }
.button-primary { color: white; background: var(--green); }
.button-primary:hover { background: #24533f; }
.button-quiet { color: var(--green); background: var(--green-soft); }
.button-quiet:hover { background: #dbe6dc; }
.button-full { width: 100%; margin-top: 4px; }
.join-card { grid-column: 1 / -1; padding: 19px 22px; display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: end; }
.join-card h2 { margin-bottom: 0; }
.join-fields { display: grid; grid-template-columns: 1.4fr 1fr; gap: 10px; }
.join-fields .field { margin: 10px 0 0; }
.join-fields input { height: 42px; }
.join-card .button { min-width: 128px; }
.hint { color: var(--muted); font-size: 12px; margin: 13px 2px 0; }
.app-title-row { display: flex; justify-content: space-between; align-items: start; gap: 14px; margin: 18px 0; }
.app-title-row h1 { margin: 0; font: 800 clamp(26px, 5vw, 34px)/1.1 'Manrope', sans-serif; letter-spacing: -.05em; }
.app-title-row p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.budget-card { color: #fffefa; background: var(--green); border-radius: 25px; padding: 23px 25px 20px; position: relative; overflow: hidden; }
.budget-card::after { content: ''; position: absolute; right: -48px; top: -70px; width: 190px; height: 190px; border: 1px solid #ffffff18; border-radius: 50%; box-shadow: 0 0 0 28px #ffffff08, 0 0 0 56px #ffffff06; pointer-events: none; }
.budget-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; position: relative; z-index: 1; }
.budget-label { color: #d4ded6; font-size: 12px; font-weight: 600; }
.budget-period { border: 1px solid #ffffff30; border-radius: 999px; color: #e9eee9; padding: 6px 10px; background: transparent; font-size: 11px; }
.remaining { margin: 8px 0 0; font: 800 clamp(36px, 8vw, 48px)/1.1 'Manrope', sans-serif; letter-spacing: -.06em; position: relative; z-index: 1; }
.budget-breakdown { display: flex; gap: 22px; margin-top: 14px; position: relative; z-index: 1; }
.budget-breakdown div { display: grid; gap: 3px; }
.budget-breakdown span { color: #c1d0c3; font-size: 11px; }
.budget-breakdown strong { font-size: 13px; font-weight: 700; }
.progress-track { height: 6px; border-radius: 999px; background: #ffffff24; margin-top: 19px; overflow: hidden; position: relative; z-index: 1; }
.progress-fill { height: 100%; border-radius: inherit; background: var(--gold); transition: width .3s; }
.progress-fill.over { background: #ee947d; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 28px 2px 13px; }
.section-heading h2 { margin: 0; font: 700 18px 'Manrope', sans-serif; letter-spacing: -.04em; }
.count { min-width: 25px; height: 25px; border-radius: 99px; display: inline-grid; place-items: center; color: var(--green); background: var(--green-soft); font-size: 12px; font-weight: 700; margin-left: 5px; }
.add-card { padding: 17px; display: grid; grid-template-columns: 1fr 105px 135px auto; gap: 9px; align-items: end; }
.add-card .field { margin: 0; }
.add-card input, .add-card select { height: 44px; }
.add-card .button { height: 44px; }
.list { display: grid; gap: 9px; }
.item { display: flex; align-items: center; gap: 13px; padding: 14px 16px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; }
.item-icon { width: 39px; height: 39px; flex: 0 0 39px; display: grid; place-items: center; border-radius: 13px; background: #f1efe6; font-size: 18px; }
.item-main { min-width: 0; flex: 1; }
.item-name { margin: 0; font-weight: 700; font-size: 14px; overflow-wrap: anywhere; }
.item-meta { color: var(--muted); font-size: 11px; margin: 4px 0 0; }
.item-actions { display: flex; align-items: center; gap: 7px; }
.icon-button { width: 35px; height: 35px; border: 0; border-radius: 11px; display: grid; place-items: center; color: var(--muted); background: transparent; font-size: 17px; }
.icon-button:hover { color: var(--red); background: #f8eae7; }
.buy-button { border: 0; border-radius: 11px; min-height: 36px; padding: 0 12px; white-space: nowrap; color: var(--green); background: var(--green-soft); font-size: 12px; font-weight: 700; }
.buy-button:hover { background: #dbe6dc; }
.empty { text-align: center; color: var(--muted); background: #efeee7; border: 1px dashed #d9d8ce; border-radius: 16px; padding: 24px 16px; font-size: 13px; line-height: 1.6; }
.empty strong { display: block; color: var(--ink); font-size: 14px; margin-bottom: 3px; }
.history { display: grid; gap: 8px; }
.purchase { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; padding: 12px 15px; background: #eeede6; border-radius: 14px; }
.purchase-name { font-size: 13px; font-weight: 700; margin: 0; }
.purchase-meta { font-size: 11px; color: var(--muted); margin: 4px 0 0; }
.purchase-amount { font-weight: 700; font-size: 13px; white-space: nowrap; }
.undo-button { border: 0; background: transparent; color: var(--muted); font-size: 11px; text-decoration: underline; text-underline-offset: 3px; }
.sync-note { color: var(--muted); text-align: center; font-size: 11px; padding-top: 22px; }
.footer-actions { display: flex; justify-content: center; margin-top: 15px; }
.text-button { border: 0; background: transparent; color: var(--muted); font-size: 12px; padding: 8px 10px; text-decoration: underline; text-underline-offset: 3px; }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 15px); opacity: 0; pointer-events: none; max-width: calc(100vw - 30px); padding: 12px 16px; color: white; background: #263b2f; border-radius: 13px; box-shadow: 0 8px 28px #0002; font-size: 13px; z-index: 5; transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.dialog { width: min(420px, calc(100% - 28px)); border: 0; border-radius: 23px; padding: 25px; background: var(--card); color: var(--ink); box-shadow: 0 24px 90px #14251b44; }
.dialog::backdrop { background: #1b2b2077; backdrop-filter: blur(3px); }
.dialog h2 { margin: 0; font: 800 23px 'Manrope', sans-serif; letter-spacing: -.04em; }
.eyebrow { margin: 0 0 8px; color: #89938a; font-size: 10px; font-weight: 800; letter-spacing: .13em; }
.dialog-copy { color: var(--muted); font-size: 13px; margin: 8px 0 21px; }
.dialog label { display: block; margin-bottom: 8px; }
.dialog label span { color: var(--green); }
.dialog-actions { display: flex; justify-content: end; gap: 8px; margin-top: 20px; }
.dialog-actions .button { min-width: 100px; }
.error { color: var(--red); font-size: 12px; margin: 8px 0 0; min-height: 16px; }
.site-footer { padding: 0 12px max(18px, env(safe-area-inset-bottom)); text-align: center; }
.site-footer a { color: var(--muted); font-size: 12px; text-decoration: none; }
.site-footer a:hover { color: var(--green); text-decoration: underline; text-underline-offset: 3px; }

@media (max-width: 620px) {
  .shell { width: min(100% - 24px, 520px); padding-top: 19px; }
  .topbar { margin-bottom: 20px; }
  .install-button { padding: 9px 11px; font-size: 11px; }
  .welcome { margin-top: 4vh; }
  .welcome-grid { grid-template-columns: 1fr; }
  .join-card { grid-column: auto; grid-template-columns: 1fr; gap: 8px; }
  .join-card .button { width: 100%; }
  .join-fields { grid-template-columns: 1fr; gap: 0; }
  .app-title-row { margin: 14px 0; }
  .budget-card { padding: 19px 19px 17px; border-radius: 21px; }
  .add-card { grid-template-columns: 1fr 94px; }
  .add-card .field:first-child { grid-column: 1 / -1; }
  .add-card .field:nth-child(3) { grid-column: 1; }
  .add-card .button { grid-column: 2; }
  .item { padding: 12px; gap: 10px; }
  .item-icon { width: 35px; height: 35px; flex-basis: 35px; }
  .buy-button { padding: 0 9px; font-size: 11px; }
  .purchase { grid-template-columns: 1fr auto; }
  .purchase .undo-button { grid-column: 1 / -1; justify-self: end; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; } }
