:root {
  color-scheme: dark;
  --void: #08090a;
  --carbon: #0f1011;
  --obsidian: #161718;
  --graphite: #23252a;
  --smoke: #383b3f;
  --ash: #62666d;
  --fog: #8a8f98;
  --mist: #d0d6e0;
  --bone: #e5e5e6;
  --paper: #fff;
  --acid: #e4f222;
  --pulse: #27a644;
  --coral: #eb5757;
  --iris: #6366f1;
  --font-ui: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--void); }
body { margin: 0; min-width: 320px; background: var(--void); color: var(--mist); font-family: var(--font-ui); font-size: 15px; font-weight: 400; line-height: 1.5; font-feature-settings: "cv01" on, "ss03" on, "zero" on; }
button, input, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 2px solid var(--acid); outline-offset: 2px; }
::selection { background: var(--acid); color: var(--void); }
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: var(--smoke); border-radius: 9999px; }

.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.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; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -.013em; }
.label { display: block; color: var(--fog); font-size: 10px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; }
.app-shell { width: 100%; min-height: 100svh; padding: env(safe-area-inset-top) 14px calc(104px + env(safe-area-inset-bottom)); }

.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; max-width: 720px; margin: 0 auto; padding: 19px 2px 18px; }
.topbar h1 { margin: 1px 0 0; color: var(--paper); font-size: 20px; font-weight: 510; line-height: 1.2; letter-spacing: -.012em; }
.topbar-date { color: var(--fog); font-size: 10px; letter-spacing: .07em; text-transform: uppercase; }
.sync-state { display: flex; align-items: center; gap: 7px; color: var(--fog); font-size: 11px; }
.sync-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--acid); box-shadow: 0 0 0 3px rgba(228,242,34,.08); }

.loading-state { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 56vh; color: var(--fog); font-size: 13px; }
.loading-state span { width: 15px; height: 15px; border: 1px solid var(--smoke); border-top-color: var(--acid); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

main { max-width: 720px; margin: 0 auto; }
.screen { display: none; animation: screen-in .24s cubic-bezier(.22,1,.36,1); }
.screen.is-active { display: block; }
@keyframes screen-in { from { opacity: .01; transform: translateY(7px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { .screen, .loading-state span { animation: none; } }

.balance-panel { padding: 20px; background: var(--carbon); border-radius: 12px; box-shadow: inset 0 0 0 .5px var(--graphite); }
.balance-head, .section-heading, .data-row, .debt-card-head, .mini-row, .wealth-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.balance-value { margin-top: 6px; color: var(--paper); font-size: clamp(26px, 8vw, 36px); font-weight: 400; line-height: 1.1; letter-spacing: -.03em; }
.icon-button { display: grid; place-items: center; width: 44px; height: 44px; flex: 0 0 auto; border: .5px solid var(--graphite); border-radius: 6px; background: var(--obsidian); color: var(--mist); cursor: pointer; }
.icon-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.wealth-line { margin-top: 17px; padding-top: 13px; border-top: .5px solid var(--graphite); color: var(--fog); font-size: 11px; }
.wealth-line strong { color: var(--mist); font-weight: 400; }

.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.metric { min-width: 0; padding: 13px 14px; border-radius: 6px; background: rgba(255,255,255,.02); box-shadow: inset 0 0 0 .5px var(--graphite); }
.metric strong { display: block; margin-top: 5px; overflow: hidden; color: var(--bone); font-size: 14px; font-weight: 400; text-overflow: ellipsis; white-space: nowrap; }

.account-strip { display: flex; gap: 6px; margin: 10px -14px 0; padding: 0 14px; overflow-x: auto; scrollbar-width: none; }
.account-strip::-webkit-scrollbar { display: none; }
.account-chip { flex: 0 0 auto; padding: 6px 10px; border-radius: 9999px; background: rgba(255,255,255,.04); color: var(--fog); font-size: 11px; }
.account-chip strong { margin-left: 5px; color: var(--mist); font-family: var(--font-mono); font-weight: 400; }

.home-section { margin-top: 25px; }
.compact-section { padding-bottom: 8px; }
.section-heading { margin-bottom: 8px; }
.section-heading h3 { margin: 0; color: var(--bone); font-size: 14px; font-weight: 510; letter-spacing: -.01em; }
.section-meta { color: var(--ash); font-size: 11px; }
.text-action { min-height: 44px; margin: -12px 0; padding: 0; border: 0; background: transparent; color: var(--mist); font-size: 11px; text-decoration: underline; text-decoration-color: var(--smoke); text-underline-offset: 4px; cursor: pointer; }

.debt-summary { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 11px; width: 100%; min-height: 66px; padding: 11px 12px; border: .5px solid var(--graphite); border-radius: 6px; background: var(--carbon); color: var(--mist); text-align: left; cursor: pointer; }
.debt-summary-mark { display: grid; place-items: center; width: 39px; height: 39px; border-radius: 6px; background: var(--acid); color: var(--void); font-size: 19px; }
.debt-summary-main small, .debt-summary-side { color: var(--fog); font-size: 10px; }
.debt-summary-main strong { display: block; margin-top: 1px; color: var(--paper); font-family: var(--font-mono); font-size: 15px; font-weight: 400; }
.debt-summary-side { text-align: right; }

.data-list { overflow: hidden; border-radius: 6px; background: var(--carbon); box-shadow: inset 0 0 0 .5px var(--graphite); }
.data-row { min-height: 58px; padding: 10px 12px; border-bottom: .5px solid var(--graphite); }
.data-row:last-child { border-bottom: 0; }
.data-row-main { min-width: 0; flex: 1; }
.data-row-title { overflow: hidden; color: var(--bone); font-size: 12px; font-weight: 510; text-overflow: ellipsis; white-space: nowrap; }
.data-row-meta { margin-top: 3px; color: var(--ash); font-size: 10px; }
.data-row-value { flex: 0 0 auto; color: var(--mist); font-family: var(--font-mono); font-size: 11px; white-space: nowrap; }
.data-row-value::first-letter { color: var(--fog); }
.empty-state { padding: 26px 18px; color: var(--ash); font-size: 12px; text-align: center; }

.category-list { padding: 2px 0; }
.category-item { display: grid; grid-template-columns: minmax(75px,1fr) 2fr auto; align-items: center; gap: 8px; min-height: 31px; }
.category-name, .category-value { font-size: 10px; }
.category-name { overflow: hidden; color: var(--fog); text-overflow: ellipsis; white-space: nowrap; }
.category-value { color: var(--mist); font-family: var(--font-mono); }
.category-track { height: 2px; background: var(--graphite); }
.category-bar { height: 100%; background: var(--iris); }

.page-heading { display: flex; justify-content: space-between; align-items: flex-start; margin: 3px 2px 17px; }
.page-heading h2 { margin: 0; color: var(--paper); font-size: 24px; font-weight: 510; line-height: 1.2; letter-spacing: -.022em; }
.page-heading p { margin: 4px 0 0; color: var(--fog); font-size: 12px; }
.search-row { display: grid; grid-template-columns: 1fr auto; gap: 7px; }
input, select { width: 100%; min-height: 46px; border: .5px solid var(--graphite); border-radius: 6px; background: rgba(255,255,255,.02); color: var(--mist); padding: 10px 12px; font-size: 16px; }
input::placeholder { color: var(--ash); opacity: 1; }
select { padding-right: 32px; }
.search-row select { width: 128px; font-size: 13px; }

.transaction-timeline { margin-top: 17px; }
.date-group { margin-bottom: 18px; }
.date-heading { margin: 0 2px 7px; color: var(--ash); font-size: 10px; font-weight: 500; letter-spacing: .07em; text-transform: uppercase; }
.transaction-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; min-height: 58px; padding: 10px 12px; border-bottom: .5px solid var(--graphite); background: var(--carbon); }
.transaction-row:first-of-type { border-radius: 6px 6px 0 0; }
.transaction-row:last-child { border-bottom: 0; border-radius: 0 0 6px 6px; }
.transaction-row:only-of-type { border-radius: 6px; }
.transaction-title { color: var(--bone); font-size: 12px; font-weight: 510; }
.transaction-meta { margin-top: 3px; color: var(--ash); font-size: 10px; }
.transaction-amount { align-self: center; color: var(--mist); font-family: var(--font-mono); font-size: 11px; white-space: nowrap; }

.ghost-button, .primary-button { min-height: 44px; border-radius: 6px; padding: 9px 13px; cursor: pointer; }
.ghost-button { border: .5px solid var(--graphite); background: transparent; color: var(--mist); font-size: 12px; }
.primary-button { border: 0; background: var(--acid); color: var(--void); font-size: 13px; font-weight: 510; }
.block-button { width: 100%; margin-top: 10px; }
.ghost-button[hidden] { display: none; }

.debt-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.debt-metrics article { padding: 14px; border-radius: 6px; background: var(--carbon); box-shadow: inset 0 0 0 .5px var(--graphite); }
.debt-metrics strong { display: block; margin-top: 5px; color: var(--bone); font-size: 14px; font-weight: 400; }
.segmented-control { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; margin-top: 12px; padding: 3px; border-radius: 6px; background: var(--carbon); box-shadow: inset 0 0 0 .5px var(--graphite); }
.segmented-control button { min-height: 40px; border: 0; border-radius: 4px; background: transparent; color: var(--fog); font-size: 12px; cursor: pointer; }
.segmented-control button.is-active { background: var(--obsidian); color: var(--paper); box-shadow: inset 0 0 0 .5px var(--smoke); }
.transaction-type button.is-active { background: var(--acid); color: var(--void); box-shadow: none; }

.debt-list { margin-top: 12px; }
.debt-card { padding: 14px; margin-bottom: 8px; border-radius: 6px; background: var(--carbon); box-shadow: inset 0 0 0 .5px var(--graphite); }
.debt-card-name { color: var(--paper); font-size: 13px; font-weight: 510; }
.status-badge { padding: 2px 6px; border-radius: 4px; background: rgba(255,255,255,.05); color: var(--fog); font-size: 10px; }
.status-badge.overdue { background: rgba(235,87,87,.12); color: var(--bone); }
.debt-amount { margin-top: 9px; color: var(--paper); font-size: 18px; font-weight: 400; }
.debt-progress { height: 3px; margin-top: 12px; overflow: hidden; background: var(--graphite); }
.debt-progress span { display: block; height: 100%; background: var(--acid); }
.debt-card-meta { display: flex; justify-content: space-between; gap: 12px; margin-top: 7px; color: var(--ash); font-size: 10px; }
.debt-actions { display: grid; grid-template-columns: 1fr 44px; gap: 7px; margin-top: 12px; }
.debt-actions .ghost-button { margin: 0; }
.danger-button { display: grid; place-items: center; min-height: 44px; border: .5px solid var(--graphite); border-radius: 6px; background: transparent; color: var(--fog); cursor: pointer; }
.danger-button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; }

.settings-stack { border-top: .5px solid var(--graphite); }
.settings-group { border-bottom: .5px solid var(--graphite); }
.settings-group summary { display: flex; align-items: center; justify-content: space-between; min-height: 59px; color: var(--bone); font-size: 13px; cursor: pointer; list-style: none; }
.settings-group summary::-webkit-details-marker { display: none; }
.settings-group summary span { display: flex; align-items: center; gap: 9px; }
.settings-group summary svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.settings-group summary .chevron { color: var(--ash); transition: transform .2s ease; }
.settings-group[open] summary .chevron { transform: rotate(90deg); }
.settings-content { padding: 0 0 15px; }
.helper { margin: 0 0 10px; color: var(--fog); font-size: 11px; }
.mini-list { overflow: hidden; border-radius: 6px; background: var(--carbon); }
.mini-row { min-height: 49px; padding: 8px 10px; border-bottom: .5px solid var(--graphite); }
.mini-row:last-child { border-bottom: 0; }
.mini-main { min-width: 0; }
.mini-title { overflow: hidden; color: var(--bone); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.mini-meta { margin-top: 2px; color: var(--ash); font-size: 9px; }
.mini-value { color: var(--mist); font-family: var(--font-mono); font-size: 10px; white-space: nowrap; }
.chip-list { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { padding: 4px 8px; border-radius: 4px; background: rgba(255,255,255,.05); color: var(--fog); font-size: 10px; }
.inline-form { display: grid; grid-template-columns: 1fr auto; gap: 7px; margin-top: 10px; }
.inline-form input { min-height: 44px; }

.bottom-nav { position: fixed; z-index: 20; right: 10px; bottom: calc(9px + env(safe-area-inset-bottom)); left: 10px; display: grid; grid-template-columns: repeat(4,1fr); max-width: 700px; margin: 0 auto; padding: 5px; border: .5px solid var(--graphite); border-radius: 12px; background: rgba(15,16,17,.96); box-shadow: 0 4px 32px rgba(8,9,10,.6); }
.bottom-nav button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 55px; border: 0; border-radius: 6px; background: transparent; color: var(--ash); font-size: 9px; cursor: pointer; }
.bottom-nav button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.bottom-nav button.is-active { background: var(--obsidian); color: var(--paper); box-shadow: inset 0 0 0 .5px var(--graphite); }
.bottom-nav button.is-active svg { color: var(--acid); }
.primary-fab { position: fixed; z-index: 21; right: max(18px,calc((100vw - 700px)/2 + 18px)); bottom: calc(79px + env(safe-area-inset-bottom)); display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 47px; padding: 0 15px; border: 0; border-radius: 6px; background: var(--acid); color: var(--void); box-shadow: 0 5px 2px rgba(0,0,0,.02),0 3px 2px rgba(0,0,0,.08),0 1px 1px rgba(0,0,0,.14); font-size: 12px; font-weight: 510; cursor: pointer; }
.primary-fab svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
body:not(.ready) .bottom-nav, body:not(.ready) .primary-fab { visibility: hidden; }

.row-delete, .mini-delete, .mini-use, .chip button {
  border: 0;
  background: transparent;
  color: var(--ash);
  cursor: pointer;
}
.row-delete, .mini-delete { display: grid; place-items: center; width: 44px; height: 44px; margin: -3px -8px -3px 0; border-radius: 6px; }
.row-delete svg, .mini-delete svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.transaction-row { grid-template-columns: minmax(0,1fr) auto 44px; align-items: center; }
.mini-use { min-height: 40px; padding: 0 7px; color: var(--mist); font-size: 10px; text-decoration: underline; text-decoration-color: var(--smoke); text-underline-offset: 3px; }
.chip button { min-width: 24px; min-height: 24px; margin: -4px -6px -4px 1px; }
.member-default { width: 132px; min-height: 38px; padding: 6px 9px; font-size: 11px; }

.sheet-dialog { width: 100%; max-width: none; height: 100%; max-height: none; margin: 0; padding: 0; border: 0; background: rgba(8,9,10,.72); }
.sheet-dialog[open] { display: flex; align-items: flex-end; justify-content: center; }
.sheet-dialog::backdrop { background: rgba(8,9,10,.72); }
.sheet { width: 100%; max-width: 720px; max-height: min(88svh,760px); overflow-y: auto; padding: 10px 14px calc(18px + env(safe-area-inset-bottom)); border: .5px solid var(--graphite); border-bottom: 0; border-radius: 12px 12px 0 0; background: var(--carbon); box-shadow: 0 -8px 32px rgba(0,0,0,.38); }
.sheet-handle { width: 38px; height: 3px; margin: 0 auto 11px; border-radius: 9999px; background: var(--smoke); }
.sheet-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.sheet-title h2 { margin: 0; color: var(--paper); font-size: 18px; font-weight: 510; letter-spacing: -.012em; }
.sheet-title p { margin: 3px 0 0; color: var(--fog); font-size: 11px; }
.sheet .segmented-control { margin-top: 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px 8px; margin-top: 14px; }
.form-grid label { color: var(--fog); font-size: 10px; letter-spacing: .03em; }
.form-grid input, .form-grid select { margin-top: 5px; }
.span-2 { grid-column: span 2; }
.sheet-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 7px; margin-top: 16px; }
.toast { position: fixed; z-index: 40; top: calc(12px + env(safe-area-inset-top)); left: 50%; width: min(calc(100% - 28px),480px); padding: 10px 12px; border: .5px solid var(--smoke); border-radius: 6px; background: var(--obsidian); color: var(--bone); box-shadow: 0 4px 32px rgba(8,9,10,.6); font-size: 11px; opacity: 0; pointer-events: none; transform: translate(-50%,-12px); transition: opacity .18s ease,transform .18s ease; }
.toast.is-visible { opacity: 1; transform: translate(-50%,0); }
.toast.is-error { border-color: rgba(235,87,87,.45); }
.confirm-dialog { width: min(calc(100% - 28px),390px); padding: 0; border: .5px solid var(--graphite); border-radius: 12px; background: var(--carbon); color: var(--mist); box-shadow: 0 4px 32px rgba(8,9,10,.6); }
.confirm-dialog::backdrop { background: rgba(8,9,10,.78); }
.confirm-panel { padding: 18px; }
.confirm-panel h2 { margin: 0; color: var(--paper); font-size: 17px; font-weight: 510; }
.confirm-panel p { margin: 7px 0 0; color: var(--fog); font-size: 12px; }

@media (min-width: 760px) {
  .app-shell { padding-right: 24px; padding-left: 24px; }
  .balance-panel { padding: 24px; }
  .home-section { margin-top: 30px; }
}

@media (max-width: 370px) {
  .app-shell { padding-right: 10px; padding-left: 10px; }
  .balance-panel { padding: 16px; }
  .balance-value { font-size: 24px; }
  .search-row { grid-template-columns: 1fr; }
  .search-row select { width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
}
