:root {
  color-scheme: light;
  --ink: #17322a;
  --muted: #65736d;
  --paper: #fffdf8;
  --ivory: #f6f1e7;
  --line: #ded8ca;
  --green: #175c45;
  --green-2: #d9ebdf;
  --red: #a53b32;
  --shadow: 0 12px 30px rgb(45 55 43 / 8%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  line-height: 1.5;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--ivory); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button, select, input[type="file"] { min-height: 44px; }
button { cursor: pointer; }
a { color: var(--green); }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(1.65rem, 6vw, 2.5rem); line-height: 1.12; letter-spacing: -.035em; }
h2 { font-size: 1.25rem; letter-spacing: -.02em; }
.skip-link { position: fixed; left: 1rem; top: -5rem; z-index: 20; background: var(--ink); color: white; padding: .7rem 1rem; border-radius: .5rem; }
.skip-link:focus { top: 1rem; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: .75rem; min-height: 66px; padding: .65rem max(1rem, calc((100vw - 1080px) / 2)); background: rgb(246 241 231 / 92%); border-bottom: 1px solid rgb(222 216 202 / 75%); backdrop-filter: blur(12px); }
.brand { display: flex; align-items: center; gap: .6rem; color: var(--ink); font-weight: 780; letter-spacing: -.02em; }
.brand svg { width: 34px; height: 34px; flex: none; }
.group-picker { flex: 1; min-width: 0; max-width: 340px; margin-left: auto; }
.group-picker select { width: 100%; }
.sync-pill { display: inline-flex; align-items: center; gap: .35rem; min-height: 44px; padding: .35rem .65rem; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); color: var(--muted); font-size: .78rem; white-space: nowrap; }
.account-button { margin-left: auto; padding: .1rem; }
.account-button .avatar { width: 38px; height: 38px; }
.sync-dot { width: .5rem; height: .5rem; border-radius: 50%; background: #6d9b7c; }
.sync-pill[data-status="error"] .sync-dot, .sync-pill[data-status="offline"] .sync-dot { background: #c46e4f; }
main { width: min(1080px, 100%); margin: 0 auto; padding: 1.2rem 1rem 6.5rem; }
.page-head, .row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.page-head { margin-bottom: 1rem; align-items: end; }
.page-head h1 { margin-bottom: .15rem; }
.eyebrow { color: var(--green); font-size: .75rem; font-weight: 750; letter-spacing: .09em; text-transform: uppercase; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.grid { display: grid; gap: 1rem; }
.card { padding: 1rem; border: 1px solid var(--line); border-radius: 18px; background: var(--paper); box-shadow: var(--shadow); }
.card h2:last-child, .card p:last-child { margin-bottom: 0; }
.hero { max-width: 680px; margin: clamp(2rem, 8vh, 6rem) auto; padding: clamp(1.25rem, 5vw, 2.8rem); }
.hero-logo { width: 64px; height: 64px; margin-bottom: 1.1rem; }
.form-grid { display: grid; gap: .9rem; }
label, legend { color: var(--ink); font-weight: 650; font-size: .88rem; }
fieldset { margin: 0; padding: 0; border: 0; }
label span { display: block; margin-bottom: .3rem; }
input, select, textarea { width: 100%; border: 1px solid #cfc8b8; border-radius: 10px; background: #fff; color: var(--ink); padding: .65rem .75rem; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 3px solid rgb(23 92 69 / 22%); outline-offset: 2px; border-color: var(--green); }
textarea { min-height: 76px; resize: vertical; }
.actions { display: flex; flex-wrap: wrap; gap: .65rem; align-items: center; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 44px; padding: .6rem .9rem; border: 1px solid transparent; border-radius: 10px; background: var(--green); color: white; font-weight: 700; text-decoration: none; }
.button.secondary { border-color: var(--line); background: var(--paper); color: var(--ink); }
.button.danger { border-color: #efd2cf; background: #fff7f5; color: var(--red); }
.button.ghost { min-height: 36px; padding: .35rem .55rem; border-color: transparent; background: transparent; color: var(--green); }
.button:disabled { cursor: wait; opacity: .55; }
.icon-button { width: 44px; padding: 0; }
.summary { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; margin-bottom: 1rem; }
.metric { padding: 1rem; border-radius: 16px; background: var(--green); color: white; }
.metric.alt { background: #e4dccb; color: var(--ink); }
.metric span { display: block; font-size: .75rem; opacity: .76; }
.metric strong { display: block; font-size: 1.3rem; letter-spacing: -.025em; }
.toolbar { display: grid; grid-template-columns: 1fr auto; gap: .6rem; margin-bottom: 1rem; }
.list { display: grid; gap: .65rem; }
.expense { display: grid; grid-template-columns: auto 1fr auto; gap: .75rem; align-items: center; }
.date-tile { width: 46px; text-align: center; color: var(--muted); font-size: .7rem; line-height: 1.15; }
.date-tile strong { display: block; color: var(--ink); font-size: 1.15rem; }
.expense h3 { margin: 0; font-size: 1rem; }
.amount { text-align: right; font-weight: 760; white-space: nowrap; }
.balance-row { display: grid; grid-template-columns: 40px 1fr auto; gap: .75rem; align-items: center; padding: .65rem 0; border-bottom: 1px solid var(--line); }
.balance-row:last-child { border-bottom: 0; }
.avatar { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--green-2); color: var(--green); font-weight: 800; }
.positive { color: var(--green); }
.negative { color: var(--red); }
.empty { padding: 2rem 1rem; border: 1px dashed #cfc8b8; border-radius: 16px; text-align: center; color: var(--muted); }
.bottom-nav { position: fixed; inset: auto 0 0; z-index: 6; display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); padding: .4rem .5rem max(.4rem, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: rgb(255 253 248 / 96%); backdrop-filter: blur(12px); }
.bottom-nav button { border: 0; background: transparent; color: var(--muted); font-size: .78rem; font-weight: 700; }
.bottom-nav button[aria-current="page"] { color: var(--green); }
.desktop-aside { display: none; }
dialog { width: min(620px, calc(100% - 1.5rem)); max-height: calc(100vh - 1.5rem); padding: 0; border: 0; border-radius: 20px; color: var(--ink); background: var(--paper); box-shadow: 0 24px 80px rgb(24 45 36 / 25%); }
dialog::backdrop { background: rgb(24 45 36 / 48%); backdrop-filter: blur(3px); }
.dialog-body { padding: 1.15rem; }
.dialog-head { display: flex; align-items: start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.dialog-head h2 { margin: 0; }
.dialog-scroll { max-height: 72vh; overflow: auto; padding: 2px; }
.split-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: .3rem; padding: .3rem; border-radius: 12px; background: var(--ivory); }
.split-tabs label { position: relative; text-align: center; }
.split-tabs input { position: absolute; opacity: 0; pointer-events: none; }
.split-tabs span { display: block; padding: .5rem .25rem; border-radius: 9px; font-size: .75rem; }
.split-tabs input:checked + span { background: var(--paper); color: var(--green); box-shadow: 0 2px 8px rgb(30 50 40 / 9%); }
.split-tabs input:focus-visible + span { outline: 3px solid rgb(23 92 69 / 22%); outline-offset: 2px; }
.split-values { display: grid; gap: .5rem; }
.split-value { display: grid; grid-template-columns: 1fr minmax(90px, 130px); gap: .75rem; align-items: center; }
.error { min-height: 1.4rem; margin: .4rem 0 0; color: var(--red); font-size: .85rem; }
.toast { position: fixed; z-index: 30; left: 50%; bottom: 5.4rem; translate: -50% 1rem; max-width: calc(100% - 2rem); padding: .7rem 1rem; border-radius: 999px; background: var(--ink); color: white; opacity: 0; pointer-events: none; transition: .2s; }
.toast.show { translate: -50% 0; opacity: 1; }
.notice { padding: .8rem 1rem; border-left: 3px solid var(--green); background: var(--green-2); border-radius: 8px; }
.setting { padding: 1rem 0; border-bottom: 1px solid var(--line); }
.setting:last-child { border-bottom: 0; }
.conflict { display: grid; gap: .5rem; padding: .75rem 0; border-bottom: 1px solid var(--line); }
.conflict pre { overflow: auto; padding: .6rem; background: var(--ivory); font-size: .72rem; }
.radio-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.radio-row label { display: flex; align-items: center; gap: .4rem; }
.radio-row input { width: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (min-width: 760px) {
  main { padding: 2rem 1.5rem 4rem; }
  .bottom-nav { position: static; display: flex; width: auto; margin-left: .5rem; padding: 0; border: 0; background: transparent; }
  .bottom-nav button { padding: .55rem .7rem; }
  .layout { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(260px, .8fr); gap: 1rem; align-items: start; }
  .desktop-aside { display: block; position: sticky; top: 88px; }
  .summary { grid-template-columns: repeat(2, minmax(170px, 1fr)); }
  .form-two { grid-template-columns: repeat(2, 1fr); }
  .toast { bottom: 1.5rem; }
}

@media (max-width: 620px) {
  .brand > span, .account-button > span:last-child, .sync-pill > span:last-child { display: none; }
  .brand svg { width: 38px; height: 38px; }
  .group-picker { max-width: none; }
}

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