:root {
  color-scheme: light;
  --ink: #101c18;
  --muted: #53665f;
  --paper: #f4efe3;
  --panel: #fffaf0;
  --line: #d6cbb5;
  --green: #0f2f27;
  --green-2: #1f6a58;
  --gold: #d9b45f;
  --blue: #3f7895;
  --red: #b94f4f;
  --security-blue: #8bb4c7;
  --shadow: 0 16px 34px rgba(15, 47, 39, 0.13);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  background: linear-gradient(135deg, #0b261f 0%, var(--green) 62%, #174439 100%);
  color: #fffdf8;
  padding: 18px 18px 16px;
  border-bottom: 3px solid rgba(139, 180, 199, 0.55);
}

.brand {
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand-title {
  margin: 0;
  font-size: 24px;
  line-height: 1.1;
  font-weight: 800;
}

.brand-subtitle {
  margin: 4px 0 0;
  color: rgba(255, 253, 248, 0.78);
  font-size: 14px;
}

.month-pill {
  border: 1px solid rgba(255, 255, 255, 0.24);
  color: #fffdf8;
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 700;
  white-space: nowrap;
  background: rgba(139, 180, 199, 0.12);
}

.brand-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.version-pill {
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.1);
  color: rgba(255, 253, 248, 0.82);
  font-size: 12px;
  font-weight: 900;
  padding: 7px 10px;
}

.cloud-pill {
  border: 1px solid rgba(139, 180, 199, 0.34);
  border-radius: 999px;
  background: rgba(139, 180, 199, 0.14);
  color: rgba(255, 253, 248, 0.86);
  font-size: 12px;
  font-weight: 900;
  padding: 7px 10px;
}

.signout-button {
  min-height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.08);
  color: #fffdf8;
  font-size: 12px;
  font-weight: 900;
  padding: 7px 10px;
}

.main {
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.auth-main {
  align-items: start;
  display: grid;
  justify-items: center;
}

.auth-card {
  width: min(520px, 100%);
}

.cloud-seed-card {
  margin-bottom: 16px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.tab {
  min-height: 44px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  border-radius: 8px;
  font-weight: 800;
}

.tab.active {
  background: var(--green);
  border-color: var(--green);
  color: #fffdf8;
}

.grid,
.setup-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.dashboard-grid {
  grid-template-columns: 1fr;
}

.today-grid {
  grid-template-columns: 1fr;
  max-width: 920px;
  margin: 0 auto;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px;
  min-width: 0;
}

.pulse-stats {
  align-items: stretch;
}

.metric-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  display: grid;
  gap: 8px;
  padding: 10px;
}

.metric-group-title {
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.segmented.pace-lens-toggle {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 8px 0;
  width: 100%;
}

.segmented.pace-lens-toggle button {
  min-height: 44px;
  font-size: 14px;
  font-weight: 900;
}

.pace-plan-select {
  width: 100%;
  max-width: 360px;
  margin-bottom: 8px;
}

.retirement-inline {
  border: 1px solid rgba(35, 88, 78, 0.24);
  border-radius: 8px;
  background: #f5faf6;
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding: 12px;
}

.retirement-inline h3 {
  margin: 0;
  font-size: 15px;
}

.compact-summary {
  margin-top: 0;
}

.edit-focus-card {
  border-color: rgba(154, 107, 63, 0.5);
  background:
    linear-gradient(90deg, rgba(244, 201, 93, 0.2), transparent 28%),
    #fff9ec;
  box-shadow: 0 14px 30px rgba(96, 73, 39, 0.16);
  position: relative;
}

.edit-focus-card::before {
  content: "";
  position: absolute;
  inset: 12px auto 12px 0;
  width: 4px;
  border-radius: 0 999px 999px 0;
  background: var(--gold);
}

.hero-card {
  background:
    linear-gradient(135deg, rgba(139, 180, 199, 0.14), transparent 42%),
    var(--green);
  color: #fffdf8;
  align-content: start;
}

.kicker {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.hero-card .kicker {
  color: rgba(255, 253, 248, 0.72);
}

.big-money {
  margin: 0;
  font-size: clamp(44px, 5vw, 68px);
  line-height: 1;
  font-weight: 900;
}

.subline {
  margin: 10px 0 0;
  color: var(--muted);
}

.hero-card .subline {
  color: rgba(255, 253, 248, 0.78);
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 16px;
}

.stat {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  padding: 12px;
}

.stat-label {
  display: block;
  color: rgba(255, 253, 248, 0.7);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.stat-value {
  display: block;
  margin-top: 4px;
  font-size: 24px;
  font-weight: 900;
}

.form {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.field input,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  min-height: 44px;
  padding: 10px 12px;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.check-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-self: start;
  width: fit-content;
  max-width: max-content;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  padding: 4px 2px;
}

.check-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--green-2);
}

.primary,
.secondary,
.danger {
  border: 0;
  border-radius: 8px;
  min-height: 44px;
  padding: 10px 14px;
  font-weight: 900;
}

.primary {
  background: var(--gold);
  color: #1d241e;
}

.secondary {
  background: #e8e2d5;
  color: var(--ink);
}

.danger {
  background: #f2dddd;
  color: #7d2525;
}

.section-title {
  margin: 0 0 12px;
  font-size: 18px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-header .section-title {
  margin: 0;
}

.sort-select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 6px 10px;
  font-weight: 800;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #e8e2d5;
  padding: 4px;
}

.segmented button {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 6px 10px;
  font-weight: 900;
}

.segmented button.active {
  background: var(--panel);
  color: var(--green);
}

.readable-date {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
  text-align: center;
}

.readable-date span,
.readable-date label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.readable-date strong {
  display: block;
  margin-top: 3px;
  font-size: 20px;
}

.readable-date input {
  margin-top: 8px;
  width: min(190px, 100%);
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fdfaf3;
  color: var(--ink);
  padding: 6px 8px;
  text-align: center;
}

.date-arrow {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #e8e2d5;
  color: var(--ink);
  font-size: 22px;
  font-weight: 900;
}

.date-arrow:disabled,
.today-jump:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.today-jump {
  min-height: 40px;
  border: 1px solid var(--green-2);
  border-radius: 8px;
  background: #e8f0ed;
  color: var(--green);
  font-weight: 900;
}

.spare-preview,
.spare-today {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-radius: 8px;
  padding: 10px;
}

.reality-check {
  display: grid;
  gap: 10px;
  margin: 14px 0;
}

.pace-reality-check {
  border-top: 1px solid rgba(35, 88, 78, 0.16);
  margin: 12px 0 0;
  padding-top: 12px;
}

.reality-panel,
.info-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.reality-panel {
  position: relative;
  display: grid;
  gap: 6px;
  padding: 12px 38px 12px 12px;
}

.reality-panel p {
  margin: 0;
  color: var(--muted);
}

.signal-wrap {
  display: grid;
  gap: 6px;
}

.info-button {
  width: 22px;
  height: 22px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f5efdf;
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  padding: 0;
  vertical-align: middle;
}

.info-panel {
  position: relative;
  padding: 12px 38px 12px 12px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.info-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f5efdf;
  color: var(--green);
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
  padding: 0;
}

.text-link {
  border: 0;
  background: transparent;
  color: var(--green-2);
  padding: 0;
  font-weight: 900;
  text-decoration: underline;
}

.edit-mode-note {
  margin: 0;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fffaf0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.4;
  padding: 10px;
}

.savings-note {
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 10px;
  font-size: 14px;
  background: #fffaf0;
}

.total-savings-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  border-radius: 8px;
  padding: 12px;
  background: var(--green);
  color: #fffdf8;
}

.total-savings-row span {
  font-weight: 900;
}

.total-savings-row strong {
  font-size: 22px;
}

.total-savings-row .info-button {
  border-color: rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.14);
  color: #fffdf8;
}

.compact-total-card {
  background: var(--green);
  color: #fffdf8;
}

.compact-total-card .info-panel {
  margin-top: 10px;
  color: var(--muted);
}

.total-monthly-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.total-monthly-card span {
  font-weight: 900;
}

.total-monthly-card strong {
  font-size: 28px;
}

.total-monthly-card .info-button {
  border-color: rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.14);
  color: #fffdf8;
}

.category-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.compact-segmented {
  grid-template-columns: repeat(2, minmax(58px, 1fr));
}

.charts-grid {
  display: grid;
  gap: 12px;
}

.history-mode-toggle {
  margin-top: 12px;
  max-width: 360px;
}

.subview-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-color: rgba(35, 88, 78, 0.3);
  background: linear-gradient(180deg, #fffdf8 0%, #edf4f0 100%);
}

.subview-kicker {
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.subview-toggle {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  min-height: 48px;
  padding: 5px;
}

.subview-toggle button {
  font-size: 15px;
  min-height: 38px;
}

.compact-button {
  min-height: 34px;
  padding: 6px 12px;
}

.chart-panel {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  padding: 16px;
  overflow: hidden;
}

.chart-panel h3 {
  margin: 0;
  font-size: 16px;
}

.chart-note {
  color: var(--muted);
  font-size: 13px;
}

.line-chart,
.pie-chart {
  display: block;
  width: 100%;
}

.line-chart {
  height: auto;
  min-height: 260px;
  max-height: none;
  border-radius: 8px;
  background:
    linear-gradient(180deg, #fffdf8 0%, #f8f1df 100%),
    linear-gradient(90deg, transparent, rgba(139, 180, 199, 0.18), transparent);
  overflow: visible;
}

.line-chart line {
  stroke: #d8d0c2;
  stroke-width: 2;
}

.line-chart .chart-grid-line {
  stroke: #e0d6bd;
  stroke-width: 1.5;
}

.line-chart-area {
  fill: url(#dailyFlowFill);
  stroke: none;
}

.line-chart polyline {
  fill: none;
  stroke: #16614f;
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pace-chart .expected-line {
  stroke: #837b69;
  stroke-width: 4;
  stroke-dasharray: 12 10;
}

.pace-chart .actual-line {
  stroke: #16614f;
  stroke-width: 5;
}

.pace-chart .zero-line {
  stroke: var(--red);
  stroke-width: 2;
  opacity: 0.55;
}

.pace-end-dot {
  fill: var(--gold);
  stroke: var(--green);
  stroke-width: 2;
}

.pace-end-dot.danger {
  fill: var(--red);
  stroke: #7d2525;
}

.chart-key {
  font-size: 13px;
  font-weight: 900;
}

.expected-key {
  fill: #75684d;
}

.actual-key {
  fill: var(--green-2);
}

.pace-focus-card {
  border-color: rgba(31, 106, 88, 0.24);
}

.pace-focus-card.pace-under {
  background: linear-gradient(180deg, #fffdf8 0%, #eef7f1 100%);
  border-color: rgba(31, 106, 88, 0.34);
}

.pace-focus-card.pace-over {
  background: linear-gradient(180deg, #fffdf8 0%, #fff2ed 100%);
  border-color: rgba(185, 79, 79, 0.34);
}

.pace-focus-card.pace-even {
  background: linear-gradient(180deg, #fffdf8 0%, #fbf3de 100%);
  border-color: rgba(217, 180, 95, 0.42);
}

.pace-status-value.pace-under {
  color: var(--green-2);
}

.pace-status-value.pace-over {
  color: var(--red);
}

.pace-status-value.pace-even {
  color: #9a6b3f;
}

.pace-card-value {
  border: 1px solid rgba(31, 106, 88, 0.24);
  border-radius: 8px;
  background: #fffdf8;
  font-size: 24px;
  font-weight: 900;
  padding: 8px 12px;
  white-space: nowrap;
}

.spending-pace-chart .expected-line {
  stroke: #837b69;
  stroke-width: 4;
  stroke-dasharray: 12 10;
}

.spending-pace-chart .actual-line {
  stroke: var(--green-2);
  stroke-width: 5;
}

.spending-pace-chart.pace-over .actual-line {
  stroke: var(--red);
}

.spending-pace-chart.pace-even .actual-line {
  stroke: var(--gold);
}

.spending-pace-chart .pace-end-dot {
  fill: var(--green-2);
  stroke: var(--green);
}

.spending-pace-chart.pace-over .pace-end-dot {
  fill: var(--red);
  stroke: #7d2525;
}

.spending-pace-chart.pace-even .pace-end-dot {
  fill: var(--gold);
  stroke: #9a6b3f;
}

.spending-pace-chart .legend-sample {
  stroke-linecap: round;
  stroke-width: 4;
}

.spending-pace-chart .expected-legend-sample {
  stroke: #837b69;
  stroke-dasharray: 12 8;
}

.spending-pace-chart .actual-legend-sample {
  stroke: var(--green-2);
}

.spending-pace-chart.pace-over .actual-legend-sample {
  stroke: var(--red);
}

.spending-pace-chart.pace-even .actual-legend-sample {
  stroke: var(--gold);
}

.danger-label {
  fill: var(--red);
}

.line-chart circle {
  fill: var(--gold);
  stroke: var(--green);
  stroke-width: 2;
}

.line-chart text {
  fill: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.line-chart .axis-label {
  fill: #675f4f;
}

.monthly-bar-chart rect {
  stroke: rgba(18, 49, 43, 0.12);
  stroke-width: 1;
}

.monthly-bar-chart .positive-bar {
  fill: #1f6a58;
}

.monthly-bar-chart .negative-bar {
  fill: var(--red);
}

.category-trend-chart,
.category-trend-values {
  display: grid;
  gap: 10px;
}

.category-trend-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
}

.category-trend-legend span {
  align-items: center;
  color: var(--muted);
  display: inline-flex;
  font-size: 12px;
  font-weight: 900;
  gap: 6px;
}

.category-trend-legend i {
  border-radius: 999px;
  display: inline-block;
  height: 9px;
  width: 9px;
}

.category-trend-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.category-trend-chip {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  display: inline-flex;
  gap: 7px;
  min-height: 38px;
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 900;
}

.category-trend-chip.active {
  border-color: rgba(31, 106, 88, 0.45);
  background: #e8f0ed;
  color: var(--green);
}

.category-trend-chip small {
  color: inherit;
  font-size: 11px;
  opacity: 0.78;
}

.category-trend-actions {
  margin-top: 2px;
}

.ytd-snapshot {
  display: grid;
  gap: 12px;
}

.ytd-primary-stats .stat-value {
  font-size: 30px;
}

.ytd-support-stats {
  margin-top: 0;
}

.dual-line-chart .spending-line {
  stroke: #9a4d3f;
}

.dual-line-chart .savings-line {
  stroke: #1f6a58;
}

.dual-line-chart .spending-dot {
  fill: #f2c45d;
  stroke: #9a4d3f;
}

.dual-line-chart .savings-dot {
  fill: #d8e8df;
  stroke: #1f6a58;
}

.dual-line-chart .legend-line {
  fill: none;
  stroke-linecap: round;
  stroke-width: 4;
}

.dual-line-chart .spending-legend-line {
  stroke: #9a4d3f;
}

.dual-line-chart .savings-legend-line {
  stroke: #1f6a58;
}

.dual-line-chart .legend-dot {
  stroke-width: 2;
}

.dual-line-chart .point-value {
  font-size: 11px;
  font-weight: 900;
  paint-order: stroke;
  stroke: #fffdf8;
  stroke-width: 4px;
}

.multi-line-chart .category-line {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 4;
}

.multi-line-chart .category-dot {
  stroke-width: 2;
}

.spending-key,
.spending-value {
  fill: #9a4d3f;
}

.savings-key,
.savings-value {
  fill: #1f6a58;
}

.chart-with-readout {
  display: grid;
  gap: 12px;
}

.monthly-readout-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.monthly-readout-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  display: grid;
  gap: 3px;
  padding: 10px;
}

.monthly-readout-row strong {
  color: var(--ink);
}

.monthly-readout-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.month-metric-list {
  display: grid;
  gap: 10px;
}

.month-metric-row {
  display: grid;
  grid-template-columns: 44px minmax(120px, 1fr) 96px;
  gap: 10px;
  align-items: center;
  font-weight: 900;
}

.month-metric-row > span {
  color: var(--muted);
}

.month-metric-row strong {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.month-metric-track {
  height: 12px;
  border-radius: 999px;
  background: #efe7d7;
  overflow: hidden;
}

.month-metric-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.month-metric-track .positive-fill {
  background: #1f6a58;
}

.month-metric-track .negative-fill {
  background: var(--red);
}

.monthly-log-card {
  align-content: start;
}

.monthly-log-list {
  display: grid;
  gap: 14px;
  margin-top: 12px;
}

.monthly-log-day {
  display: grid;
  gap: 8px;
}

.monthly-log-day h3 {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
  text-transform: uppercase;
}

.monthly-log-transaction {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  display: grid;
  gap: 8px;
  padding: 10px;
}

.monthly-log-row {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.monthly-log-row span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 800;
  margin-top: 2px;
}

.monthly-log-actions {
  align-items: center;
  display: flex;
  gap: 8px;
}

.monthly-log-actions button {
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  min-height: 32px;
  padding: 6px 8px;
}

.monthly-log-actions button[data-monthly-log-delete] {
  color: var(--red);
}

.monthly-log-edit-form {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.pie-layout {
  display: grid;
  gap: 12px;
}

.category-chart-layout {
  display: grid;
  gap: 14px;
  align-items: center;
}

.pie-chart {
  max-width: 300px;
  margin: 0 auto;
}

.donut-chart {
  max-width: 260px;
  overflow: visible;
}

.donut-slice {
  cursor: pointer;
  transform-box: fill-box;
  transform-origin: center;
  transition: filter 140ms ease, opacity 140ms ease, transform 140ms ease;
}

.donut-slice:hover,
.donut-slice.chart-active {
  filter: drop-shadow(0 6px 8px rgba(15, 47, 39, 0.28));
  opacity: 0.96;
  transform: scale(1.035);
}

.donut-total-label {
  fill: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.donut-total-value {
  fill: var(--ink);
  font-size: 24px;
  font-weight: 900;
}

.category-chart-list {
  display: grid;
  gap: 8px;
}

.category-chart-row {
  display: grid;
  grid-template-columns: 14px 1fr;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.category-chart-row.chart-active {
  border-color: var(--green-2);
  background: #e8f0ed;
  transform: translateX(2px);
}

.category-chart-row strong,
.category-chart-row span:not(.category-swatch) {
  display: block;
}

.category-chart-row span:not(.category-swatch) {
  color: var(--muted);
  margin-top: 2px;
}

.category-swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
}

.pie-chart-labeled {
  min-height: 260px;
}

.pie-leader {
  fill: none;
  stroke: #9c9382;
  stroke-width: 1.2;
}

.pie-data-label {
  fill: var(--ink);
  font-size: 11px;
  font-weight: 800;
}

.pie-data-label tspan:nth-child(2),
.pie-data-label tspan:nth-child(3) {
  fill: var(--muted);
  font-weight: 700;
}

.pie-legend {
  display: grid;
  gap: 6px;
}

.legend-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  font-size: 14px;
}

.legend-row span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.legend-row i {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

@media (min-width: 980px) {
  .charts-grid {
    grid-template-columns: 1fr 1fr;
  }

  .chart-panel-wide {
    grid-column: 1 / -1;
  }

  .category-chart-layout {
    grid-template-columns: minmax(220px, 0.7fr) 1fr;
  }
}

.spare-preview {
  background: #f5efdf;
  border: 1px solid #e5d7b4;
  color: #5f5137;
  justify-content: space-between;
}

.spare-today {
  margin-top: 12px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: rgba(255, 253, 248, 0.88);
}

.list {
  display: grid;
  gap: 8px;
}

.transaction,
.day-row,
.category-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.transaction-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.transaction-actions .money {
  min-width: 58px;
  text-align: right;
  font-size: 22px;
  line-height: 1;
}

.quiet-actions {
  display: flex;
  gap: 4px;
}

.quiet-actions button {
  min-height: 36px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  padding: 6px 8px;
  font-size: 13px;
  font-weight: 800;
}

.quiet-actions button:hover {
  background: #eee7da;
}

.quiet-actions button[data-delete] {
  color: var(--red);
}

.transaction-meta,
.day-meta {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.money {
  font-weight: 900;
}

.positive {
  color: var(--green-2);
}

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

.dashboard-stat {
  background: #f5efdf;
  border-color: #e5d7b4;
}

.dashboard-stat .stat-label {
  color: #75684d;
}

.dashboard-stat .stat-value {
  color: var(--ink);
}

.progress {
  height: 10px;
  background: #e8e2d5;
  border-radius: 999px;
  overflow: hidden;
}

.progress span {
  display: block;
  height: 100%;
  background: var(--blue);
  border-radius: 999px;
}

.empty {
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 18px;
  text-align: center;
}

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

.budget-lines-card {
  grid-column: 1 / -1;
}

.budget-line-list {
  display: grid;
  gap: 8px;
  min-height: 24px;
  padding: 2px 0;
}

.budget-line {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.budget-line.dragging {
  opacity: 0.55;
}

.drag-handle {
  width: 34px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f5efdf;
  color: var(--muted);
  cursor: grab;
  font-size: 20px;
  font-weight: 900;
  line-height: 1;
  padding: 0;
}

.budget-line-meta {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.budget-line-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.budget-line-actions button {
  min-height: 34px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  padding: 6px 8px;
  font-size: 13px;
  font-weight: 800;
}

.budget-line-actions button:hover {
  background: #eee7da;
}

.budget-line-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.budget-line-actions button[data-budget-line-delete],
.budget-line-actions button[data-annual-bill-delete],
.budget-line-actions button[data-fund-account-delete],
.budget-line-actions button[data-fund-delete] {
  color: var(--red);
}

.fund-summary-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.fund-rule {
  margin: 12px 0 0;
}

.fund-account-card {
  gap: 12px;
}

.fund-bucket-list {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.fund-account-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-weight: 900;
  padding-top: 10px;
}

.fund-account-total strong {
  color: var(--ink);
}

.fund-detail-stats {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 12px;
}

.fund-row {
  grid-template-columns: 1fr auto;
}

.fund-muted {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.fund-activity-list {
  display: grid;
  gap: 6px;
  margin-top: 12px;
}

.fund-activity-row {
  display: grid;
  grid-template-columns: 120px minmax(130px, 0.7fr) 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.fund-activity-row span:first-child,
.fund-activity-row span:nth-child(2),
.fund-activity-row span:nth-child(3) {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.compact-check-row {
  max-width: max-content;
}

.budget-line-shell {
  display: grid;
  gap: 8px;
}

.budget-line-shell.edit-focus-card {
  border-radius: 8px;
  padding: 8px;
}

.inline-budget-form {
  border: 1px solid rgba(35, 88, 78, 0.28);
  border-radius: 8px;
  background: #f5faf6;
  padding: 12px;
}

.section-add-row {
  display: flex;
  justify-content: flex-start;
  margin: 8px 0 10px;
}

.section-add-row-bottom {
  margin: 10px 0 0;
}

.category-plan-form {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  margin-bottom: 14px;
  padding: 12px;
}

.warning-panel {
  border: 1px solid rgba(185, 79, 79, 0.32);
  border-radius: 8px;
  background: #fff2ed;
  color: #7d2525;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.45;
  margin-top: 12px;
  padding: 12px;
}

.method-note {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--muted);
  display: grid;
  gap: 6px;
  line-height: 1.45;
  margin-bottom: 12px;
  padding: 12px;
}

.method-note strong {
  color: var(--text);
}

.method-note p {
  margin: 0;
}

.daily-preview-card {
  border: 1px solid rgba(35, 88, 78, 0.24);
  border-radius: 8px;
  background: #f5faf6;
  display: grid;
  gap: 4px;
  margin-bottom: 12px;
  padding: 12px;
}

.daily-preview-card span {
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.daily-preview-card strong {
  font-size: 24px;
}

.daily-preview-card p {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.4;
  margin: 0;
}

.annual-due-panel,
.annual-closeout-check,
.rollover-reminder {
  border: 1px solid rgba(154, 107, 63, 0.3);
  border-radius: 8px;
  background: #fff6df;
  color: #76512f;
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
  padding: 12px;
}

.annual-due-panel span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.4;
}

.annual-bill-form {
  margin-bottom: 12px;
}

.annual-due-date-editor {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  display: grid;
  gap: 10px;
  padding: 12px;
}

.annual-due-date-row {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) minmax(120px, 180px);
}

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

.setup-closeout-row {
  margin-top: 12px;
}

.budget-style-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 12px;
}

.budget-style-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  display: grid;
  gap: 5px;
  padding: 10px;
}

.budget-style-grid strong {
  font-size: 13px;
}

.budget-style-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
}

.field-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.mapped-category-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mapped-category-chip {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  display: inline-flex;
  gap: 7px;
  min-height: 38px;
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 900;
  width: fit-content;
}

.mapped-category-chip input {
  accent-color: var(--green-2);
  height: 16px;
  width: 16px;
}

.mapped-category-chip:has(input:checked) {
  border-color: rgba(31, 106, 88, 0.45);
  background: #e8f0ed;
  color: var(--green);
}

.planned-mini-card {
  align-self: stretch;
}

.planned-mini-list {
  display: grid;
  gap: 12px;
}

.planned-mini-row {
  display: grid;
  gap: 6px;
}

.category-plan-list {
  display: grid;
  gap: 10px;
}

.category-plan-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.category-plan-row-simple {
  align-items: start;
}

.category-plan-values {
  display: grid;
  gap: 3px;
  justify-items: end;
  text-align: right;
}

.category-plan-values strong {
  font-size: 22px;
}

.category-plan-values span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.category-plan-values button {
  min-height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  padding: 6px 8px;
  font-size: 13px;
  font-weight: 800;
}

.inline-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.inline-actions button[data-category-plan-delete] {
  color: var(--red);
}

.category-plan-breakdown {
  display: grid;
  gap: 5px;
  margin-top: 8px;
}

.category-plan-breakdown div {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 12px;
  font-weight: 800;
  justify-content: space-between;
}

.category-plan-breakdown span {
  align-items: center;
  display: inline-flex;
  gap: 7px;
  min-width: 0;
}

.category-plan-breakdown i {
  border-radius: 999px;
  display: inline-block;
  height: 9px;
  width: 9px;
}

.category-plan-breakdown strong {
  color: var(--text);
  margin-left: 12px;
  min-width: 78px;
  text-align: right;
}

.segmented-progress {
  display: flex;
  gap: 0;
  overflow: hidden;
}

.segmented-progress span {
  flex: 0 0 auto;
  min-width: 0;
  border-radius: 0;
}

.segmented-progress span:first-child {
  border-bottom-left-radius: 999px;
  border-top-left-radius: 999px;
}

.segmented-progress span:last-child {
  border-bottom-right-radius: 999px;
  border-top-right-radius: 999px;
}

.segmented-progress .progress-segment + .progress-segment {
  border-left: 1px solid rgba(255, 253, 248, 0.9);
}

.mini-total {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 8px 10px;
  font-weight: 800;
}

.chip button {
  border: 0;
  background: transparent;
  color: var(--red);
  font-weight: 900;
  padding: 0;
}

.chip .chip-label {
  color: inherit;
  font-weight: 900;
  text-align: left;
}

.chip .chip-label:hover {
  text-decoration: underline;
}

.chip small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.savings-chip {
  border-color: rgba(31, 106, 88, 0.35);
  background: #e8f0ed;
  color: var(--green);
}

.setup-summary {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.setup-summary div {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.setup-summary span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.setup-summary strong {
  font-size: 20px;
}

.history-step {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.history-step span {
  color: var(--muted);
  line-height: 1.4;
}

.inline-history-form {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(120px, 160px) auto;
  gap: 10px;
  align-items: end;
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.inline-history-form label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.inline-history-form input {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  font: inherit;
  font-weight: 900;
}

.inline-history-form .subline {
  grid-column: 1 / -1;
  margin: 0;
}

.history-budget-sections {
  display: grid;
  gap: 14px;
}

.history-budget-section {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  padding: 14px;
}

.history-budget-section h3 {
  margin: 0;
  font-size: 16px;
}

.history-budget-list {
  display: grid;
  gap: 8px;
}

.history-budget-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid rgba(34, 65, 55, 0.12);
  border-radius: 8px;
  background: #fff;
  padding: 10px 12px;
}

.history-budget-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.history-budget-actions button {
  min-height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  padding: 6px 8px;
  font-size: 13px;
  font-weight: 800;
}

.history-budget-actions button:hover {
  background: #eee7da;
}

.history-budget-actions button[data-archive-budget-line-delete] {
  color: var(--red);
}

.history-budget-line span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.history-month-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 150px 118px 118px 140px;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 12px;
  text-align: left;
}

.history-status-cell {
  justify-self: stretch;
}

.history-metric-cell {
  display: grid;
  justify-items: end;
  min-width: 0;
  text-align: right;
}

.history-metric-cell strong {
  font-variant-numeric: tabular-nums;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border: 1px solid rgba(31, 106, 88, 0.28);
  border-radius: 999px;
  background: #e8f0ed;
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
  padding: 4px 10px;
  white-space: nowrap;
}

.history-warning {
  border: 1px solid rgba(154, 107, 63, 0.28);
  border-radius: 8px;
  background: #fff6df;
  color: #76512f;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.4;
  margin: 14px 0 0;
  padding: 10px 12px;
}

.history-month-row:hover {
  border-color: var(--green-2);
  background: #e8f0ed;
}

.history-month-row span {
  display: grid;
  gap: 2px;
}

.history-month-row .status-pill {
  display: inline-flex;
}

.history-month-row small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.transaction-history-list {
  display: grid;
  gap: 6px;
}

.history-transaction-row {
  display: grid;
  grid-template-columns: 110px 1fr minmax(110px, 0.6fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.history-transaction-row span:first-child,
.history-transaction-row span:nth-child(3) {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.history-transaction-row span:last-child {
  font-weight: 900;
}

.history-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.history-grid span {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-weight: 800;
  padding: 10px;
}

.history-actions {
  margin-top: 14px;
}

.history-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 900;
}

.history-back-strong {
  min-height: 38px;
  border: 1px solid rgba(31, 106, 88, 0.3);
  border-radius: 8px;
  background: #e8f0ed;
  color: var(--green);
  padding: 8px 12px;
  font-weight: 900;
}

.history-back-strong:hover {
  border-color: var(--green-2);
  background: #dce9e5;
}

.modal-backdrop {
  align-items: start;
  background: rgba(18, 49, 43, 0.36);
  bottom: 0;
  display: flex;
  justify-content: center;
  left: 0;
  overflow-y: auto;
  padding: 24px;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 10;
}

.closeout-panel {
  max-width: 760px;
  width: min(760px, 100%);
}

.closeout-form {
  margin-top: 12px;
}

.closeout-entry-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) minmax(120px, 180px);
}

.closeout-entry-list {
  margin-top: 12px;
}

@media (min-width: 820px) {
  .grid {
    align-items: start;
    grid-template-columns: minmax(0, 1fr) minmax(340px, 0.82fr);
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .today-grid {
    grid-template-columns: 1fr;
  }

  .setup-grid {
    grid-template-columns: 1fr;
    max-width: 1180px;
    margin: 0 auto;
  }

  .hero-card {
    min-height: 220px;
  }
}

@media (min-width: 1180px) {
  .grid:not(.dashboard-grid):not(.setup-grid):not(.today-grid) {
    grid-template-columns: minmax(420px, 0.9fr) minmax(420px, 1fr);
  }

  .today-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-grid {
    gap: 16px;
  }

  .chart-panel {
    padding: 18px;
  }

  .line-chart {
    min-height: 330px;
  }

  .hero-card {
    min-height: 250px;
  }

  .hero-card .stats {
    max-width: 620px;
  }
}

@media (max-width: 480px) {
  .main {
    padding: 12px;
  }

  .brand {
    align-items: flex-start;
    flex-direction: column;
  }

  .big-money {
    font-size: 46px;
  }

  .stats,
  .fund-summary-grid,
  .row {
    grid-template-columns: 1fr;
  }

  .budget-style-grid {
    grid-template-columns: 1fr;
  }

  .section-header {
    align-items: stretch;
    flex-direction: column;
  }

  .category-controls {
    justify-content: stretch;
  }

  .category-controls .sort-select,
  .category-controls .segmented {
    width: 100%;
  }

  .budget-line,
  .category-plan-row,
  .monthly-log-entry,
  .transaction {
    grid-template-columns: 1fr;
  }

  .budget-line-actions,
  .category-plan-values {
    align-items: start;
    justify-items: start;
    text-align: left;
  }

  .line-chart,
  .pie-chart {
    max-width: 100%;
  }

  .history-month-row,
  .history-transaction-row,
  .history-budget-line,
  .inline-history-form,
  .closeout-entry-grid,
  .annual-due-date-row,
  .annual-bill-row,
  .fund-row,
  .fund-activity-row {
    grid-template-columns: 1fr;
  }

  .history-status-cell,
  .history-metric-cell {
    justify-items: start;
    text-align: left;
  }

  .month-metric-row {
    grid-template-columns: 40px 1fr 86px;
  }

  .tabs {
    position: sticky;
    bottom: 0;
    z-index: 2;
    background: rgba(247, 244, 239, 0.96);
    padding-top: 8px;
  }
}
