:root {
  color-scheme: dark;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #f5f3ff;
  background: #10111a;
  --ink: #10111a;
  --panel: #181a27;
  --border: #2e3044;
  --muted: #b0b1c8;
  --lime: #c8fd67;
  --mint: #82f1b6;
  --coral: #ff9b94;
  --violet: #ae99ff;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(ellipse at 16% 0%, #262142 0, transparent 47rem), var(--ink); }
h1,h2,h3,p { margin: 0; }
button,input,a { font: inherit; }
button,a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
button:focus-visible,a:focus-visible,input:focus-visible,.category:has(:focus-visible) { outline: 2px solid var(--lime); outline-offset: 3px; }
[hidden] { display: none !important; }
.wrap { width: min(1040px, calc(100% - 40px)); margin-inline: auto; padding: clamp(21px, 5vw, 53px) 0 40px; }
.masthead,.brand,.form-head,.history-head { display: flex; align-items: center; }
.masthead,.form-head,.history-head { justify-content: space-between; gap: 12px; }
.masthead { padding-bottom: 20px; margin-bottom: 23px; border-bottom: 1px solid #ffffff1c; }
.brand { gap: 12px; min-width: 0; }
.logo { display: flex; align-items: end; justify-content: center; gap: 4px; padding-bottom: 13px; width: 44px; height: 44px; flex: 0 0 auto; border-radius: 14px; color: #222138; background: var(--lime); box-shadow: 0 3px 20px #a5ec4b29; }
.logo i { width: 4px; height: 8px; border-radius: 2px; background: currentColor; transform: skewY(-14deg); }
.logo i:nth-child(2) { height: 13px; }
.logo i:nth-child(3) { height: 19px; }
h1 { font-size: clamp(1.15rem, 4.7vw, 1.52rem); font-weight: 740; letter-spacing: -.04em; line-height: 1.13; }
.brand p,.subtle { color: var(--muted); font-size: .81rem; line-height: 1.45; }
.brand p { margin-top: 4px; }
.brand p::first-letter { text-transform: uppercase; }
.quiet,.close,.danger,.primary { display: inline-grid; place-items: center; min-height: 41px; border: 1px solid #42425a; border-radius: 10px; padding: 0 12px; color: #f1edff; background: #202132; font-size: .8rem; font-weight: 680; }
.quiet:hover,.close:hover { background: #303148; }
.dashboard { display: grid; grid-template-columns: minmax(0,1.08fr) minmax(0,1fr); gap: 20px; align-items: start; }
.balance { position: relative; isolation: isolate; overflow: hidden; padding: clamp(17px,4vw,25px); border: 1px solid #7264b8; border-radius: 22px; background: radial-gradient(ellipse at 100% 5%,#6545c8,transparent 69%), linear-gradient(142deg,#272145,#33216a 75%); box-shadow: 0 20px 36px #0905164d; }
.balance::before { content: ""; position: absolute; z-index: -1; width: 290px; aspect-ratio: 1; right: -132px; top: -177px; border-radius: 50%; border: 1px solid #dfd1ff49; box-shadow: 0 0 0 17px #dfd1ff19,0 0 0 35px #dfd1ff13,0 0 0 54px #dfd1ff0e,0 0 0 75px #dfd1ff0a; }
.balance-top { display: flex; flex-direction: column; align-items: start; gap: 19px; }
.period { display: inline-flex; align-items: center; gap: 3px; padding: 3px; border-radius: 11px; border: 1px solid #f1eaff2e; background: #170f35a6; }
.period button { min-height: 35px; min-width: 51px; padding: 0 9px; border: 0; border-radius: 8px; color: #e5dfff; background: none; font-size: .78rem; font-weight: 670; }
.period button[aria-pressed="true"] { color: #221346; background: #eee7ff; }
.period button:hover:not([aria-pressed="true"]) { background: #ffffff25; }
.net { min-width: 0; }
.net h2 { color: #e1d6ff; font-size: .84rem; font-weight: 560; }
#balance { display: block; margin-top: 3px; font-size: clamp(2.05rem,8.3vw,3.45rem); font-weight: 760; letter-spacing: -.061em; line-height: 1.08; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
#balance.negative { color: #ffc0ba; }
.flow { display: flex; height: 5px; gap: 3px; margin: 19px 0 15px; overflow: hidden; border-radius: 6px; background: #ffffff23; }
.flow i { border-radius: inherit; min-width: 0; }
.flow i:first-child { background: var(--lime); }
.flow i:last-child { background: var(--coral); }
.totals,.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.summary { display: block; min-width: 0; padding: 10px 11px; text-align: left; border-radius: 11px; border: 1px solid #ede6ff37; background: #1d153f80; color: #f8f4ff; }
.summary:hover { background: #271d55; }
.summary-label { display: flex; align-items: center; gap: 6px; color: #e1d6ff; font-size: .77rem; }
.summary-label i { width: 6px; height: 6px; flex: 0 0 auto; border-radius: 50%; background: var(--accent); }
.chevron { margin-left: auto; color: #d3c2ff; font-size: 1rem; line-height: .8; }
.summary strong { display: block; margin-top: 4px; font-size: clamp(.95rem,4.2vw,1.24rem); line-height: 1.15; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.incoming { --accent: var(--lime); }
.outgoing { --accent: var(--coral); }
.actions { margin-top: 13px; }
.action,.save { min-height: 54px; padding: 9px; border: 1px solid #ffffff1f; border-radius: 13px; background: var(--accent); color: #1c1722; font-weight: 780; }
.action { display: flex; align-items: center; justify-content: center; gap: 8px; }
.action span { display: grid; place-items: center; width: 25px; height: 25px; background: #1811241b; border-radius: 7px; font-size: 1.13rem; line-height: 1; }
.action:hover,.save:hover { filter: brightness(1.07); }
.history { min-width: 0; min-height: 158px; padding: 19px; border: 1px solid var(--border); border-radius: 19px; background: #181a28; }
.history h2 { font-size: 1.06rem; letter-spacing: -.021em; }
.history-head span { padding: 3px 8px; border-radius: 7px; background: #30264f; color: #ddceff; font-size: .74rem; font-weight: 720; }
.day-group { margin-top: 17px; }
.day-group h3 { color: #c3bfd9; font-size: .75rem; font-weight: 660; }
.day-group ul,#summaryRows { list-style: none; padding: 0; margin: 5px 0 0; }
.day-group li + li { border-top: 1px solid #ffffff10; }
.entry-row { width: 100%; display: grid; grid-template-columns: 31px minmax(0,1fr) auto 8px; align-items: center; gap: 9px; min-height: 49px; padding: 5px 0; text-align: left; color: #f7f5ff; background: none; border: 0; border-radius: 8px; }
.entry-row:hover { background: #ffffff09; }
.entry-icon { display: grid; place-items: center; width: 31px; height: 31px; border-radius: 9px; color: var(--accent); background: #262f29; font-weight: 760; }
.entry-icon.outgoing { background: #372536; }
.entry-name { font-size: .86rem; overflow-wrap: anywhere; }
.entry-amount { text-align: right; color: var(--accent); font-size: .83rem; font-weight: 720; font-variant-numeric: tabular-nums; white-space: nowrap; }
#empty { margin-top: 14px; color: var(--muted); font-size: .85rem; }
dialog { width: min(450px, calc(100% - 28px)); max-height: 90dvh; border: 1px solid #51446d; border-radius: 20px; background: #1d1b2e; color: inherit; padding: 20px; box-shadow: 0 22px 60px #0a081dbb; }
dialog::backdrop { background: #090717b8; }
.form-head h2 { font-size: 1.25rem; letter-spacing: -.035em; }
.close { flex: 0 0 auto; width: 42px; padding: 0; font-size: 1.45rem; }
fieldset { margin: 14px 0; padding: 0; border: 0; }
legend,form label { color: #e7e4f5; font-size: .81rem; font-weight: 650; }
.category-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.category { position: relative; display: flex; align-items: center; min-height: 42px; padding: 0 10px; border: 1px solid #51446d; border-radius: 9px; background: #28243b; cursor: pointer; overflow-wrap: anywhere; max-width: 100%; }
.category:has(:checked) { color: #211437; background: #c9b6ff; border-color: #c9b6ff; }
.category input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1.15fr; gap: 9px; margin-top: 12px; }
form input:not([type="radio"]) { display: block; width: 100%; min-width: 0; margin-top: 5px; padding: 9px; min-height: 45px; color: #f8f5ff; background: #151420; border: 1px solid #51446d; border-radius: 9px; font-size: 1rem; }
.save { width: 100%; margin-top: 13px; }
.error { color: #ffb0ab; font-size: .81rem; margin-top: 8px; }
.error:empty { display: none; }
.delete { display: block; min-height: 42px; margin: 4px auto 0; border: 0; background: none; color: var(--coral); font-size: .82rem; font-weight: 650; }
.delete-confirm { margin-top: 12px; padding: 10px; border: 1px solid #6b4354; border-radius: 10px; font-size: .83rem; }
.delete-confirm div,.backup-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
.danger { color: #31151b; background: var(--coral); border-color: var(--coral); }
.subtle { margin-top: 10px; }
#summaryRows li { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid #ffffff19; font-size: .89rem; }
#summaryRows li:last-child { border: 0; }
#summaryRows strong { color: var(--accent); white-space: nowrap; }
.primary { color: #211437; background: #c9b6ff; border-color: #c9b6ff; }
#status:empty { display: none; }
#status { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); max-width: calc(100% - 24px); width: max-content; padding: 10px 14px; border: 1px solid #6a5489; border-radius: 10px; background: #352755; color: white; font-size: .84rem; }
@media(max-width:730px) {
  .wrap { width: min(500px, calc(100% - 28px)); }
  .masthead { padding-bottom: 15px; margin-bottom: 16px; }
  .dashboard { grid-template-columns: minmax(0,1fr); gap: 17px; }
  .history { padding: 15px; }
}
@media(max-width:345px) {
  .logo { width: 37px; height: 37px; padding-bottom: 10px; }
  .brand { gap: 8px; }
  .quiet { padding-inline: 8px; }
}

.header-actions { display: flex; align-items: center; gap: 6px; }
.report-button { color: #e7dcff; border-color: #65548b; background: #352755; }
.profile-button { display: flex; align-items: center; gap: 6px; padding: 0; max-width: 100%; text-align: left; border: 0; background: none; color: inherit; font: inherit; letter-spacing: inherit; }
#profileName { overflow-wrap: anywhere; }
.profile-edit { flex: 0 0 auto; color: var(--violet); font-size: .79em; }
.balance-top { gap: 12px; }
.range { display: flex; align-items: center; gap: 8px; min-height: 34px; color: #ede3ff; font-size: .79rem; font-weight: 670; }
.range button { display: grid; place-items: center; min-width: 38px; min-height: 36px; padding: 0; color: #f5f3ff; background: #1d153f80; border: 1px solid #ede6ff37; border-radius: 9px; font-size: 1.13rem; }
.range button:hover:not(:disabled) { background: #271d55; }
.range button:disabled { opacity: .35; cursor: default; }
.profile-field { display: block; margin-top: 14px; }
#reportDialog { width: min(590px, calc(100% - 28px)); }
.report-body { margin-top: 12px; }
.report-body h3 { font-size: 1.05rem; }
.report-body p { margin: 4px 0 10px; color: var(--muted); font-size: .82rem; }
.report-totals { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 6px; margin: 10px 0 12px; }
.report-totals div { border: 1px solid #51446d; border-radius: 9px; padding: 7px; }
.report-totals dt { font-size: .74rem; }
.report-totals dd { margin: 3px 0 0; font-size: .82rem; font-weight: 720; overflow-wrap: anywhere; }
.report-body table { width: 100%; border-collapse: collapse; font-size: .81rem; }
.report-body th,.report-body td { padding: 7px 4px; border-bottom: 1px solid #51446d; text-align: left; }
.report-body td:nth-child(2) { overflow-wrap: anywhere; }
.report-body th:last-child,.report-body td:last-child { text-align: right; white-space: nowrap; }
.report-actions { display: flex; gap: 7px; margin-top: 13px; }
.report-text { width: 100%; min-height: 95px; margin-top: 8px; }
@media(max-width:430px) {
  .masthead { flex-wrap: wrap; gap: 8px; }
  .header-actions { margin-left: auto; }
  .header-actions .quiet { min-height: 38px; padding-inline: 8px; }
}
@media print {
  :root,body { color-scheme: light; background: white !important; color: black; }
  .wrap,dialog,#status { display: none !important; }
  #printArea { display: block !important; }
  #printArea .report-body p { color: #222; }
  #printArea td,#printArea th,#printArea .report-totals div { border-color: #aaa; }
  #printArea tr { break-inside: avoid; }
  #printArea thead { display: table-header-group; }
}

.auth-wrap { display: grid; place-items: center; min-height: 100svh; padding: 24px 14px; }
.auth-card { width: min(100%,420px); padding: clamp(20px,6vw,30px); border: 1px solid #65548b; border-radius: 22px; background: linear-gradient(145deg,#292143,#191b2a 62%); box-shadow: 0 22px 50px #09051677; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.auth-card form label { display: block; margin-top: 14px; }
#authLoading { color: var(--muted); font-size: .83rem; }
#authSubmit:disabled,#logoutButton:disabled { opacity: .65; cursor: wait; }
@media print { .auth-wrap { display: none !important; } }
