:root {
  --canvas: #eef3f1;
  --surface: #fbfcfa;
  --surface-soft: #f3f6f4;
  --ink: #172126;
  --muted: #68736f;
  --line: #c8d3cf;
  --line-soft: #dde5e2;
  --blue: #176b55;
  --blue-focus: #0f7b5f;
  --blue-soft: #e2efea;
  --cash: #8d9d97;
  --credit: #176b55;
  --danger: #a3483a;
  --danger-soft: #f6e9e5;
  --radius: 14px;
}

* { box-sizing: border-box; }
html { color-scheme: light; background: var(--canvas); }
body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--canvas);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.47;
  letter-spacing: -.01em;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button { color: inherit; }
button, [data-view], [data-task], [data-action] { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--blue-focus);
  outline-offset: 2px;
}
button:active { transform: scale(.97); }
.hidden { display: none !important; }

.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  width: 216px;
  padding: 24px 16px 18px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line-soft);
  background: rgba(238,243,241,.9);
  backdrop-filter: saturate(180%) blur(20px);
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: white;
  background: var(--blue);
  font-weight: 600;
}
.brand strong, .brand span { display: block; }
.brand strong { font-family: "Songti SC", "STSong", ui-serif, serif; font-size: 17px; font-weight: 700; letter-spacing: -.02em; }
.brand span { margin-top: 1px; color: var(--muted); font-size: 11px; letter-spacing: 0; }
.sidebar nav { margin-top: 40px; display: grid; gap: 4px; }
.nav-item {
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #424245;
  background: transparent;
  cursor: pointer;
  text-align: left;
  transition: background-color .15s ease, color .15s ease;
}
.nav-item:hover { background: var(--surface-soft); }
.nav-item.active { color: var(--blue); background: var(--blue-soft); font-weight: 600; }
.sidebar-footer {
  margin-top: auto;
  padding: 12px 8px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}

.text-button {
  min-height: 32px;
  padding: 5px 8px;
  border: 0;
  border-radius: 8px;
  color: var(--blue);
  background: transparent;
  cursor: pointer;
}
.text-button:hover { background: var(--blue-soft); }

main {
  min-height: 100vh;
  margin-left: 216px;
  padding: 44px clamp(28px, 4vw, 64px) 80px;
}
main > * { width: min(100%, 1280px); margin-left: auto; margin-right: auto; }
.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 32px; }
.eyebrow {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}
h1, h2, h3, p { margin-top: 0; }
h1 {
  margin-bottom: 10px;
  font-family: "Songti SC", "STSong", ui-serif, serif;
  font-size: clamp(32px, 3.4vw, 48px);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -.04em;
}
h2 { letter-spacing: -.025em; }
.lead { max-width: 720px; margin-bottom: 0; color: var(--muted); font-size: 16px; line-height: 1.55; }
.month-control {
  min-height: 44px;
  padding: 3px;
  display: flex;
  align-items: center;
  gap: 3px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: var(--surface);
}
.month-control button {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  color: var(--blue);
  background: transparent;
  cursor: pointer;
}
.month-control button:hover { background: var(--blue-soft); }
.month-control strong { padding: 0 10px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.month-picker-label { display: inline-flex; align-items: center; min-width: 132px; color: var(--ink); white-space: nowrap; }
.month-picker-label select { appearance: auto; width: 100%; min-height: 36px; padding: 0 24px 0 10px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: var(--surface); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.activity-filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0; }
.filter-chip { padding: 8px 14px; border: 1px solid var(--line-soft); border-radius: 999px; color: var(--muted); background: var(--surface); cursor: pointer; }
.filter-chip:hover, .filter-chip.active { border-color: var(--blue); color: var(--blue); background: var(--blue-soft); }
.account-figure small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; white-space: nowrap; }

.month-ledger {
  position: relative;
  margin-top: 34px;
  padding: 28px 32px 30px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-top: 4px double var(--ink);
  border-radius: 4px;
  background:
    repeating-linear-gradient(to bottom, transparent 0, transparent 31px, rgba(23,33,38,.045) 31px, rgba(23,33,38,.045) 32px),
    var(--surface);
}
.ledger-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}
.ledger-heading > div span, .ledger-heading > div small { display: block; }
.ledger-heading > div span { font-family: "Songti SC", "STSong", ui-serif, serif; font-size: 20px; font-weight: 700; }
.ledger-heading > div small { margin-top: 4px; color: var(--muted); font-size: 11px; }
.close-state {
  padding: 7px 12px;
  border: 1px solid rgba(163,72,58,.36);
  border-radius: 3px;
  color: var(--danger);
  background: rgba(246,233,229,.82);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
}
.close-state.closed { border-color: rgba(23,107,85,.32); color: var(--blue); background: rgba(226,239,234,.82); }
.ledger-result { padding: 34px 0 26px; display: flex; align-items: baseline; justify-content: space-between; gap: 28px; }
.ledger-result strong {
  font-family: "SFMono-Regular", "Roboto Mono", "Menlo", monospace;
  font-size: clamp(44px, 6vw, 78px);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -.07em;
  color: var(--blue);
  white-space: nowrap;
}
.ledger-result strong.negative { color: var(--danger); }
.ledger-result span { max-width: 310px; color: var(--muted); font-size: 12px; text-align: right; }
.ledger-equation {
  padding-top: 20px;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  align-items: center;
  gap: 22px;
}
.ledger-equation div { min-width: 0; }
.ledger-equation span, .ledger-equation small { display: block; color: var(--muted); font-size: 11px; }
.ledger-equation strong {
  display: block;
  margin-top: 5px;
  font-family: "SFMono-Regular", "Roboto Mono", "Menlo", monospace;
  font-size: clamp(19px, 2vw, 28px);
  font-weight: 600;
  letter-spacing: -.04em;
  white-space: nowrap;
}
.ledger-equation small { margin-top: 4px; line-height: 1.4; }
.ledger-equation b { color: var(--muted); font-family: "Songti SC", "STSong", ui-serif, serif; font-size: 24px; font-weight: 400; }
.quick-figures {
  margin-top: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-top: 0;
  background: rgba(251,252,250,.72);
}
.quick-figures > div { min-width: 0; padding: 18px 20px; border-right: 1px solid var(--line); }
.quick-figures > div:last-child { border-right: 0; }
.quick-figures span, .quick-figures small { display: block; color: var(--muted); font-size: 10px; }
.quick-figures strong {
  display: block;
  margin: 7px 0 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: "SFMono-Regular", "Roboto Mono", "Menlo", monospace;
  font-size: clamp(16px, 1.7vw, 23px);
  font-weight: 600;
  letter-spacing: -.04em;
  white-space: nowrap;
}

.cash-segment { background: var(--cash); }
.credit-segment { background: var(--credit); }
.p-0 { --portion: 0%; }
.p-1 { --portion: 5%; }
.p-2 { --portion: 10%; }
.p-3 { --portion: 15%; }
.p-4 { --portion: 20%; }
.p-5 { --portion: 25%; }
.p-6 { --portion: 30%; }
.p-7 { --portion: 35%; }
.p-8 { --portion: 40%; }
.p-9 { --portion: 45%; }
.p-10 { --portion: 50%; }
.p-11 { --portion: 55%; }
.p-12 { --portion: 60%; }
.p-13 { --portion: 65%; }
.p-14 { --portion: 70%; }
.p-15 { --portion: 75%; }
.p-16 { --portion: 80%; }
.p-17 { --portion: 85%; }
.p-18 { --portion: 90%; }
.p-19 { --portion: 95%; }
.p-20 { --portion: 100%; }

.content-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, .75fr);
  gap: 16px;
}
.supporting-grid { grid-template-columns: 1fr 1fr; }
.panel, .ledger-section {
  padding: 24px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface);
}
.ledger-section { border-radius: 4px; }
.panel-header {
  margin-bottom: 22px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.panel-header h2 { margin-bottom: 4px; font-size: 20px; font-weight: 600; }
.panel-header p { margin: 0; color: var(--muted); font-size: 12px; }

.primary-button, .secondary-button, .ghost-button {
  min-height: 44px;
  padding: 10px 20px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 400;
  transition: background-color .15s ease, border-color .15s ease, opacity .15s ease;
}
.primary-button { border: 1px solid var(--blue); color: white; background: var(--blue); }
.primary-button:hover { border-color: var(--blue-focus); background: var(--blue-focus); }
.secondary-button { border: 1px solid var(--blue); color: var(--blue); background: transparent; }
.secondary-button:hover { background: var(--blue-soft); }
.ghost-button { border: 1px solid var(--line-soft); color: var(--ink); background: var(--surface-soft); }
.ghost-button:hover { border-color: var(--line); background: #f0f0f2; }
.primary-button:disabled, .secondary-button:disabled, .ghost-button:disabled { opacity: .45; cursor: default; }

.trend-chart { height: 208px; display: flex; align-items: stretch; gap: 16px; }
.trend-column {
  position: relative;
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 10px;
  color: inherit;
  background: transparent;
  cursor: pointer;
  text-align: center;
}
.trend-column:active { transform: none; }
.bar-space { height: 182px; display: flex; align-items: flex-end; justify-content: center; gap: 6px; border-bottom: 1px solid var(--line-soft); }
.surplus-space { align-items: flex-end; }
.surplus-bar { width: min(38px, 72%); border-radius: 9px 9px 3px 3px; background: var(--green); }
.surplus-bar.negative { background: var(--danger); }
.legend-dot.surplus { background: var(--green); }
.legend-dot.negative { background: var(--danger); }
.bar, .expense-stack { width: min(24px, 36%); min-height: 3px; }
.bar-space > [class*="p-"] { height: var(--portion); }
.bar { border-radius: 6px 6px 0 0; background: var(--ink); }
.bar.income { background: var(--ink); }
.expense-stack {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  border-radius: 6px 6px 0 0;
  background: var(--line-soft);
}
.expense-stack i { display: block; width: 100%; }
.expense-stack > [class*="p-"] { height: var(--portion); }
.trend-month { color: var(--muted); font-size: 11px; white-space: nowrap; }
.trend-column:hover .trend-month,
.trend-column:focus-visible .trend-month,
.trend-column.is-selected .trend-month { color: var(--ink); font-weight: 600; }
.trend-column:hover .bar-space,
.trend-column:focus-visible .bar-space,
.trend-column.is-selected .bar-space { border-bottom-color: var(--ink); }
.trend-tooltip {
  position: absolute;
  top: 8px;
  left: 50%;
  z-index: 8;
  width: 196px;
  padding: 12px 13px;
  border: 1px solid rgba(23,33,38,.18);
  border-radius: 10px;
  display: grid;
  gap: 5px;
  color: var(--ink);
  background: rgba(251,252,250,.98);
  box-shadow: 0 14px 32px rgba(23,33,38,.16);
  opacity: 0;
  pointer-events: none;
  text-align: left;
  transform: translate(-50%, 5px);
  transition: opacity .14s ease, transform .14s ease;
}
.trend-tooltip::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -5px;
  width: 8px;
  height: 8px;
  border-right: 1px solid rgba(23,33,38,.18);
  border-bottom: 1px solid rgba(23,33,38,.18);
  background: var(--surface);
  transform: translateX(-50%) rotate(45deg);
}
.trend-tooltip > strong { margin-bottom: 3px; font-size: 12px; font-weight: 650; }
.trend-tooltip > span { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 6px; color: var(--muted); font-size: 10px; }
.trend-tooltip > span b { color: var(--ink); font-size: 11px; font-weight: 600; }
.trend-tooltip .legend-dot { margin: 0; }
.trend-tooltip .trend-tooltip-total {
  margin-top: 3px;
  padding-top: 7px;
  border-top: 1px solid var(--line-soft);
  grid-template-columns: 1fr auto;
}
.trend-tooltip .trend-tooltip-total b.negative { color: var(--danger); }
.trend-column:hover .trend-tooltip,
.trend-column:focus-visible .trend-tooltip,
.trend-column.is-selected .trend-tooltip { opacity: 1; transform: translate(-50%, 0); }
.trend-column:first-child .trend-tooltip { left: 0; transform: translate(0, 5px); }
.trend-column:first-child:hover .trend-tooltip,
.trend-column:first-child:focus-visible .trend-tooltip,
.trend-column:first-child.is-selected .trend-tooltip { transform: translate(0, 0); }
.trend-column:last-child .trend-tooltip { right: 0; left: auto; transform: translate(0, 5px); }
.trend-column:last-child:hover .trend-tooltip,
.trend-column:last-child:focus-visible .trend-tooltip,
.trend-column:last-child.is-selected .trend-tooltip { transform: translate(0, 0); }
.chart-legend { display: flex; gap: 16px; margin-top: 14px; color: var(--muted); font-size: 11px; }
.legend-dot { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; }
.legend-dot.income { background: var(--ink); }
.legend-dot.cash { background: var(--cash); }
.legend-dot.credit { background: var(--credit); }

.task-list, .record-list, .account-list, .compact-list { display: grid; gap: 8px; }
.task-item, .record-item, .account-row, .compact-row {
  min-width: 0;
  min-height: 58px;
  padding: 11px 12px;
  border: 0;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-soft);
}
.task-item { width: 100%; text-align: left; cursor: pointer; }
.task-item:hover { background: #f0f0f2; }
.task-icon, .asset-mark {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: var(--blue);
  background: var(--blue-soft);
  font-size: 12px;
  font-weight: 600;
}
.task-copy, .record-copy, .account-copy { min-width: 0; flex: 1; }
.task-copy strong, .record-copy strong, .account-copy strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 600;
}
.task-copy span, .record-copy span, .account-copy span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}
.task-amount, .record-amount { font-size: 13px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.record-item.is-void { opacity: .48; }
.empty-state { padding: 32px 14px; text-align: center; color: var(--muted); font-size: 13px; }
.empty-state strong { display: block; margin-bottom: 6px; color: var(--ink); font-weight: 600; }

.year-summary { min-height: 126px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.summary-stat {
  padding: 16px;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--surface-soft);
}
.summary-stat span { color: var(--muted); font-size: 11px; }
.summary-stat strong { margin-top: 18px; font-size: clamp(18px, 2vw, 25px); font-weight: 600; letter-spacing: -.035em; }
.summary-stat.highlight { color: white; background: var(--ink); }
.summary-stat.highlight span { color: #a1a1a6; }
.bridge-head { padding: 2px 2px 18px; border-bottom: 1px solid var(--line-soft); }
.bridge-head span, .bridge-head small { display: block; color: var(--muted); font-size: 11px; }
.bridge-head strong { display: block; margin: 7px 0 4px; font-size: 28px; font-weight: 600; letter-spacing: -.04em; }
.bridge-list { display: grid; gap: 6px; margin-top: 12px; }
.bridge-row { padding: 9px 2px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.bridge-row span { min-width: 0; }
.bridge-row strong, .bridge-row small { display: block; }
.bridge-row strong { font-size: 12px; font-weight: 600; }
.bridge-row small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.bridge-row b { white-space: nowrap; font-size: 12px; font-weight: 600; }
.net-worth-list { display: grid; gap: 8px; }
.net-worth-row { padding: 16px; border-radius: 14px; background: var(--surface-soft); }
.net-worth-row div { display: flex; align-items: baseline; justify-content: space-between; gap: 18px; }
.net-worth-row span { color: var(--muted); font-size: 11px; }
.net-worth-row strong { font-size: 22px; font-weight: 600; letter-spacing: -.035em; white-space: nowrap; }
.net-worth-row p { margin: 7px 0 0; color: var(--muted); font-size: 10px; }

.close-banner {
  margin-top: 16px;
  padding: 18px 20px;
  border: 1px solid #c9dcf5;
  border-radius: var(--radius);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  background: var(--blue-soft);
}
.close-banner.closed { border-color: var(--line-soft); background: var(--surface-soft); }
.close-banner strong { display: block; margin-bottom: 3px; font-weight: 600; }
.close-banner span { color: var(--muted); font-size: 12px; }

.toolbar { margin-top: 24px; display: flex; gap: 10px; flex-wrap: wrap; }
.activity-panel { margin-top: 18px; }
.ledger-toolbar {
  margin-top: 28px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.ledger-toolbar > div:first-child { display: flex; align-items: baseline; gap: 8px; }
.ledger-toolbar > div:first-child strong { font-family: "SFMono-Regular", "Roboto Mono", "Menlo", monospace; font-size: 24px; }
.ledger-toolbar > div:first-child span { color: var(--muted); font-size: 12px; }
.ledger-toolbar > div:last-child { display: flex; gap: 10px; }
.account-ledger-toolbar > div:first-child { align-items: center; }
.account-ledger-toolbar > div:first-child strong {
  font-family: "Songti SC", "STSong", ui-serif, serif;
  font-size: 20px;
  letter-spacing: -.02em;
}
.account-book-summary {
  margin-top: 28px;
  border: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  background: var(--line);
  gap: 1px;
}
.account-book-summary > div { min-width: 0; padding: 18px 20px; background: var(--surface); }
.account-book-summary span,
.account-book-summary small { display: block; color: var(--muted); font-size: 10px; }
.account-book-summary strong {
  display: block;
  margin: 7px 0 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: "SFMono-Regular", "Roboto Mono", "Menlo", monospace;
  font-size: 22px;
  letter-spacing: -.04em;
  white-space: nowrap;
}
.asset-summary-strip {
  margin-top: 28px;
  display: flex;
  gap: 1px;
  border: 1px solid var(--line);
  background: var(--line);
}
.asset-summary-strip > div { min-width: 220px; padding: 20px; flex: 1; background: var(--surface); }
.asset-summary-strip span, .asset-summary-strip small { display: block; color: var(--muted); font-size: 11px; }
.asset-summary-strip strong { display: block; margin: 8px 0 4px; font-family: "SFMono-Regular", "Roboto Mono", "Menlo", monospace; font-size: 24px; letter-spacing: -.04em; }
.account-ledger { margin-top: 34px; }
.account-ledger > header {
  padding: 0 2px 12px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 2px solid var(--ink);
}
.account-ledger > header h2 { margin: 0; font-family: "Songti SC", "STSong", ui-serif, serif; font-size: 23px; font-weight: 700; }
.account-ledger > header p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.account-ledger > header > span { color: var(--muted); font-size: 11px; }
.account-ledger-list { display: grid; }
.account-ledger-columns {
  padding: 9px 4px 7px;
  display: grid;
  grid-template-columns: minmax(220px, 1.5fr) minmax(150px, .9fr) minmax(130px, .7fr) auto;
  gap: 20px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 9px;
  letter-spacing: .04em;
}
.account-ledger-columns span:last-child { text-align: right; }
.account-ledger-row {
  min-height: 68px;
  padding: 9px 4px;
  display: grid;
  grid-template-columns: minmax(220px, 1.5fr) minmax(150px, .9fr) minmax(130px, .7fr) auto;
  align-items: center;
  gap: 20px;
  border-bottom: 1px solid var(--line);
}
.account-ledger-row:hover { background: rgba(251,252,250,.56); }
.account-identity { min-width: 0; display: flex; align-items: center; gap: 12px; }
.account-glyph {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  color: var(--blue);
}
.account-glyph svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.account-glyph.credit { color: var(--danger); }
.account-glyph.asset { color: #4e5f78; }
.account-glyph.liability { color: var(--danger); }
.account-identity strong, .account-identity span,
.account-figure span, .account-figure strong,
.account-freshness span, .account-freshness strong { display: block; }
.account-identity strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 600; }
.account-identity span, .account-figure span, .account-freshness span { margin-top: 2px; color: var(--muted); font-size: 10px; }
.account-rule { color: var(--muted); font-size: 11px; line-height: 1.35; }
.fixed-plan-list { border-top: 1px solid var(--line); }
.fixed-plan-row { display: grid; grid-template-columns: minmax(260px, 1.4fr) 1fr 1fr; gap: 28px; align-items: center; padding: 22px 4px; border-bottom: 1px solid var(--line); }
.fixed-plan-row > div:not(.plan-identity) { display: grid; gap: 4px; }
.fixed-plan-row span, .fixed-plan-row small { color: var(--muted); font-size: 11px; }
.fixed-plan-row strong { font-size: 18px; }
.plan-identity { display: flex; align-items: center; gap: 12px; }
.account-glyph.plan { color: var(--blue); background: var(--blue-soft); font-size: 22px; }
.account-figure strong {
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: "SFMono-Regular", "Roboto Mono", "Menlo", monospace;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -.03em;
  white-space: nowrap;
}
.account-freshness strong { margin-top: 3px; font-size: 12px; font-weight: 500; }
.account-row-actions { display: flex; justify-content: flex-end; gap: 6px; }
.row-action {
  min-height: 32px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--blue);
  background: var(--surface);
  cursor: pointer;
  font-size: 11px;
}
.row-action:hover { border-color: var(--blue); background: var(--blue-soft); }
.row-action.emphasized { border-color: var(--blue); color: white; background: var(--blue); }
.row-action.emphasized:hover { color: white; background: var(--blue-focus); }

.liability-ledger { margin-top: 46px; }
.liability-ledger > header {
  padding: 0 2px 12px;
  border-bottom: 3px double var(--ink);
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 22px;
}
.liability-ledger > header h2 {
  margin: 0;
  font-family: "Songti SC", "STSong", ui-serif, serif;
  font-size: 23px;
  font-weight: 700;
}
.liability-ledger > header p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.liability-ledger > header > div:last-child { display: flex; align-items: center; gap: 12px; }
.liability-ledger > header > div:last-child > span { color: var(--muted); font-size: 11px; }
.liability-list { display: grid; }
.liability-row {
  min-height: 112px;
  padding: 17px 4px;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: minmax(190px, 1.2fr) minmax(190px, 1fr) minmax(190px, .95fr) auto;
  align-items: center;
  gap: 24px;
}
.liability-row:hover { background: rgba(251,252,250,.56); }
.liability-identity { min-width: 0; display: flex; align-items: center; gap: 12px; }
.liability-identity strong,
.liability-identity span,
.liability-balance > span,
.liability-balance > strong,
.liability-balance > small,
.liability-schedule span,
.liability-schedule strong,
.liability-schedule small { display: block; }
.liability-identity strong { font-size: 14px; font-weight: 650; }
.liability-identity span,
.liability-balance > span,
.liability-balance > small,
.liability-schedule span,
.liability-schedule small { color: var(--muted); font-size: 10px; }
.liability-balance > strong {
  margin-top: 3px;
  font-family: "SFMono-Regular", "Roboto Mono", "Menlo", monospace;
  font-size: 18px;
  letter-spacing: -.035em;
}
.liability-progress {
  width: min(160px, 100%);
  height: 3px;
  margin: 8px 0 5px;
  overflow: hidden;
  background: var(--line-soft);
}
.liability-progress i { display: block; height: 100%; background: var(--blue); }
.liability-progress > [class*="p-"] { width: var(--portion); }
.liability-schedule strong { margin-top: 4px; font-size: 13px; font-weight: 600; }
.liability-schedule small { margin-top: 3px; }
.liability-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }
.recorded-mark,
.settled-mark,
.statement-waiting {
  min-height: 32px;
  padding: 7px 10px;
  border-radius: 4px;
  color: var(--blue);
  background: var(--blue-soft);
  font-size: 11px;
}
.settled-mark { color: var(--muted); background: var(--surface-soft); }
.statement-waiting { color: var(--muted); background: var(--surface-soft); }
.liability-empty {
  min-height: 168px;
  padding: 30px 4px;
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 7px;
  border-bottom: 1px solid var(--line);
}
.liability-empty strong { font-family: "Songti SC", "STSong", ui-serif, serif; font-size: 19px; }
.liability-empty span { max-width: 560px; color: var(--muted); font-size: 12px; }
.liability-empty button { margin-top: 8px; }
.liability-payment-head {
  grid-column: 1 / -1;
  padding: 16px;
  border-top: 3px double var(--ink);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
}
.liability-payment-head span { color: var(--muted); font-size: 11px; }
.liability-payment-head strong {
  font-family: "SFMono-Regular", "Roboto Mono", "Menlo", monospace;
  font-size: 22px;
  letter-spacing: -.04em;
}
.difference-preview.invalid { color: var(--danger); background: var(--danger-soft); }
.auth-screen { min-height: 100vh; padding: 24px; display: grid; place-items: center; }
.auth-card {
  width: min(440px, 100%);
  padding: 40px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface);
}
.auth-card .brand-mark { margin-bottom: 28px; }
.auth-card h1 { font-size: 36px; }
.auth-copy { color: var(--muted); font-size: 16px; }
.auth-form { display: grid; gap: 16px; margin-top: 24px; }
.auth-form label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; }
.auth-form input { min-height: 46px; padding: 0 14px; border: 1px solid var(--line); border-radius: 11px; }
.auth-form .primary-button, #login-button { width: 100%; margin-top: 8px; }
.subtle { margin: 14px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }

dialog {
  width: min(640px, calc(100% - 32px));
  max-height: min(88vh, 780px);
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 22px;
  color: var(--ink);
  background: var(--surface);
}
dialog::backdrop { background: rgba(0,0,0,.32); backdrop-filter: blur(10px); }
.modal-shell { max-height: min(88vh, 780px); display: flex; flex-direction: column; }
.modal-shell > header {
  flex: 0 0 auto;
  padding: 26px 28px 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  background: var(--surface);
}
.modal-shell h2 { margin: 0; font-size: 26px; font-weight: 600; letter-spacing: -.035em; }
.close-button {
  width: 44px;
  height: 44px;
  margin: -6px -6px 0 0;
  border: 0;
  border-radius: 50%;
  color: #424245;
  background: var(--surface-soft);
  cursor: pointer;
  font-size: 24px;
  font-weight: 300;
  line-height: 1;
}
.close-button:hover { background: #ededf0; }
#modal-body { min-height: 0; padding: 0 28px 28px; overflow-y: auto; overscroll-behavior: contain; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: grid; gap: 7px; color: var(--muted); font-size: 12px; }
.field.full { grid-column: 1 / -1; }
.field span { padding-left: 2px; }
.field span small { color: #a1a1a6; font-size: 10px; }
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--ink);
  background: var(--surface);
  outline: none;
}
.field input, .field select { min-height: 46px; padding: 0 14px; }
.field textarea { min-height: 92px; padding: 12px 14px; resize: vertical; }
.field input::placeholder, .field textarea::placeholder { color: #a1a1a6; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--blue-focus);
  box-shadow: 0 0 0 3px rgba(0,113,227,.12);
}
.field input[type="number"] { appearance: textfield; }
.field input[type="number"]::-webkit-inner-spin-button,
.field input[type="number"]::-webkit-outer-spin-button { margin: 0; appearance: none; }
.field input[type="checkbox"] { width: 18px; min-height: 18px; margin: 0 8px 0 0; accent-color: var(--blue); vertical-align: middle; }
.form-actions {
  position: sticky;
  bottom: -28px;
  z-index: 2;
  grid-column: 1 / -1;
  margin: 4px -28px -28px;
  padding: 16px 28px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--line-soft);
  background: rgba(255,255,255,.92);
  backdrop-filter: saturate(180%) blur(16px);
}
.difference-preview {
  grid-column: 1 / -1;
  padding: 12px 14px;
  border-radius: 11px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 12px;
}
.statement-installments {
  grid-column: 1 / -1;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
}
.statement-installments > header {
  padding: 13px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface-soft);
}
.statement-installments > header strong,
.statement-installments > header span { display: block; }
.statement-installments > header strong { font-size: 12px; }
.statement-installments > header div > span,
.statement-installments > header > span { margin-top: 2px; color: var(--muted); font-size: 10px; }
.statement-installment-row {
  padding: 12px 14px;
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 120px 110px;
  align-items: end;
  gap: 12px;
  border-bottom: 1px solid var(--line-soft);
}
.statement-installment-row:last-child { border-bottom: 0; }
.statement-installment-name { min-width: 0; display: flex; align-items: center; gap: 9px; }
.statement-installment-name > span {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--blue);
  background: var(--blue-soft);
}
.statement-installment-name svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; }
.statement-installment-name strong,
.statement-installment-name small { display: block; }
.statement-installment-name strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.statement-installment-name small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.statement-installment-row label { display: grid; gap: 5px; color: var(--muted); font-size: 10px; }
.statement-installment-row input {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: none;
}
.statement-installment-row input:focus {
  border-color: var(--blue-focus);
  box-shadow: 0 0 0 3px rgba(0,113,227,.12);
}

#toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 100;
  max-width: min(360px, calc(100% - 48px));
  padding: 12px 18px;
  border-radius: 999px;
  color: white;
  background: var(--ink);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
#toast.show { opacity: 1; transform: translateY(0); }
#toast.error { background: var(--danger); }
.mobile-topbar, .mobile-nav { display: none; }

@media (max-width: 1100px) {
  .account-ledger-row { grid-template-columns: minmax(200px, 1.35fr) minmax(140px, .8fr) auto; }
  .account-freshness { display: none; }
  .account-ledger-columns { grid-template-columns: minmax(200px, 1.35fr) minmax(140px, .8fr) auto; }
  .account-ledger-columns span:nth-child(3) { display: none; }
  .liability-row { grid-template-columns: minmax(190px, 1.2fr) minmax(180px, 1fr) minmax(180px, .9fr); }
  .liability-actions { grid-column: 1 / -1; justify-content: flex-start; }
}

@media (max-width: 760px) {
  body { padding-bottom: env(safe-area-inset-bottom); }
  .sidebar { display: none; }
  .mobile-topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--line-soft);
    background: rgba(255,255,255,.82);
    backdrop-filter: saturate(180%) blur(20px);
  }
  .mobile-topbar .brand-mark { width: 34px; height: 34px; }
  .mobile-add-button { min-height: 38px; padding: 7px 12px; border: 1px solid var(--blue); border-radius: 4px; color: white; background: var(--blue); }
  main { margin: 0; padding: 28px 16px 104px; }
  .page-header { display: block; }
  h1 { font-size: 34px; }
  .lead { font-size: 15px; }
  .month-control { width: fit-content; margin-top: 20px; }
  .month-ledger { margin-top: 26px; padding: 22px 20px 24px; }
  .ledger-heading > div small { max-width: 220px; }
  .ledger-result { padding: 28px 0 22px; display: block; }
  .ledger-result strong { font-size: clamp(38px, 12vw, 56px); }
  .ledger-result span { display: block; margin-top: 10px; max-width: none; text-align: left; }
  .ledger-equation { grid-template-columns: 1fr; gap: 12px; }
  .ledger-equation div { padding: 10px 0; display: flex; align-items: baseline; justify-content: space-between; gap: 14px; }
  .ledger-equation div small { display: none; }
  .ledger-equation b { display: none; }
  .ledger-equation strong { margin: 0; font-size: 20px; }
  .quick-figures { grid-template-columns: 1fr 1fr; }
  .quick-figures > div { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
  .quick-figures > div:nth-child(2n) { border-right: 0; }
  .quick-figures > div:nth-last-child(-n+2) { border-bottom: 0; }
  .content-grid, .supporting-grid { grid-template-columns: 1fr; }
  .panel { padding: 19px; }
  .panel-header { margin-bottom: 18px; }
  .year-summary { grid-template-columns: 1fr; }
  .summary-stat { min-height: 92px; }
  .ledger-toolbar { align-items: flex-start; }
  .ledger-toolbar > div:last-child { flex-wrap: wrap; justify-content: flex-end; }
  .account-book-summary { overflow-x: auto; display: flex; }
  .account-book-summary > div { flex: 0 0 230px; }
  .asset-summary-strip { overflow-x: auto; }
  .asset-summary-strip > div { flex: 0 0 240px; }
  .account-ledger-columns { display: none; }
  .account-ledger-row { grid-template-columns: minmax(0, 1fr) auto; gap: 12px 18px; padding: 14px 2px; }
  .account-figure { text-align: right; }
  .account-freshness { display: block; grid-column: 1; }
  .account-row-actions { grid-column: 2; grid-row: 2; }
  .liability-ledger > header { align-items: flex-start; flex-direction: column; }
  .liability-ledger > header > div:last-child { width: 100%; justify-content: space-between; }
  .liability-row { grid-template-columns: 1fr; gap: 14px; padding: 20px 2px; }
  .liability-identity,
  .liability-balance,
  .liability-schedule,
  .liability-actions { grid-column: 1; }
  .liability-actions { justify-content: flex-start; }
  .mobile-nav {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    z-index: 30;
    padding: 5px;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    border: 1px solid var(--line-soft);
    border-radius: 18px;
    background: rgba(255,255,255,.9);
    backdrop-filter: saturate(180%) blur(20px);
  }
  .mobile-nav button { min-height: 44px; border: 0; border-radius: 13px; color: var(--muted); background: transparent; font-size: 11px; }
  .mobile-nav button.active { color: var(--blue); background: var(--blue-soft); font-weight: 600; }
  .close-banner { align-items: flex-start; flex-direction: column; }
  dialog { width: 100%; max-height: calc(100dvh - env(safe-area-inset-top)); margin: auto 0 0; border-width: 1px 0 0; border-radius: 22px 22px 0 0; overscroll-behavior: contain; }
  .modal-shell { max-height: inherit; }
  .modal-shell > header { padding: 22px 20px 14px; }
  #modal-body { padding: 0 20px calc(88px + env(safe-area-inset-bottom)); -webkit-overflow-scrolling: touch; }
  .form-grid { grid-template-columns: 1fr; gap: 14px; }
  .field.full, .form-actions, .difference-preview, .liability-payment-head { grid-column: auto; }
  .statement-installments { grid-column: auto; }
  .statement-installment-row { grid-template-columns: 1fr 1fr; }
  .statement-installment-name { grid-column: 1 / -1; }
  .field input, .field select, .field textarea, .auth-form input { font-size: 16px; }
  .form-actions { bottom: 0; margin: 4px -20px 0; padding: 12px 20px max(12px, env(safe-area-inset-bottom)); }
  .form-actions button { flex: 1; }
  .fixed-plan-row { grid-template-columns: 1fr; gap: 12px; padding: 18px 2px; }
}

@media (max-width: 420px) {
  .trend-chart { gap: 8px; }
  .bar-space { height: 170px; }
  .trend-tooltip { width: 176px; padding: 10px 11px; }
  .panel-header { display: block; }
  .panel-header button { margin-top: 12px; }
  .quick-figures { grid-template-columns: 1fr; }
  .quick-figures > div, .quick-figures > div:nth-child(2n), .quick-figures > div:nth-last-child(-n+2) { border-right: 0; border-bottom: 1px solid var(--line); }
  .quick-figures > div:last-child { border-bottom: 0; }
  .ledger-toolbar { display: block; }
  .ledger-toolbar > div:last-child { margin-top: 14px; justify-content: flex-start; }
}

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