:root {
  color-scheme: light;
  --page: #f5f4f9;
  --surface: #fff;
  --ink: #201a31;
  --muted: #655f73;
  --line: #e7e3ee;
  --brand: #592bd4;
  --brand-hover: #491eb9;
  --lavender: #eee7fe;
  --second: #ae91fa;
  --danger: #9c2442;
  font: 400 100%/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--page); color: var(--ink); }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.95rem, 4vw, 2.65rem); letter-spacing: -.055em; line-height: 1.12; }
h2 { font-size: 1.125rem; line-height: 1.3; letter-spacing: -.025em; }
h3 { font-size: 1rem; line-height: 1.35; letter-spacing: -.01em; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .65; }
:focus-visible { outline: 3px solid #805cf4; outline-offset: 3px; }
.muted { color: var(--muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.brand { display: flex; align-items: center; gap: .65rem; font-weight: 750; letter-spacing: -.025em; }
.brand-mark { position: relative; display: block; width: 34px; height: 34px; flex: 0 0 34px; border-radius: 10px; background: var(--brand); }
.brand-mark::before, .brand-mark::after { content: ""; position: absolute; width: 10px; height: 13px; top: 8px; border: 1.5px solid #fff; border-radius: 6px; transform: rotate(38deg); }
.brand-mark::before { left: 9px; }
.brand-mark::after { top: 12px; left: 15px; border-color: #d0bcff; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; padding: .64rem .95rem; min-height: 44px; border: 1px solid transparent; border-radius: 10px; font-weight: 680; font-size: .875rem; line-height: 1.25; white-space: nowrap; }
.primary { background: var(--brand); color: #fff; }
.primary:hover { background: var(--brand-hover); }
.secondary { background: #fff; color: var(--ink); border-color: var(--line); }
.secondary:hover, .ghost:hover, .icon-button:hover { background: var(--lavender); }
.ghost, .icon-button { background: transparent; color: var(--muted); }
.danger { background: var(--danger); color: #fff; }
.danger:hover { background: #781931; }
.plus { font-size: 1.24rem; line-height: .8; font-weight: 450; }
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-inner { width: min(100% - 3rem, 72rem); min-height: 68px; margin: auto; display: flex; align-items: center; justify-content: space-between; gap: .5rem 1rem; }
.profile { display: flex; align-items: center; gap: .6rem; font-size: .875rem; font-weight: 650; min-width: 0; }
#profile-name { overflow-wrap: anywhere; }
.avatar { display: grid; place-items: center; width: 32px; height: 32px; flex: 0 0 32px; border-radius: 50%; color: #4e22b3; background: var(--lavender); font-size: .875rem; }

.dashboard { width: min(100% - 3rem, 72rem); margin: 2.45rem auto 4rem; }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.6rem; }
.page-header p { margin-top: .45rem; }
.overview { display: grid; grid-template-columns: 1.65fr 1fr; gap: 1rem; }
.balance-card { isolation: isolate; position: relative; overflow: hidden; background: #29194f; color: #fff; padding: 1.45rem 1.6rem 1.55rem; border-radius: 18px; }
.balance-card::after { content: ""; position: absolute; z-index: -1; pointer-events: none; width: 18rem; height: 18rem; right: -3rem; top: -4.1rem; border-radius: 50%; background: repeating-radial-gradient(circle at center, transparent 0, transparent 19px, #d4baff1d 20px, transparent 21px, transparent 26px); mask-image: linear-gradient(110deg, transparent 4%, #000 65%); }
.balance-card h2 { font-size: .95rem; color: #e2d5f9; letter-spacing: 0; }
.balance-amount { font-size: clamp(2.6rem, 6vw, 3.45rem); line-height: 1.13; font-weight: 750; letter-spacing: -.055em; margin-top: .35rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.balance-message { color: #e2d5f9; margin: .25rem 0 1rem; font-size: .95rem; overflow-wrap: anywhere; }
.transfer-button { border-color: #9883b9; background: #39285d; color: #fff; }
.transfer-button:hover { background: #4b3774; }
.panel { padding: 1.25rem; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; min-width: 0; box-shadow: 0 2px 4px #28184006; }
.split-card { display: flex; flex-direction: column; justify-content: center; padding: 1.5rem; }
.split-bar { display: flex; height: 10px; gap: 4px; margin: 1.3rem 0 .85rem; }
.split-bar span { width: 51%; background: var(--brand); border-radius: 99px; }
.split-bar span + span { width: 49%; background: var(--second); }
.split-people { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }
.split-person { min-width: 0; overflow-wrap: anywhere; }
.split-person strong { display: block; font-size: 1.65rem; letter-spacing: -.04em; }
.split-person span { color: var(--muted); font-size: .875rem; }
.split-person:last-child { text-align: right; }

.period { margin: 1.85rem 0 .8rem; display: flex; justify-content: space-between; align-items: center; gap: .7rem; }
.period h2 { font-size: 1.35rem; }
.period select { width: auto; max-width: 100%; }
.monthly { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 1rem; align-items: start; }
.panel-title { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; margin-bottom: .9rem; }
.panel-title > span { font-size: .875rem; white-space: nowrap; }
.panel-title strong { font-size: .95rem; font-variant-numeric: tabular-nums; }
.category-list { display: grid; gap: .63rem; }
.category-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .2rem .6rem; font-size: .875rem; }
.category-row strong { font-variant-numeric: tabular-nums; font-weight: 650; }
.category-row meter { grid-column: 1 / -1; appearance: none; width: 100%; height: 4px; border: 0; border-radius: 99px; background: #eeeaf6; }
.category-row meter::-webkit-meter-bar { height: 4px; background: #eeeaf6; border: 0; }
.category-row meter::-webkit-meter-optimum-value { background: var(--brand); border-radius: 99px; }
.category-row meter::-moz-meter-bar { background: var(--brand); border-radius: 99px; }
.paid-summary { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-bottom: .8rem; }
.paid-person { min-width: 0; padding: .6rem .75rem; border-radius: 10px; background: #f5f1fd; font-size: .875rem; overflow-wrap: anywhere; }
.paid-person strong { display: block; font-variant-numeric: tabular-nums; }
.paid-person span { color: var(--muted); }
.empty { padding: 1.8rem .75rem; border: 1px dashed #dcd3ee; border-radius: 12px; text-align: center; }
.empty strong { display: block; margin-bottom: .25rem; }
.empty p { font-size: .875rem; color: var(--muted); }
.transaction { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: .6rem; padding: .7rem 0; border-bottom: 1px solid var(--line); }
.transaction:last-child { border-bottom: 0; padding-bottom: 0; }
.transaction strong { font-size: .875rem; overflow-wrap: anywhere; }
.transaction p { margin-top: .12rem; font-size: .8125rem; color: var(--muted); overflow-wrap: anywhere; }
.transaction .amount { white-space: nowrap; font-variant-numeric: tabular-nums; }
.icon-button { width: 38px; min-height: 38px; padding: 0; font-size: 1.3rem; font-weight: 450; }

.welcome { min-height: 100vh; display: grid; place-items: center; padding: 1.25rem; background: radial-gradient(ellipse at 70% 0, #e9defe 0, transparent 47%), var(--page); }
.auth-card { width: min(100%, 28rem); padding: clamp(1.25rem, 5vw, 2.25rem); border-radius: 22px; border: 1px solid var(--line); background: var(--surface); box-shadow: 0 14px 48px #32204e0d; }
.auth-card h1 { margin: 1.3rem 0 .45rem; }
.auth-card form { margin-top: 1.3rem; }
.auth-card form > .button { margin-top: .35rem; width: 100%; }
label { display: grid; gap: .25rem; min-width: 0; font-size: .875rem; font-weight: 650; margin-bottom: .75rem; }
input, select { width: 100%; min-height: 44px; min-width: 0; padding: .46rem .6rem; border-radius: 9px; border: 1px solid #d9d3e4; background: #fff; color: var(--ink); font-size: 1rem; font-weight: 450; }
input::placeholder { color: var(--muted); }
select { appearance: none; padding-right: 1.75rem; background: linear-gradient(45deg, transparent 50%, var(--muted) 50%) calc(100% - 15px) 50% / 5px 5px no-repeat, linear-gradient(135deg, var(--muted) 50%, transparent 50%) calc(100% - 10px) 50% / 5px 5px no-repeat, #fff; }
.form-note { font-size: .875rem; color: var(--muted); margin: .65rem 0; }
.form-note:empty { display: none; }
.error { font-size: .875rem; color: var(--danger); background: #fff0f4; padding: .55rem .7rem; border-radius: 8px; margin: .55rem 0; }
.dashboard-error { margin: 0 0 1rem; }
dialog { width: min(calc(100% - 1.5rem), 28rem); max-height: calc(100% - 1.5rem); border: 1px solid var(--line); border-radius: 18px; color: var(--ink); padding: 1.25rem; box-shadow: 0 24px 80px #25174644; }
dialog::backdrop { background: #20163389; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.dialog-heading h2 { font-size: 1.4rem; }
dialog .muted { font-size: .875rem; margin: .3rem 0 1rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .55rem; margin-top: 1rem; }
.toast:empty { display: none; }
.toast { position: fixed; z-index: 2; left: 50%; transform: translateX(-50%); bottom: 1.1rem; width: max-content; max-width: calc(100% - 1.5rem); color: #fff; background: #29194f; border-radius: 10px; padding: .6rem .9rem; box-shadow: 0 8px 24px #20163338; font-size: .875rem; }
@media (max-width: 43rem) {
  .topbar-inner, .dashboard { width: calc(100% - 1.6rem); }
  .dashboard { margin-top: 1.5rem; }
  .overview, .monthly { grid-template-columns: 1fr; }
  .activity { order: -1; }
  .profile { gap: .3rem; }
  #profile-name { display: none; }
}
@media (max-width: 30rem) {
  .page-header { flex-direction: column; align-items: stretch; }
  .page-header .button { align-self: flex-start; }
  .topbar-inner .brand { font-size: .875rem; }
  .topbar-inner .avatar { display: none; }
}
