:root {
  color-scheme: light;
  --paper: #f5f4fb;
  --ink: #1d1930;
  --muted: #625e75;
  --accent: #5138b2;
  --accent-dark: #412a99;
  --lavender: #eee9ff;
  --line: #e4e0ed;
  --surface: #fff;
  --success: #226551;
  --shadow: 0 16px 48px #28213f12;
  font-family: "Instrument Sans", ui-sans-serif, system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
[hidden] { display: none !important; }
button, input { font: inherit; }
button { cursor: pointer; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.75rem, 3vw, 2.5rem); letter-spacing: -.055em; line-height: 1.06; }
h2 { font-size: 1.15rem; letter-spacing: -.025em; }
p { line-height: 1.55; }
button:focus-visible, input:focus-visible {
  outline: 3px solid #8769fd;
  outline-offset: 3px;
}
button:disabled { opacity: .6; cursor: progress; }
.primary, .secondary, .link-button, .close {
  border: 0; border-radius: .75rem; min-height: 2.65rem; padding: .65rem 1rem;
  font-weight: 680;
}
.primary { background: var(--accent); color: white; }
.primary:hover { background: var(--accent-dark); }
.secondary { background: var(--lavender); color: var(--accent-dark); }
.secondary:hover { background: #e7deff; }
.link-button { background: transparent; color: var(--accent-dark); padding-inline: .65rem; }
.link-button:hover { background: var(--lavender); }
.muted { color: var(--muted); font-size: .9rem; }
.brand { display: flex; align-items: center; gap: .75rem; font-weight: 750; letter-spacing: -.035em; }
.brand img, .auth-copy img, .empty img { border-radius: 22%; }
.dashboard { display: grid; grid-template-columns: minmax(238px, 292px) minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 1.75rem 1.3rem; gap: 2.4rem; }
.sidebar-content { flex: 1; min-height: 8rem; }
.section-label { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: 1rem; }
.section-label .secondary { min-height: 2.25rem; padding: .45rem .65rem; font-size: .85rem; }
.friends { display: grid; gap: .35rem; }
.friend {
  display: grid; grid-template-columns: 2.35rem 1fr auto; gap: .6rem; align-items: center;
  width: 100%; text-align: left; padding: .6rem .5rem; border: 1px solid transparent;
  background: transparent; color: var(--ink); border-radius: .8rem;
}
.friend:hover { background: #f8f6ff; }
.friend[aria-current="true"] { border-color: #e1d8fb; background: var(--lavender); }
.friend-info { overflow: hidden; min-width: 0; }
.friend-info strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .91rem; }
.friend-info small { display: block; color: var(--muted); font-size: .76rem; margin-top: .2rem; }
.friend-balance { font-size: .83rem; font-weight: 700; white-space: nowrap; }
.avatar { background: #e5dcfa; color: #482d91; border-radius: .75rem; width: 2.35rem; height: 2.35rem; display: grid; place-items: center; font-weight: 750; font-size: .82rem; }
.avatar.large { width: 3.35rem; height: 3.35rem; border-radius: 1rem; font-size: 1.1rem; }
.profile { display: flex; justify-content: space-between; align-items: center; gap: .5rem; border-top: 1px solid var(--line); padding-top: .85rem; font-size: .88rem; }
.workspace { width: min(100%, 980px); padding: clamp(1.25rem, 5vw, 4rem); margin: 0 auto; }
.account-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.4rem; }
.account-person { display: flex; gap: .85rem; align-items: center; min-width: 0; }
.account-person p { margin-top: .25rem; }
.balance-card {
  position: relative; overflow: hidden; isolation: isolate; display: grid; align-content: center;
  min-height: 11rem; padding: 1.45rem 1.75rem; border-radius: 1.3rem;
  background: #2e2157; color: white;
}
.balance-card::after {
  content: ""; z-index: -1; width: 18rem; height: 18rem; position: absolute;
  top: -50%; right: -2rem; border: 1.15rem solid #a48aef30; border-radius: 50%;
  box-shadow: 0 0 0 1.8rem #a48aef16, 0 0 0 3.7rem #a48aef10;
}
.balance-card > span { color: #e4ddf7; font-weight: 600; }
.balance-card strong { display: block; font-size: clamp(2.2rem, 6vw, 4.1rem); line-height: 1.15; letter-spacing: -.06em; margin: .25rem 0; font-variant-numeric: tabular-nums; }
.balance-card p { color: #eee8ff; }
.history-heading { display: flex; align-items: center; justify-content: space-between; margin: 1.45rem 0 .45rem; }
#movements { display: grid; gap: .55rem; }
.entry { background: var(--surface); border: 1px solid var(--line); border-radius: 1rem; padding: .9rem 1rem; }
.entry-summary { display: grid; grid-template-columns: 2.4rem minmax(0, 1fr) auto; gap: .7rem; align-items: center; }
.entry-symbol { display: grid; place-items: center; width: 2.4rem; height: 2.4rem; border-radius: .8rem; background: var(--lavender); color: var(--accent-dark); font-size: 1.25rem; }
.entry-body strong { display: block; overflow-wrap: anywhere; }
.entry-body small { display: block; margin-top: .25rem; color: var(--muted); font-size: .82rem; line-height: 1.35; }
.entry-amount { white-space: nowrap; font-weight: 750; font-variant-numeric: tabular-nums; }
.entry-actions { margin-top: .65rem; display: flex; flex-wrap: wrap; gap: .35rem .65rem; justify-content: flex-end; }
.entry-actions button { min-height: 2.15rem; padding-block: .4rem; font-size: .86rem; }
.quiet, .empty, .invite-panel { border: 1px solid var(--line); border-radius: 1.2rem; background: var(--surface); }
.quiet { padding: 1.5rem; color: var(--muted); text-align: center; }
.empty { padding: clamp(1.5rem, 6vw, 4rem); min-height: 19rem; display: grid; justify-items: start; align-content: center; gap: .9rem; box-shadow: var(--shadow); }
.empty p { max-width: 32rem; color: var(--muted); }
.invite-panel { padding: 1rem; margin-bottom: 1rem; display: flex; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.invite-panel p { color: var(--muted); }
.auth { max-width: 1050px; min-height: 100vh; margin: 0 auto; padding: clamp(1.2rem, 8vw, 5rem); display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 360px); gap: clamp(1.5rem, 7vw, 5rem); align-items: center; }
.auth-copy { display: grid; gap: 1.2rem; }
.auth-copy h1 { font-size: clamp(2.6rem, 6.2vw, 5.2rem); }
.auth-copy h1 span { color: var(--accent); }
.auth-copy p { color: var(--muted); max-width: 24rem; }
.auth-card, dialog { color: var(--ink); border: 1px solid var(--line); border-radius: 1.35rem; background: var(--surface); box-shadow: var(--shadow); padding: 1.5rem; }
.auth-card h2 { font-size: 1.65rem; }
.auth-card p { color: var(--muted); margin: .45rem 0 .85rem; }
.auth-card .link-button { margin-top: .65rem; width: 100%; }
form { display: grid; gap: .8rem; }
label { display: grid; gap: .38rem; font-size: .9rem; font-weight: 650; }
input:not([type="radio"]) { border: 1px solid #cfc8de; padding: .65rem .75rem; border-radius: .65rem; min-height: 2.75rem; width: 100%; color: var(--ink); background: white; }
input[type="radio"] { accent-color: var(--accent); }
fieldset { border: 1px solid var(--line); border-radius: .85rem; margin: 0; padding: .75rem; display: flex; flex-wrap: wrap; gap: .75rem; }
legend { font-size: .9rem; font-weight: 650; padding-inline: .25rem; }
.direction { display: flex; align-items: center; gap: .3rem; }
.form-pair { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: .75rem; }
dialog { width: min(calc(100vw - 2rem), 29rem); }
dialog::backdrop { background: #1d153672; }
.dialog-top { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin-bottom: .85rem; }
dialog > p { margin-bottom: .85rem; color: var(--muted); }
.close { background: var(--lavender); color: var(--ink); min-height: 2.3rem; width: 2.3rem; padding: .2rem; font-size: 1.3rem; }
.dialog-actions { display: flex; gap: .5rem; margin-top: .85rem; flex-wrap: wrap; }
#notice {
  position: fixed; z-index: 4; left: 50%; bottom: 1rem; transform: translateX(-50%);
  max-width: calc(100vw - 2rem); width: max-content; color: white; background: var(--ink);
  padding: .75rem 1rem; border-radius: .7rem; box-shadow: var(--shadow); font-size: .92rem;
}
@media (max-width: 650px) {
  .dashboard { display: block; }
  .sidebar { gap: .9rem; border-right: 0; border-bottom: 1px solid var(--line); padding: 1rem; }
  .sidebar-content { min-height: auto; }
  .friends { grid-auto-columns: minmax(10.3rem, 55%); grid-auto-flow: column; overflow-x: auto; }
  .profile { padding-top: .25rem; }
  .workspace { padding: 1rem; }
  .auth { grid-template-columns: 1fr; min-height: auto; padding-top: 2.5rem; padding-bottom: 2.5rem; }
}

.form-pair label { min-width: 0; }
