:root {
  interpolate-size: allow-keywords;
  --bg: #0e1a2b;
  --bg-deep: #0a1422;
  --surface: #15253c;
  --surface-elevated: #1a2d47;
  --surface-hover: #213756;
  --ink: #f4f1ea;
  --muted: #98acc4;
  --line: rgba(196, 214, 236, 0.13);
  --line-strong: rgba(217, 190, 143, 0.32);
  --brass: #d9be8f;
  --brass-soft: rgba(217, 190, 143, 0.14);
  --sage: #86cbb0;
  --sage-soft: rgba(134, 203, 176, 0.14);
  --terracotta: #e89c8b;
  --terracotta-soft: rgba(232, 156, 139, 0.15);
  --chart: #7f9ec4;
  --radius: 10px;
  --serif: Baskerville, "Baskerville Old Face", "Songti SC", "Noto Serif SC", Georgia, serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; color-scheme: dark; }
body {
  margin: 0;
  min-height: 100dvh;
  background: radial-gradient(1200px 600px at 15% -10%, #1c314f 0%, var(--bg) 55%, var(--bg-deep) 100%);
  color: var(--ink);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; min-height: 40px; border: 0; transition: background .16s ease, border-color .16s ease, transform .1s ease, opacity .16s ease; }
button:active:not(:disabled) { transform: scale(.985); }
button:disabled { opacity: .45; cursor: default; }
a, button, input, select, textarea, summary { touch-action: manipulation; }
:where(button, a, input, select, textarea, summary):focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(22px, 2.4vw, 30px); font-weight: 560; letter-spacing: -.025em; line-height: 1.3; }
h2 { font-size: 17px; font-weight: 580; letter-spacing: -.015em; }
h3 { font-size: 15px; font-weight: 580; }
.small { font-size: 12px; }
.muted { color: var(--muted); }
.negative { color: var(--terracotta) !important; }

.brand {
  color: var(--ink);
  font: 400 clamp(20px, 2.2vw, 26px)/1.05 var(--serif);
  text-transform: uppercase;
  letter-spacing: .2em;
  white-space: nowrap;
  text-decoration: none;
}
.eyebrow {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--brass);
}

/* Inputs & Buttons */
label { display: block; font-size: 12px; font-weight: 500; color: var(--muted); }
.field-label { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 8px; }
input, select, textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid rgba(196, 214, 236, 0.22);
  border-radius: var(--radius);
  background: rgba(11, 22, 37, 0.65);
  color: var(--ink);
  padding: 10px 12px;
  min-height: 44px;
  margin-top: 6px;
}
input::placeholder, textarea::placeholder { color: rgba(152, 172, 196, 0.65); }
select option { background: #142338; color: var(--ink); }
textarea { resize: vertical; min-height: 70px; }

.primary {
  background: var(--ink);
  color: #0e1a2b;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-weight: 600;
}
.primary:hover:not(:disabled) { background: #ffffff; }
.accent-btn {
  background: var(--brass);
  color: #111d2e;
  padding: 9px 16px;
  border-radius: 9px;
  font-weight: 650;
  font-size: 13px;
  white-space: nowrap;
}
.accent-btn:hover:not(:disabled) { background: #e6cfa5; }
.secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  border: 1px solid rgba(196, 214, 236, 0.2);
  border-radius: var(--radius);
  padding: 9px 15px;
}
.secondary:hover:not(:disabled) { background: rgba(255, 255, 255, 0.1); }
.ghost-pill {
  min-height: 32px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  font-size: 12px;
  white-space: nowrap;
}
.ghost-pill:hover:not(:disabled) { border-color: var(--line-strong); background: var(--brass-soft); color: var(--brass); }
.text-button { background: transparent; color: var(--brass); padding: 6px 8px; font-size: 13px; font-weight: 500; min-height: 36px; }
.text-button:hover { text-decoration: underline; text-underline-offset: 3px; }
.danger-btn { background: rgba(191, 78, 63, 0.85); color: #fff; padding: 10px 16px; border-radius: var(--radius); font-weight: 600; }
.danger-btn:hover { background: #c55344; }
.wide { width: 100%; }
.compact-btn { min-height: 36px; padding: 6px 12px; font-size: 12px; }
.button-link { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; min-height: 44px; }

.inline-error {
  padding: 10px 12px;
  border-radius: 9px;
  background: var(--terracotta-soft);
  border: 1px solid rgba(232, 156, 139, 0.35);
  color: #ffd0c6;
  font-size: 13px;
}
.inline-info {
  padding: 10px 12px;
  border-radius: 9px;
  background: var(--brass-soft);
  border: 1px solid var(--line-strong);
  color: var(--brass);
  font-size: 13px;
}

/* Auth & Onboarding */
.auth-screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.auth-card {
  width: min(440px, 100%);
  background: rgba(21, 37, 60, 0.92);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 34px 28px;
  box-shadow: 0 28px 70px rgba(4, 10, 20, 0.55);
  backdrop-filter: blur(12px);
}
.onboarding-card { width: min(520px, 100%); }
.onboarding-card h1 { margin-top: 14px; font-family: var(--serif); font-size: 26px; font-weight: 500; }
.onboarding-card > p { margin: 8px 0 22px; }
.auth-brand { text-align: center; margin-bottom: 24px; }
.auth-tagline { color: var(--muted); font-size: 13px; margin-top: 8px; }
.auth-tabs, .type-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 10px;
  background: rgba(9, 18, 31, 0.65);
  border: 1px solid var(--line);
  margin-bottom: 18px;
}
.auth-tabs button, .type-tabs button {
  flex: 1;
  min-height: 36px;
  background: transparent;
  color: var(--muted);
  border-radius: 7px;
  font-size: 13px;
}
.auth-tabs .selected, .type-tabs .selected {
  background: var(--surface-elevated);
  color: var(--ink);
  font-weight: 600;
}
.auth-form, .stack-form { display: grid; gap: 14px; }
.otp-mode-switch { display: flex; gap: 18px; font-size: 13px; }
.inline-radio { display: flex; align-items: center; gap: 6px; cursor: pointer; color: var(--ink); }
.inline-radio input { width: auto; min-height: auto; margin: 0; accent-color: var(--brass); }
.otp-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; }
.center-btn { justify-self: center; }

.chip-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 38px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  font-size: 13px;
}
.chip.selected { background: var(--brass); color: #111d2e; border-color: var(--brass); font-weight: 600; }
.onboarding-actions { display: grid; gap: 8px; margin-top: 8px; }

/* Navigation */
.layout { min-height: 100dvh; }
.masthead {
  view-transition-name: masthead;
  position: sticky;
  top: 0;
  z-index: 12;
  min-height: 62px;
  padding: 0 clamp(20px, 5vw, 72px);
  display: flex;
  align-items: center;
  gap: clamp(20px, 4vw, 52px);
  background: rgba(12, 23, 39, 0.84);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.masthead nav { display: flex; gap: clamp(14px, 2vw, 28px); align-items: center; }
.masthead nav button {
  background: transparent;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
  min-height: 61px;
  padding: 0 4px;
  font-size: 13px;
}
.masthead nav button:hover, .masthead nav button.active { color: var(--ink); font-weight: 580; }
.masthead nav button.active::after { content: ""; position: absolute; inset: auto 0 0; height: 2px; background: var(--brass); }
.masthead nav svg, .mobile-entry { display: none; }
.masthead-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.kbd-hint { font-size: 12px; color: var(--muted); }
.kbd-hint kbd {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 5px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.06);
  color: var(--brass);
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, monospace;
}

main {
  width: 100%;
  max-width: 1260px;
  margin: 0 auto;
  padding: 28px clamp(18px, 5vw, 64px) 76px;
}

/* Top-layer Popover Toast with Undo & Explicit Close */
.toast {
  position: fixed;
  inset: auto 24px 24px auto;
  margin: 0;
  max-width: min(460px, calc(100vw - 28px));
  border: 0;
  padding: 11px 14px 11px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: #0e1a2b;
  font-size: 13px;
  font-weight: 560;
  box-shadow: 0 14px 36px rgba(0, 0, 0, .45);
  opacity: 0;
  transition-property: opacity, transform, display, overlay;
  transition-duration: 0.22s;
  transition-timing-function: ease-out;
  transition-behavior: allow-discrete;
}
@media (prefers-reduced-motion: no-preference) {
  .toast { transform: translateY(8px); }
}
.toast:is(:popover-open, .is-open):where(:not([data-closing])) {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  opacity: 1;
  @starting-style { opacity: 0; }
  @media (prefers-reduced-motion: no-preference) {
    transform: translateY(0);
    @starting-style { transform: translateY(8px); }
  }
}
@supports not selector(:popover-open) {
  .toast:not(.is-open) { display: none; }
}
.toast.error { background: #c55344; color: #fff; }
.toast-undo {
  min-height: 28px;
  padding: 3px 10px;
  border-radius: 6px;
  background: #0e1a2b;
  color: var(--brass);
  font-size: 12px;
  font-weight: 600;
}
.toast-close {
  min-height: 28px;
  width: 28px;
  padding: 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  opacity: .72;
  font-size: 18px;
  line-height: 1;
}
.toast-close:hover { opacity: 1; background: rgba(0, 0, 0, .08); }

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.month-heading, .month-arrows, .header-actions { display: flex; align-items: center; gap: 8px; }
.month-heading h1 { font-family: var(--serif); font-weight: 500; font-size: clamp(24px, 2.5vw, 32px); }
.month-arrows button { background: transparent; color: var(--muted); width: 32px; font-size: 22px; border-radius: 6px; }
.month-arrows button:hover { background: var(--surface-hover); color: var(--ink); }
.month-input { width: 132px; min-height: 36px; margin: 0; padding: 5px 8px; font-size: 12px; }
.header-actions select { width: auto; margin: 0; min-height: 38px; font-size: 13px; }

/* SIGNATURE HOOK #1: LIVE-CHIP COMPOSER */
.live-composer {
  margin-bottom: 26px;
  padding: 14px 16px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(28, 47, 74, 0.88) 0%, rgba(20, 35, 57, 0.92) 100%);
  border: 1px solid var(--line-strong);
  box-shadow: 0 14px 38px rgba(4, 10, 20, 0.35);
  transition: border-color .2s ease, box-shadow .2s ease;
}
.live-composer:focus-within {
  border-color: var(--brass);
  box-shadow: 0 16px 44px rgba(4, 10, 20, 0.45), 0 0 0 3px rgba(217, 190, 143, 0.14);
}
.composer-input-wrap {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.composer-lead {
  color: var(--brass);
  font-size: 16px;
  line-height: 40px;
  flex: none;
}
#live-input {
  flex: 1;
  width: 100%;
  height: auto;
  field-sizing: content;
  min-block-size: 1.8lh;
  max-block-size: 7lh;
  margin: 0;
  padding: 8px 4px;
  min-height: 40px;
  max-height: 168px;
  border: 0;
  background: transparent;
  font-size: 15px;
  line-height: 1.55;
  resize: none;
  outline: none;
}
.composer-actions { display: flex; align-items: center; gap: 8px; flex: none; padding-top: 2px; }
.composer-examples {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.example-pill {
  min-height: 28px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}
.example-pill:hover { color: var(--ink); border-color: var(--line-strong); background: var(--brass-soft); }

.live-preview-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
@keyframes chipIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.live-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(11, 21, 36, 0.65);
  border: 1px solid var(--line);
  animation: chipIn .16s ease-out;
}
.live-row.incomplete { border-color: rgba(232, 156, 139, 0.4); }
.live-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid transparent;
  color: var(--ink);
}
.live-chip.kind-expense { background: rgba(127, 158, 196, 0.16); color: #d7e6f9; }
.live-chip.kind-income { background: var(--sage-soft); color: var(--sage); }
.live-chip.kind-refund { background: var(--terracotta-soft); color: var(--terracotta); }
.live-chip.kind-transfer { background: var(--brass-soft); color: var(--brass); }
.live-chip.amount-chip { font-weight: 650; font-size: 13px; background: var(--brass-soft); color: var(--brass); border-color: var(--line-strong); }
.live-chip.warn-chip { border-color: rgba(232, 156, 139, 0.55); color: var(--terracotta); }
.live-chip select {
  field-sizing: content;
  width: auto;
  max-inline-size: 16ch;
  min-height: 24px;
  margin: 0;
  padding: 0 2px;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 12px;
  cursor: pointer;
}
.live-chip .category-icon { width: 14px; height: 14px; }
.date-chip { position: relative; cursor: pointer; margin: 0; font-weight: 400; color: var(--ink); }
.date-chip:hover { border-color: var(--line-strong); background: var(--brass-soft); }
.date-chip input[type="date"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  padding: 0;
  min-height: 0;
  cursor: pointer;
}
.live-desc { margin-left: auto; font-size: 12px; color: var(--muted); max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer-hint { margin-top: 8px; font-size: 12px; color: var(--brass); }

/* SIGNATURE HOOK #2: HERO EDITORIAL PACING */
.hero-editorial {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1.35fr);
  gap: 24px;
  margin-bottom: 24px;
}
.margin-card, .panel, .story-card {
  padding: 24px;
  border-radius: 16px;
  background: rgba(21, 37, 60, 0.72);
  border: 1px solid var(--line);
}
.margin-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: linear-gradient(160deg, rgba(27, 46, 73, 0.92) 0%, rgba(18, 32, 52, 0.88) 100%);
}
.margin-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pace-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
}
.pace-badge.calm { background: var(--sage-soft); color: var(--sage); }
.pace-badge.steady { background: var(--brass-soft); color: var(--brass); }
.pace-badge.fast, .pace-badge.over { background: var(--terracotta-soft); color: var(--terracotta); }
.pace-badge.unbudgeted { background: rgba(255,255,255,0.07); color: var(--muted); }

.margin-figure-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.margin-headline {
  font-family: var(--serif);
  font-size: clamp(38px, 4.5vw, 56px);
  font-weight: 500;
  letter-spacing: -.03em;
  line-height: 1.08;
  color: var(--ink);
}
.pace-subtext { margin-top: 10px; font-size: 13px; color: var(--muted); line-height: 1.6; }

/* Dual Pace Bar */
.pace-bar-wrap { margin-top: 18px; }
.pace-track {
  position: relative;
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: visible;
}
.pace-spent-fill {
  height: 100%;
  max-width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #7f9ec4, var(--brass));
  transition: width .45s cubic-bezier(.22, 1, .36, 1);
}
.pace-spent-fill.over { background: var(--terracotta); }
.pace-time-marker {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 2px;
  border-radius: 2px;
  background: var(--ink);
  box-shadow: 0 0 8px rgba(244, 241, 234, 0.65);
  transition: left .45s cubic-bezier(.22, 1, .36, 1);
}
.pace-legend {
  display: flex;
  justify-content: space-between;
  margin-top: 7px;
  font-size: 11px;
  color: var(--muted);
}

.sub-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.sub-metric span { display: block; font-size: 11px; color: var(--muted); }
.sub-metric strong { display: block; font-size: 18px; font-weight: 580; margin: 3px 0 2px; overflow-wrap: anywhere; }
.sub-metric small { display: block; font-size: 11px; color: var(--muted); }
.other-currencies { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 11px; color: var(--muted); }

/* Rhythm 30-day calm dot strip */
.rhythm-block { margin-bottom: 18px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.rhythm-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.rhythm-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12px, 1fr));
  gap: 5px;
  align-items: center;
}
.rhythm-dot {
  height: 14px;
  min-height: 14px;
  border-radius: 4px;
  padding: 0;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.05);
}
.rhythm-dot.zero {
  background: transparent;
  border-color: rgba(217, 190, 143, 0.42);
}
.rhythm-dot.light { background: rgba(127, 158, 196, 0.38); }
.rhythm-dot.medium { background: rgba(127, 158, 196, 0.72); }
.rhythm-dot.heavy { background: var(--brass); }
.rhythm-dot.refund { background: var(--sage); }
.rhythm-dot.future { background: rgba(255, 255, 255, 0.03); border-color: rgba(255,255,255,0.06); }
.rhythm-dot:hover { transform: scaleY(1.35); border-color: var(--ink); }

/* Magazine-Style Monthly Story Card */
.story-card {
  margin-bottom: 24px;
  background: linear-gradient(135deg, rgba(217, 190, 143, 0.09) 0%, rgba(21, 37, 60, 0.78) 55%);
  border-color: var(--line-strong);
}
.story-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.story-serif { font-family: var(--serif); font-size: 22px; font-weight: 500; margin-top: 2px; color: var(--ink); }
.story-lines { list-style: none; padding: 0; margin: 0; display: grid; gap: 9px; }
.story-lines li {
  position: relative;
  padding-left: 16px;
  font-size: 14px;
  line-height: 1.65;
  color: #e4ebf4;
}
.story-lines li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--brass);
}

/* Charts & Ledger Grid */
.ledger-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.segmented { display: flex; gap: 10px; }
.segmented button { min-height: 30px; background: transparent; color: var(--muted); padding: 4px; border-bottom: 1.5px solid transparent; font-size: 12px; }
.segmented .selected { color: var(--ink); border-color: var(--brass); font-weight: 600; }

.chart-summary { display: flex; justify-content: flex-end; }
.chart-key { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--muted); }
.chart-key i { display: inline-block; width: 7px; height: 7px; background: var(--chart); border-radius: 1px; }
.chart-key .refund-key { background: var(--terracotta); margin-left: 8px; }
.trend-chart { margin-top: 6px; }
.trend-chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-grid-line { stroke: var(--line); stroke-width: 1; }
.chart-zero { stroke: rgba(196, 214, 236, 0.35); stroke-width: 1; }
.chart-axis { fill: var(--muted); font-size: 11px; }
.chart-axis.is-selected { fill: var(--ink); font-weight: 650; }
.chart-bar { fill: var(--chart); }
.chart-bar.is-selected:not(.negative-bar) { fill: var(--brass); }
.chart-bar.negative-bar { fill: var(--terracotta); }
.chart-line { fill: none; stroke: var(--brass); stroke-width: 2.3; stroke-linejoin: round; stroke-linecap: round; }
.chart-area { fill: rgba(217, 190, 143, 0.14); }
.chart-selection { stroke: rgba(217, 190, 143, 0.5); stroke-dasharray: 3 4; pointer-events: none; }
.chart-day-band { fill: var(--brass); opacity: .14; pointer-events: none; }
.chart-point { fill: var(--ink); stroke: var(--bg); stroke-width: 2; pointer-events: none; }
.chart-hit { cursor: pointer; }
.day-inspector { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.day-inspector label { font-size: 11px; color: var(--muted); }
.day-inspector input[type="range"] { flex: 1; min-width: 100px; accent-color: var(--brass); min-height: auto; padding: 0; margin: 0; border: 0; background: transparent; }
.day-stepper { display: none; gap: 4px; }
.day-stepper button { width: 34px; min-height: 34px; display: grid; place-items: center; background: var(--surface-elevated); color: var(--ink); border-radius: 6px; }
.day-stepper svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.chart-data { margin-top: 8px; font-size: 12px; color: var(--muted); }
.chart-data summary { cursor: pointer; min-height: 30px; }
.chart-data table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 12px; }
.chart-data th, .chart-data td { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: left; }

.category-chart { display: grid; gap: 12px; }
.category-row { display: block; width: 100%; background: transparent; color: var(--ink); text-align: left; padding: 4px 0; min-height: 44px; }
.category-label { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 13px; margin-bottom: 6px; }
.category-label > span { display: flex; align-items: center; gap: 7px; }
.category-track { position: relative; height: 5px; border-radius: 3px; background: rgba(255,255,255,0.08); overflow: hidden; }
.category-zero { position: absolute; top: 0; bottom: 0; width: 1px; background: rgba(255,255,255,0.28); }
.category-fill { position: absolute; top: 0; bottom: 0; background: linear-gradient(90deg, var(--chart), var(--brass)); border-radius: 3px; }
.category-fill.negative-bar { background: var(--terracotta); }
.category-icon { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Transaction list */
.transaction-list { display: grid; }
.tx-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px 8px;
  background: transparent;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  text-align: left;
  width: 100%;
  border-radius: 8px;
}
.tx-row:hover { background: rgba(255, 255, 255, 0.04); }
.tx-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  color: var(--brass);
}
.tx-main b { display: block; font-size: 14px; font-weight: 550; overflow-wrap: anywhere; }
.tx-main small { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.tx-amount { text-align: right; font-weight: 600; font-size: 15px; white-space: nowrap; }
.tx-amount.income, .tx-amount.refund { color: var(--sage); }
.empty { color: var(--muted); padding: 20px 0; font-size: 13px; white-space: pre-line; }

.filter-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.8fr) repeat(3, minmax(110px, .8fr)) auto auto;
  gap: 10px;
  margin-bottom: 16px;
  align-items: center;
}
.filter-row > * { margin: 0; }

/* Accounts, Projects, Settings */
.funds-totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.fund-card { padding: 18px 20px; border: 1px solid var(--line); border-radius: 14px; background: rgba(21, 37, 60, 0.72); }
.fund-card span { display: block; font-size: 12px; color: var(--muted); }
.fund-card strong { display: block; font-family: var(--serif); font-size: 28px; margin: 5px 0; }
.account-list { display: grid; }
.account-row {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) auto auto;
  align-items: center;
  gap: 16px;
  padding: 15px 6px;
  border-bottom: 1px solid var(--line);
}
.account-row p { font-size: 12px; color: var(--muted); margin-top: 2px; }
.account-balance { text-align: right; font-size: 17px; font-weight: 600; }
.project-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.project-card { padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: rgba(21, 37, 60, 0.72); display: grid; gap: 6px; }

.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 20px; }
.settings-card {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(21, 37, 60, 0.72);
  display: grid;
  gap: 14px;
  align-content: start;
}
.settings-links { display: flex; flex-wrap: wrap; gap: 10px; }
.toggle-row { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; color: var(--ink); font-weight: 400; }
.toggle-row input { width: 18px; height: 18px; min-height: 18px; margin: 3px 0 0; accent-color: var(--brass); flex: none; }
.toggle-row strong { display: block; font-size: 14px; }
.toggle-row small { display: block; color: var(--muted); font-size: 12px; }
.danger-zone { margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.danger-zone summary { cursor: pointer; color: var(--terracotta); font-size: 13px; margin-bottom: 10px; }

/* Smooth intrinsic-size disclosure animation for <details> */
details::details-content {
  block-size: 0;
  overflow: hidden;
  transition-property: block-size, content-visibility;
  transition-duration: 0.28s;
  transition-timing-function: ease-out;
  transition-behavior: allow-discrete;
}
details[open]::details-content {
  block-size: auto;
}

/* COHESIVE DARK-SLATE GLASS DIALOGS with Top-Layer Animation & Scroll Lock */
.sheet-dialog {
  width: min(520px, calc(100vw - 24px));
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  padding: 24px;
  background: #14243a;
  color: var(--ink);
  box-shadow: 0 28px 80px rgba(3, 8, 18, 0.72);
  opacity: 0;
  transition-property: opacity, transform, display, overlay;
  transition-duration: 0.24s;
  transition-timing-function: cubic-bezier(.22, 1, .36, 1);
  transition-behavior: allow-discrete;
}
@media (prefers-reduced-motion: no-preference) {
  .sheet-dialog { transform: translateY(10px) scale(0.97); }
}
.sheet-dialog:modal {
  overscroll-behavior: contain;
}
.sheet-dialog[open]:where(:not([data-closing])) {
  opacity: 1;
  @starting-style { opacity: 0; }
  @media (prefers-reduced-motion: no-preference) {
    transform: translateY(0) scale(1);
    @starting-style { transform: translateY(10px) scale(0.97); }
  }
}
.sheet-dialog::backdrop {
  overflow: hidden;
  overscroll-behavior: contain;
  background-color: rgba(6, 12, 22, 0);
  backdrop-filter: blur(0px);
  transition-property: background-color, backdrop-filter, display, overlay;
  transition-duration: 0.24s;
  transition-timing-function: ease-out;
  transition-behavior: allow-discrete;
}
.sheet-dialog[open]:where(:not([data-closing]))::backdrop {
  background-color: rgba(6, 12, 22, 0.72);
  backdrop-filter: blur(5px);
  @starting-style {
    background-color: rgba(6, 12, 22, 0);
    backdrop-filter: blur(0px);
  }
}
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.dialog-head .secondary { min-height: 34px; padding: 5px 12px; font-size: 12px; }
.nl-bar { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.nl-bar input { margin: 0; }
.amount-box {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(217, 190, 143, 0.35);
  border-radius: 12px;
  padding: 4px 14px;
  margin-top: 6px;
  background: rgba(10, 20, 34, 0.65);
}
.amount-box:focus-within { border-color: var(--brass); }
.amount-box b { font-size: 24px; font-weight: 400; color: var(--brass); }
.amount-box input { border: 0; background: transparent; margin: 0; padding: 6px 0; font-size: 28px; font-weight: 600; outline: none; }
.category-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; }
.cat-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 10px 6px;
  min-height: 60px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  font-size: 12px;
}
.cat-pill:hover { background: rgba(255, 255, 255, 0.09); }
.cat-pill.selected { background: var(--brass); color: #111d2e; border-color: var(--brass); font-weight: 650; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.more-fields { border-top: 1px solid var(--line); padding-top: 10px; }
.more-fields summary { cursor: pointer; font-size: 13px; color: var(--brass); margin-bottom: 10px; }
.compact-toggle { align-items: center; }
.compact-toggle input { margin-top: 0; }
.detail-body { display: grid; gap: 8px; margin-bottom: 18px; }
.detail-kv { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.detail-kv span { color: var(--muted); }
.detail-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.managed-list { list-style: none; padding: 0; margin: 10px 0 16px; max-height: 240px; overflow-y: auto; }
.managed-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.managed-list .cat-title { display: flex; align-items: center; gap: 8px; font-weight: 550; }
.divider-top { border-top: 1px solid var(--line); padding-top: 14px; }

/* Mobile */
@media (max-width: 780px) {
  .hero-editorial, .ledger-grid { grid-template-columns: 1fr; }
  .sub-metrics { grid-template-columns: 1fr 1fr; }
  .filter-row { grid-template-columns: 1fr 1fr; }
  .filter-row input[type="search"] { grid-column: 1 / -1; }
  .day-inspector input[type="range"] { display: none; }
  .day-stepper { display: inline-flex; }
  .masthead {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    min-height: 62px;
    padding: 0 6px env(safe-area-inset-bottom);
    border-top: 1px solid var(--line);
    border-bottom: 0;
    gap: 0;
  }
  .masthead .brand, .masthead-right { display: none; }
  .masthead nav { width: 100%; justify-content: space-around; gap: 0; }
  .masthead nav button { flex-direction: column; min-height: 56px; font-size: 11px; gap: 3px; padding: 6px 8px; }
  .masthead nav button.active::after { display: none; }
  .masthead nav svg { display: block; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
  .mobile-entry {
    display: flex !important;
    background: var(--brass) !important;
    color: #111d2e !important;
    border-radius: 12px;
    padding: 6px 14px !important;
    min-height: 42px !important;
    font-weight: 650;
  }
  main { padding: 18px 14px 96px; }
  .form-grid { grid-template-columns: 1fr; }
  .account-row { grid-template-columns: 1fr auto; }
  .live-desc { margin-left: 0; max-width: 100%; }
  .toast { inset: auto 14px 78px 14px; max-width: none; justify-content: space-between; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .sheet-dialog, .sheet-dialog::backdrop, .toast { transition-duration: 0.08s !important; }
  details::details-content { transition: none !important; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
  .live-row { animation: none !important; }
}
