:root {
  --bg: #f5f7f6;
  --surface: #ffffff;
  --surface-alt: #eef2f0;
  --ink: #1c2622;
  --muted: #66736d;
  --border: #dce3df;
  --border-strong: #c7d0cb;
  --sidebar: #202825;
  --sidebar-muted: #9eaaa4;
  --income: #16795a;
  --income-soft: #e5f3ed;
  --expense: #c64b4b;
  --expense-soft: #fbeaea;
  --pending: #b67812;
  --pending-soft: #fff3dc;
  --blue: #426ca6;
  --blue-soft: #eaf0f8;
  --shadow: 0 1px 2px rgb(21 35 29 / 5%), 0 8px 28px rgb(21 35 29 / 5%);
  --sidebar-width: 232px;
  color-scheme: light;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
}

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

button { color: inherit; }

button,
a,
input,
select,
textarea { outline-color: var(--income); }

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgb(22 121 90 / 20%);
  outline-offset: 2px;
}

button { border: 0; cursor: pointer; }

button:disabled { cursor: not-allowed; opacity: .48; }

a { color: inherit; text-decoration: none; }

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

h1 { font-size: 28px; line-height: 1.25; font-weight: 700; }
h2 { font-size: 18px; line-height: 1.3; font-weight: 700; }
h3 { font-size: 15px; line-height: 1.4; font-weight: 700; }

svg { display: block; width: 18px; height: 18px; stroke-width: 1.8; }

[hidden] { display: none !important; }

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

.eyebrow {
  margin-bottom: 6px;
  color: var(--income);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
}

.eyebrow.light { color: #a8d8c7; }

.brand-mark {
  display: inline-flex;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  color: #fff;
  background: var(--income);
}

.brand-mark.small { width: 30px; height: 30px; flex-basis: 30px; }
.brand-mark.small svg { width: 16px; height: 16px; }

/* Login */
.login-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: minmax(430px, .9fr) minmax(520px, 1.1fr);
  background: var(--surface);
}

.login-panel {
  display: flex;
  width: min(100%, 520px);
  min-height: 100vh;
  justify-self: end;
  flex-direction: column;
  justify-content: center;
  padding: 56px 72px;
}

.login-brand {
  position: absolute;
  top: 36px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 800;
}

.login-copy { margin-bottom: 30px; }
.login-copy h1 { margin-bottom: 10px; font-size: 32px; }
.login-copy > p:last-child { color: var(--muted); }

.login-aside {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  color: #fff;
  background: var(--sidebar);
}

.login-aside::before,
.login-aside::after {
  position: absolute;
  content: "";
  border: 1px solid rgb(255 255 255 / 9%);
  border-radius: 50%;
}

.login-aside::before { width: 420px; height: 420px; right: -150px; top: -130px; }
.login-aside::after { width: 650px; height: 650px; left: -330px; bottom: -430px; }

.login-aside-inner {
  position: relative;
  z-index: 1;
  display: flex;
  width: min(100%, 620px);
  min-height: 100%;
  flex-direction: column;
  justify-content: center;
  padding: 72px 84px;
}

.login-aside h2 {
  max-width: 430px;
  margin-bottom: 54px;
  font-size: 36px;
  line-height: 1.28;
}

.flow-steps { display: grid; gap: 28px; }
.flow-step { display: flex; align-items: center; gap: 18px; color: #aeb9b4; }
.flow-step > span {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  place-items: center;
  border: 1px solid #55605b;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
}
.flow-step strong { display: block; margin-bottom: 2px; color: #fff; font-size: 15px; }
.flow-step small { font-size: 13px; }
.flow-step.is-active > span { border-color: #75bea4; color: #fff; background: var(--income); }

/* Shared controls */
.stack-form { display: grid; gap: 18px; }

.field { display: grid; align-content: start; gap: 7px; min-width: 0; }
.field > span:first-child,
.type-switch legend {
  color: #38443f;
  font-size: 13px;
  font-weight: 700;
}
.field small { color: var(--muted); font-weight: 500; }

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  color: var(--ink);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}

input,
select { height: 42px; padding: 0 12px; }
textarea { min-height: 84px; padding: 10px 12px; resize: vertical; }
input::placeholder,
textarea::placeholder { color: #9ba5a0; }
input:focus,
select:focus,
textarea:focus { border-color: var(--income); box-shadow: 0 0 0 3px rgb(22 121 90 / 10%); }

.input-wrap { position: relative; display: block; }
.input-wrap > svg { position: absolute; z-index: 1; left: 12px; top: 12px; width: 17px; height: 17px; color: var(--muted); }
.input-wrap > input { padding-left: 38px; }

.form-error { min-height: 20px; color: var(--expense); font-size: 13px; }

.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-weight: 700;
  white-space: nowrap;
  transition: background .15s, border-color .15s, transform .15s;
}
.button:active { transform: translateY(1px); }
.button.primary { color: #fff; background: var(--income); }
.button.primary:hover { background: #106b4e; }
.button.secondary { border-color: var(--border-strong); background: var(--surface); }
.button.secondary:hover { border-color: #9eaaa4; background: var(--surface-alt); }
.button.danger { color: #fff; background: var(--expense); }
.button.danger:hover { background: #ad3d3d; }
.button.danger-outline { border-color: #e2b5b5; color: var(--expense); background: var(--surface); }
.button.danger-outline:hover { border-color: var(--expense); background: var(--expense-soft); }
.button.warning { border-color: #e2c58e; color: #81550c; background: var(--pending-soft); }
.button.warning:hover { border-color: var(--pending); background: #ffebc5; }
.button.wide { width: 100%; }

.icon-button {
  position: relative;
  display: inline-grid;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}
.icon-button:hover { background: var(--surface-alt); }
.icon-button.solid { border-color: var(--income); color: #fff; background: var(--income); }
.icon-button[data-tooltip]::after {
  position: absolute;
  z-index: 20;
  bottom: calc(100% + 8px);
  left: 50%;
  padding: 5px 8px;
  border-radius: 4px;
  color: #fff;
  background: #18201d;
  content: attr(data-tooltip);
  font-size: 12px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 4px);
  transition: opacity .15s, transform .15s;
  white-space: nowrap;
}
.icon-button[data-tooltip]:hover::after,
.icon-button[data-tooltip]:focus-visible::after { opacity: 1; transform: translate(-50%, 0); }

/* App frame */
.app-shell { min-height: 100vh; padding-left: var(--sidebar-width); }

.sidebar {
  position: fixed;
  z-index: 10;
  inset: 0 auto 0 0;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  color: #fff;
  background: var(--sidebar);
}

.brand { display: flex; height: 74px; align-items: center; gap: 10px; padding: 0 24px; font-size: 16px; font-weight: 800; }
.main-nav { display: grid; gap: 4px; padding: 18px 12px; }
.nav-item {
  position: relative;
  display: flex;
  height: 46px;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  border-radius: 6px;
  color: #bac4c0;
  background: transparent;
  text-align: left;
}
.nav-item:hover { color: #fff; background: rgb(255 255 255 / 6%); }
.nav-item.is-active { color: #fff; background: #33403b; }
.nav-item.is-active::before { position: absolute; left: 0; width: 3px; height: 22px; border-radius: 0 2px 2px 0; background: #5cc19a; content: ""; }
.nav-item span { flex: 1; }
.nav-count {
  display: grid;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  place-items: center;
  border-radius: 10px;
  color: #1d2b25;
  background: #a8d8c7;
  font-size: 11px;
}

.sidebar-foot { margin: auto 20px 22px; padding-top: 18px; border-top: 1px solid #39433f; }
.sidebar-foot p { margin-bottom: 2px; color: var(--sidebar-muted); font-size: 11px; }
.sidebar-foot strong { display: block; margin-bottom: 12px; font-size: 13px; }
.sidebar-foot span { display: flex; align-items: center; gap: 6px; color: #7fae9b; font-size: 11px; }
.sidebar-foot svg { width: 13px; height: 13px; }

.workspace { min-width: 0; }
.topbar {
  position: sticky;
  z-index: 9;
  top: 0;
  display: flex;
  height: 64px;
  align-items: center;
  justify-content: flex-end;
  padding: 0 34px;
  border-bottom: 1px solid var(--border);
  background: rgb(255 255 255 / 94%);
  backdrop-filter: blur(10px);
}
.mobile-brand { display: none; }
.topbar-context { display: flex; align-items: center; gap: 8px; margin-right: 22px; color: var(--muted); font-size: 12px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #32a475; box-shadow: 0 0 0 3px #e5f3ed; }

.account-menu-wrap { position: relative; }
.account-trigger { display: flex; align-items: center; gap: 10px; padding: 5px 8px; border-radius: 6px; background: transparent; text-align: left; }
.account-trigger:hover { background: var(--surface-alt); }
.account-trigger > svg { width: 15px; height: 15px; color: var(--muted); }
.avatar { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 50%; color: #fff; background: #426c5d; font-weight: 800; }
.account-meta { display: grid; min-width: 76px; }
.account-meta strong { font-size: 13px; }
.account-meta small { color: var(--muted); font-size: 11px; }
.account-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 168px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.account-menu button { display: flex; width: 100%; align-items: center; gap: 9px; padding: 9px 10px; border-radius: 5px; background: transparent; text-align: left; }
.account-menu button:hover { background: var(--surface-alt); }
.account-menu svg { width: 16px; height: 16px; }
.danger-text { color: var(--expense); }

.view { display: none; width: min(100%, 1480px); margin: 0 auto; padding: 32px 34px 54px; }
.view.is-active { display: block; }

.page-heading { display: flex; min-height: 64px; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.page-heading h1 { margin-bottom: 6px; }
.page-heading > div:first-child > p:last-child { color: var(--muted); }
.permission-badge { display: inline-flex; align-items: center; gap: 7px; padding: 8px 11px; border: 1px solid #bcd9ce; border-radius: 6px; color: var(--income); background: var(--income-soft); font-size: 12px; font-weight: 700; }
.permission-badge svg { width: 15px; height: 15px; }

.panel {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.panel-heading { display: flex; min-height: 64px; align-items: center; justify-content: space-between; gap: 16px; padding: 0 22px; border-bottom: 1px solid var(--border); }
.panel-heading > div:first-child { display: flex; align-items: center; gap: 10px; }
.panel-heading > span { color: var(--muted); font-size: 11px; }
.section-index { display: grid; width: 25px; height: 25px; place-items: center; border-radius: 5px; color: var(--income); background: var(--income-soft); font-size: 10px; font-weight: 800; }
.panel-heading h2 { font-size: 16px; }

/* New entry */
.entry-layout { display: grid; grid-template-columns: minmax(420px, .9fr) minmax(500px, 1.1fr); align-items: start; gap: 20px; }
.entry-form { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 16px; padding: 22px; }
.span-2 { grid-column: 1 / -1; }
.entry-mode-banner { display: flex; min-width: 0; align-items: center; gap: 12px; padding: 12px 13px; border: 1px solid #e1c58f; border-radius: 7px; background: var(--pending-soft); }
.entry-mode-banner > div { display: grid; min-width: 0; flex: 1; }
.entry-mode-banner strong { font-size: 13px; }
.entry-mode-banner small { color: #745d35; font-size: 11px; }
.revision-tag { display: inline-flex; width: fit-content; align-items: center; gap: 5px; padding: 4px 8px; border: 1px solid #dfbd7d; border-radius: 4px; color: #80550d; background: var(--pending-soft); font-size: 11px; font-weight: 800; white-space: nowrap; }
.revision-tag.compact { padding: 3px 6px; font-size: 10px; }
.revision-tag svg { width: 13px; height: 13px; }
.type-switch { display: grid; grid-column: 1 / -1; grid-template-columns: 1fr 1fr; gap: 8px; min-width: 0; margin: 0; padding: 0; border: 0; }
.type-switch legend { margin-bottom: 7px; }
.type-option { min-width: 0; }
.type-option input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.type-option span { display: flex; height: 42px; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--border-strong); border-radius: 6px; color: var(--muted); cursor: pointer; font-weight: 700; }
.type-option input:checked + span { border-color: var(--income); color: var(--income); background: var(--income-soft); box-shadow: inset 0 0 0 1px var(--income); }
.type-option.expense input:checked + span { border-color: var(--expense); color: var(--expense); background: var(--expense-soft); box-shadow: inset 0 0 0 1px var(--expense); }
.type-option input:focus-visible + span { outline: 3px solid rgb(22 121 90 / 20%); outline-offset: 2px; }
.amount-input { position: relative; display: block; }
.amount-input b { position: absolute; left: 12px; top: 10px; color: var(--muted); }
.amount-input input { padding-left: 32px; font-variant-numeric: tabular-nums; }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 16px; padding-top: 3px; }
.form-actions p { display: flex; align-items: flex-start; gap: 6px; color: var(--muted); font-size: 11px; }
.form-actions p svg { width: 14px; height: 14px; flex: 0 0 14px; margin-top: 1px; }

.queue-panel { min-height: 512px; }
.queue-heading { align-items: center; }
.mini-tabs { display: flex; align-self: stretch; gap: 18px; }
.mini-tabs button { position: relative; padding: 0; color: var(--muted); background: transparent; font-size: 12px; font-weight: 700; }
.mini-tabs button.is-active { color: var(--ink); }
.mini-tabs button.is-active::after { position: absolute; right: 0; bottom: 0; left: 0; height: 2px; background: var(--income); content: ""; }
.mini-tabs b { display: inline-grid; min-width: 18px; height: 18px; margin-left: 2px; place-items: center; border-radius: 9px; color: var(--pending); background: var(--pending-soft); font-size: 10px; }

.queue-list { display: grid; }
.queue-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.queue-item[data-queue-row] { cursor: pointer; transition: background .15s; }
.queue-item[data-queue-row]:hover { background: #fafcfb; }
.queue-item:last-child { border-bottom: 0; }
.queue-main { min-width: 0; }
.queue-title-line { display: flex; min-width: 0; align-items: center; gap: 8px; margin-bottom: 8px; }
.queue-title-line strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.type-badge { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 4px; padding: 3px 7px; border-radius: 4px; font-size: 11px; font-weight: 800; }
.type-badge.income { color: var(--income); background: var(--income-soft); }
.type-badge.expense { color: var(--expense); background: var(--expense-soft); }
.type-badge svg { width: 12px; height: 12px; }
.queue-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-size: 11px; }
.queue-meta span { display: inline-flex; align-items: center; gap: 5px; }
.queue-meta svg { width: 13px; height: 13px; }
.queue-note { margin-top: 8px; color: #4e5a55; font-size: 12px; word-break: break-word; }
.review-reason { margin-top: 9px; padding: 8px 10px; border-left: 3px solid var(--expense); color: #704141; background: var(--expense-soft); font-size: 12px; }
.queue-side { display: grid; min-width: 118px; align-content: space-between; justify-items: end; gap: 12px; }
.queue-amount { font-size: 16px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.queue-amount.income { color: var(--income); }
.queue-amount.expense { color: var(--expense); }
.queue-actions { display: flex; gap: 6px; }
.queue-actions .button { min-height: 32px; padding: 0 10px; font-size: 12px; }
.queue-actions .button svg { width: 14px; height: 14px; }
.self-review-hint { color: var(--muted); font-size: 11px; text-align: right; }

.empty-state { display: grid; min-height: 270px; place-items: center; align-content: center; gap: 5px; padding: 24px; color: var(--muted); text-align: center; }
.empty-state svg { width: 32px; height: 32px; margin-bottom: 8px; color: #9ca8a2; }
.empty-state strong { color: #3c4943; }
.empty-state span { font-size: 12px; }

/* Records */
.filters { display: grid; grid-template-columns: 142px 142px 130px 150px minmax(190px, 1fr) auto; align-items: end; gap: 10px; margin-bottom: 18px; padding: 16px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.field.compact { gap: 5px; }
.field.compact > span:first-child { font-size: 11px; }
.field.compact input,
.field.compact select { height: 38px; font-size: 12px; }
.field.compact .input-wrap > svg { top: 10px; width: 16px; height: 16px; }
.filter-button { min-height: 38px; }

.table-section { overflow: hidden; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.table-toolbar { display: flex; min-height: 66px; align-items: center; justify-content: space-between; gap: 20px; padding: 0 20px; border-bottom: 1px solid var(--border); }
.table-toolbar h2 { margin-bottom: 2px; font-size: 15px; }
.table-toolbar p,
.section-heading p { color: var(--muted); font-size: 11px; }
.legend { display: flex; gap: 16px; color: var(--muted); font-size: 11px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; }
.income-dot { background: var(--income); }
.expense-dot { background: var(--expense); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th,
td { padding: 13px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { color: var(--muted); background: #fafbfa; font-size: 11px; font-weight: 700; white-space: nowrap; }
td { font-size: 12px; }
tbody tr:hover { background: #fafcfb; }
tbody tr:last-child td { border-bottom: 0; }
td.number,
th.number { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.number.income { color: var(--income); font-weight: 800; }
td.number.expense { color: var(--expense); font-weight: 800; }
.record-item { min-width: 150px; max-width: 280px; font-weight: 700; }
.record-party { min-width: 110px; max-width: 190px; color: #53605a; }
.record-item span,
.record-party span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.record-tags { display: flex; align-items: center; gap: 5px; }
.action-cell { width: 116px; text-align: center; }
.table-actions { display: flex; align-items: center; justify-content: center; gap: 2px; }
.table-action-button { position: relative; display: inline-grid; width: 30px; height: 30px; flex: 0 0 30px; place-items: center; border-radius: 5px; color: var(--muted); background: transparent; }
.table-action-button:hover { color: var(--income); background: var(--income-soft); }
.table-action-button.revise:hover { color: #80550d; background: var(--pending-soft); }
.table-action-button svg { width: 16px; height: 16px; }
.table-action-button[data-tooltip]::after {
  position: absolute;
  z-index: 20;
  bottom: calc(100% + 7px);
  left: 50%;
  padding: 5px 7px;
  border-radius: 4px;
  color: #fff;
  background: #18201d;
  content: attr(data-tooltip);
  font-size: 11px;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%);
  white-space: nowrap;
}
.table-action-button[data-tooltip]:hover::after,
.table-action-button[data-tooltip]:focus-visible::after { opacity: 1; }
.pagination { display: flex; min-height: 56px; align-items: center; justify-content: center; gap: 14px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.pagination .icon-button { width: 30px; height: 30px; flex-basis: 30px; }

/* Stats */
.stats-page-heading { align-items: flex-end; }
.stats-date-filter { display: flex; align-items: center; gap: 7px; padding: 6px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); }
.stats-date-filter input { width: 126px; height: 34px; padding: 0 8px; border-color: transparent; background: var(--surface-alt); font-size: 11px; }
.stats-date-filter > span { color: var(--muted); font-size: 11px; }
.stats-date-filter .icon-button { width: 34px; height: 34px; flex-basis: 34px; }
.quick-ranges { display: flex; align-items: center; gap: 2px; margin-right: 4px; }
.quick-ranges button { height: 30px; padding: 0 9px; border-radius: 5px; color: var(--muted); background: transparent; font-size: 11px; }
.quick-ranges button:hover { background: var(--surface-alt); }
.quick-ranges button.is-active { color: var(--ink); background: var(--surface-alt); font-weight: 700; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric { min-width: 0; padding: 18px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.metric > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; color: var(--muted); font-size: 12px; }
.metric > div svg { width: 17px; height: 17px; }
.income-metric > div svg { color: var(--income); }
.expense-metric > div svg { color: var(--expense); }
.balance-metric > div svg { color: var(--blue); }
.count-metric > div svg { color: var(--pending); }
.metric strong { display: block; overflow: hidden; margin-bottom: 3px; font-size: 22px; font-variant-numeric: tabular-nums; text-overflow: ellipsis; white-space: nowrap; }
.income-metric strong { color: var(--income); }
.expense-metric strong { color: var(--expense); }
.metric small { color: var(--muted); font-size: 10px; }

.stats-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(340px, .75fr); gap: 18px; }
.chart-section,
.person-section { min-width: 0; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.section-heading { display: flex; min-height: 66px; align-items: center; justify-content: space-between; gap: 16px; padding: 0 20px; border-bottom: 1px solid var(--border); }
.section-heading h2 { margin-bottom: 2px; font-size: 15px; }

.trend-chart { position: relative; min-height: 330px; padding: 24px 20px 18px 58px; }
.chart-grid { position: absolute; inset: 24px 20px 50px 58px; display: grid; grid-template-rows: repeat(4, 1fr); pointer-events: none; }
.chart-grid-line { position: relative; border-top: 1px solid #e5e9e7; }
.chart-grid-line span { position: absolute; right: calc(100% + 9px); top: -8px; color: var(--muted); font-size: 10px; white-space: nowrap; }
.chart-bars { position: relative; z-index: 1; display: grid; height: 258px; grid-auto-columns: minmax(30px, 1fr); grid-auto-flow: column; align-items: end; gap: 8px; }
.chart-period { display: grid; min-width: 0; height: 100%; grid-template-rows: 1fr 26px; align-items: end; gap: 7px; }
.chart-bar-pair { display: flex; height: 100%; align-items: end; justify-content: center; gap: 3px; }
.chart-bar { position: relative; width: min(16px, 42%); min-height: 0; border-radius: 3px 3px 0 0; transition: height .3s ease; }
.chart-bar.income { background: var(--income); }
.chart-bar.expense { background: var(--expense); }
.chart-bar:hover { filter: brightness(.9); }
.chart-bar.level-0 { height: 0; }
.chart-bar.level-1 { height: 5%; }
.chart-bar.level-2 { height: 10%; }
.chart-bar.level-3 { height: 15%; }
.chart-bar.level-4 { height: 20%; }
.chart-bar.level-5 { height: 25%; }
.chart-bar.level-6 { height: 30%; }
.chart-bar.level-7 { height: 35%; }
.chart-bar.level-8 { height: 40%; }
.chart-bar.level-9 { height: 45%; }
.chart-bar.level-10 { height: 50%; }
.chart-bar.level-11 { height: 55%; }
.chart-bar.level-12 { height: 60%; }
.chart-bar.level-13 { height: 65%; }
.chart-bar.level-14 { height: 70%; }
.chart-bar.level-15 { height: 75%; }
.chart-bar.level-16 { height: 80%; }
.chart-bar.level-17 { height: 85%; }
.chart-bar.level-18 { height: 90%; }
.chart-bar.level-19 { height: 95%; }
.chart-bar.level-20 { height: 100%; }
.chart-bar[data-value]::after {
  position: absolute;
  z-index: 5;
  bottom: calc(100% + 6px);
  left: 50%;
  padding: 5px 7px;
  border-radius: 4px;
  color: #fff;
  background: #18201d;
  content: attr(data-value);
  font-size: 10px;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%);
  white-space: nowrap;
}
.chart-bar:hover::after { opacity: 1; }
.chart-period-label { overflow: hidden; color: var(--muted); font-size: 10px; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.chart-empty { display: grid; min-height: 280px; place-items: center; color: var(--muted); }

.person-list { display: grid; }
.person-row { display: grid; grid-template-columns: minmax(86px, .7fr) minmax(150px, 1.3fr) auto; align-items: center; gap: 14px; padding: 15px 18px; border-bottom: 1px solid var(--border); }
.person-row:last-child { border-bottom: 0; }
.person-name { display: flex; min-width: 0; align-items: center; gap: 8px; }
.person-name .avatar { width: 28px; height: 28px; flex: 0 0 28px; font-size: 11px; }
.person-name strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.person-bars { display: grid; gap: 6px; }
.person-bar-line { display: grid; grid-template-columns: 26px 1fr; align-items: center; gap: 6px; color: var(--muted); font-size: 9px; }
.person-bar-track { height: 5px; overflow: hidden; border-radius: 3px; background: var(--surface-alt); }
.person-bar-fill { height: 100%; border-radius: 3px; }
.person-bar-fill.income { background: var(--income); }
.person-bar-fill.expense { background: var(--expense); }
.person-bar-fill.level-0 { width: 0; }
.person-bar-fill.level-1 { width: 5%; }
.person-bar-fill.level-2 { width: 10%; }
.person-bar-fill.level-3 { width: 15%; }
.person-bar-fill.level-4 { width: 20%; }
.person-bar-fill.level-5 { width: 25%; }
.person-bar-fill.level-6 { width: 30%; }
.person-bar-fill.level-7 { width: 35%; }
.person-bar-fill.level-8 { width: 40%; }
.person-bar-fill.level-9 { width: 45%; }
.person-bar-fill.level-10 { width: 50%; }
.person-bar-fill.level-11 { width: 55%; }
.person-bar-fill.level-12 { width: 60%; }
.person-bar-fill.level-13 { width: 65%; }
.person-bar-fill.level-14 { width: 70%; }
.person-bar-fill.level-15 { width: 75%; }
.person-bar-fill.level-16 { width: 80%; }
.person-bar-fill.level-17 { width: 85%; }
.person-bar-fill.level-18 { width: 90%; }
.person-bar-fill.level-19 { width: 95%; }
.person-bar-fill.level-20 { width: 100%; }
.person-balance { text-align: right; }
.person-balance strong { display: block; font-size: 12px; font-variant-numeric: tabular-nums; }
.person-balance span { color: var(--muted); font-size: 9px; }

.funds-section { margin-top: 18px; overflow: hidden; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.funds-heading { min-height: 76px; }
.funds-total { display: grid; justify-items: end; gap: 3px; }
.funds-total span { color: var(--muted); font-size: 10px; }
.funds-total strong { font-size: 17px; font-variant-numeric: tabular-nums; }
.funds-total strong.positive { color: var(--income); }
.funds-total strong.negative { color: var(--expense); }
.funds-columns,
.funds-row { display: grid; grid-template-columns: minmax(210px, 1.35fr) repeat(3, minmax(120px, 1fr)) minmax(76px, .55fr); align-items: center; column-gap: 18px; }
.funds-columns { min-height: 38px; padding: 0 20px; border-bottom: 1px solid var(--border); color: var(--muted); background: var(--surface-alt); font-size: 10px; font-weight: 700; }
.funds-columns span:not(:first-child) { text-align: right; }
.funds-row { min-height: 70px; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.funds-row:last-child { border-bottom: 0; }
.funds-person { display: flex; min-width: 0; align-items: center; gap: 10px; }
.funds-person .avatar { width: 32px; height: 32px; flex: 0 0 32px; font-size: 11px; }
.funds-person > span:last-child { min-width: 0; }
.funds-person strong,
.funds-person small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.funds-person strong { margin-bottom: 2px; font-size: 13px; }
.funds-person small { color: var(--muted); font-size: 9px; }
.funds-value { min-width: 0; text-align: right; }
.funds-value > span { display: none; color: var(--muted); font-size: 9px; }
.funds-value strong { display: block; overflow: hidden; font-size: 12px; font-variant-numeric: tabular-nums; text-overflow: ellipsis; white-space: nowrap; }
.funds-value.income strong,
.funds-value.funds.positive strong { color: var(--income); }
.funds-value.expense strong,
.funds-value.funds.negative strong { color: var(--expense); }
.funds-value.count strong { color: var(--muted); font-weight: 600; }

/* Dialogs */
.dialog {
  width: min(520px, calc(100% - 28px));
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 24px 80px rgb(12 21 17 / 22%);
}
.dialog::backdrop { background: rgb(14 22 19 / 55%); backdrop-filter: blur(2px); }
.wide-dialog { width: min(820px, calc(100% - 28px)); }
.small-dialog { width: min(440px, calc(100% - 28px)); }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.dialog-heading > div { display: flex; align-items: center; gap: 12px; }
.dialog-heading .eyebrow { margin-bottom: 2px; }
.dialog-heading h2 { font-size: 17px; }
.dialog-icon { display: grid; width: 38px; height: 38px; flex: 0 0 38px; place-items: center; border-radius: 7px; color: var(--income); background: var(--income-soft); }
.dialog-icon.reject { color: var(--expense); background: var(--expense-soft); }
.dialog-icon.neutral { color: var(--blue); background: var(--blue-soft); }
.dialog-close { border: 0; }
.review-summary { display: grid; gap: 8px; margin-bottom: 18px; padding: 14px; border-left: 3px solid var(--income); background: var(--surface-alt); }
.review-summary.reject { border-left-color: var(--expense); }
.review-summary > div { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.review-summary strong { font-size: 15px; }
.review-summary .review-amount { font-size: 17px; font-variant-numeric: tabular-nums; }
.review-summary p { color: var(--muted); font-size: 12px; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; margin-top: 20px; }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 22px; }
.detail-field { min-width: 0; }
.detail-field.full { grid-column: 1 / -1; }
.detail-field > span { display: block; margin-bottom: 3px; color: var(--muted); font-size: 11px; }
.detail-field strong { display: block; word-break: break-word; }
.detail-audit { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding-top: 16px; border-top: 1px solid var(--border); }

.user-admin-layout { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(260px, .8fr); gap: 24px; }
.user-admin-layout h3 { margin-bottom: 12px; }
.users-list { overflow: hidden; border: 1px solid var(--border); border-radius: 7px; }
.user-row { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 12px; border-bottom: 1px solid var(--border); }
.user-row:last-child { border-bottom: 0; }
.user-row .avatar { width: 32px; height: 32px; font-size: 11px; }
.user-row strong,
.user-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-row small { color: var(--muted); font-size: 10px; }
.role-chip { padding: 3px 7px; border-radius: 4px; color: var(--blue); background: var(--blue-soft); font-size: 10px; font-weight: 700; }
.role-chip.reviewer { color: var(--income); background: var(--income-soft); }
.role-chip.member { color: #715b36; background: var(--pending-soft); }
.create-user-section { padding-left: 24px; border-left: 1px solid var(--border); }

.toast-region { position: fixed; z-index: 100; right: 24px; bottom: 24px; display: grid; width: min(360px, calc(100% - 32px)); gap: 8px; pointer-events: none; }
.toast { display: flex; align-items: flex-start; gap: 9px; padding: 12px 14px; border: 1px solid #bfd8ce; border-radius: 7px; color: #164b38; background: #f0faf6; box-shadow: var(--shadow); animation: toast-in .18s ease-out; }
.toast.error { border-color: #ebc0c0; color: #793535; background: #fff4f4; }
.toast svg { width: 17px; height: 17px; flex: 0 0 17px; margin-top: 1px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.mobile-nav { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

@media (max-width: 1180px) {
  .entry-layout { grid-template-columns: 1fr; }
  .queue-panel { min-height: 0; }
  .filters { grid-template-columns: repeat(4, minmax(120px, 1fr)); }
  .search-field { grid-column: span 3; }
  .stats-grid { grid-template-columns: 1fr; }
  .person-section { min-height: 0; }
}

@media (max-width: 900px) {
  :root { --sidebar-width: 190px; }
  .brand { padding: 0 16px; }
  .view { padding-right: 22px; padding-left: 22px; }
  .topbar { padding-right: 22px; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .stats-page-heading { align-items: flex-start; flex-direction: column; }
  .stats-date-filter { width: 100%; flex-wrap: wrap; }
}

@media (max-width: 720px) {
  body { padding-bottom: 68px; }
  h1 { font-size: 24px; }
  .login-shell { display: block; min-height: calc(100vh - 68px); }
  .login-panel { width: min(100%, 470px); min-height: calc(100vh - 68px); margin: 0 auto; padding: 88px 28px 36px; }
  .login-brand { top: 28px; }
  .login-aside { display: none; }

  .app-shell { padding-left: 0; }
  .sidebar { display: none; }
  .topbar { height: 58px; justify-content: space-between; padding: 0 16px; }
  .mobile-brand { display: flex; align-items: center; gap: 8px; }
  .topbar-context { display: none; }
  .account-meta { display: none; }
  .account-trigger { gap: 6px; padding-right: 0; }
  .view { padding: 24px 14px 28px; }
  .page-heading { min-height: 0; flex-direction: column; gap: 14px; margin-bottom: 20px; }
  .page-heading .button { align-self: stretch; }
  .entry-form { grid-template-columns: 1fr; padding: 18px 16px; }
  .span-2 { grid-column: auto; }
  .type-switch { grid-column: auto; }
  .panel-heading { padding: 0 16px; }
  .form-actions { align-items: stretch; flex-direction: column; }
  .form-actions .button { width: 100%; }
  .queue-heading { min-height: 108px; align-items: flex-start; flex-direction: column; justify-content: center; }
  .mini-tabs { width: 100%; min-height: 38px; }
  .queue-item { grid-template-columns: minmax(0, 1fr); padding: 16px; }
  .queue-side { min-width: 0; grid-template-columns: 1fr auto; align-items: center; justify-items: start; }
  .queue-actions { justify-self: end; }
  .self-review-hint { justify-self: end; }

  .filters { grid-template-columns: 1fr 1fr; padding: 13px; }
  .search-field { grid-column: 1 / -1; }
  .filter-button { grid-column: 1 / -1; width: 100%; }
  .table-toolbar { align-items: flex-start; flex-direction: column; justify-content: center; gap: 8px; padding: 14px 16px; }
  th, td { padding: 11px 12px; }

  .stats-page-heading { gap: 16px; }
  .stats-date-filter { display: grid; grid-template-columns: 1fr auto 1fr auto; gap: 6px; }
  .quick-ranges { grid-column: 1 / -1; margin: 0 0 2px; }
  .quick-ranges button { flex: 1; }
  .stats-date-filter input { width: 100%; }
  .metrics { gap: 10px; }
  .metric { padding: 14px; }
  .metric strong { font-size: 18px; }
  .trend-chart { min-height: 290px; padding-right: 12px; padding-left: 48px; }
  .chart-grid { right: 12px; left: 48px; }
  .chart-bars { height: 218px; gap: 4px; overflow-x: auto; }
  .chart-period { min-width: 34px; }
  .person-row { grid-template-columns: minmax(80px, .8fr) minmax(110px, 1.2fr) auto; gap: 9px; padding: 13px 12px; }
  .funds-columns { display: none; }
  .funds-heading { align-items: flex-start; flex-direction: column; justify-content: center; padding-top: 14px; padding-bottom: 14px; }
  .funds-total { justify-items: start; }
  .funds-row { grid-template-columns: 1fr 1fr; gap: 14px 18px; padding: 16px; }
  .funds-person { grid-column: 1 / -1; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
  .funds-value { text-align: left; }
  .funds-value > span { display: block; margin-bottom: 3px; }
  .funds-value.funds { grid-column: 1 / -1; padding: 11px 12px; border-radius: 6px; background: var(--surface-alt); }
  .funds-value.funds strong { font-size: 16px; }
  .funds-value.count { grid-column: 2; grid-row: 4; align-self: end; text-align: right; }

  .mobile-nav {
    position: fixed;
    z-index: 30;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    height: 64px;
    grid-template-columns: repeat(3, 1fr);
    border-top: 1px solid var(--border);
    background: rgb(255 255 255 / 96%);
    box-shadow: 0 -8px 24px rgb(25 37 32 / 6%);
    backdrop-filter: blur(10px);
  }
  .mobile-nav button { position: relative; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 3px; color: var(--muted); background: transparent; font-size: 10px; }
  .mobile-nav button.is-active { color: var(--income); font-weight: 800; }
  .mobile-nav button.is-active::before { position: absolute; top: 0; width: 30px; height: 2px; background: var(--income); content: ""; }
  .mobile-nav svg { width: 20px; height: 20px; }
  .mobile-nav b { position: absolute; top: 7px; left: calc(50% + 8px); display: grid; min-width: 17px; height: 17px; padding: 0 4px; place-items: center; border-radius: 9px; color: #fff; background: var(--expense); font-size: 9px; }
  .toast-region { right: 16px; bottom: 80px; }

  .dialog { padding: 18px; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-field.full,
  .detail-audit { grid-column: auto; }
  .detail-audit { grid-template-columns: 1fr; }
  .user-admin-layout { grid-template-columns: 1fr; }
  .create-user-section { padding: 20px 0 0; border-top: 1px solid var(--border); border-left: 0; }
}

@media (max-width: 420px) {
  .login-panel { padding-right: 20px; padding-left: 20px; }
  .login-copy h1 { font-size: 28px; }
  .metrics { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr; }
  .search-field,
  .filter-button { grid-column: auto; }
  .queue-side { grid-template-columns: 1fr; }
  .queue-actions,
  .self-review-hint { justify-self: start; }
  .stats-date-filter { grid-template-columns: 1fr auto 1fr; }
  .stats-date-filter .icon-button { grid-column: 1 / -1; width: 100%; }
  .person-row { grid-template-columns: 1fr auto; }
  .person-bars { grid-column: 1 / -1; grid-row: 2; }
}
