@font-face {
  font-family: "Geist";
  src: url("/fonts/geist-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Geist Mono";
  src: url("/fonts/geist-mono-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --font-ui: "Geist", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Geist Mono", "SFMono-Regular", Consolas, monospace;
  --ground: #f2f4f7;
  --surface: #ffffff;
  --raised: #f7f8fa;
  --sunken: #eef1f4;
  --ink: #111315;
  --ink-soft: #2b3035;
  --muted: #5c636a;
  --faint: #6f767e;
  --border: #e3e7eb;
  --rule: #edf0f3;
  --control: #cfd5db;
  --accent: #1d5fbf;
  --accent-soft: #e8f0fc;
  --accent-ink: #0d3f86;
  --positive: #2e7d32;
  --negative: #c4242a;
  --warning: #92400e;
  --chart-ink: #141414;
  --chart-grey: #aab2bc;
  --chart-grid: #e7ebef;
  --chart-surface: #ffffff;
  --chart-text: #111315;
  --chart-muted: #5c636a;
  --border-subtle: #eef1f4;
  --radius-card: 8px;
  --radius-control: 6px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

a {
  color: inherit;
  text-decoration-color: var(--control);
  text-underline-offset: 2px;
}

a:hover {
  text-decoration-color: currentColor;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

::selection {
  background: #dbe7f8;
  color: var(--ink);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: var(--radius-control);
  background: var(--ink);
  color: var(--surface);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transform: translateY(-160%);
}

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

/* Shell */

.app-shell {
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  align-self: start;
  height: 100vh;
  min-height: 0;
  padding: 22px 16px 18px;
  overflow-y: auto;
  background: var(--raised);
  border-right: 1px solid var(--border);
}

.brand-lockup {
  padding: 2px 10px 26px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.015em;
  line-height: 1;
  text-decoration: none;
}

.brand-mark {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
}

.brand-name {
  padding-top: 1px;
}

.brand-scope {
  margin: 10px 0 0 34px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.nav {
  flex: 1 1 auto;
}

.nav-group {
  margin-bottom: 24px;
}

.nav-group-label {
  margin: 0 10px 8px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.4;
}

.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 36px;
  padding: 7px 10px;
  border-radius: var(--radius-control);
  color: #3f454c;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.35;
  text-decoration: none;
}

.nav-link:hover {
  background: #eef1f4;
  color: var(--ink);
}

.nav-link[aria-current="page"] {
  background: #e6eaef;
  color: var(--ink);
  font-weight: 500;
}

.nav-link[aria-current="page"]::before {
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 0;
  width: 2px;
  border-radius: 1px;
  background: var(--ink);
  content: "";
}

.sidebar-foot {
  display: grid;
  gap: 12px;
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 0 4px;
}

.user-initial {
  display: grid;
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid #dfe4e9;
  border-radius: 50%;
  background: #e9edf1;
  color: #3f454c;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
}

.sidebar-user-copy {
  display: grid;
  min-width: 0;
  gap: 1px;
}

.sidebar-username {
  overflow: hidden;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-role {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.35;
}

.sidebar-foot .button {
  width: 100%;
}

.mobile-bar {
  display: none;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgb(17 19 21 / 32%);
}

.app-main {
  min-width: 0;
}

.page {
  width: min(100%, 1180px);
  margin: 0 auto;
  padding: 32px 36px 64px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin: 4px 0 28px;
}

.page-head h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 500;
  letter-spacing: -0.025em;
  line-height: 1.25;
}

.page-head .muted,
.page-subtitle {
  max-width: 68ch;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.page-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 2px;
}

/* Type and utilities */

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

.hint {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.45;
}

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

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

.amount,
.money {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  white-space: nowrap;
}

.amount {
  text-align: right;
}

code {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

.table-date {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.note {
  max-width: 24rem;
  overflow-wrap: anywhere;
}

.transfer-arrow {
  padding: 0 3px;
  color: var(--faint);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Cards and layout blocks */

.card {
  min-width: 0;
  margin: 0 0 16px;
  padding: 20px 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
}

.card:last-child {
  margin-bottom: 0;
}

.card h2 {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.015em;
  line-height: 1.35;
}

.card h3 {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
}

.card p {
  margin: 0 0 12px;
}

.card p:last-child {
  margin-bottom: 0;
}

.card > .muted {
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 13px;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.card-head h2 {
  margin: 0;
}

.card-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.section-meta {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
  white-space: nowrap;
}

.panel-grid {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-grid > .card {
  margin-bottom: 0;
}

.dashboard-split {
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
}

.chart-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.category-layout,
.page-split,
.csv-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.8fr) minmax(0, 1.35fr);
  gap: 16px;
  align-items: start;
}

.category-layout > *,
.page-split > *,
.csv-layout > * {
  min-width: 0;
}

.category-main {
  display: grid;
  gap: 16px;
}

.category-main > .card,
.category-layout > .card,
.page-split > .card,
.csv-layout > .card {
  margin-bottom: 0;
}

/* Metrics */

.metrics-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
}

.metric {
  min-width: 0;
  padding: 18px 24px 20px;
}

.metric + .metric {
  border-left: 1px solid var(--rule);
}

.metric-label {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 400;
  line-height: 1.4;
}

.metric-value {
  margin: 0;
  overflow-wrap: anywhere;
  font-family: var(--font-mono);
  font-size: clamp(22px, 2.2vw, 30px);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.15;
}

.metric-value.text-negative {
  color: var(--negative);
}

.metric-note {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin: 0;
}

.summary-grid > div {
  min-width: 0;
}

.summary-label {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
}

.summary-value {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 22px;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

/* Forms */

.form {
  display: grid;
  gap: 16px;
  max-width: 560px;
}

.form-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  max-width: none;
}

.form-inline .field {
  flex: 1 1 150px;
  max-width: 240px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.field {
  display: grid;
  min-width: 0;
  gap: 6px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
}

.field input {
  min-width: 0;
}

.field-wide {
  grid-column: 1 / -1;
}

.transaction-form {
  max-width: none;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid var(--control);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 400;
  line-height: 1.45;
}

input::placeholder,
textarea::placeholder {
  color: var(--faint);
}

input:hover,
select:hover,
textarea:hover {
  border-color: #b9c1c9;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  border-color: var(--accent);
  outline: 2px solid rgb(29 95 191 / 18%);
  outline-offset: 0;
}

select {
  padding-right: 32px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='m3 4.75 3 3 3-3' fill='none' stroke='%235c636a' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-position: right 10px center;
  background-repeat: no-repeat;
  background-size: 12px;
}

textarea {
  min-height: 88px;
  resize: vertical;
}

input[type="file"] {
  padding: 6px 8px;
}

input[type="file"]::file-selector-button {
  margin-right: 10px;
  padding: 4px 9px;
  border: 1px solid var(--control);
  border-radius: 4px;
  background: var(--raised);
  color: var(--ink);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}

/* Buttons */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  background: var(--ink);
  color: var(--surface);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.button:hover {
  background: #2b3035;
  color: var(--surface);
}

.button:active {
  background: #000000;
}

.button-quiet {
  border-color: var(--control);
  background: var(--surface);
  color: var(--ink);
}

.button-quiet:hover {
  border-color: #b9c1c9;
  background: var(--raised);
  color: var(--ink);
}

.button-danger {
  border-color: transparent;
  background: transparent;
  color: var(--negative);
}

.button-danger:hover {
  border-color: transparent;
  background: #ffedea;
  color: #831c1e;
}

.button-small {
  min-height: 30px;
  padding: 0 9px;
  font-size: 12.5px;
}

.form .button {
  justify-self: start;
}

.inline-form {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.input-small {
  width: auto;
  max-width: 8.5rem;
  min-height: 30px;
  padding: 4px 7px;
  font-family: var(--font-mono);
  font-size: 12px;
}

.month-field {
  display: flex;
}

.month-field input {
  width: 150px;
}

/* Tables */

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: middle;
}

th {
  padding-top: 0;
  padding-bottom: 9px;
  border-bottom-color: var(--border);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
  white-space: nowrap;
}

th.amount {
  font-family: var(--font-ui);
  font-weight: 500;
}

td {
  line-height: 1.45;
}

th:first-child,
td:first-child {
  padding-left: 0;
}

th:last-child,
td:last-child {
  padding-right: 0;
}

tbody tr:hover {
  background: #fafbfc;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tr:last-child td {
  border-bottom: 0;
}

.table-lead {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.table-note {
  color: var(--muted);
}

.table-number {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.transactions-table {
  min-width: 760px;
}

.accounts-table {
  min-width: 520px;
}

.account-form {
  grid-template-columns:
    minmax(0, 1.35fr) minmax(140px, 0.75fr)
    minmax(150px, 0.8fr) auto;
  gap: 12px 16px;
  align-items: end;
  max-width: none;
}

.account-form-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
}

.account-form-hint {
  margin-top: 10px;
}

.account-ledger {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(250px, 1fr);
  gap: 28px;
  align-items: start;
}

.balance-chart {
  min-width: 0;
  padding-left: 28px;
  border-left: 1px solid var(--rule);
}

.balance-chart h3 {
  margin: 0;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.4;
}

.balance-list {
  display: grid;
  gap: 12px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.balance-row {
  min-width: 0;
}

.balance-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.balance-name {
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.balance-value {
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 500;
}

.balance-value.text-negative {
  color: var(--negative);
}

.balance-track {
  height: 6px;
  margin-top: 6px;
  overflow: hidden;
  border-radius: 3px;
  background: var(--sunken);
}

.balance-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.balance-fill-negative {
  background: var(--negative);
}

.balance-chart > .hint {
  margin: 12px 0 0;
}

.category-table {
  min-width: 440px;
}

.budget-table {
  min-width: 760px;
}

.budget-table td:last-child {
  min-width: 200px;
}

/* Guidance cards and member list */

.category-side {
  display: grid;
  gap: 16px;
  align-content: start;
}

.category-side > .card,
.category-main > .card {
  margin-bottom: 0;
}

.category-guide .muted {
  margin-bottom: 0;
}

.guide-list {
  display: grid;
  gap: 10px;
  margin: 14px 0 0;
  padding: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
  list-style: none;
}

.guide-list li {
  position: relative;
  padding-left: 16px;
}

.guide-list li::before {
  position: absolute;
  top: 0.6em;
  left: 0;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  content: "";
}

.member-form {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 12px 16px;
  align-items: end;
  max-width: none;
}

.member-form-actions {
  display: flex;
  align-items: center;
  min-height: 36px;
}

.member-ledger {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(240px, 1fr);
  gap: 28px;
  align-items: start;
}

.member-notes {
  min-width: 0;
  padding-left: 28px;
  border-left: 1px solid var(--rule);
}

.member-notes h3 {
  margin: 0;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.4;
}

.member-notes .guide-list {
  margin-top: 14px;
}

/* Transaction guidance */

.form-guide {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
}

.form-guide > div {
  padding: 18px 22px;
}

.form-guide > div + div {
  border-left: 1px solid var(--rule);
}

.form-guide h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
}

.form-guide p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
}

/* CSV format reference */

.csv-format {
  margin-top: 16px;
}

.csv-format-list {
  display: grid;
  margin: 0;
}

.csv-format-list > div {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) minmax(140px, auto);
  gap: 16px;
  align-items: baseline;
  padding: 10px 0;
  border-top: 1px solid var(--rule);
}

.csv-format-list > div:first-child {
  padding-top: 0;
  border-top: 0;
}

.csv-format-list > div:last-child {
  padding-bottom: 0;
}

.csv-format-list dt {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 500;
}

.csv-format-list dd {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.csv-format-list .csv-example {
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 12px;
  text-align: right;
  white-space: nowrap;
}

.csv-format > .hint {
  margin: 14px 0 0;
}

/* Badges and progress */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 21px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--sunken);
  color: #3d434a;
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.35;
  white-space: nowrap;
}

.badge::before {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  content: "";
  opacity: 0.8;
}

.badge-active,
.badge-safe {
  background: #e7f4eb;
  color: #205c34;
}

.badge-inactive {
  background: #f4e9e8;
  color: #7a2f2b;
}

.badge-warning {
  background: #fbf3e4;
  color: #75450f;
}

.badge-over {
  background: #ffedea;
  color: #831c1e;
}

.badge-income {
  background: #eaf4ee;
  color: #285b3f;
}

.badge-expense {
  background: #f8edec;
  color: #7a3230;
}

.badge-transfer {
  background: var(--sunken);
  color: #3d434a;
}

.progress {
  width: 100%;
  min-width: 120px;
  height: 6px;
  overflow: hidden;
  border-radius: 3px;
  background: var(--sunken);
}

.progress-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--ink);
}

.progress-safe {
  background: var(--accent);
}

.progress-warning {
  background: #b7791f;
}

.progress-over {
  background: var(--negative);
}

.progress-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

/* Alerts */

.alert {
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  color: var(--ink);
  font-size: 13.5px;
  line-height: 1.5;
}

.alert p {
  margin: 0 0 8px;
}

.alert p:last-child {
  margin-bottom: 0;
}

.alert-error {
  border-color: #ecc9c6;
  background: #fff7f6;
  color: #7a2f2b;
}

.alert-success {
  border-color: #c9e3d2;
  background: #f5fbf7;
  color: #24563a;
}

.alert-warning {
  border-color: #e8d6b9;
  background: #fffbf3;
  color: #6f430e;
}

/* Charts and ledger lists */

.chart-card {
  display: flex;
  flex-direction: column;
}

.chart-canvas {
  position: relative;
  width: 100%;
  height: 260px;
  min-height: 240px;
  margin-top: 20px;
}

.chart-card .chart-canvas {
  flex: 1 1 auto;
}

.balance-card .chart-canvas {
  flex: 0 0 auto;
  height: 240px;
}

.chart-canvas canvas {
  width: 100% !important;
  height: 100% !important;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  padding-top: 2px;
}

.legend-key {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.legend-key::before {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--chart-grey);
  content: "";
}

.legend-income::before {
  background: var(--accent);
}

.legend-expense::before {
  background: var(--chart-grey);
}

.legend-balance::before {
  background: var(--chart-ink);
}

.legend-category::before {
  background: var(--accent);
}

.chart-caption {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.chart-caption strong {
  color: var(--ink);
  font-family: var(--font-mono);
  font-weight: 500;
}

.category-list {
  display: grid;
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
}

.category-row {
  min-width: 0;
  padding: 13px 0;
  border-top: 1px solid var(--rule);
}

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

.category-row:last-child {
  padding-bottom: 0;
}

.category-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.category-name {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.category-figures {
  display: flex;
  flex: 0 0 auto;
  align-items: baseline;
  gap: 10px;
}

.category-share {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.category-amount {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  white-space: nowrap;
}

.category-track {
  height: 5px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 3px;
  background: var(--rule);
}

.category-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.data-table {
  padding: 0;
  overflow: hidden;
}

.data-table summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.4;
  list-style: none;
  cursor: pointer;
}

.data-table summary::-webkit-details-marker {
  display: none;
}

.data-table summary::after {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  content: "Buka";
}

.data-table[open] summary {
  border-bottom: 1px solid var(--rule);
}

.data-table[open] summary::after {
  content: "Tutup";
}

.data-table .table-wrap {
  padding: 4px 24px 16px;
}

.data-table-inline {
  margin-top: 16px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-control);
  background: #fbfcfd;
}

.data-table-inline summary {
  padding: 11px 14px;
  font-size: 12.5px;
  font-weight: 400;
}

.data-table-inline .table-wrap {
  padding: 0 14px 12px;
}

.empty-state {
  margin: 16px 0 0;
  padding: 24px 16px;
  border: 1px dashed var(--control);
  border-radius: var(--radius-control);
  background: #fafbfc;
  color: var(--muted);
  font-size: 13.5px;
  text-align: center;
}

/* Import and export */

.import-result {
  margin: 0 0 18px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--raised);
}

.import-result h3 {
  margin: 0 0 14px;
}

.import-result .table-wrap {
  margin-top: 14px;
}

.import-result .table-wrap table {
  font-size: 12.5px;
}

/* Settings */

.settings-stack {
  margin-bottom: 16px;
  padding: 0 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
}

.settings-row {
  display: grid;
  grid-template-columns: minmax(220px, 0.78fr) minmax(0, 1.5fr);
  gap: 40px;
  align-items: start;
  padding: 28px 0;
  border-top: 1px solid var(--rule);
}

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

.settings-intro h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.35;
}

.settings-intro p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.settings-intro .hint {
  margin-top: 10px;
}

.settings-panel {
  min-width: 0;
  padding: 20px;
  border-radius: var(--radius-card);
  background: var(--raised);
}

.settings-panel .form {
  max-width: 600px;
}

.settings-panel .form-inline {
  max-width: none;
}

.settings-panel > p:first-child {
  margin-top: 0;
}

.settings-panel > p:last-child {
  margin-bottom: 0;
}

.settings-panel .table-wrap {
  margin-top: 16px;
}

.settings-panel .alert {
  margin-bottom: 16px;
}

.token-value {
  display: block;
  padding: 10px 12px;
  overflow-wrap: anywhere;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  user-select: all;
}

/* Sign in and notices */

.auth-body {
  background: var(--ground);
}

.auth-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.auth-page-split {
  display: block;
  padding: 0;
}

.auth-shell {
  display: grid;
  width: 100%;
  grid-template-columns: minmax(0, 1.1fr) minmax(430px, 0.9fr);
  min-height: 100vh;
}

.auth-aside {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 40px;
  padding: clamp(40px, 6vw, 88px);
  border-right: 1px solid var(--border);
  background: var(--raised);
}

.auth-aside .auth-brand {
  margin: 0;
}

.auth-aside-copy {
  max-width: 500px;
}

.auth-aside-copy h2 {
  margin: 0;
  font-size: clamp(30px, 3vw, 42px);
  font-weight: 500;
  letter-spacing: -0.035em;
  line-height: 1.1;
}

.auth-aside-copy p {
  max-width: 42ch;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.auth-points {
  display: grid;
  gap: 12px;
  max-width: 480px;
  margin: 0;
  padding: 0;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.5;
  list-style: none;
}

.auth-points li {
  position: relative;
  padding-left: 18px;
}

.auth-points li::before {
  position: absolute;
  top: 0.55em;
  left: 0;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  content: "";
}

.auth-aside-foot {
  max-width: 44ch;
  margin: 0;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.auth-panel {
  display: grid;
  min-width: 0;
  place-items: center;
  padding: 40px;
  background: transparent;
}

.auth-shell .auth-card {
  width: min(440px, 100%);
  padding: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
}

.auth-shell .auth-card .auth-brand,
.auth-shell .auth-card .auth-brand-scope {
  display: none;
}

.auth-card {
  width: min(400px, 100%);
  margin: 0;
  padding: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 30px;
  color: var(--ink);
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.015em;
  line-height: 1;
}

.auth-brand .brand-mark {
  width: 26px;
  height: 26px;
}

.auth-brand-scope {
  margin: -22px 0 30px 36px;
  color: var(--muted);
  font-size: 13px;
}

.auth-card h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 500;
  letter-spacing: -0.025em;
  line-height: 1.25;
}

.auth-card > .muted {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.5;
}

.auth-card .form {
  max-width: none;
  margin-top: 24px;
}

.auth-card .button {
  width: 100%;
}

.auth-card .alert {
  margin-top: 18px;
  margin-bottom: 0;
}

.auth-note {
  margin: 22px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.notice-actions {
  margin: 22px 0 0;
}

.auth-card .notice-actions {
  margin-top: 20px;
}

.notice-card {
  width: min(560px, 100%);
  margin: 8vh auto 0;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
}

.notice-card h1 {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 500;
  letter-spacing: -0.025em;
  line-height: 1.25;
}

.notice-card p {
  margin: 0 0 18px;
  color: var(--muted);
}

.notice-card p:last-child {
  margin-bottom: 0;
}

/* Motion */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* Responsive */

@media (max-width: 1180px) {
  .page {
    padding: 28px 28px 56px;
  }
}

@media (max-width: 1080px) {
  .dashboard-split,
  .chart-grid,
  .category-layout,
  .page-split,
  .csv-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .settings-row {
    grid-template-columns: minmax(180px, 0.7fr) minmax(0, 1.3fr);
    gap: 28px;
  }

  .account-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .account-form-actions {
    grid-column: 1 / -1;
  }

  .account-ledger {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
  }

  .balance-chart {
    padding-top: 20px;
    padding-left: 0;
    border-top: 1px solid var(--rule);
    border-left: 0;
  }

  .member-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .member-form-actions {
    grid-column: 1 / -1;
  }

  .member-ledger {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
  }

  .member-notes {
    padding-top: 20px;
    padding-left: 0;
    border-top: 1px solid var(--rule);
    border-left: 0;
  }
}

@media (max-width: 900px) {
  body.nav-open {
    overflow: hidden;
  }

  .app-shell {
    display: block;
  }

  .mobile-bar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
  }

  .mobile-bar .brand {
    font-size: 16px;
  }

  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 36px;
    padding: 0 10px;
    border: 1px solid var(--control);
    border-radius: var(--radius-control);
    background: var(--surface);
    color: var(--ink);
    font-size: 12.5px;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
  }

  .nav-toggle:hover {
    background: var(--raised);
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 40;
    width: min(288px, calc(100vw - 48px));
    height: 100vh;
    padding: 20px 16px 18px;
    border-right: 1px solid var(--border);
    background: var(--surface);
    transform: translateX(-102%);
    transition: transform 180ms ease;
  }

  body.nav-open .sidebar {
    transform: none;
  }

  .sidebar .nav-link {
    min-height: 42px;
  }

  .page {
    padding: 24px 20px 48px;
  }

  .page-head {
    margin-top: 0;
  }

  .settings-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    padding: 24px 0;
  }

  .auth-shell {
    display: block;
    min-height: 100vh;
  }

  .auth-aside {
    display: none;
  }

  .auth-panel {
    min-height: 100vh;
    padding: 24px;
    background: var(--ground);
  }

  .auth-shell .auth-card {
    width: min(400px, 100%);
    padding: 32px;
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    background: var(--surface);
  }

  .auth-shell .auth-card .auth-brand {
    display: flex;
  }

  .auth-shell .auth-card .auth-brand-scope {
    display: block;
  }
}

@media (max-width: 760px) {
  .page-head {
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
  }

  .page-actions {
    width: 100%;
    justify-content: flex-start;
    padding-top: 0;
  }

  .page-actions .button {
    flex: 1 1 auto;
  }

  .month-field {
    flex: 1 1 160px;
  }

  .month-field input {
    width: 100%;
  }

  .form-inline .field {
    max-width: none;
  }

  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .settings-stack {
    padding: 0 20px;
  }
}

@media (max-width: 640px) {
  .page {
    padding: 20px 16px 40px;
  }

  .mobile-bar {
    padding: 0 16px;
  }

  .page-head h1 {
    font-size: 22px;
  }

  .metrics-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .metric {
    padding: 16px 18px;
  }

  .metric + .metric {
    border-top: 1px solid var(--rule);
    border-left: 0;
  }

  .metric-value {
    font-size: 26px;
  }

  .account-form {
    grid-template-columns: minmax(0, 1fr);
  }

  .account-form-actions {
    flex-wrap: wrap;
  }

  .category-side {
    gap: 12px;
  }

  .member-form {
    grid-template-columns: minmax(0, 1fr);
  }

  .member-form-actions {
    flex-wrap: wrap;
  }

  .form-guide {
    grid-template-columns: minmax(0, 1fr);
  }

  .form-guide > div + div {
    border-top: 1px solid var(--rule);
    border-left: 0;
  }

  .csv-format-list > div {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
  }

  .csv-format-list .csv-example {
    text-align: left;
  }

  /* Phone table rows: each table becomes a two-line list. */

  .stack-table {
    display: block;
    min-width: 0;
  }

  .stack-table thead {
    display: none;
  }

  .stack-table tbody {
    display: block;
  }

  .stack-table tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 3px 12px;
    align-items: baseline;
    padding: 12px 0;
    border-top: 1px solid var(--rule);
  }

  .stack-table tbody tr:first-child {
    border-top: 0;
  }

  .stack-table tbody tr:hover {
    background: transparent;
  }

  .stack-table td {
    min-width: 0;
    padding: 0;
    border: 0;
  }

  .stack-table .empty-cell {
    grid-column: 1 / -1;
    padding: 8px 0;
    color: var(--muted);
  }

  .stack-table .cell-title {
    grid-area: 1 / 1 / 2 / 2;
    overflow-wrap: anywhere;
    color: var(--ink);
    font-weight: 500;
  }

  .stack-table .cell-money {
    grid-area: 1 / 2 / 2 / 3;
    justify-self: end;
    text-align: right;
    white-space: nowrap;
  }

  .stack-table .cell-meta {
    grid-area: 2 / 1 / 3 / 2;
    color: var(--muted);
    font-size: 12.5px;
  }

  .stack-table .cell-badge {
    grid-area: 2 / 2 / 3 / 3;
    justify-self: end;
  }

  .stack-table .cell-actions {
    grid-area: 3 / 1 / 4 / 3;
    margin-top: 8px;
  }

  .stack-table .cell-actions .row-actions {
    flex-wrap: wrap;
  }

  .category-table .cell-badge {
    grid-area: 1 / 2 / 2 / 3;
  }

  .category-table .cell-meta {
    grid-area: 2 / 1 / 3 / 3;
  }

  .budget-table .cell-remaining {
    grid-area: 1 / 2 / 2 / 3;
  }

  .budget-table .cell-remaining::before {
    color: var(--muted);
    font-family: var(--font-ui);
    font-size: 12.5px;
    font-weight: 400;
    content: "Sisa ";
  }

  .budget-table .cell-budget {
    grid-area: 2 / 1 / 3 / 2;
    color: var(--muted);
    font-size: 12.5px;
  }

  .budget-table .cell-spent {
    grid-area: 2 / 2 / 3 / 3;
    justify-self: end;
    color: var(--muted);
    font-size: 12.5px;
  }

  .budget-table .cell-budget::before {
    content: "Anggaran ";
  }

  .budget-table .cell-spent::before {
    content: "Terpakai ";
  }

  .budget-table .cell-progress {
    grid-area: 3 / 1 / 4 / 3;
    margin-top: 6px;
  }

  .budget-table .cell-actions {
    grid-area: 4 / 1 / 5 / 3;
  }

  .transactions-table .cell-date {
    grid-area: 2 / 1 / 3 / 2;
    color: var(--muted);
    font-size: 12.5px;
  }

  .transactions-table .cell-type {
    grid-area: 2 / 2 / 3 / 3;
    justify-self: end;
  }

  .transactions-table .cell-account {
    grid-area: 3 / 1 / 4 / 3;
    color: var(--muted);
    font-size: 12.5px;
  }

  .transactions-table .cell-note {
    grid-area: 4 / 1 / 5 / 3;
    color: var(--muted);
    font-size: 12.5px;
  }

  .transactions-table .cell-note:empty {
    display: none;
  }

  .transactions-table .cell-actions {
    grid-area: 5 / 1 / 6 / 3;
  }

  .members-table .cell-badge {
    grid-area: 1 / 2 / 2 / 3;
  }

  .members-table .cell-date {
    grid-area: 2 / 2 / 3 / 3;
    justify-self: end;
    color: var(--muted);
    font-size: 12.5px;
  }

  .members-table .cell-date::before {
    content: "Dibuat ";
  }

  .tokens-table .cell-badge {
    grid-area: 1 / 2 / 2 / 3;
  }

  .tokens-table .cell-created {
    grid-area: 2 / 1 / 3 / 2;
    color: var(--muted);
    font-size: 12.5px;
  }

  .tokens-table .cell-last-used {
    grid-area: 2 / 2 / 3 / 3;
    justify-self: end;
    color: var(--muted);
    font-size: 12.5px;
  }

  .tokens-table .cell-created::before {
    content: "Dibuat ";
  }

  .tokens-table .cell-last-used::before {
    content: "Dipakai ";
  }

  .csv-fail-table .cell-meta {
    grid-area: 2 / 1 / 3 / 3;
    color: var(--muted);
  }

  .card {
    padding: 16px;
  }

  .data-table {
    padding: 0;
  }

  .data-table summary {
    padding: 14px 16px;
  }

  .data-table .table-wrap {
    padding: 4px 16px 12px;
  }

  .summary-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .summary-grid > div {
    padding-left: 12px;
    border-left: 2px solid var(--rule);
  }

  .settings-stack {
    padding: 0 16px;
  }

  .settings-panel {
    padding: 16px;
  }

  .settings-row {
    padding: 22px 0;
  }

  .form-inline {
    align-items: stretch;
  }

  .form-inline .field {
    flex-basis: 100%;
  }

  .form-inline > .button {
    align-self: flex-start;
  }

  .inline-form {
    flex-wrap: wrap;
  }

  .row-actions {
    align-items: flex-start;
  }

  .auth-page {
    padding: 16px;
  }

  .auth-page-split {
    padding: 0;
  }

  .auth-panel {
    padding: 16px;
  }

  .auth-shell .auth-card {
    padding: 24px;
  }

  .auth-card {
    padding: 24px;
  }

  .auth-brand {
    margin-bottom: 26px;
  }

  .auth-brand-scope {
    margin-top: -18px;
    margin-bottom: 26px;
  }

  .chart-canvas {
    height: 220px;
    min-height: 220px;
  }

  .balance-card .chart-canvas {
    height: 220px;
  }

  .chart-legend {
    gap: 10px;
  }

  .category-line {
    align-items: flex-start;
  }

  .category-figures {
    display: grid;
    justify-items: end;
    gap: 2px;
  }

  .category-share {
    order: 2;
  }

  .category-list {
    margin-top: 14px;
  }

  .notice-card {
    margin-top: 4vh;
    padding: 22px;
  }
}

@media (max-width: 420px) {
  .page-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .page-actions .button,
  .month-field {
    width: 100%;
  }

  .category-layout,
  .page-split,
  .csv-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}
