:root {
  color-scheme: light;
  --bg: #f1f2f4;
  --surface: #ffffff;
  --ink: #16181d;
  --muted: #6b7280;
  --line: #e6e8ec;
  --pill: #eceef2;
  --positive: #168a57;
  --negative: #c43d3d;
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --sidebar-width: 232px;
  --sidebar-width-collapsed: 72px;
  --item-height: 44px;
  --item-gap: 4px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.4;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button {
  font: inherit;
  color: inherit;
}

h1,
h2,
h3,
p {
  margin: 0;
}

/* One focus treatment for everything interactive: a ring that shows on the keyboard and stays out of the way of the mouse. */
:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

#main:focus {
  outline: none;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 10;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

/* Layout */

.app {
  display: flex;
  gap: 12px;
  height: 100vh;
  height: 100dvh;
  padding: 12px;
  overflow: hidden;
}

.sidebar {
  display: flex;
  flex: none;
  flex-direction: column;
  gap: 24px;
  width: var(--sidebar-width);
  padding: 16px 12px;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.sidebar[data-collapsed="true"] {
  width: var(--sidebar-width-collapsed);
}

.main {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.stage {
  display: grid;
  flex: 1;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  /* The padding keeps focus rings of the first and last items from being clipped by the scroll container. */
  padding: 4px;
  margin: -4px;
  overflow-x: hidden;
  overflow-y: auto;
}

/* The leaving and the entering view share one cell. */
.view {
  grid-area: 1 / 1;
  min-width: 0;
}

/* Sidebar */

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 40px;
  padding: 0 4px;
  white-space: nowrap;
}

.brand-mark {
  display: grid;
  flex: none;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  font-weight: 700;
}

.brand-name {
  font-size: 1.0625rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.nav {
  flex: 1;
}

.nav-list {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--item-gap);
}

.nav-indicator {
  position: absolute;
  top: calc(var(--index) * (var(--item-height) + var(--item-gap)));
  right: 0;
  left: 0;
  height: var(--item-height);
  border-radius: var(--radius-sm);
  background: var(--pill);
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--item-height);
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}

.nav-item:hover,
.nav-item[aria-current="page"] {
  color: var(--ink);
}

.icon {
  flex: none;
}

.sidebar[data-collapsed="true"] .nav-item {
  justify-content: center;
  padding: 0;
}

.sidebar[data-collapsed="true"] :is(.brand-name, .nav-label, .user-text) {
  display: none;
}

.sidebar[data-collapsed="true"] .brand {
  justify-content: center;
  padding: 0;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  white-space: nowrap;
}

.sidebar[data-collapsed="true"] .user-chip {
  justify-content: center;
  padding: 8px 0;
}

.avatar {
  display: grid;
  flex: none;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
}

.user-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.user-name {
  font-size: 0.875rem;
  font-weight: 600;
}

.user-role {
  color: var(--muted);
  font-size: 0.75rem;
}

/* Top bar */

.topbar {
  display: flex;
  flex: none;
  align-items: center;
  gap: 12px;
  height: 48px;
}

.topbar-title {
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.icon-button {
  display: grid;
  flex: none;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}

.icon-button:hover {
  color: var(--ink);
}

.button {
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-weight: 600;
  cursor: pointer;
}

.button.primary {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

/* Cards */

.card {
  padding: 20px;
  border-radius: var(--radius-md);
  background: var(--surface);
}

.placeholder {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.placeholder h2 {
  font-size: 1.0625rem;
}

.placeholder p {
  color: var(--muted);
}

/* Overview */

.overview {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  /* Equal-width digits, so a counting number does not make its tile shimmer. */
  font-variant-numeric: tabular-nums;
}

.stat-note {
  color: var(--muted);
  font-size: 0.8125rem;
}

.progress {
  height: 8px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--pill);
}

.progress-fill {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: var(--positive);
  transform-origin: left;
}

.activity {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.activity h2 {
  font-size: 1.0625rem;
}

.activity-list {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
}

.activity-row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto minmax(96px, auto);
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.activity-row:first-child {
  border-top: 0;
}

.activity-avatar {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--muted);
  font-weight: 700;
}

.activity-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.activity-merchant {
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-category,
.activity-date {
  color: var(--muted);
  font-size: 0.8125rem;
}

.amount {
  font-weight: 600;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.amount.positive {
  color: var(--positive);
}

.amount.negative {
  color: var(--negative);
}

/* Bills */

[hidden] {
  display: none !important;
}

.bills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}

.bill-card {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 16px;
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}

.bill-card:hover {
  box-shadow: 0 6px 20px rgb(22 24 29 / 8%);
}

.bill-body {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 18px;
}

.bill-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
}

.bill-name {
  font-weight: 600;
}

.badge {
  flex: none;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--pill);
  color: var(--muted);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.bill-amount {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.bill-due {
  color: var(--muted);
  font-size: 0.875rem;
}

.bill-due.overdue {
  color: var(--negative);
  font-weight: 600;
}

.bill-due.paid {
  color: var(--positive);
  font-weight: 600;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding: 3px 10px 3px 3px;
  border-radius: 999px;
  background: var(--bg);
  font-size: 0.8125rem;
}

.chip-mark {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 700;
}

.paid-badge {
  position: absolute;
  right: 18px;
  bottom: 18px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--positive);
  color: #fff;
}

/* The dialog and its backdrop live in <body>; damped animates their opacity and box. */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgb(22 24 29 / 38%);
  opacity: 0;
  pointer-events: none;
}

.backdrop[data-open="true"] {
  pointer-events: auto;
}

.bill-dialog {
  position: fixed;
  inset: 0;
  z-index: 21;
  width: min(440px, calc(100vw - 32px));
  height: fit-content;
  max-height: calc(100dvh - 32px);
  margin: auto;
  overflow: hidden;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 24px 60px rgb(22 24 29 / 22%);
}

.bill-dialog:focus {
  outline: none;
}

.dialog-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 24px;
}

.dialog-body h2 {
  font-size: 1.125rem;
}

.dialog-amount {
  margin: 2px 0 0;
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.dialog-payee {
  font-weight: 600;
}

.dialog-route,
.dialog-note {
  color: var(--muted);
  font-size: 0.875rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
}

.field label {
  font-size: 0.8125rem;
  font-weight: 600;
}

.field input {
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font: inherit;
  font-variant-numeric: tabular-nums;
}

.field input[aria-invalid="true"] {
  border-color: var(--negative);
}

.field-error {
  color: var(--negative);
  font-size: 0.8125rem;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.button:disabled {
  opacity: 0.55;
  cursor: default;
}

/* Toasts */

.toast-region {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}

@media (max-width: 640px) {
  .toast-region {
    right: 0;
    left: 0;
    margin-inline: auto;
  }
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px 12px 14px;
  border-radius: var(--radius-md);
  background: var(--ink);
  box-shadow: 0 12px 32px rgb(22 24 29 / 24%);
  color: #fff;
  pointer-events: auto;
}

.toast-mark {
  display: grid;
  flex: none;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--positive);
}

.toast-message {
  flex: 1;
  margin: 0;
  font-size: 0.875rem;
  font-weight: 500;
}

.toast-close {
  display: grid;
  flex: none;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: rgb(255 255 255 / 70%);
  cursor: pointer;
}

.toast-close:hover {
  color: #fff;
}

.toast :focus-visible {
  outline-color: #fff;
}

/* Activity */

.activity-view {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.activity-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.net {
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.activity-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip-toggle {
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
}

.chip-toggle[aria-pressed="true"] {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.sort {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.875rem;
}

.sort select {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

/* The card paints its background on .tx-surface so that layer can glide to a new height on its own; the content sits above it. */
.tx-card {
  position: relative;
  padding-block: 8px;
  background: transparent;
}

.tx-surface {
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: var(--radius-md);
  background: var(--surface);
}

.tx-list {
  position: relative;
  z-index: 1;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tx-row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 48px 64px minmax(96px, auto) 36px;
  align-items: center;
  gap: 14px;
  height: 64px;
  border-top: 1px solid var(--line);
}

.tx-row:first-child {
  border-top: 0;
}

.tx-who {
  color: var(--muted);
  font-size: 0.8125rem;
}

.tx-delete {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.tx-delete:hover {
  background: var(--bg);
  color: var(--negative);
}

.tx-empty {
  position: relative;
  z-index: 1;
  padding: 24px 0;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 720px) {
  .tx-row {
    grid-template-columns: 40px minmax(0, 1fr) 64px minmax(88px, auto) 36px;
  }

  .tx-who {
    display: none;
  }
}

.toast-action {
  flex: none;
  height: 28px;
  padding: 0 10px;
  border: 1px solid rgb(255 255 255 / 35%);
  border-radius: 8px;
  background: transparent;
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
}

.toast-action:hover {
  background: rgb(255 255 255 / 12%);
}

/* Spring lab */

.lab {
  position: fixed;
  z-index: 15;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  overflow-y: auto;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: 0 18px 48px rgb(22 24 29 / 20%);
  /* top, right, width and max-height come from the button the lab is anchored to. */
  transform-origin: top right;
}

.lab h2 {
  font-size: 1.0625rem;
}

.lab h3 {
  font-size: 0.875rem;
}

.lab-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.lab-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 0.875rem;
}

.lab-label label {
  font-weight: 600;
}

.lab-label output {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.lab input[type="range"] {
  width: 100%;
  accent-color: var(--ink);
}

.lab-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.875rem;
}

.lab-hint {
  color: var(--muted);
  font-size: 0.8125rem;
}

.lab-demo {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.lab-track {
  position: relative;
  height: 64px;
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.lab-dot {
  position: absolute;
  left: 8px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
}

.lab-dot.is-compositor {
  top: 12px;
}

.lab-dot.is-js {
  top: 36px;
}

.is-compositor {
  background: var(--positive);
}

.is-js {
  background: var(--ink);
}

.lab-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.8125rem;
}

.swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-left: 8px;
  border-radius: 50%;
}

.swatch:first-child {
  margin-left: 0;
}
