:root {
  color-scheme: light;
  --ink: #17251f;
  --muted: #66716b;
  --paper: #f5f0e8;
  --card: #fffdf8;
  --line: #ded8ce;
  --green: #184f3a;
  --green-2: #2b6b50;
  --lime: #dff25e;
  --coral: #ed755c;
  --blue: #c9e7f0;
  --shadow: 0 18px 50px rgba(23, 37, 31, 0.08);
  --radius: 24px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(43, 107, 80, 0.28);
  outline-offset: 2px;
}

.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;
}

.app-shell { max-width: 1220px; margin: 0 auto; min-height: 100vh; }

.topbar {
  height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  border-bottom: 1px solid rgba(23, 37, 31, 0.1);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 850;
  font-size: 1.35rem;
  letter-spacing: -0.04em;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px 12px 12px 4px;
  background: var(--green);
  color: var(--lime);
  transform: rotate(-3deg);
}

.top-actions { display: flex; align-items: center; gap: 12px; }
.role-switch select {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  color: var(--ink);
  padding: 0 36px 0 14px;
  font-weight: 700;
}

.avatar {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--coral);
  color: #291810;
  font-weight: 850;
}

main { padding: 46px 28px 120px; }
.screen { display: none; animation: rise 220ms ease both; }
.screen.active { display: block; }

@keyframes rise {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}

h1, h2, p { margin-top: 0; }
h1 { max-width: 760px; margin-bottom: 10px; font-size: clamp(2rem, 5vw, 3.7rem); line-height: 0.98; letter-spacing: -0.065em; }
h2 { margin-bottom: 8px; font-size: 1.35rem; letter-spacing: -0.035em; }
.eyebrow, .overline { margin-bottom: 9px; color: var(--green-2); font-size: 0.76rem; font-weight: 850; letter-spacing: 0.11em; text-transform: uppercase; }
.muted, .subhead { color: var(--muted); }
.subhead { max-width: 620px; line-height: 1.55; }

.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; margin-bottom: 30px; }
.page-heading h1 { font-size: clamp(2.15rem, 4vw, 3.2rem); }

.button {
  min-height: 48px;
  border: 0;
  border-radius: 16px;
  padding: 0 20px;
  font-weight: 800;
  transition: transform 150ms ease, background 150ms ease;
}
.button:hover { transform: translateY(-1px); }
.button.primary { background: var(--green); color: white; box-shadow: 0 8px 24px rgba(24, 79, 58, 0.19); }
.button.primary:hover { background: #0d402e; }
.button.soft { background: #dceade; color: var(--green); }
.button.ghost { background: transparent; color: var(--ink); }
.button.danger-outline { margin-top: 22px; border: 1px solid #c9503b; color: #9f351f; background: transparent; }
.text-button { min-height: 42px; padding: 0; border: 0; background: transparent; color: var(--green-2); font-weight: 800; text-align: left; }

.empty-state {
  min-height: calc(100vh - 250px);
  display: grid;
  place-items: center;
  align-content: center;
  text-align: center;
}
.empty-state h1 { max-width: 760px; }
.empty-state > p:not(.eyebrow) { max-width: 560px; color: var(--muted); line-height: 1.6; }
.empty-art { display: flex; align-items: flex-end; gap: 7px; height: 90px; margin-bottom: 28px; }
.empty-art span { display: block; width: 54px; height: 48px; border-radius: 20px 20px 8px 8px; background: var(--green); }
.empty-art span:nth-child(1) { height: 64px; background: var(--coral); transform: rotate(-8deg); }
.empty-art span:nth-child(3) { height: 72px; background: var(--lime); transform: rotate(7deg); }

.stay-card {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  border-radius: 28px;
  background: var(--green);
  color: white;
  padding: 30px;
  box-shadow: var(--shadow);
}
.stay-card::after { content: ""; position: absolute; right: -35px; bottom: -65px; width: 190px; height: 190px; border: 28px solid rgba(223,242,94,.18); border-radius: 50%; }
.stay-card .overline { color: var(--lime); }
.stay-card .muted { color: rgba(255,255,255,.72); }
.status-pill { position: relative; z-index: 1; align-self: start; border-radius: 99px; padding: 8px 13px; background: var(--lime); color: #25300e; font-size: .78rem; font-weight: 850; }
.progress-block { grid-column: 1 / -1; position: relative; z-index: 1; }
.progress-copy { display: flex; justify-content: space-between; margin-bottom: 9px; color: rgba(255,255,255,.76); font-size: .86rem; }
.progress-copy strong { color: white; }
.progress-track { height: 10px; border-radius: 99px; background: rgba(255,255,255,.18); overflow: hidden; }
.progress-track span { display: block; height: 100%; border-radius: inherit; background: var(--lime); }

.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
.metric-card, .details-card, .boundary-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); padding: 24px; }
.balance-card { background: var(--blue); border-color: transparent; }
.metric { margin-bottom: 7px; font-size: 2.15rem; font-weight: 880; letter-spacing: -0.06em; }
.metric small { font-size: 1rem; letter-spacing: 0; }
.date-metric { font-size: 1.35rem; }
.metric-card .muted { min-height: 42px; font-size: .9rem; line-height: 1.45; }

.section-block { margin-top: 42px; }
.section-heading { display: flex; justify-content: space-between; align-items: end; margin-bottom: 14px; }
.activity-list, .ledger-list, .chore-list { display: grid; gap: 10px; }
.list-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  padding: 14px 16px;
}
.list-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; background: #e6eddf; color: var(--green); font-weight: 900; }
.list-icon.payment { background: var(--blue); }
.list-icon.chore { background: #f7dfd8; color: #8d3a27; }
.list-copy strong, .list-copy span { display: block; }
.list-copy span { margin-top: 4px; color: var(--muted); font-size: .84rem; }
.list-value { text-align: right; font-weight: 850; }
.list-value small { display: block; margin-top: 4px; color: var(--muted); font-weight: 650; }
.empty-list { border: 1px dashed #bcb5aa; border-radius: 20px; color: var(--muted); padding: 30px; text-align: center; }

.summary-strip { display: grid; grid-template-columns: repeat(4, 1fr); margin-bottom: 22px; border-radius: var(--radius); background: var(--green); color: white; overflow: hidden; }
.summary-item { padding: 24px; border-right: 1px solid rgba(255,255,255,.16); }
.summary-item:last-child { border-right: 0; }
.summary-item span { display: block; margin-bottom: 6px; color: rgba(255,255,255,.68); font-size: .78rem; font-weight: 750; text-transform: uppercase; letter-spacing: .08em; }
.summary-item strong { font-size: 1.55rem; }

.filter-row { display: flex; gap: 8px; margin-bottom: 18px; }
.filter { min-height: 42px; border: 1px solid var(--line); border-radius: 99px; background: var(--card); padding: 0 17px; color: var(--muted); font-weight: 750; }
.filter.active { background: var(--ink); border-color: var(--ink); color: white; }
.chore-row { grid-template-columns: auto 1fr auto; }
.chore-check { width: 30px; height: 30px; margin: 0; accent-color: var(--green); }
.chore-row.done .list-copy { text-decoration: line-through; opacity: .55; }
.badge { display: inline-block !important; width: fit-content; margin-top: 7px !important; border-radius: 99px; padding: 5px 9px; background: #e8eee7; color: var(--green) !important; font-size: .72rem !important; font-weight: 800; }
.delete-button { min-width: 44px; min-height: 44px; border: 0; border-radius: 12px; background: transparent; color: #9f351f; font-weight: 800; }
.contribution-row { grid-template-columns: auto 1fr auto auto; }
.row-actions { display: flex; gap: 6px; }
.mini-button { min-height: 40px; border: 0; border-radius: 11px; background: #e3ecdf; color: var(--green); padding: 0 11px; font-size: .78rem; font-weight: 850; }
.mini-button.danger { background: #f8e4df; color: #9f351f; }

.details-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.details-card p:last-child { margin-bottom: 0; font-size: 1.2rem; font-weight: 800; }
.boundary-card { margin-top: 16px; background: #eee9dc; }
.notes-copy { white-space: pre-wrap; line-height: 1.65; color: #4b5650; }

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  width: min(620px, calc(100% - 32px));
  min-height: 72px;
  transform: translateX(-50%);
  border: 1px solid rgba(23,37,31,.12);
  border-radius: 22px;
  background: rgba(255,253,248,.9);
  box-shadow: 0 18px 45px rgba(23,37,31,.16);
  backdrop-filter: blur(18px);
  padding: 7px;
}
.nav-item { display: grid; place-items: center; align-content: center; gap: 3px; min-height: 56px; border: 0; border-radius: 16px; background: transparent; color: var(--muted); font-size: .72rem; font-weight: 800; }
.nav-item.active { background: var(--green); color: white; }
.nav-item:disabled { cursor: not-allowed; opacity: .45; }
.nav-icon { font-size: 1.25rem; line-height: 1; }

dialog { width: min(660px, calc(100% - 24px)); max-height: calc(100vh - 30px); border: 0; border-radius: 28px; background: var(--card); color: var(--ink); padding: 0; box-shadow: 0 28px 90px rgba(23,37,31,.28); }
dialog::backdrop { background: rgba(19,31,26,.55); backdrop-filter: blur(4px); }
dialog form { padding: 26px; }
.dialog-heading { display: flex; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.dialog-heading h2 { font-size: 1.75rem; }
.icon-button { width: 44px; height: 44px; border: 0; border-radius: 14px; background: #ece7de; color: var(--ink); font-size: 1.5rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
label { display: grid; gap: 7px; color: #46524c; font-size: .84rem; font-weight: 750; }
label.full { grid-column: 1 / -1; }
label.check { display: flex; align-items: center; gap: 10px; min-height: 38px; }
label.check input { width: 20px; height: 20px; accent-color: var(--green); }
input, select, textarea { width: 100%; min-height: 48px; border: 1px solid #cec7bc; border-radius: 13px; background: white; color: var(--ink); padding: 10px 12px; }
textarea { resize: vertical; }
.money-input, .suffix-input { display: flex; align-items: center; min-height: 48px; border: 1px solid #cec7bc; border-radius: 13px; background: white; overflow: hidden; }
.money-input span, .suffix-input span { padding: 0 11px; color: var(--muted); }
.money-input input, .suffix-input input { border: 0; border-radius: 0; padding-left: 0; }
.suffix-input input { padding-left: 12px; padding-right: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }
.form-error { min-height: 20px; margin: 10px 0 0; color: #a23822; font-weight: 750; }

.toast { position: fixed; left: 50%; bottom: 108px; z-index: 30; transform: translate(-50%, 18px); border-radius: 14px; background: var(--ink); color: white; padding: 13px 17px; opacity: 0; pointer-events: none; transition: .2s ease; box-shadow: var(--shadow); font-weight: 750; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 760px) {
  .topbar { height: 70px; padding: 0 18px; }
  .role-switch select { width: 112px; }
  main { padding: 34px 16px 110px; }
  .page-heading { align-items: flex-start; flex-direction: column; gap: 16px; }
  .page-heading .button { width: 100%; }
  .desktop-action { display: none; }
  .metric-grid { grid-template-columns: 1fr; }
  .metric-card .muted { min-height: 0; }
  .summary-strip { grid-template-columns: 1fr; }
  .summary-item { border-right: 0; border-bottom: 1px solid rgba(255,255,255,.16); }
  .summary-item:last-child { border-bottom: 0; }
  .details-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  label.full { grid-column: auto; }
  dialog { border-radius: 24px 24px 0 0; margin: auto 0 0; width: 100%; max-width: none; max-height: 92vh; }
  dialog form { padding: 22px 18px 28px; }
  .list-row { gap: 10px; padding: 12px; }
  .contribution-row { grid-template-columns: auto 1fr auto; }
  .contribution-row .row-actions { grid-column: 2 / -1; justify-content: flex-end; }
}

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