:root {
  color-scheme: light;
  --green: #146c5a;
  --green-dark: #0e594a;
  --green-soft: #e8f4ef;
  --ink: #1d2926;
  --muted: #82908c;
  --line: #edf0ee;
  --canvas: #f7f9f8;
  --red: #d76758;
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--canvas); color: var(--ink); }
button, input { font: inherit; }
button { cursor: pointer; }
.app-shell { width: 100%; max-width: 560px; min-height: 100dvh; margin: 0 auto; background: #fff; position: relative; box-shadow: 0 0 50px #17372b0a; }
.topbar { height: 66px; padding: 0 22px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #f3f5f4; }
.brand { display: flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; font-family: Manrope, sans-serif; font-weight: 800; font-size: 21px; letter-spacing: -1px; }
.brand-mark { width: 33px; height: 33px; border-radius: 11px 11px 11px 4px; background: var(--green); color: white; display: grid; place-items: center; font-size: 10px; font-family: Manrope, sans-serif; font-weight: 800; letter-spacing: -.5px; }
.brand-dot { color: #48a284; }
main { padding: 28px 22px 110px; }
.view { display: none; animation: appear .18s ease-out; }
.view.active { display: block; }
@keyframes appear { from { opacity: .6; transform: translateY(3px); } to { opacity: 1; transform: translateY(0); } }
.page-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 21px; }
.eyebrow { margin: 0 0 7px; color: #93a09c; font-size: 9px; line-height: 1.3; font-weight: 700; letter-spacing: 1.45px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font: 800 29px/1.15 Manrope, sans-serif; letter-spacing: -1.15px; }
h2 { margin: 0; font: 700 16px/1.25 Manrope, sans-serif; letter-spacing: -.3px; }
.primary-button { border: 0; border-radius: 12px; background: var(--green); color: white; min-height: 45px; padding: 0 16px; font-weight: 700; font-size: 13px; transition: background .15s, transform .15s; }
.primary-button:active { background: var(--green-dark); transform: scale(.98); }
.add-party-top { display: inline-flex; align-items: center; gap: 5px; }
.add-party-top span:first-child { font-size: 19px; font-weight: 400; line-height: 1; }
.summary-card { min-height: 155px; border-radius: 19px; padding: 23px 24px; display: flex; justify-content: space-between; align-items: center; overflow: hidden; position: relative; color: #fff; background: linear-gradient(118deg, #146c5a 0%, #227e66 100%); }
.summary-copy { display: flex; flex-direction: column; align-items: flex-start; position: relative; z-index: 1; }
.summary-label { font-size: 12px; color: #d4eee5; font-weight: 500; }
.summary-amount { margin-top: 6px; font: 800 30px/1.2 Manrope, sans-serif; letter-spacing: -1px; }
.summary-footnote { margin-top: 8px; color: #c1e0d5; font-size: 11px; }
.summary-art { width: 109px; height: 109px; position: relative; margin-right: -6px; }
.summary-art svg { width: 85px; position: absolute; z-index: 1; top: 16px; right: 3px; fill: none; stroke: #e5f5ee; stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round; }
.art-circle { position: absolute; width: 94px; height: 94px; border-radius: 50%; top: 7px; right: -3px; background: #ffffff19; }
.section-title-row { display: flex; justify-content: space-between; align-items: center; margin: 27px 0 14px; }
.count-pill { margin-left: 5px; display: inline-grid; place-items: center; vertical-align: 2px; min-width: 21px; height: 21px; padding: 0 6px; border-radius: 20px; color: #71817b; background: #f1f4f2; font: 600 10px 'DM Sans', sans-serif; }
.text-button { padding: 5px 0 5px 8px; border: 0; background: transparent; color: var(--green); font-size: 11px; font-weight: 700; }
.text-button span { font-size: 15px; padding-left: 2px; }
.search-box { height: 46px; border: 1px solid #eff2f0; border-radius: 12px; background: #fbfcfb; display: flex; align-items: center; padding: 0 13px; gap: 10px; }
.search-box svg { width: 18px; fill: none; stroke: #96a39f; stroke-width: 1.8; }
.search-box input { flex: 1; border: 0; outline: 0; min-width: 0; background: transparent; color: var(--ink); font-size: 13px; }
.search-box input::placeholder { color: #a1aca8; }
.party-list { margin-top: 8px; }
.party-row { width: 100%; display: flex; align-items: center; gap: 12px; min-height: 75px; padding: 10px 2px; border: 0; border-bottom: 1px solid #f0f2f1; background: #fff; text-align: left; color: inherit; }
.party-row:active { background: #fbfdfc; }
.avatar { width: 43px; height: 43px; border-radius: 15px; flex: 0 0 auto; background: #eaf3ef; color: var(--green); display: grid; place-items: center; font: 700 15px Manrope, sans-serif; text-transform: uppercase; }
.avatar.color-1 { background: #f8eee5; color: #ad7451; }
.avatar.color-2 { background: #f1eef8; color: #7763a9; }
.avatar.color-3 { background: #eaf0f8; color: #5c7ba7; }
.avatar.color-4 { background: #f9eded; color: #bb6863; }
.party-main { flex: 1; min-width: 0; }
.party-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 700; }
.party-subtitle { display: block; margin-top: 5px; color: #99a49f; font-size: 10px; }
.party-balance { text-align: right; white-space: nowrap; }
.party-balance strong { display: block; font-size: 12px; font-weight: 700; }
.party-balance small { display: block; margin-top: 4px; font-size: 9px; color: #96a29d; }
.positive-text { color: var(--green); }
.negative-text { color: var(--red); }
.zero-text { color: #82908c; }
.empty-state { padding: 38px 18px 30px; text-align: center; }
.empty-illustration { margin: 0 auto 15px; width: 56px; height: 56px; border-radius: 19px; display: grid; place-items: center; background: var(--green-soft); color: var(--green); font: 400 31px Manrope, sans-serif; }
.empty-state h3 { margin: 0 0 7px; font: 700 15px Manrope, sans-serif; }
.empty-state p { margin: 0 auto 17px; max-width: 245px; color: #909d98; font-size: 12px; line-height: 1.6; }
.balance-overview { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 22px 0 24px; }
.balance-overview > div { padding: 17px; border: 1px solid var(--line); border-radius: 15px; }
.balance-overview span { display: block; color: #8a9792; font-size: 11px; }
.balance-overview strong { display: block; margin-top: 8px; font: 700 20px Manrope, sans-serif; letter-spacing: -.5px; }
.list-caption { margin: 0 0 8px; color: #8b9793; font-size: 11px; }
.back-button { padding: 2px 0 18px; border: 0; background: transparent; color: var(--green); font-size: 12px; font-weight: 700; }
.back-button span { padding-right: 5px; font-size: 16px; }
.ledger-header { display: flex; align-items: center; gap: 13px; }
.avatar-large { width: 55px; height: 55px; border-radius: 18px; font-size: 19px; }
.ledger-person { min-width: 0; flex: 1; }
.ledger-name-row { display: flex; align-items: center; gap: 5px; }
.ledger-name-row h1 { font-size: 21px; overflow-wrap: anywhere; }
.muted { color: #93a09b; font-size: 11px; }
.ledger-person > .muted { display: block; margin-top: 5px; }
.icon-button { width: 38px; height: 38px; display: inline-grid; place-items: center; border: 0; border-radius: 12px; background: #f6f8f7; color: #64736d; }
.icon-button svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.edit-party-button { width: 31px; height: 31px; background: transparent; }
.ledger-balance-card { display: flex; flex-direction: column; align-items: center; margin-top: 22px; padding: 17px; background: #f7faf8; border: 1px solid #eff3f0; border-radius: 15px; }
.ledger-balance-card > span:first-child { color: #84928c; font-size: 11px; }
.ledger-balance-card strong { margin: 5px 0 3px; font: 800 27px Manrope, sans-serif; letter-spacing: -.8px; }
.balance-status { color: var(--green); font-size: 10px; }
.balance-status.debt { color: var(--red); }
.transaction-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; margin-top: 15px; }
.transaction-button { height: 65px; padding: 0 12px; display: flex; align-items: center; justify-content: center; gap: 9px; border: 0; border-radius: 13px; text-align: left; }
.gave-button { background: #eaf5f0; color: #176f5b; }
.got-button { background: #fff0ed; color: #c05f51; }
.action-icon { width: 29px; height: 29px; border: 1px solid currentColor; border-radius: 10px; display: grid; place-items: center; font-size: 18px; line-height: 1; }
.transaction-button strong, .transaction-button small { display: block; }
.transaction-button strong { font-size: 11px; }
.transaction-button small { margin-top: 4px; font-size: 9px; opacity: .72; }
.history-title { margin-top: 28px; }
.history-list { border-top: 1px solid #f0f2f1; }
.history-item { min-height: 70px; padding: 11px 1px; display: flex; align-items: center; gap: 11px; border-bottom: 1px solid #f0f2f1; }
.entry-symbol { width: 36px; height: 36px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 12px; background: #eaf5f0; color: #176f5b; font-size: 16px; }
.entry-symbol.got { background: #fff0ed; color: #c05f51; }
.entry-info { flex: 1; min-width: 0; }
.entry-title { display: block; font-size: 11px; font-weight: 700; }
.entry-date { display: block; margin-top: 4px; color: #98a39f; font-size: 9px; }
.entry-note { display: block; margin-top: 3px; overflow: hidden; color: #788680; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.entry-amount { white-space: nowrap; font-size: 12px; font-weight: 700; }
.history-empty { padding: 24px 12px; text-align: center; color: #98a39f; font-size: 11px; }
.danger-zone { margin-top: 34px; padding-top: 17px; border-top: 1px solid #f1f2f2; text-align: center; }
.danger-button { padding: 8px; border: 0; background: transparent; color: #c76b60; font-size: 11px; font-weight: 600; }
.bottom-nav { position: fixed; z-index: 5; bottom: 0; left: 50%; transform: translateX(-50%); width: min(100%, 560px); height: calc(70px + env(safe-area-inset-bottom)); padding: 7px 30px env(safe-area-inset-bottom); display: flex; align-items: flex-start; justify-content: center; gap: 66px; background: #ffffffed; border-top: 1px solid #eff2f0; backdrop-filter: blur(12px); }
.nav-item { width: 72px; height: 55px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border: 0; background: transparent; color: #9aa59f; font-size: 9px; font-weight: 600; }
.nav-item svg { width: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav-item.active { color: var(--green); }
.modal { width: min(100% - 24px, 430px); max-width: 430px; max-height: min(90dvh, 700px); padding: 25px 22px 20px; border: 0; border-radius: 20px; color: var(--ink); box-shadow: 0 20px 70px #152b2340; }
.modal::backdrop { background: #11221dcc; backdrop-filter: blur(2px); }
.modal form { display: flex; flex-direction: column; }
.modal-heading { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 23px; }
.modal-heading h2 { font-size: 21px; }
.close-button { width: 31px; height: 31px; margin-top: -3px; border: 0; border-radius: 10px; background: #f4f6f5; color: #74817c; font-size: 23px; line-height: 1; }
.field-label { margin: 0 0 7px; color: #4a5852; font-size: 11px; font-weight: 700; }
.optional { color: #a0aaa6; font-weight: 400; }
.text-input { width: 100%; height: 47px; margin-bottom: 18px; padding: 0 13px; outline: 0; border: 1px solid #e8eeea; border-radius: 11px; background: #fcfdfc; color: var(--ink); font-size: 13px; }
.text-input:focus, .amount-input-wrap:focus-within { border-color: #75ad9a; box-shadow: 0 0 0 3px #146c5a13; }
.text-input::placeholder { color: #a6b0ac; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 4px; }
.secondary-button { min-height: 45px; padding: 0 16px; border: 1px solid #e7ece9; border-radius: 12px; background: white; color: #697770; font-size: 12px; font-weight: 600; }
.entry-party-name { margin: -14px 0 19px; color: #87958f; font-size: 12px; }
.amount-input-wrap { height: 58px; display: flex; align-items: center; gap: 9px; margin-bottom: 19px; padding: 0 13px; border: 1px solid #e8eeea; border-radius: 11px; background: #fcfdfc; }
.amount-input-wrap > span { color: #82918b; font-size: 18px; }
.amount-input-wrap input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); font: 700 22px Manrope, sans-serif; }
.toast { position: fixed; z-index: 10; bottom: calc(82px + env(safe-area-inset-bottom)); left: 50%; transform: translate(-50%, 10px); max-width: calc(100vw - 32px); padding: 11px 16px; border-radius: 12px; background: #24352f; color: white; box-shadow: 0 7px 25px #0002; font-size: 12px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.startup-screen { min-height: 100dvh; padding: 24px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; background: #fff; color: #64736d; font-size: 12px; }
.startup-screen p { margin: 0; color: var(--red); text-align: center; line-height: 1.5; }
.startup-mark { width: 52px; height: 52px; margin-bottom: 4px; display: grid; place-items: center; border-radius: 17px 17px 17px 6px; background: var(--green); color: #fff; font: 800 15px Manrope, sans-serif; letter-spacing: -.5px; }
.startup-spinner, .button-spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid #dfe9e4; border-top-color: var(--green); border-radius: 50%; animation: spin .7s linear infinite; }
.button-spinner { width: 14px; height: 14px; border-color: #ffffff66; border-top-color: #fff; vertical-align: -2px; margin-right: 7px; }
@keyframes spin { to { transform: rotate(360deg); } }
.auth-shell { min-height: 100dvh; padding: 24px; display: grid; place-items: center; background: var(--canvas); }
.auth-card { width: min(100%, 380px); padding: 30px 24px 25px; border: 1px solid #edf1ee; border-radius: 20px; background: #fff; box-shadow: 0 12px 40px #17372b0a; }
.auth-card .startup-mark { margin-bottom: 22px; }
.auth-card h1 { font-size: 25px; }
.auth-description { margin: 9px 0 24px; color: #87958f; font-size: 12px; }
.auth-card form { display: flex; flex-direction: column; }
.auth-card .text-input { margin-bottom: 12px; }
.auth-card .submit-button { width: 100%; margin-top: 5px; }
.form-error { margin: 0 0 12px; color: var(--red); font-size: 11px; line-height: 1.5; }
button:disabled { cursor: wait; opacity: .76; }
.topbar-actions { display: flex; align-items: center; gap: 7px; }
[hidden] { display: none !important; }

@media (min-width: 700px) {
  body { padding: 20px 0; }
  .app-shell { min-height: calc(100dvh - 40px); border-radius: 22px; overflow: hidden; }
  .bottom-nav { bottom: 20px; border-radius: 0 0 22px 22px; }
}
@media (max-width: 360px) {
  main { padding-right: 16px; padding-left: 16px; }
  .topbar { padding: 0 16px; }
  .summary-card { padding-right: 17px; padding-left: 19px; }
  .summary-art { width: 85px; }
  .summary-art svg { right: -4px; }
  .transaction-actions { gap: 8px; }
  .transaction-button { padding: 0 8px; gap: 7px; }
}
