:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: dark;
  --page: #191919;
  --surface: #252525;
  --glass: #303030;
  --ink: #f5f5f5;
  --muted: #c0c0c0;
  --line: rgba(255, 255, 255, .12);
  --field-line: #9a9a9a;
  --focus: #efefef;
  --error: #ffaaaa;
  --glass-edge: rgba(255, 255, 255, .23);
  --glass-light: linear-gradient(158deg, rgba(255, 255, 255, .13), transparent 54%);
  --glass-shadow: inset 0 1px 0 rgba(255, 255, 255, .14), 0 12px 34px rgba(0, 0, 0, .22);
  --control-light: linear-gradient(165deg, rgba(255, 255, 255, .10), rgba(255, 255, 255, .03));
  --control-hover: linear-gradient(165deg, rgba(255, 255, 255, .18), rgba(255, 255, 255, .08));
  background: var(--page);
  color: var(--ink);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  grid-template-rows: 1fr;
  min-height: 100vh;
  background:
    radial-gradient(ellipse 52rem 30rem at 12% 0, #363636, transparent 98%),
    radial-gradient(ellipse 46rem 30rem at 97% 28%, #262626, transparent),
    var(--page);
}

a { color: var(--ink); text-decoration-color: var(--muted); text-underline-offset: .2em; }
a:hover { text-decoration-color: currentColor; }

:where(a, button, input, select):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

aside,
main > header,
.login-card,
#category-dialog,
#account-dialog {
  border: 1px solid var(--glass-edge);
  background: var(--glass-light), var(--glass);
  box-shadow: var(--glass-shadow);
}

@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  aside,
  main > header,
  .login-card,
  #category-dialog,
  #account-dialog {
    background-color: rgba(40, 40, 40, .78);
    -webkit-backdrop-filter: blur(22px);
    backdrop-filter: blur(22px);
  }
}

aside {
  align-self: start;
  min-width: 0;
  margin: 18px 0 18px 18px;
  padding: 20px 14px 17px;
  border-radius: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding-inline: 4px;
  color: var(--ink);
  font-size: 21px;
  font-weight: 720;
  letter-spacing: -.035em;
  text-decoration: none;
}
.brand img { flex: none; }

.caption { margin: 10px 5px 22px; color: var(--muted); font-size: 12px; }

nav { display: grid; gap: 4px; }

nav a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 13px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}

nav a[aria-current="page"] {
  border-color: var(--glass-edge);
  background: var(--control-hover);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .15);
  color: var(--ink);
}

.aside-note {
  margin: 18px 4px 0;
  padding-top: 15px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

main { min-width: 0; padding: 0 clamp(18px, 3vw, 44px) 28px; }

main > header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 56px;
  margin-top: 18px;
  padding: 6px 9px 6px 16px;
  border-radius: 22px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}

.heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 16px;
  margin: 28px 0 18px;
}

h1 { margin: 0; overflow-wrap: anywhere; font-size: clamp(28px, 3vw, 43px); line-height: 1.13; letter-spacing: -.04em; }
h2 { margin: 0 0 16px; font-size: 18px; letter-spacing: -.02em; }
.muted, .note, footer { color: var(--muted); font-size: 13px; line-height: 1.6; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 18px 0; }

.metric, .panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 19px;
  background: var(--surface);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .12);
}

.metric { padding: 17px 16px; overflow-wrap: anywhere; }
.metric p { margin: 0 0 10px; color: var(--muted); font-size: 13px; line-height: 1.4; }
.metric strong { display: block; font-size: clamp(24px, 2.8vw, 36px); font-variant-numeric: tabular-nums; letter-spacing: -.04em; }
.panel { padding: 21px; margin-bottom: 16px; }
.overview-grid { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); gap: 16px; }
.balance-list { margin: 0; }
.balance-list div { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.balance-list div:last-child { border-bottom: 0; }
dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.note { margin: 14px 0 0; }

.table-scroll { overflow: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; white-space: nowrap; font-size: 13px; }
th { color: var(--muted); font-size: 12px; font-weight: 600; padding: 0 13px 12px 0; }
td { padding: 13px 13px 13px 0; border-top: 1px solid var(--line); }
td:last-child, th:last-child { padding-right: 0; }

.badge {
  display: inline-block;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .07);
  font-size: 12px;
}

.text-link { display: inline-block; margin-top: 12px; font-size: 14px; }
.search { display: grid; gap: 8px; max-width: 380px; margin: 0 0 20px; color: var(--muted); font-size: 13px; }

input, select {
  min-width: 0;
  min-height: 44px;
  padding: 9px 13px;
  border: 1px solid var(--field-line);
  border-radius: 14px;
  background: #202020;
  color: var(--ink);
  font: inherit;
}

input::placeholder { color: var(--muted); opacity: 1; }
footer { padding-top: 14px; }
section[hidden] { display: none; }
#status { max-width: 80ch; }

button { font: inherit; cursor: pointer; }

.signout,
.pager button,
.login-submit {
  min-height: 42px;
  padding: 8px 14px;
  border: 1px solid var(--glass-edge);
  border-radius: 999px;
  background: var(--control-light);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .13);
  color: var(--ink);
  font-weight: 600;
}

.pager { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 18px; font-size: 13px; }
.pager button:disabled { opacity: .5; cursor: default; }

.login-page { grid-template-columns: minmax(0, 1fr); place-items: center; padding: 18px; }
.login-card { width: min(100%, 432px); padding: clamp(20px, 5vw, 32px); border-radius: 28px; }
.login-card h1 { margin-top: 14px; font-size: clamp(23px, 5vw, 30px); }
.login-card form { display: grid; gap: 16px; margin-top: 24px; }
.login-card label { display: grid; gap: 8px; font-size: 14px; }

.login-submit, #credit-submit {
  border-color: #bcbcbc;
  background: linear-gradient(#eee, #c7c7c7);
  color: #202020;
}

.error { color: var(--error); font-size: 14px; }

.credit-form { display: flex; flex-wrap: wrap; align-items: end; gap: 14px; margin-top: 15px; }
.credit-form label { display: grid; gap: 7px; min-width: min(150px, 100%); flex: 1; color: var(--muted); font-size: 13px; }
.credit-form label:first-child { flex: 0 1 180px; }
.credit-form input:disabled { opacity: .7; }
.credit-form button:disabled { opacity: .6; cursor: wait; }
#credit-status { margin-top: 12px; color: var(--ink); font-size: 14px; line-height: 1.5; }

.category-folders {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 202px), 1fr));
  gap: 10px;
}

.category-folder {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--control-light);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.35;
  text-align: left;
  overflow-wrap: anywhere;
}

.category-folder strong {
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .08);
  color: var(--ink);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.folder-symbol {
  position: relative;
  display: block;
  width: 22px;
  height: 15px;
  margin-top: 3px;
  border: 1.5px solid #c8c8c8;
  border-radius: 4px;
  background: #454545;
}

.folder-symbol::before {
  position: absolute;
  top: -5px;
  left: -1.5px;
  width: 10px;
  height: 5px;
  border: 1.5px solid #c8c8c8;
  border-bottom: 0;
  border-radius: 4px 4px 0 0;
  background: #454545;
  content: "";
}

#category-dialog {
  width: min(660px, calc(100% - 28px));
  max-height: calc(100% - 36px);
  padding: 24px;
  border-radius: 25px;
  color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .15), 0 22px 72px rgba(0, 0, 0, .55);
}

#category-dialog::backdrop, #account-dialog::backdrop { background: rgba(0, 0, 0, .60); }
.category-dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.category-dialog-header h2 { min-width: 0; margin: 0; font-size: 22px; overflow-wrap: anywhere; }
.category-dialog-header form { flex: none; }
#category-total { margin: 12px 0 18px; }
#category-ranking { max-height: 60vh; }
body:has(#category-dialog[open], #account-dialog[open]) { overflow: hidden; }

@media (hover: hover) {
  nav a:hover,
  .category-folder:hover,
  .signout:not(:disabled):hover,
  .pager button:not(:disabled):hover {
    border-color: var(--glass-edge);
    background: var(--control-hover);
    color: var(--ink);
  }

  nav a[aria-current="page"]:hover { border-color: rgba(255, 255, 255, .4); }
  .login-submit:hover, #credit-submit:not(:disabled):hover {
    border-color: #e1e1e1;
    background: linear-gradient(#fff, #d4d4d4);
    color: #202020;
  }
}

@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  nav a,
  button {
    transition: transform 180ms cubic-bezier(.2, .8, .2, 1);
  }

  nav a:hover,
  button:enabled:hover {
    transform: scale(1.04);
  }

  .category-folder:enabled:hover {
    transform: scale(1.025);
  }
}

@media (min-width: 651px) and (min-height: 480px) {
  html { scroll-padding-top: 88px; }
  aside, main > header { position: sticky; top: 18px; z-index: 1; }
}

@media (max-width: 1050px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overview-grid { grid-template-columns: minmax(0, 1fr); gap: 0; }
}

@media (max-width: 650px) {
  body { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  aside { margin: 10px 12px 0; padding: 12px 8px 8px; border-radius: 20px; }
  .caption, .aside-note { display: none; }
  .brand { padding-inline: 7px; font-size: 19px; }
  nav { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 8px; }
  nav a { padding-inline: 10px; font-size: 13px; }
  main { padding-inline: 12px; }
  main > header { margin-top: 10px; }
  .login-page { grid-template-rows: 1fr; }
  .metric { padding: 13px 11px; }
  .panel { padding: 16px; }
  .heading { margin-top: 22px; }
}

@media (max-width: 440px) {
  #category-dialog { padding: 16px; }
  .category-dialog-header h2 { font-size: 19px; }
  .category-dialog-header .signout { padding-inline: 10px; }
}

@media (prefers-reduced-transparency: reduce), (prefers-contrast: more) {
  aside, main > header, .login-card, #category-dialog, #account-dialog {
    background-color: #282828;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

#account-dialog {
  width: min(960px, calc(100% - 28px));
  max-height: calc(100% - 32px);
  --profile-padding: clamp(14px, 3vw, 26px);
  padding: 0;
  border-radius: 24px;
  color: var(--ink);
  overflow: auto;
  overscroll-behavior: contain;
}
#account-dialog .category-dialog-header {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 12px var(--profile-padding);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
#account-content { padding: 0 var(--profile-padding) var(--profile-padding); }
#account-status { margin: 10px var(--profile-padding); }
#account-history { max-height: min(45vh, 360px); }
#account-status:empty { display: none; }
#account-meta { margin-top: 11px; }
#account-dialog .panel:last-child { margin-bottom: 0; }
#account-dialog .pager:not(:empty) { margin: 12px 0 0; }
@media (max-width: 440px) {
  #account-dialog .category-dialog-header { align-items: start; }
  #account-dialog .category-dialog-header .signout { white-space: nowrap; }
}

.header-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-inline-start: auto; }
.header-actions .site-link { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
