:root {
  color-scheme: light;
  --ink: #1f2926;
  --muted: #66706c;
  --paper: #f4f2ec;
  --card: #fffefa;
  --surface: #ecefe9;
  --surface-strong: #e1e8e3;
  --line: #d9ddd7;
  --brand: #246b5a;
  --brand-dark: #185043;
  --brand-soft: #dcebe5;
  --accent: #e59668;
  --positive: #23705a;
  --negative: #b6534b;
  --shadow: 0 20px 60px rgb(31 41 38 / 14%);
  font-family: "Avenir Next", "Helvetica Neue", ui-sans-serif, system-ui, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.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; }

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

html, body, .balance-strip, .expense-dialog-scroll, .dialog-body {
  -webkit-overflow-scrolling: touch;
}

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.shell {
  width: min(100%, 760px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 22px calc(96px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: max(20px, env(safe-area-inset-top)) 0 18px;
}
.topbar > :last-child { margin-left: auto; }
.topbar-with-back { gap: 8px; }
.top-actions { display: flex; align-items: center; gap: 4px; }
.account-menu-wrap { position: relative; }
.account-menu {
  position: absolute;
  z-index: 30;
  top: calc(100% + 10px);
  right: 0;
  display: grid;
  width: 184px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 6px;
  background: var(--card);
  box-shadow: 0 14px 36px rgb(31 41 38 / 16%);
}
.account-menu > button {
  min-height: 40px;
  border: 0;
  border-radius: 10px;
  padding: 0 12px;
  color: var(--ink);
  background: transparent;
  font-weight: 600;
  text-align: left;
}
.account-menu > button:hover, .account-menu > button:focus-visible { background: var(--surface); outline: none; }
.language-switcher { display: flex; align-items: center; gap: 7px; margin-top: 4px; border-top: 1px solid var(--line); padding: 8px 12px 3px; color: var(--muted); }
.language-switcher button { border: 0; padding: 3px 0; color: var(--muted); background: transparent; font-size: .78rem; font-weight: 600; }
.language-switcher button[aria-pressed="true"] { color: var(--brand); font-weight: 700; }
.language-switcher button:focus-visible { border-radius: 4px; outline: 2px solid var(--accent); outline-offset: 2px; }
.auth-language { flex: 0 0 auto; justify-content: flex-end; margin: 0; border: 0; padding: 3px 0; }
.avatar-button, .avatar-preview {
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  color: white;
  background: var(--brand);
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .02em;
}
.avatar-button { transition: transform .12s ease, background .12s ease; }
.avatar-button:hover { background: var(--brand-dark); }
.avatar-button:active { transform: scale(.95); }
.avatar-button:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--ink); font-weight: 700; font-size: 1.4rem; line-height: 1; letter-spacing: -.07em; }
.brand-symbol { width: 28px; height: 28px; overflow: visible; }
.brand-symbol circle:first-child { fill: var(--brand); }
.brand-symbol path { fill: none; stroke: var(--card); stroke-width: 4; stroke-linecap: round; }
.brand-symbol .brand-spark { fill: var(--accent); }
.brand-large { gap: 14px; font-size: clamp(2.5rem, 9vw, 4.2rem); }
.brand-large .brand-symbol { width: 52px; height: 52px; }
.auth-layout { width: min(100%, 820px); }
.auth-topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding-top: max(28px, env(safe-area-inset-top)); }
.auth-brand { margin: 0; }
.brand-mark { color: var(--brand); }

.eyebrow { margin: 0 0 8px; color: var(--brand); font-size: .72rem; font-weight: 700; letter-spacing: normal; }
h1, h2, h3, p { text-wrap: pretty; }
h1, h2, h3 { font-family: "Avenir Next", "Helvetica Neue", sans-serif; }
h1 { margin: 0; font-size: clamp(2.15rem, 10vw, 4rem); font-weight: 700; line-height: .98; letter-spacing: -.055em; }
h2 { margin: 0; font-size: 1.32rem; font-weight: 700; line-height: 1.15; letter-spacing: -.035em; }
h3 { margin: 0; font-size: 1rem; font-weight: 700; letter-spacing: -.02em; }
.muted { color: var(--muted); }

.button {
  min-height: 46px;
  border: 0;
  border-radius: 999px;
  padding: 0 19px;
  color: white;
  background: var(--brand);
  font-weight: 700;
  transition: transform .12s ease, background .12s ease, opacity .12s ease;
}
.button:hover { background: var(--brand-dark); }
.button:active { transform: scale(.97); }
.button:disabled { cursor: not-allowed; opacity: .45; }
.button.secondary { color: var(--brand-dark); background: var(--brand-soft); }
.button.secondary:hover { background: #cce0d8; }
.button.ghost { min-height: 38px; padding: 0 8px; color: var(--muted); background: transparent; }
.button.danger { color: white; background: var(--negative); }
.button.danger:hover { background: #96423c; }
.button.full { width: 100%; }
.icon-button { display: grid; flex: 0 0 44px; place-items: center; width: 44px; height: 44px; min-width: 44px; min-height: 44px; padding: 0; border: 0; border-radius: 50%; color: var(--ink); background: var(--surface); font-size: 1.2rem; font-weight: 700; }
.icon-button:hover { background: var(--surface-strong); }

.hero { padding: clamp(42px, 8vh, 76px) 0 34px; }
.hero > p:not(.eyebrow) { max-width: 34rem; margin: 18px 0 0; color: var(--muted); font-size: 1.05rem; line-height: 1.6; }
.home-heading, .group-heading, .profile-heading { padding: 32px 0 28px; }
.auth-card, .card { border: 0; border-radius: 24px; background: var(--card); box-shadow: 0 12px 42px rgb(31 41 38 / 8%); }
.auth-card { width: min(100%, 500px); margin: 0 auto 0 0; padding: 7px; }
.auth-body { padding: 22px 14px 14px; }
.auth-legal { margin: 2px 0 10px; text-align: center; }
.auth-legal a, .privacy-link, .privacy-content a { color: var(--brand); font-weight: 700; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.auth-legal a { font-size: .74rem; }
.auth-explainer, .auth-message > .muted { margin: 0; font-size: .88rem; line-height: 1.5; }
.auth-link { justify-self: end; min-height: 30px; margin-top: -10px; border: 0; padding: 0; color: var(--brand); background: transparent; font-size: .78rem; font-weight: 700; }
.auth-link:hover { color: var(--brand-dark); }
.email-verification { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 18px; margin: 4px 0 22px; padding: 17px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.email-verification h2 { font-size: 1rem; }
.email-verification p { max-width: 32rem; margin: 5px 0 0; color: var(--muted); font-size: .8rem; line-height: 1.45; }
.email-verification-actions { display: flex; gap: 8px; }
.email-verification-actions .button { min-height: 40px; padding-inline: 14px; font-size: .76rem; }
.tabs, .segments { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; padding: 4px; border-radius: 999px; background: var(--surface); }
.tabs button, .segments button { display: grid; place-items: center; width: 100%; min-height: 46px; border: 0; border-radius: 999px; color: var(--muted); background: transparent; font-weight: 650; text-align: center; cursor: pointer; user-select: none; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.tabs button.active, .segments button.active { color: white; background: var(--brand); }
.tabs { gap: 0; padding: 0 12px; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; }
.tabs button { min-height: 52px; border-bottom: 2px solid transparent; border-radius: 0; font-size: .88rem; font-weight: 600; }
.tabs button.active { border-bottom-color: var(--brand); color: var(--brand); background: transparent; }
.segments button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.stack { display: grid; gap: 17px; }
.field { display: grid; gap: 7px; }
.field > span, .field legend { font-size: .82rem; font-weight: 700; }
input, textarea, select {
  width: 100%;
  min-height: 48px;
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 11px 13px;
  color: var(--ink);
  background: var(--surface);
  outline: none;
  transition: background .12s ease, border-color .12s ease, box-shadow .12s ease;
}
select {
  appearance: none;
  padding-right: 42px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14' fill='none'%3E%3Cpath d='m3 5 4 4 4-4' stroke='%23707975' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 14px;
}
textarea { min-height: 80px; resize: vertical; }
input:hover, textarea:hover, select:hover { background-color: #e7eae5; }
input:focus, textarea:focus, select:focus { border-color: var(--brand); background-color: var(--card); box-shadow: 0 0 0 3px var(--brand-soft); }
.error { margin: 0; color: var(--negative); font-size: .86rem; }
.error:empty { display: none; }

.password-strength { display: grid; gap: 6px; margin-top: -9px; color: var(--muted); }
.password-strength > span { height: 4px; overflow: hidden; border-radius: 999px; background: var(--surface-strong); }
.password-strength > span::after { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--negative); content: ""; transition: width .18s ease, background .18s ease; }
.password-strength small { font-size: .76rem; line-height: 1.35; }
.password-strength[data-level="weak"] { color: var(--negative); }
.password-strength[data-level="weak"] > span::after { width: 34%; }
.password-strength[data-level="good"] { color: var(--brand); }
.password-strength[data-level="good"] > span::after { width: 68%; background: var(--brand); }
.password-strength[data-level="strong"] { color: var(--positive); }
.password-strength[data-level="strong"] > span::after { width: 100%; background: var(--positive); }
.password-match { min-height: 1.2em; margin: -8px 0 0; color: var(--muted); font-size: .8rem; }
.password-match[data-state="match"] { color: var(--positive); }
.password-match[data-state="mismatch"] { color: var(--negative); }
input.match { border-color: var(--positive); background: var(--card); box-shadow: 0 0 0 3px var(--brand-soft); }
input.mismatch { border-color: var(--negative); background: var(--card); box-shadow: 0 0 0 3px rgb(182 83 75 / 12%); }

.section-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin: 25px 0 10px; }
.group-heading { display: flex; align-items: end; justify-content: space-between; gap: 18px; }
.group-heading .eyebrow { margin-bottom: 8px; }
.group-actions { display: flex; align-items: center; gap: 8px; }
.settings-button svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.group-list, .expense-list, .reimbursement-list { display: grid; gap: 0; }
.load-more { display: block; min-width: 150px; margin: 20px auto 92px; }
.home-overview { padding: 4px 0 25px; border-bottom: 1px solid var(--line); }
.overview-net { display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.overview-net > span { color: var(--muted); font-size: .82rem; }
.overview-net strong { font-size: clamp(2rem, 8vw, 3.1rem); line-height: 1; letter-spacing: -.055em; white-space: nowrap; }
.overview-breakdown { display: grid; grid-template-columns: repeat(2, 1fr); margin-top: 22px; border-top: 1px solid var(--line); }
.overview-breakdown > div { display: grid; gap: 5px; padding: 16px 0 0; }
.overview-breakdown > div + div { border-left: 1px solid var(--line); padding-left: 20px; }
.overview-breakdown span { color: var(--muted); font-size: .72rem; }
.overview-breakdown strong { font-size: 1rem; }
.home-groups > .section-head { margin-top: 30px; }
.home-groups > .section-head h2 { font-size: 1.55rem; }
.group-card { display: flex; align-items: center; justify-content: space-between; gap: 14px; width: 100%; padding: 17px 2px; border: 0; border-bottom: 1px solid var(--line); color: inherit; background: transparent; text-align: left; transition: color .12s ease, transform .12s ease; }
.group-card:hover { color: var(--brand); transform: translateX(3px); }
.group-icon { display: grid; place-items: center; flex: 0 0 42px; height: 42px; border-radius: 50%; color: var(--brand); background: var(--brand-soft); font-size: 1.1rem; }
.group-copy { flex: 1; min-width: 0; }
.group-copy p { margin: 4px 0 0; color: var(--muted); font-size: .86rem; }
.group-balance { display: grid; flex: 0 0 auto; justify-items: end; gap: 2px; font-size: .88rem; font-weight: 700; white-space: nowrap; }
.group-balance small { color: var(--muted); font-size: .66rem; font-weight: 600; }
.group-balance.settled { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .75rem; font-weight: 600; }
.group-balance.settled span { display: grid; place-items: center; width: 19px; height: 19px; border-radius: 50%; color: white; background: var(--positive); font-size: .68rem; }
.home-activity { margin-top: 34px; }
.home-activity .section-head { margin-bottom: 7px; }
.home-activity ol { display: grid; margin: 0; padding: 0; list-style: none; }
.home-activity li { border-bottom: 1px solid var(--line); }
.home-activity-event { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; align-items: center; gap: 11px; width: 100%; min-height: 76px; border: 0; padding: 12px 2px; color: inherit; background: transparent; text-align: left; }
.home-activity-event:hover { color: var(--brand); }
.home-activity-event:focus-visible { border-radius: 10px; outline: 3px solid var(--brand-soft); outline-offset: 2px; }
.home-activity-event .activity-dot { align-self: start; margin-top: 8px; }
.home-activity-event > span:nth-child(2) { display: grid; gap: 2px; min-width: 0; }
.activity-group { overflow: hidden; color: var(--brand); font-size: .68rem; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.activity-copy { font-size: .84rem; line-height: 1.35; }
.activity-detail { color: var(--ink); font-size: .76rem; }
.home-activity-event time { color: var(--muted); font-size: .68rem; }
.empty { padding: 42px 24px; border: 0; border-radius: 20px; background: rgb(255 254 250 / 62%); text-align: center; }
.empty .emoji { font-size: 2rem; }

.balance-strip { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(156px, 1fr); gap: 10px; margin: 20px -22px 0; padding: 0 22px 6px; overflow-x: auto; scrollbar-width: none; }
.balance { display: grid; align-content: start; min-height: 122px; padding: 16px; border: 0; border-radius: 17px; background: var(--card); }
.balance-positive { background: #e2eee9; }
.balance-negative { background: #f4e8e5; }
.balance-zero { background: var(--card); }
.balance p { overflow: hidden; margin: 0 0 13px; color: var(--muted); font-size: .82rem; text-overflow: ellipsis; white-space: nowrap; }
.balance-status { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .7rem; font-weight: 700; }
.balance-status::before { display: inline-grid; place-items: center; width: 19px; height: 19px; border-radius: 50%; font-size: .72rem; line-height: 1; }
.balance-positive .balance-status { color: var(--positive); }
.balance-positive .balance-status::before { color: white; background: var(--positive); content: "↑"; }
.balance-negative .balance-status { color: var(--negative); }
.balance-negative .balance-status::before { color: white; background: var(--negative); content: "↓"; }
.balance-zero .balance-status::before { color: var(--muted); background: var(--surface); content: "✓"; }
.balance strong { margin-top: 5px; font-size: 1.12rem; }
.positive { color: var(--positive); }
.negative { color: var(--negative); }

.group-tabs { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 26px; border-bottom: 1px solid var(--line); }
.group-tabs button { min-height: 52px; padding: 0 12px; border: 0; border-bottom: 3px solid transparent; color: var(--muted); background: transparent; font-weight: 700; }
.group-tabs button:hover { color: var(--ink); }
.group-tabs button.active { border-bottom-color: var(--brand); color: var(--brand); }
.group-tabs button:focus-visible { outline: 3px solid var(--brand-soft); outline-offset: -3px; }
.group-tabs span { display: inline-grid; place-items: center; min-width: 23px; height: 23px; margin-left: 5px; padding: 0 6px; border-radius: 999px; background: var(--surface); font-size: .7rem; }
.group-tabs button.active span { background: var(--brand-soft); }

.monthly-summary { padding: 22px 0 20px; border-bottom: 1px solid var(--line); }
.recurrence-panel { padding: 22px 0 20px; border-bottom: 1px solid var(--line); }
.recurrence-panel > .section-head { margin: 0 0 8px; }
.recurrence-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px 14px; min-height: 72px; padding: 12px 2px; border-top: 1px solid var(--line); }
.recurrence-row > div:first-child { display: grid; gap: 3px; }
.recurrence-row > div:first-child span { color: var(--muted); font-size: .74rem; }
.recurrence-row > strong { font-size: .86rem; white-space: nowrap; }
.recurrence-actions { display: flex; grid-column: 1 / -1; gap: 7px; }
.recurrence-actions .button { min-height: 36px; padding-inline: 13px; font-size: .72rem; }
.monthly-summary-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.summary-month select { width: auto; min-height: 38px; padding: 7px 38px 7px 11px; border-radius: 999px; color: var(--brand-dark); background-color: var(--brand-soft); font-size: .76rem; font-weight: 700; }
.summary-month-label { color: var(--muted); font-size: .78rem; }
.summary-total { display: flex; align-items: baseline; gap: 9px; margin-top: 17px; }
.summary-total strong { font-size: 1.8rem; letter-spacing: -.045em; }
.summary-total span { color: var(--muted); font-size: .76rem; }
.category-summary { display: grid; gap: 11px; margin: 17px 0 0; padding: 0; list-style: none; }
.category-summary li > div { display: flex; justify-content: space-between; gap: 14px; margin-bottom: 5px; font-size: .78rem; }
.category-summary li strong { font-weight: 700; }
.category-track { display: block; width: 100%; height: 4px; overflow: hidden; border: 0; border-radius: 999px; appearance: none; background: var(--surface-strong); }
.category-track::-webkit-progress-bar { border-radius: inherit; background: var(--surface-strong); }
.category-track::-webkit-progress-value { border-radius: inherit; background: var(--brand); }
.category-track::-moz-progress-bar { border-radius: inherit; background: var(--brand); }
.summary-empty { margin: 18px 0 0; color: var(--muted); font-size: .82rem; }

.expense, .reimbursement { display: grid; grid-template-columns: 42px 1fr auto; gap: 13px; align-items: center; width: 100%; padding: 14px 2px; border: 0; border-bottom: 1px solid var(--line); color: inherit; background: transparent; font: inherit; text-align: left; touch-action: manipulation; transition: color .12s ease, transform .12s ease; }
.expense:hover, .reimbursement:hover { color: var(--brand); transform: translateX(3px); }
.expense.history-locked, .reimbursement.history-locked { cursor: default; }
.expense.history-locked:hover, .reimbursement.history-locked:hover { color: inherit; transform: none; }
.expense:focus-visible, .reimbursement:focus-visible { border-radius: 10px; outline: 3px solid var(--brand-soft); outline-offset: 2px; }
.expense-date { display: grid; place-items: center; height: 44px; border: 0; border-radius: 12px; color: var(--brand); background: var(--brand-soft); font-size: .68rem; font-weight: 700; line-height: 1.05; text-align: center; }
.expense-date b { color: var(--ink); font-size: 1.08rem; }
.expense p, .reimbursement p { margin: 3px 0 0; color: var(--muted); font-size: .8rem; }
.expense-amount { color: var(--ink); text-align: right; font-weight: 700; white-space: nowrap; }
.edit-mark { margin-left: 3px; color: var(--muted); font-size: 1.2rem; }
.history-lock { display: block; margin-top: 2px; color: var(--brand); font-size: .66rem; font-weight: 600; }

.activity-list { display: grid; margin: 0; padding: 0; list-style: none; }
.activity-event { position: relative; display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 11px; min-height: 72px; padding: 13px 2px; }
.activity-event:not(:last-child)::before { position: absolute; top: 31px; bottom: -13px; left: 9px; width: 1px; background: var(--line); content: ""; }
.activity-dot { z-index: 1; width: 9px; height: 9px; margin: 7px 0 0 5px; border: 2px solid var(--card); border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.activity-event p { margin: 0; line-height: 1.4; }
.activity-event p strong { font-weight: 700; }
.activity-event div > span { display: block; margin-top: 3px; color: var(--ink); font-size: .82rem; }
.activity-event time { display: block; margin-top: 4px; color: var(--muted); font-size: .72rem; }

.count-badge { display: grid; place-items: center; min-width: 29px; height: 29px; padding: 0 8px; border-radius: 999px; color: var(--brand); background: var(--brand-soft); font-size: .82rem; font-weight: 700; }
.fab { position: fixed; right: max(20px, calc((100vw - 720px) / 2)); bottom: calc(20px + env(safe-area-inset-bottom)); min-height: 56px; padding: 0 23px; border: 0; border-radius: 999px; color: white; background: var(--brand); box-shadow: 0 10px 28px rgb(36 107 90 / 24%); font-weight: 700; transition: transform .12s ease, background .12s ease; }
.fab:hover { background: var(--brand-dark); }
.fab:active { transform: scale(.96); }

.settlement-panel { margin-top: 22px; padding: 20px 0 8px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.group-tabs + [role="tabpanel"] .settlement-panel { margin-top: 0; border-top: 0; }
.settlement-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 10px; }
.settlement-head .eyebrow { margin-bottom: 6px; }
.suggestion-list { display: grid; }
.suggestion-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; border-top: 1px solid var(--line); }
.suggestion { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 10px; min-height: 54px; padding: 10px 2px; border: 0; color: inherit; background: transparent; font: inherit; text-align: left; }
.suggestion:hover { color: var(--brand); }
.suggestion > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggestion b { font-weight: 700; white-space: nowrap; }
.reminder-button { min-height: 36px; padding-inline: 13px; font-size: .72rem; }
.settled-message { margin: 0; padding: 17px 2px 13px; border-top: 1px solid var(--line); color: var(--muted); font-size: .88rem; }
.compact-empty { padding-block: 28px; }

dialog { width: min(calc(100% - 24px), 440px); max-height: calc(100dvh - 24px); margin: auto; border: 0; border-radius: 24px; padding: 0; color: var(--ink); background: var(--card); box-shadow: var(--shadow); }
dialog::backdrop { background: rgb(22 31 28 / 45%); backdrop-filter: blur(4px); }
#expense-dialog { height: min(680px, calc(100dvh - 24px)); overflow: hidden; }
#expense-dialog .expense-dialog-body { display: grid; grid-template-rows: auto auto minmax(0, 1fr); height: 100%; padding: 0; overflow: hidden; }
#expense-dialog .expense-dialog-head { margin: 0; padding: 22px 22px 12px; }
.expense-tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 0 22px; border-bottom: 1px solid var(--line); }
.expense-tabs button { min-height: 48px; border: 0; border-bottom: 2px solid transparent; padding: 0 10px; color: var(--muted); background: transparent; font-size: .86rem; font-weight: 600; }
.expense-tabs button.active { border-bottom-color: var(--brand); color: var(--brand); }
.expense-tabs button:focus-visible { outline: 3px solid var(--brand-soft); outline-offset: -3px; }
.expense-form { display: grid; grid-template-rows: minmax(0, 1fr) auto; min-height: 0; }
.expense-dialog-scroll { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 22px; }
.expense-dialog-footer { padding: 14px 22px 18px; border-top: 1px solid var(--line); background: var(--card); }
.expense-dialog-footer .error { margin-bottom: 10px; }
.confirm-dialog { width: min(calc(100% - 32px), 340px); }
.confirm-dialog p { margin: 8px 0 0; line-height: 1.45; }
#profile-authorization-dialog .dialog-head { align-items: flex-start; }
.confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.confirm-actions .button { white-space: nowrap; }
.confirm-actions.notice-only { grid-template-columns: 1fr; }
.expense-actions { display: flex; gap: 10px; }
.expense-actions #save-expense { flex: 1; }
.dialog-body { padding: 22px; overflow: auto; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 22px; }
.dialog-head-actions { display: flex; align-items: center; gap: 5px; }
.dialog-head .eyebrow { margin-bottom: 5px; }
.group-members { margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--line); }
.group-notifications { display: grid; gap: 12px; margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--line); }
.group-notifications form { display: grid; gap: 11px; }
.notification-choice { display: grid; grid-template-columns: 24px minmax(0, 1fr); align-items: start; gap: 11px; cursor: pointer; }
.notification-choice input { width: 21px; min-height: 21px; margin: 1px 0 0; padding: 0; accent-color: var(--brand); }
.notification-choice strong, .notification-choice small { display: block; }
.notification-choice strong { font-size: .86rem; }
.notification-choice small { margin-top: 3px; color: var(--muted); font-size: .76rem; line-height: 1.4; }
.group-members-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.group-member-list { display: grid; }
.group-member { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; align-items: center; gap: 11px; min-height: 64px; border-bottom: 1px solid var(--line); }
.group-member:last-child { border-bottom: 0; }
.member-avatar { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; color: var(--brand-dark); background: var(--brand-soft); font-size: .72rem; font-weight: 700; }
.group-member strong { display: block; overflow: hidden; font-size: .9rem; text-overflow: ellipsis; white-space: nowrap; }
.group-member p { overflow: hidden; margin: 3px 0 0; color: var(--muted); font-size: .74rem; text-overflow: ellipsis; white-space: nowrap; }
.member-role { color: var(--brand); font-size: .7rem; font-weight: 700; white-space: nowrap; }
.member-meta { display: grid; justify-items: end; gap: 5px; }
.member-action { min-height: 32px; border: 0; padding: 0 4px; color: var(--negative); background: transparent; font-size: .72rem; font-weight: 700; }
.member-action:hover { color: #8f3f39; }
.member-action.owner-action { color: var(--brand); }
.member-action.owner-action:hover { color: var(--brand-dark); }
.member-leave { width: 100%; margin-top: 18px; color: var(--negative); background: #f4e8e5; }
.member-leave:hover { color: white; background: var(--negative); }
.group-danger { display: grid; gap: 10px; margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--line); }
.group-danger p, .delete-warning { margin: 0; color: var(--muted); font-size: .82rem; line-height: 1.45; }
.group-danger .button { justify-self: start; }
.delete-warning strong { color: var(--ink); }
.group-invitations { display: grid; gap: 10px; margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--line); }
.email-invitation-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 10px; }
.email-invitation-form .error { grid-column: 1 / -1; min-height: 0; }
.email-invitation-form .button { min-height: 48px; }
.invitation-list-head { margin-top: 14px; }
.invitation-list { display: grid; }
.invitation-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; min-height: 62px; border: 0; border-bottom: 1px solid var(--line); padding: 7px 3px; color: inherit; background: transparent; text-align: left; }
.invitation-row:hover { color: var(--brand-dark); }
.invitation-row strong { font-size: .82rem; }
.invitation-meta { display: block; margin-top: 4px; color: var(--muted); font-size: .72rem; }
.invitation-arrow { color: var(--muted); font-size: 1.45rem; line-height: 1; }
.invitation-empty { margin: 4px 0; color: var(--muted); font-size: .72rem; }
.invitation-dialog { width: min(calc(100% - 32px), 420px); }
.invitation-dialog .dialog-head { margin-bottom: 2px; }
.invitation-detail { margin: -6px 0 2px; font-size: .78rem; }
.invitation-actions { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.amount-input { position: relative; }
.amount-field, .date-field { width: 50%; }
.amount-input input { height: 58px; padding-right: 40px; font-size: 1.45rem; font-weight: 700; letter-spacing: -.025em; }
.amount-input span { position: absolute; right: 14px; top: 18px; color: var(--muted); font-weight: 700; }
.recurrence-create { display: grid; gap: 12px; }
.recurrence-create .toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding-block: 13px; }
.recurrence-create .toggle-row > span { display: grid; gap: 3px; }
.recurrence-create .toggle-row input { flex: 0 0 22px; width: 22px; min-height: 22px; accent-color: var(--brand); }
.recurrence-create .field small, .recurrence-existing small { color: var(--muted); font-size: .74rem; }
.recurrence-existing { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.recurrence-existing > div { display: grid; gap: 3px; }
.recurrence-existing .button { flex: 0 0 auto; }

.split-table-head, .member-split, .split-summary { display: grid; grid-template-columns: auto minmax(0, 1fr) 122px 44px; gap: 8px; }
.split-table-head { align-items: end; padding: 0 0 8px; border-bottom: 1px solid var(--brand); color: var(--brand); font-size: .68rem; font-weight: 700; }
.split-table-head span:first-child { grid-column: 1 / 3; }
.split-table-head span:nth-child(2) { text-align: right; }
.split-table-head span:last-child { text-align: center; }
.member-split { align-items: center; min-height: 64px; border-bottom: 1px solid var(--line); transition: opacity .15s ease; }
.member-split.excluded { opacity: .42; }
.member-split input[type="checkbox"], .member-split input[type="radio"] { width: 21px; min-height: 21px; accent-color: var(--brand); }
.share-cell { width: 122px; min-width: 0; text-align: right; }
.equal-share { font-size: .88rem; font-weight: 700; white-space: nowrap; }
.share-editor { display: flex; align-items: center; justify-content: end; gap: 4px; }
.member-split .share-input { width: 102px; min-height: 38px; padding: 6px 7px; border-radius: 9px; font-size: .88rem; text-align: right; font-weight: 700; }
.share-suffix { position: static; color: var(--muted); font-size: .8rem; font-weight: 700; pointer-events: none; }
.member-name { overflow: hidden; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.payer-control { display: grid; place-items: center; align-self: stretch; cursor: pointer; }
.split-summary { align-items: center; padding: 12px 0 4px; color: var(--positive); font-size: .88rem; }
.split-summary > span { display: flex; grid-column: 1 / 3; align-items: center; gap: 7px; font-weight: 700; }
.split-summary:not(.invalid) > span::before { display: inline-grid; place-items: center; width: 19px; height: 19px; border-radius: 50%; color: white; background: var(--positive); font-size: .68rem; content: "✓"; }
.split-summary strong { grid-column: 3; color: var(--ink); font-size: .88rem; font-weight: 700; text-align: right; white-space: nowrap; }
.split-summary.invalid, .split-summary.invalid strong { color: var(--negative); }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 10; transform: translate(-50%, 18px); max-width: calc(100% - 40px); padding: 12px 17px; border-radius: 999px; color: white; background: var(--ink); box-shadow: 0 8px 28px rgb(31 41 38 / 20%); font-size: .9rem; opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

.profile-heading > .muted { max-width: 30rem; margin: 14px 0 0; line-height: 1.55; }
.profile-identity { display: flex; align-items: center; gap: 14px; margin-bottom: 26px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.profile-identity .avatar-preview { flex-basis: 52px; width: 52px; height: 52px; color: var(--brand-dark); background: var(--brand-soft); font-size: 1rem; }
.profile-identity p { margin: 4px 0 0; font-size: .86rem; }
.profile-email { display: flex; align-items: center; gap: 7px; }
.email-confirmed-mark { display: inline-grid; flex: 0 0 19px; place-items: center; width: 19px; height: 19px; border-radius: 50%; color: white; background: var(--positive); font-size: .68rem; font-weight: 700; }
.profile-identity + .email-verification { margin-top: -22px; border-top: 0; }
.profile-passwords { display: grid; gap: 17px; margin-top: 4px; padding-top: 21px; border-top: 1px solid var(--line); }
.profile-danger { margin-top: 34px; padding-top: 24px; border-top: 1px solid var(--line); }
.profile-danger p { max-width: 36rem; margin: 8px 0 16px; color: var(--muted); font-size: .84rem; line-height: 1.5; }
.profile-account-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.profile-account-actions .button { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.privacy-link { display: inline-block; margin-top: 15px; font-size: .78rem; }
#account-delete-blockers > p { margin: 0; }
#account-delete-blockers ul { display: grid; gap: 8px; margin: 0; padding-left: 20px; color: var(--muted); font-size: .84rem; line-height: 1.45; }
.privacy-back { color: var(--ink); text-decoration: none; }
.privacy-language { margin: 0 0 0 auto; border: 0; padding: 0; }
.privacy-content { max-width: 660px; padding: 32px 0 56px; }
.privacy-heading { padding-bottom: 28px; }
.privacy-heading h1 { max-width: 560px; }
.privacy-heading > .muted { margin: 14px 0 0; font-size: .8rem; }
.privacy-content section { padding: 22px 0; border-top: 1px solid var(--line); }
.privacy-content section p { margin: 9px 0 0; color: var(--muted); font-size: .92rem; line-height: 1.65; }
@media (min-width: 700px) {
  .shell { padding-inline: 30px; }
  .auth-card { padding: 9px; }
  .auth-body { padding: 25px 17px 17px; }
  .balance-strip { margin-inline: 0; padding-inline: 0; }
}

@media (max-width: 640px) {
  #expense-dialog {
    inset: 0;
    width: 100vw;
    max-width: none;
    height: 100dvh;
    max-height: none;
    margin: 0;
    overflow: hidden;
    border-radius: 0;
  }
  #expense-dialog .dialog-body {
    height: 100%;
    padding: 0;
    overflow: hidden;
  }
  #expense-dialog .expense-dialog-head { padding: max(18px, env(safe-area-inset-top)) 18px 8px; }
  .expense-tabs { padding-inline: 18px; }
  .expense-dialog-scroll { padding: 20px 18px; }
  .expense-dialog-footer { padding: 13px 18px max(16px, env(safe-area-inset-bottom)); }
}

@media (max-width: 520px) {
  dialog { width: 100%; max-height: 92dvh; margin: auto auto 0; border-radius: 24px 24px 0 0; }
  #expense-dialog { max-height: none; margin: 0; border-radius: 0; }
  .confirm-dialog { width: calc(100% - 32px); margin: auto; border-radius: 22px; }
  .toast { width: calc(100% - 32px); max-width: none; box-sizing: border-box; text-align: center; }
  .split-table-head, .member-split, .split-summary { grid-template-columns: auto minmax(62px, 1fr) 122px 40px; gap: 6px; }
  .group-heading { align-items: start; flex-direction: column; }
  .email-verification { grid-template-columns: 1fr; }
  .email-verification-actions { display: grid; grid-template-columns: 1fr; }
  .email-invitation-form { grid-template-columns: 1fr; }
  .email-invitation-form .button { width: 100%; }
  .group-tabs button { padding-inline: 5px; font-size: .78rem; }
  .group-tabs span { display: none; }
}

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