:root {
  color-scheme: light dark;
  --bg: #f8f6f1;
  --ink: #251d18;
  --muted: #756b61;
  --line: #e7e1d9;
  --panel: #fffefa;
  --accent: #52775d;
  --accent-button: #426d4e;
  --accent-on: #ffffff;
  --accent-soft: #e8f0e8;
  --hero: #345c49;
  --hero-muted: #dcebe0;
  --gold: #c4a05b;
  --usd: #7b57b3;
  --red: #b13b46;
  --amber: #b26b16;
  --green: #52775d;
  --shadow: 0 14px 34px rgb(37 29 24 / 8%);
  --notice-bg: #fff0e8;
  --notice-line: #f0c6b4;
}

body[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0f0f;
  --ink: #f5f2ea;
  --muted: #95a6a3;
  --line: #263938;
  --panel: #111b1a;
  --accent: #92bd9b;
  --accent-button: #365f41;
  --accent-on: #ffffff;
  --accent-soft: #243a2c;
  --hero: #244735;
  --hero-muted: #d9eadf;
  --gold: #d3b574;
  --usd: #b69cff;
  --red: #ff737f;
  --amber: #e3a241;
  --green: #92bd9b;
  --shadow: 0 18px 42px rgb(0 0 0 / 28%);
  --notice-bg: #251c14;
  --notice-line: #704d2c;
}

body[data-theme="light"] {
  color-scheme: light;
  --bg: #f8f6f1;
  --ink: #1d2530;
  --muted: #6f6a63;
  --line: #e8e2da;
  --panel: #fffefa;
  --surface-soft: #f6f2eb;
  --accent: #52775d;
  --accent-button: #426d4e;
  --accent-on: #ffffff;
  --accent-soft: #e8f0e8;
  --hero: #345c49;
  --hero-muted: #dcebe0;
  --gold: #c4a05b;
  --usd: #7055b8;
  --shadow: 0 6px 18px rgb(90 68 45 / 7%);
  --notice-bg: #fff7ed;
  --notice-line: #f0ddc8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overscroll-behavior-y: none;
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html {
  min-height: 100%;
}

html,
body {
  background: var(--bg);
}

.shell {
  width: min(100%, 812px);
  margin: 0 auto;
  padding: max(12px, var(--tg-content-safe-area-inset-top, var(--tg-safe-area-inset-top, 0px))) 16px calc(96px + max(0px, var(--tg-content-safe-area-inset-bottom, var(--tg-safe-area-inset-bottom, 0px))));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 8px;
}

.quick-entry-backdrop { position: fixed; inset: 0; z-index: 29; background: rgb(0 0 0 / 35%); }
.quick-entry-sheet { position: fixed; z-index: 30; inset: auto 0 0; padding: 12px 16px calc(20px + max(0px, var(--tg-content-safe-area-inset-bottom, var(--tg-safe-area-inset-bottom, 0px)))); border-radius: 22px 22px 0 0; background: var(--panel); box-shadow: 0 -10px 30px rgb(0 0 0 / 18%); }
.quick-entry-sheet textarea { min-height: 96px; width: 100%; resize: vertical; }
.quick-entry-sheet__handle { width: 42px; height: 4px; margin: 0 auto 14px; border-radius: 9px; background: var(--line); }
.quick-entry-status { min-height: 1.25em; color: var(--muted); font-size: 13px; font-weight: 700; }
.quick-entry-spinner { display: inline-block; width: .9em; height: .9em; margin-right: .45em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; vertical-align: -.1em; animation: quick-entry-spin .7s linear infinite; }
.quick-capture-review { display: grid; gap: 12px; }
.quick-capture-review h3 { margin: 0; font-size: 17px; }
.quick-capture-review__item { display: grid; gap: 4px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.quick-capture-review__item > span { color: var(--muted); font-size: 14px; }
@keyframes quick-entry-spin { to { transform: rotate(360deg); } }

body.edit-modal-open {
  overflow: hidden;
}

body.shortcut-setup-open {
  overflow: hidden;
}

.shortcut-setup-backdrop {
  position: fixed;
  inset: 0;
  z-index: 39;
  background: rgb(0 0 0 / 38%);
}

.shortcut-setup-sheet {
  position: fixed;
  z-index: 40;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  max-height: min(680px, calc(100dvh - max(12px, var(--tg-content-safe-area-inset-top, var(--tg-safe-area-inset-top, 0px)))));
  padding: 12px 16px calc(16px + max(0px, var(--tg-content-safe-area-inset-bottom, var(--tg-safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)))));
  border-radius: 22px 22px 0 0;
  background: var(--panel);
  box-shadow: 0 -10px 30px rgb(0 0 0 / 18%);
}

.shortcut-setup-sheet__handle { width: 42px; height: 4px; margin: 0 auto 14px; border-radius: 9px; background: var(--line); }
.shortcut-setup-sheet__header { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.shortcut-setup-sheet__header h2 { margin: 0; font-size: 20px; }
.shortcut-setup-sheet__header p { margin: 5px 0 0; color: var(--muted); font-size: 14px; line-height: 1.4; }
.shortcut-setup-sheet__close { flex: 0 0 auto; width: 34px; min-height: 34px; height: 34px; padding: 0 0 3px; border-radius: 50%; background: var(--accent-soft); color: var(--ink); font-size: 22px; line-height: 1; }
.shortcut-setup-sheet__body { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 16px 0; }
.shortcut-setup-benefits { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.shortcut-setup-benefits li { position: relative; padding-left: 24px; color: var(--ink); font-size: 14px; line-height: 1.4; }
.shortcut-setup-benefits li::before { position: absolute; left: 0; color: var(--accent); content: "✓"; font-weight: 900; }
.shortcut-setup-ready,
.shortcut-setup-unavailable { display: grid; gap: 8px; margin-top: 16px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--accent-soft); }
.shortcut-setup-ready p,
.shortcut-setup-unavailable p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.4; }
.shortcut-setup-phrase { color: var(--ink) !important; font-weight: 850; }
.shortcut-key-fallback { display: grid; gap: 8px; }
.shortcut-key-fallback textarea { width: 100%; min-height: 72px; resize: vertical; }
.shortcut-setup-sheet__actions { display: grid; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }

.edit-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 49;
  background: rgb(0 0 0 / 48%);
  backdrop-filter: blur(2px);
}

.edit-modal {
  --edit-modal-edge: 12px;
  --edit-modal-safe-top: max(var(--edit-modal-edge), calc(var(--tg-content-safe-area-inset-top, var(--tg-safe-area-inset-top, 0px)) + var(--tg-fullscreen-control-extra-top, 0px)));
  --edit-modal-safe-bottom: max(var(--edit-modal-edge), var(--tg-content-safe-area-inset-bottom, var(--tg-safe-area-inset-bottom, env(safe-area-inset-bottom, 0px))));
  position: fixed;
  top: calc(var(--edit-modal-safe-top) + ((100dvh - var(--edit-modal-safe-top) - var(--edit-modal-safe-bottom)) / 2));
  right: var(--edit-modal-edge);
  bottom: auto;
  left: var(--edit-modal-edge);
  z-index: 50;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(calc(100% - 24px), 520px);
  height: auto;
  max-height: calc(100dvh - var(--edit-modal-safe-top) - var(--edit-modal-safe-bottom));
  margin: 0 auto;
  transform: translateY(-50%);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: 0 24px 70px rgb(0 0 0 / 30%);
}

.edit-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--line);
}

.edit-modal__header h2 {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.edit-modal__close {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
  padding: 0 0 3px;
}

.edit-modal__body {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px 14px;
}

.edit-modal .form-stack {
  gap: 8px;
  padding: 0;
}

.edit-modal .edit-card {
  gap: 8px;
  padding: 0;
  border: 0;
}

.edit-modal label {
  gap: 4px;
  font-size: 12px;
}

.edit-modal input,
.edit-modal select {
  min-height: 40px;
  padding: 8px 9px;
  font-size: 14px;
}

.edit-modal__advanced {
  border-block: 1px solid var(--line);
}

.edit-modal__advanced summary {
  padding: 9px 0;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.edit-modal__advanced-fields {
  display: grid;
  gap: 8px;
  padding: 0 0 10px;
}

.edit-modal .button-row {
  position: sticky;
  bottom: -12px;
  z-index: 1;
  margin: 2px -14px -12px;
  padding: 10px 14px calc(12px + max(0px, env(safe-area-inset-bottom)));
  border-top: 1px solid var(--line);
  background: var(--panel);
}

.edit-modal .edit-modal__actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.edit-modal__actions > button {
  width: 100%;
  min-width: 0;
}

@media (max-width: 430px) {
  .edit-modal {
    --edit-modal-edge: 8px;
    width: calc(100% - 16px);
    border-radius: 20px;
  }

  .edit-modal__body {
    padding: 10px 12px;
  }

  .edit-modal .field-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
  }

  .edit-modal .button-row {
    bottom: -10px;
    margin: 2px -12px -10px;
    padding-inline: 12px;
  }
}

.eyebrow,
.expense-meta,
.bar-row-display,
.form-note {
  color: var(--muted);
  font-size: 13px;
}

.eyebrow {
  margin: 0 0 4px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.1;
}

h2 {
  font-size: 18px;
}

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

.bottom-tabs {
  position: fixed;
  left: max(12px, calc((100vw - 812px) / 2 + 16px));
  right: max(12px, calc((100vw - 812px) / 2 + 16px));
  bottom: max(10px, var(--tg-content-safe-area-inset-bottom, var(--tg-safe-area-inset-bottom, env(safe-area-inset-bottom))));
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  padding: 5px;
  box-shadow: 0 -5px 18px rgb(75 58 42 / 8%);
  backdrop-filter: blur(10px);
}

.bottom-tabs::before {
  content: "";
  position: absolute;
  left: -12px;
  right: -12px;
  bottom: -12px;
  z-index: -1;
  height: 92px;
  background: linear-gradient(180deg, transparent, var(--bg) 45%);
}

.bottom-tabs .tab-button {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 3px;
  min-height: 54px;
  border: 0;
  border-radius: 15px;
  background: transparent;
  font-size: 11px;
  line-height: 1.1;
  padding: 6px 3px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar .eyebrow {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
  letter-spacing: 0;
  text-transform: none;
}

.bottom-tabs .tab-button.active {
  border-color: transparent;
  background: color-mix(in srgb, var(--accent) 14%, var(--panel));
  color: var(--accent);
}

.quick-entry-action {
  align-self: start;
  justify-self: center;
  z-index: 1;
  width: 52px;
  height: 52px;
  transform: translateY(-15px);
  border: 0;
  border-radius: 50%;
  background: var(--accent-button);
  color: var(--accent-on);
  box-shadow: 0 8px 22px color-mix(in srgb, var(--accent-button) 28%, transparent);
  font-size: 32px;
  line-height: 1;
  padding: 0 0 4px;
}

.bottom-tabs .quick-entry-action.hidden {
  display: block;
  visibility: hidden;
}

.tab-button__icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  color: currentColor;
}

.tab-button__icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tab-button__label {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab-button {
  min-height: 40px;
  border: 0;
  background: transparent;
  color: var(--muted);
}

.tab-button.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.tab-pager {
  position: relative;
  touch-action: pan-y;
}

.tab-page {
  width: 100%;
}

#historyTab,
#planTab,
#settingsTab {
  padding-top: var(--tg-fullscreen-control-extra-top, 0px);
}

.tab-page.is-pager-current,
.tab-page.is-pager-neighbor {
  will-change: transform;
}

.tab-page.is-pager-neighbor {
  position: absolute;
  inset: 0 0 auto;
  pointer-events: none;
}

.tab-pager.is-animating .tab-page.is-pager-current,
.tab-pager.is-animating .tab-page.is-pager-neighbor {
  transition: transform 220ms cubic-bezier(.22, .72, .28, 1);
}

body.is-paging {
  overflow-x: hidden;
  user-select: none;
}

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

.dashboard-card,
.next-planned,
.dashboard-disclosure,
.monthly-forecast,
.section,
.notice {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.dashboard-disclosure,
.latest-expenses {
  border-radius: 18px;
}

.dashboard-card {
  position: relative;
  min-height: 214px;
  border-radius: 24px;
  padding: 0;
  overflow: visible;
  perspective: 1000px;
}

.dashboard-card--flip {
  cursor: pointer;
}

.dashboard-card__flip-inner {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 214px;
  border-radius: 24px;
  transition: transform 480ms cubic-bezier(.2, .7, .2, 1);
  transform-style: preserve-3d;
}

.dashboard-card.is-flipped .dashboard-card__flip-inner {
  transform: rotateY(180deg);
}

.dashboard-card__face {
  min-height: 214px;
  border-radius: 24px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.dashboard-card__face--front {
  display: grid;
  grid-template-rows: auto auto auto auto minmax(2px, 1fr) auto;
  gap: 10px;
  min-height: 214px;
  padding: 24px 22px 22px;
  align-content: stretch;
}

.dashboard-card__face--back {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 214px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  background: color-mix(in srgb, var(--accent) 18%, var(--panel));
  color: var(--ink);
  box-shadow: var(--shadow);
  padding: 20px;
  transform: rotateY(180deg);
  overflow: hidden;
}

.dashboard-card__back-text {
  margin: 0;
  color: var(--ink);
  font-weight: 650;
  font-size: clamp(12px, 2.8vw, 14px);
  line-height: 1.3;
  text-align: center;
  overflow-wrap: normal;
  word-break: normal;
}

body[data-theme="dark"] .dashboard-card,
body[data-theme="dark"] .section,
body[data-theme="dark"] .next-planned,
body[data-theme="dark"] .notice,
body[data-theme="dark"] .inbox-block,
body[data-theme="dark"] .monthly-forecast {
  background: color-mix(in srgb, var(--panel) 92%, #000);
}

.dashboard-card__amount {
  color: var(--ink);
  font-size: clamp(32px, 5vw, 40px);
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.dashboard-card--danger .dashboard-card__amount {
  color: var(--red);
}

.dashboard-card__line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: baseline;
  color: var(--muted);
  font-size: clamp(15px, 2.2vw, 17px);
  font-weight: 700;
  line-height: 1.25;
  white-space: normal;
}

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

.dashboard-card__value {
  color: var(--ink);
  font-weight: 900;
  text-align: right;
  white-space: nowrap;
}

.dashboard-card__display {
  color: var(--usd);
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
  line-height: 1.25;
}

.dashboard-card__caption {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  white-space: normal;
}

.dashboard-card__reserve {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.budget-topup-shell.hidden {
  display: none;
}

.budget-topup {
  display: grid;
  gap: 8px;
  margin: 10px 0 14px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.budget-topup h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.2;
}

.budget-topup__line,
.budget-topup__item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  line-height: 1.25;
}

.budget-topup__line span,
.budget-topup__history-title,
.budget-topup__item {
  color: #6f6258;
}

.budget-topup__line--total {
  padding-top: 6px;
  border-top: 1px dashed var(--border);
}

.budget-topup__history {
  display: grid;
  gap: 6px;
  padding-top: 6px;
}

.budget-topup-card {
  display: grid;
  gap: 8px;
  margin: 10px 0 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent-soft) 32%, var(--panel));
}

.budget-topup-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.budget-topup-card__title {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.budget-topup-card__title span,
.budget-topup-card__summary,
.budget-topup-card__history-title,
.budget-topup-card__item {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.25;
}

.budget-topup-card__title strong {
  color: var(--ink);
  font-size: 20px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.budget-topup-card__toggle {
  flex: 0 0 auto;
  white-space: nowrap;
}

.budget-topup-card__details {
  display: grid;
  gap: 7px;
  padding-top: 6px;
  border-top: 1px dashed var(--line);
}

.budget-topup-card__line,
.budget-topup-card__item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.budget-topup-card__line {
  font-size: 14px;
  line-height: 1.25;
}

.budget-topup-card__line span {
  color: var(--muted);
}

.budget-topup-card__line--total {
  padding-top: 6px;
  border-top: 1px dashed var(--line);
}

.budget-topup-card__history {
  display: grid;
  gap: 6px;
  padding-top: 4px;
}

.dashboard-card--progress {
  align-content: stretch;
  min-height: 214px;
}

.dashboard-card__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  min-height: 52px;
}

.dashboard-card__info {
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  width: 24px;
  min-width: 24px;
  min-height: 24px;
  height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
  padding: 0;
}

.dashboard-card__title {
  color: #4f453e;
  font-size: 22px;
  font-weight: 820;
  line-height: 1.15;
  min-width: 0;
}

.dashboard-card__percent {
  color: var(--accent);
  font-size: 16px;
  white-space: nowrap;
}

.dashboard-card__percent[data-state="warn"] {
  color: var(--amber);
}

.dashboard-card__percent[data-state="danger"],
.dashboard-card__percent[data-state="bad"] {
  color: var(--red);
}

.dashboard-card__spacer {
  min-height: 2px;
}

.dashboard-card__progress {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #f0e8df;
}

.dashboard-card__progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.dashboard-card__progress--hidden {
  visibility: hidden;
}

.dashboard-card__progress-fill[data-state="warn"],
.bar-fill[data-state="warn"] {
  background: var(--amber);
}

.dashboard-card__progress-fill[data-state="danger"],
.dashboard-card__progress-fill[data-state="bad"],
.bar-fill[data-state="danger"] {
  background: var(--red);
}

.dashboard-card__progress-fill[data-state="good"],
.bar-fill[data-state="good"] {
  background: var(--green);
}

.hero-metric {
  --hero-state: var(--green);
  position: relative;
  display: grid;
  gap: 0;
  overflow: hidden;
  margin-bottom: 12px;
  border: 1px solid #e5ddd2;
  border-radius: 20px;
  background: linear-gradient(145deg, #fffefa 0%, #faf8f3 58%, #f4f0e9 100%);
  box-shadow: 0 10px 24px rgb(68 52 37 / 8%);
}

body[data-theme="dark"] .hero-metric {
  border-color: var(--line);
  background: linear-gradient(
    145deg,
    color-mix(in srgb, var(--panel) 88%, var(--hero)) 0%,
    var(--panel) 58%,
    color-mix(in srgb, var(--bg) 88%, var(--hero)) 100%
  );
  box-shadow: var(--shadow);
}

body[data-theme="dark"] .hero-metric__title {
  color: var(--hero-muted);
}

body[data-theme="dark"] .hero-metric__display {
  color: var(--muted);
}

body[data-theme="dark"] .hero-metric__facts {
  border-color: var(--line);
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  box-shadow: 0 4px 12px rgb(0 0 0 / 14%);
}

body[data-theme="dark"] .hero-metric__footer,
body[data-theme="dark"] .hero-metric__detail-row--subtotal {
  border-color: var(--line);
}

body[data-theme="dark"] .hero-metric__details-toggle {
  color: var(--accent);
}

body[data-theme="dark"] .hero-metric__details-toggle::after {
  color: var(--muted);
}

.hero-metric[data-state="warn"] {
  --hero-state: var(--amber);
}

.hero-metric[data-state="danger"],
.hero-metric[data-state="bad"] {
  --hero-state: var(--red);
}

.hero-metric__summary {
  position: relative;
  display: flex;
  align-items: center;
  min-height: calc(140px + var(--tg-fullscreen-control-extra-top, 0px));
  padding: calc(22px + var(--tg-fullscreen-control-extra-top, 0px)) 16px 14px;
}

.hero-metric__copy {
  position: relative;
  z-index: 3;
  display: grid;
  align-content: center;
  width: min(68%, 248px);
  min-width: 0;
}

.hero-metric__title {
  color: #244f49;
  font-size: 13px;
  font-weight: 780;
  line-height: 1.25;
  text-wrap: balance;
}

.hero-metric__amount {
  margin-top: 6px;
  color: var(--hero-state);
  font-size: clamp(31px, 9vw, 39px);
  font-weight: 820;
  line-height: 1;
  letter-spacing: -.03em;
  white-space: nowrap;
}

.hero-metric__display {
  margin-top: 5px;
  color: #4f675f;
  font-size: 13px;
  font-style: normal;
  font-weight: 700;
  line-height: 1.2;
}

.hero-metric__hint {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.2;
}

.hero-metric__hint:empty {
  display: none;
}

.hero-metric__ribbon {
  position: absolute;
  top: -32px;
  right: -58px;
  z-index: 1;
  display: block;
  width: clamp(326px, 96vw, 380px);
  height: 210px;
  color: var(--hero-state);
  filter: drop-shadow(0 7px 12px color-mix(in srgb, var(--hero-state) 13%, transparent));
  -webkit-mask-image: linear-gradient(90deg, transparent 0 20%, #000 58%);
  mask-image: linear-gradient(90deg, transparent 0 20%, #000 58%);
}

.hero-metric__ribbon-band {
  fill: currentColor;
}

.hero-metric__ribbon-band--one {
  opacity: .52;
}

.hero-metric__ribbon-band--two {
  opacity: .22;
}

.hero-metric__ribbon-band--three {
  opacity: .12;
}

.hero-metric__ribbon-dot {
  fill: var(--gold);
  opacity: .72;
}

.hero-metric__facts {
  position: relative;
  z-index: 2;
  display: grid;
  gap: 7px;
  margin: 0 12px;
  padding: 10px 12px;
  border: 1px solid #e9e1d7;
  border-radius: 14px;
  background: color-mix(in srgb, #fff 88%, #f3efe8);
  box-shadow: 0 4px 12px rgb(69 54 39 / 5%);
}

.hero-metric__facts > div:not(.hero-metric__progress),
.hero-metric__detail-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: baseline;
}

.hero-metric__facts span,
.hero-metric__detail-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 560;
  line-height: 1.25;
}

.hero-metric__facts strong,
.hero-metric__detail-row strong {
  color: var(--ink);
  font-size: 12px;
  font-weight: 760;
  line-height: 1.25;
  text-align: right;
  white-space: nowrap;
}

.hero-metric__progress {
  height: 7px;
  overflow: hidden;
  margin-top: 2px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--panel) 55%, var(--line));
}

.hero-metric__progress > div {
  height: 100%;
  border-radius: inherit;
  background: var(--hero-state);
}

.hero-metric__details {
  display: grid;
  gap: 7px;
  margin: 0 12px;
  padding: 14px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
}

.hero-metric__calculation-title {
  margin: 0 0 3px;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.25;
}

.hero-metric__calculation-rows {
  display: grid;
  gap: 7px;
}

.hero-metric__detail-row--subtotal {
  padding-top: 7px;
  border-top: 1px solid #e9e1d7;
}

.hero-metric__detail-row--result {
  margin-top: 3px;
  padding-top: 9px;
  border-top: 1px solid color-mix(in srgb, var(--hero-state) 32%, #e9e1d7);
}

.hero-metric__detail-row--result span,
.hero-metric__detail-row--result strong {
  color: var(--hero-state);
  font-weight: 820;
}

.hero-metric__calculation-note {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.hero-metric__details[hidden] {
  display: none;
}

.hero-metric__details-copy {
  color: var(--ink);
  font-size: 12px;
  font-weight: 560;
  line-height: 1.35;
}

.hero-metric__footer {
  border-top: 1px solid #e8e0d6;
}

.hero-metric__details-toggle {
  position: relative;
  width: 100%;
  min-height: 38px;
  border: 0;
  background: transparent;
  color: #244f49;
  font: inherit;
  font-size: 12px;
  font-weight: 720;
  text-align: center;
}

.hero-metric__details-toggle::after {
  content: "›";
  position: absolute;
  right: 15px;
  color: #82786e;
  font-size: 20px;
  font-weight: 400;
  line-height: 1;
  transition: transform 160ms ease;
}

.hero-metric__details-toggle[aria-expanded="true"]::after {
  transform: rotate(90deg);
}

@media (max-width: 360px) {
  .hero-metric__summary {
    min-height: calc(136px + var(--tg-fullscreen-control-extra-top, 0px));
    padding-inline: 13px;
  }

  .hero-metric__amount {
    font-size: 31px;
  }

  .hero-metric__facts > div:not(.hero-metric__progress) {
    gap: 6px;
  }
}

.dashboard-disclosure {
  margin-top: 12px;
  overflow: hidden;
}

.dashboard-disclosure__summary {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 70px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
}

.dashboard-disclosure__icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 10%, var(--panel));
  color: var(--accent);
}

.dashboard-disclosure__icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.dashboard-disclosure__summary::-webkit-details-marker {
  display: none;
}

.dashboard-disclosure__copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.dashboard-disclosure__copy > strong {
  color: var(--ink);
  font-size: 15px;
  font-weight: 850;
  line-height: 1.2;
}

.dashboard-disclosure__copy > span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.dashboard-disclosure__status {
  color: var(--accent) !important;
  font-weight: 760;
}

.dashboard-disclosure[data-state="danger"] .dashboard-disclosure__status {
  color: var(--red) !important;
}

.dashboard-disclosure__chevron {
  color: var(--muted);
  font-size: 25px;
  line-height: 1;
  transition: transform .18s ease;
}

.dashboard-disclosure[open] .dashboard-disclosure__chevron {
  transform: rotate(90deg);
}

.dashboard-disclosure__body {
  border-top: 1px solid var(--line);
  padding: 12px 14px 14px;
}

.analytics-disclosure .dashboard-disclosure__summary {
  min-height: 60px;
}

.dashboard-disclosure__badge {
  justify-self: start;
  border-radius: 999px;
  background: var(--notice-bg);
  color: var(--amber) !important;
  font-size: 11px !important;
  font-weight: 800;
  padding: 3px 7px;
}

.budget-plan__body {
  display: grid;
  gap: 12px;
}

.budget-plan .budget-topup-shell,
.budget-plan .budget-topup-card {
  margin-top: 0;
}

.analytics-disclosure .notice {
  margin: 0 0 12px;
}

.monthly-forecast__body {
  display: grid;
  gap: 6px;
}

.monthly-forecast__explanation {
  margin: 0 0 4px;
  padding: 12px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
}

.forecast-rows {
  display: grid;
}

#forecastDiffRow strong {
  white-space: normal;
  line-height: 1.25;
}

.compact-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
}

.plan-progress {
  padding: 12px 0;
}

.plan-progress-top,
.plan-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px 10px;
  align-items: baseline;
}

.plan-progress-top span,
.plan-row span {
  color: var(--muted);
  font-size: 13px;
}

.plan-row {
  border-top: 1px solid var(--line);
  padding: 10px 0;
}

.plan-row strong,
.plan-progress-top strong {
  font-size: 15px;
  text-align: right;
  white-space: nowrap;
}

.plan-row em {
  grid-column: 2;
  color: var(--usd);
  font-style: normal;
  font-size: 12px;
  font-weight: 800;
  text-align: right;
}

.plan-row.good strong {
  color: var(--accent);
}

.plan-row.bad strong {
  color: var(--amber);
}

.plan-row.neutral strong {
  color: var(--ink);
}

.plan-progress .bar-track {
  margin-top: 8px;
}

.plan-progress .bar-fill {
  width: 0%;
}

.plan-row em,
.tag-chip em {
  color: var(--usd);
  font-style: normal;
  font-size: 12px;
  font-weight: 800;
}

.notice {
  margin-top: 12px;
  padding: 14px;
  border-color: var(--notice-line);
  background: var(--notice-bg);
}

#plannedNotice {
  position: relative;
  padding: 10px 12px;
  border-color: var(--line);
  background: var(--panel);
}

.dashboard-inbox {
  border-color: var(--line);
}

.inbox-draft-row {
  background: var(--panel);
}

.dashboard-inbox .expense-row {
  border-left: 0;
}

.notice-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-weight: 900;
}

.next-planned {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding: 12px 14px;
}

.next-planned div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.next-planned span,
.next-planned em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.next-planned strong {
  overflow-wrap: anywhere;
  font-size: 15px;
}

.planned-due-list {
  display: grid;
  gap: 0;
  margin-top: 0;
}

.planned-due-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  border-top: 1px solid var(--line);
}

.planned-due-list .planned-due-row:first-child {
  border-top: 0;
}

#plannedNotice > .planned-due-row:first-child {
  border-top: 0;
}

.planned-due-row--future {
  grid-template-columns: 38px minmax(0, 1fr);
}

.planned-due-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: color-mix(in srgb, var(--amber) 12%, var(--panel));
  color: var(--amber);
}

.planned-due-icon svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.planned-due-main {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.planned-due-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.planned-due-title {
  color: var(--ink);
  font-size: 15px;
  font-weight: 900;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.planned-due-meta {
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
  line-height: 1.25;
}

.planned-due-pay {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 11px;
  white-space: nowrap;
}

@media (max-width: 480px) {
  .planned-due-row {
    grid-template-columns: 36px minmax(0, 1fr) auto;
  }
  .planned-due-row--future {
    grid-template-columns: 36px minmax(0, 1fr);
  }
  .planned-due-pay {
    min-height: 40px;
    padding: 0 12px;
  }
}

.section {
  margin-top: 12px;
  overflow: hidden;
}

.form-section {
  overflow: visible;
}

.section-heading {
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.section-heading__action {
  min-height: 32px;
  padding: 5px 8px;
  color: var(--accent);
  font-size: 12px;
}

.latest-expenses .section-heading {
  align-items: center;
  padding: 13px 14px;
}

.latest-expenses .section-heading__action {
  min-height: 30px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 760;
}

.dashboard-expense-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  width: 100%;
  border-top: 0;
  border-right: 0;
  border-left: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color 120ms ease, transform 120ms ease;
}

.dashboard-expense-row:last-child {
  border-bottom: 0;
}

.dashboard-expense-row:active {
  background: color-mix(in srgb, var(--accent) 9%, transparent);
  transform: scale(.995);
}

.dashboard-expense-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: color-mix(in srgb, var(--category-color) 16%, var(--panel));
  color: var(--category-color);
}

.dashboard-expense-icon svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.dashboard-expense-main {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.dashboard-expense-main strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  font-weight: 780;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-expense-main span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.dashboard-expense-amount {
  display: grid;
  gap: 2px;
  justify-items: end;
  min-width: 0;
  text-align: right;
}

.dashboard-expense-amount strong {
  color: var(--ink);
  font-size: 13px;
  font-weight: 850;
  line-height: 1.2;
  white-space: nowrap;
}

.dashboard-expense-amount em {
  color: var(--usd);
  font-size: 11px;
  font-style: normal;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.split-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.planned-header__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.planned-header__title {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.planned-header__heading-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.plan-info-disclosure {
  position: relative;
}

.plan-info-disclosure > summary {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: var(--accent);
  cursor: pointer;
  font-size: 17px;
  list-style: none;
}

.plan-info-disclosure > summary::-webkit-details-marker,
.planned-expense-card__menu > summary::-webkit-details-marker {
  display: none;
}

.plan-info-disclosure__body {
  position: absolute;
  z-index: 6;
  top: calc(100% + 8px);
  left: 0;
  display: grid;
  width: min(300px, calc(100vw - 56px));
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  padding: 12px;
  box-shadow: var(--shadow);
}

.plan-info-disclosure__body strong {
  font-size: 13px;
}

.plan-info-disclosure__body p {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.planned-header__top button {
  flex: 0 0 auto;
}

.planned-summary-card {
  display: grid;
  gap: 7px;
  margin: 0 14px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
  padding: 12px;
}

.planned-summary-card > strong {
  font-size: 26px;
  line-height: 1.08;
  overflow-wrap: anywhere;
}

.planned-summary-progress {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 15%, var(--line));
}

.planned-summary-progress__fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width .2s ease;
}

.planned-summary-rows {
  display: grid;
  gap: 4px;
}

.planned-summary-row {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 8px;
  align-items: baseline;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  line-height: 1.3;
}

.planned-summary-row__label {
  color: var(--muted);
}

.planned-summary-row__amount {
  min-width: 0;
  color: var(--ink);
  font-weight: 850;
  overflow-wrap: anywhere;
}

.planned-summary-card em,
.planned-summary-row__amount em {
  color: var(--usd);
  font-style: normal;
}

#plannedExpenses {
  gap: 10px;
  padding: 0 14px;
}

.planned-expense-card {
  display: block;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
}

.planned-expense-card__main,
.planned-expense-card__content {
  min-width: 0;
}

.planned-expense-card__main {
  width: 100%;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  border: 0;
  border-radius: 15px 15px 10px 10px;
  background: transparent;
  color: inherit;
  font: inherit;
  padding: 10px 12px 8px;
  text-align: left;
  cursor: pointer;
  transition: background-color 120ms ease, transform 120ms ease;
}

.planned-expense-card__main:active {
  background: color-mix(in srgb, var(--accent) 9%, transparent);
  transform: scale(.995);
}

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

.planned-expense-card__content {
  display: grid;
  gap: 2px;
}

.planned-expense-card__content strong {
  overflow-wrap: anywhere;
}

.planned-expense-card__amount {
  flex: 0 0 auto;
  font-weight: 900;
  text-align: right;
  white-space: nowrap;
}

.planned-expense-card__amount em {
  display: block;
  color: var(--usd);
  font-size: 12px;
  font-style: normal;
}

.planned-expense-card__meta,
.planned-expense-card__status {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
}

.planned-expense-card__status {
  width: fit-content;
  margin-top: 2px;
  border-radius: 999px;
  padding: 3px 7px;
}

.planned-expense-card__status--paid {
  background: color-mix(in srgb, var(--green) 13%, transparent);
  color: var(--green);
}

.planned-expense-card__status--unpaid {
  background: color-mix(in srgb, var(--amber) 13%, transparent);
  color: var(--amber);
}

.planned-expense-card__status--overdue {
  background: color-mix(in srgb, var(--red) 12%, transparent);
  color: var(--red);
}

.planned-expense-card__actions {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  gap: 7px;
  padding: 0 12px 12px 60px;
}

.planned-expense-card__actions > button,
.planned-expense-card__menu > summary {
  min-height: 36px;
  padding: 7px 9px;
  font-size: 12px;
}

.planned-expense-card__menu {
  position: relative;
}

.planned-expense-card__menu > summary {
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  list-style: none;
  font-size: 20px;
  line-height: 1;
}

.planned-expense-card__overflow {
  position: absolute;
  z-index: 5;
  top: calc(100% + 6px);
  right: 0;
  display: grid;
  width: min(260px, calc(100vw - 64px));
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  padding: 8px;
  box-shadow: var(--shadow);
}

.planned-expense-card__overflow button {
  width: 100%;
}

.expense-list,
.bar-list,
.history-list {
  display: grid;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px;
}

.tag-chip {
  display: grid;
  gap: 2px;
  min-width: 126px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff8ef;
  padding: 9px 10px;
}

.tag-chip span {
  color: var(--muted);
  font-size: 12px;
}

.tag-chip strong {
  font-size: 14px;
}

.compact-tags {
  border-top: 1px solid var(--line);
  padding: 10px 14px 12px;
}

.compact-tags .tag-chip {
  min-width: auto;
  grid-auto-flow: column;
  align-items: baseline;
  gap: 6px;
  padding: 7px 9px;
}

.compact-tags .tag-chip em {
  display: none;
}

.compact-tags .tag-chip:nth-child(n + 7) {
  display: none;
}

.heatmap {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 6px;
  padding: 14px;
}

.heatmap-day {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgb(29 127 117 / calc(0.10 + var(--heat) * 0.55));
  color: var(--ink);
  font-size: 11px;
  font-weight: 800;
}

.bar-row {
  display: grid;
  gap: 7px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  border-left: 4px solid var(--category-color, var(--accent));
}

.bar-row:last-child {
  border-bottom: 0;
}

.bar-row-top,
.history-day-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.bar-row-top span,
.history-day-heading h3 {
  min-width: 0;
  overflow-wrap: anywhere;
}

.bar-row-top strong,
.history-day-heading strong {
  white-space: nowrap;
}

.bar-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #f0e8df;
}

.bar-fill {
  height: 100%;
  min-width: 6px;
  border-radius: inherit;
  background: var(--category-color, var(--accent));
}

.compact-bars .bar-row {
  gap: 5px;
  padding: 11px 14px;
}

.compact-bars .bar-row-display {
  display: none;
}

.compact-bars .bar-row:nth-child(n + 4) {
  display: none;
}

.compact-bars .bar-track {
  height: 6px;
}

.compact-largest .expense-row {
  padding: 11px 14px;
}

.compact-largest .expense-row:nth-child(n + 2) {
  display: none;
}

.compact-heatmap {
  border-top: 1px solid var(--line);
  padding: 12px 14px;
}

.compact-heatmap .heatmap-day {
  font-size: 10px;
}

.history-day {
  border-bottom: 1px solid var(--line);
}

.history-day:last-child {
  border-bottom: 0;
}

.history-day-heading {
  padding: 12px 14px;
  background: #fff8ef;
}

body[data-theme="dark"] .history-day-heading {
  background: color-mix(in srgb, var(--panel) 84%, var(--accent));
  color: var(--ink);
}

.history-day-heading h3 {
  margin: 0;
  font-size: 15px;
}

.expense-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  border-left: 4px solid var(--category-color, var(--accent));
}

.expense-row:last-child {
  border-bottom: 0;
}

.expense-title {
  font-weight: 800;
  overflow-wrap: anywhere;
}

.expense-amount {
  font-weight: 900;
  white-space: nowrap;
  text-align: right;
}

.expense-amount em {
  display: block;
  font-size: 13px;
}

.expense-actions {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.planned-archive {
  margin: 14px 14px 0;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.planned-archive__toggle {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--ink);
  background: transparent;
  box-shadow: none;
  padding: 8px 2px;
}

.planned-archive__chevron {
  transition: transform 160ms ease;
}

.planned-archive__toggle[aria-expanded="true"] .planned-archive__chevron {
  transform: rotate(90deg);
}

.planned-archive__content {
  margin-top: 8px;
}

.planned-archive__status {
  color: var(--muted);
  font-size: 13px;
  padding: 8px 2px;
}

.planned-archive__status:empty {
  display: none;
}

.planned-archive .expense-row {
  align-items: flex-start;
}

.planned-archive .expense-title,
.planned-archive .expense-amount {
  overflow-wrap: anywhere;
  white-space: normal;
}

.inline-form,
.form-stack {
  display: grid;
  gap: 12px;
  padding: 14px;
}

@media (max-width: 430px) {
  .planned-archive .expense-actions,
  .planned-archive .button-row {
    width: 100%;
  }

  .planned-archive .button-row button {
    width: 100%;
  }
}

.inline-form {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  padding: 9px 10px;
}

.toggle-setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
}

.toggle-setting span {
  display: grid;
  gap: 3px;
}

.toggle-setting strong {
  color: var(--ink);
  font-size: 15px;
}

.toggle-setting small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.toggle-setting input {
  position: relative;
  flex: 0 0 auto;
  width: 48px;
  min-height: 28px;
  height: 28px;
  appearance: none;
  border: 0;
  border-radius: 999px;
  background: #d8d0c6;
  cursor: pointer;
  padding: 0;
  transition: background .18s ease;
}

.toggle-setting input::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgb(37 29 24 / 18%);
  transition: transform .18s ease;
}

.toggle-setting input:checked {
  background: var(--accent);
}

.toggle-setting input:checked::after {
  transform: translateX(20px);
}

.settings-page {
  display: grid;
  gap: 14px;
}

#settingsTab .settings-page {
  padding: 18px 16px 0;
}

.settings-section {
  display: grid;
  gap: 8px;
}

.settings-section-title {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
}

#settingsTab .settings-section-title {
  padding: 0 2px;
  line-height: 1.25;
}

.settings-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
}

.settings-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(160px, 1.4fr);
  align-items: center;
  gap: 12px;
}

.settings-row--stacked {
  display: grid;
  grid-template-columns: 1fr;
  align-items: stretch;
}

.currency-picker {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.currency-picker__summary {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  color: var(--ink);
  cursor: pointer;
  list-style: none;
}

.currency-picker__summary::-webkit-details-marker { display: none; }
.currency-picker__summary::after { content: "⌄"; color: var(--muted); }
.currency-picker[open] .currency-picker__summary::after { content: "⌃"; }
.currency-picker__summary strong { margin-left: auto; color: var(--accent); }
.currency-picker__controls { grid-template-columns: minmax(0, 1fr); padding: 0 12px 12px; }
.currency-picker__controls input,
.currency-picker__controls select { min-width: 0; max-width: 100%; }

.settings-hint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.settings-toggle {
  border: 0;
  background: transparent;
  padding: 0;
}

.settings-export {
  display: grid;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.timezone-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.timezone-picker { grid-column: 2; display: grid; gap: 8px; padding-top: 8px; }
.timezone-picker__options { display: grid; max-height: 280px; overflow-y: auto; border: 1px solid var(--line); border-radius: 12px; }
.timezone-picker__option { display: grid; gap: 2px; padding: 10px 12px; border-radius: 0; text-align: left; background: var(--panel); color: var(--ink); border-bottom: 1px solid var(--line); }
.timezone-picker__option small { color: var(--muted); }

.timezone-action {
  min-height: 42px;
  white-space: nowrap;
}

@media (max-width: 480px) {
  #settingsTab .settings-page {
    padding: 16px 14px 0;
  }
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--accent-button);
  color: var(--accent-on);
  font: inherit;
  font-weight: 700;
  padding: 9px 14px;
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: .55;
}

.ghost-button {
  min-height: 32px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--usd);
  font-size: 13px;
  padding: 5px 9px;
}

.danger-button {
  min-height: 32px;
  border: 1px solid #edd0d4;
  background: var(--panel);
  color: var(--red);
  font-size: 13px;
  padding: 5px 9px;
}

.danger-button--solid {
  border-color: var(--red);
  background: var(--red);
  color: #fff;
}

.danger-zone {
  margin: 18px 16px 0;
  border-top: 1px solid var(--line);
}

.danger-zone__summary {
  display: flex;
  min-height: 54px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink);
  cursor: pointer;
  list-style: none;
  outline: none;
}

.danger-zone__summary:focus-visible {
  border-radius: 8px;
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.danger-zone__summary::-webkit-details-marker {
  display: none;
}

.danger-zone__summary-copy {
  display: grid;
  gap: 2px;
}

.danger-zone__summary-copy small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.danger-zone__chevron {
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
  transition: transform 160ms ease;
}

.danger-zone[open] .danger-zone__chevron {
  transform: rotate(90deg);
}

.danger-zone[open] .danger-zone__card {
  margin-top: 4px;
}

.danger-zone__label,
.danger-zone__warning {
  color: var(--red);
}

.danger-zone__card,
.delete-account-state {
  gap: 10px;
}

.delete-account-state {
  display: grid;
}

.delete-account-state label {
  font-size: 13px;
  font-weight: 750;
}

.delete-account-state .button-row {
  margin-top: 2px;
}

.delete-account-cancel {
  justify-self: start;
}

.danger-zone--deleted {
  gap: 8px;
}

.deleted-account-state {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 14px;
  line-height: 1.5;
}

@media (max-width: 480px) {
  .danger-zone {
    margin-right: 14px;
    margin-left: 14px;
  }
}

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

.button-row.compact {
  justify-content: flex-end;
  margin-top: 0;
}

.reserve-settings {
  display: grid;
  gap: 6px;
}

.plan-reserve-section {
  margin: 0 14px 12px;
}

.reserve-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 54px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 10px 12px;
  text-align: left;
}

.reserve-summary__text {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.reserve-summary__text strong {
  font-size: 15px;
  font-weight: 850;
  line-height: 1.2;
}

.reserve-summary__text small,
.reserve-summary__note {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

#reserveSummaryDescription {
  font-weight: 650;
}

.reserve-summary__status {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 5px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 850;
  white-space: nowrap;
}

.reserve-summary__chevron {
  font-size: 21px;
  line-height: 1;
  transition: transform .18s ease;
}

.reserve-summary--expanded .reserve-summary__chevron {
  transform: rotate(90deg);
}

.reserve-summary__note {
  margin: 0;
  padding: 0 2px;
}

.inbox-category-row {
  margin-top: 9px;
}

.active-chip {
  border-color: #b9ded8;
  background: #e8f4f1;
  color: var(--accent);
}

.edit-card {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.field-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px;
  gap: 10px;
}

.form-note {
  line-height: 1.45;
}

.settings-details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px 12px;
}

.settings-details summary {
  color: var(--ink);
  cursor: pointer;
  font-weight: 850;
}

.settings-details label {
  margin-top: 12px;
}

.hidden {
  display: none;
}

.onboarding-state {
  min-height: 62vh;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 14px;
  padding: 28px 18px;
  text-align: center;
}

.onboarding-state.hidden {
  display: none;
}

.onboarding-state__icon {
  font-size: 44px;
}

.onboarding-state h1,
.onboarding-state p {
  margin: 0;
}

.onboarding-state p {
  max-width: 340px;
  color: var(--muted);
  line-height: 1.45;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 20;
  width: min(calc(100% - 32px), 420px);
  transform: translateX(-50%);
  border: 1px solid #b9ded8;
  border-radius: 10px;
  background: #103f3a;
  color: #fff;
  box-shadow: 0 16px 38px rgb(37 29 24 / 18%);
  font-weight: 850;
  padding: 12px 14px;
  text-align: center;
  white-space: pre-line;
}

.toast > span { display: block; margin-top: 3px; color: #c8ebe5; font-size: 13px; }
.toast > div { display: flex; justify-content: center; gap: 8px; margin-top: 10px; }
.toast button { min-height: 30px; padding: 4px 10px; border: 1px solid #b9ded8; border-radius: 8px; background: transparent; color: #fff; font: inherit; font-size: 13px; }

.empty,
.error {
  padding: 18px 14px;
  color: var(--muted);
}

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

@media (prefers-reduced-motion: reduce) {
  .tab-pager.is-animating .tab-page.is-pager-current,
  .tab-pager.is-animating .tab-page.is-pager-neighbor {
    transition: none;
  }

  .dashboard-card__flip-inner {
    transition: none;
  }

  .dashboard-card.is-flipped .dashboard-card__flip-inner {
    transform: none;
  }

  .dashboard-card.is-flipped .dashboard-card__face--front {
    display: none;
  }

  .dashboard-card.is-flipped .dashboard-card__face--back {
    position: static;
    transform: none;
  }
}

@media (max-width: 640px) {
  .shell {
    padding: max(14px, var(--tg-content-safe-area-inset-top, var(--tg-safe-area-inset-top, 0px))) 16px calc(96px + max(0px, var(--tg-content-safe-area-inset-bottom, var(--tg-safe-area-inset-bottom, 0px))));
  }

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

  .field-grid,
  .inline-form {
    grid-template-columns: 1fr;
  }

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

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

  .dashboard-card,
  .dashboard-card--progress,
  .dashboard-card__flip-inner,
  .dashboard-card__face,
  .dashboard-card__face--front,
  .dashboard-card__face--back {
    min-height: 140px;
  }

  .dashboard-card {
    border-radius: 17px;
  }

  .dashboard-card__flip-inner,
  .dashboard-card__face {
    border-radius: 17px;
  }

  .dashboard-card__face--front {
    gap: 5px;
    padding: 12px;
  }

  .dashboard-card__face--back {
    padding: 12px;
  }

  .dashboard-card__back-text {
    font-size: 12px;
    line-height: 1.3;
  }

  .dashboard-card__top {
    gap: 4px;
    min-height: 38px;
  }

  .dashboard-card__amount {
    font-size: clamp(19px, 5.5vw, 23px);
    line-height: 1.05;
  }

  .dashboard-card__title {
    flex: 1 1 auto;
    font-size: 13px;
    line-height: 1.12;
  }

  .dashboard-card__percent {
    flex: 0 0 auto;
    font-size: 11px;
  }

  .dashboard-card__line {
    gap: 4px;
    font-size: 11px;
    line-height: 1.15;
  }

  .dashboard-card__caption {
    font-size: 11px;
    line-height: 1.18;
  }

  .dashboard-card__reserve {
    font-size: 12px;
    line-height: 1.18;
  }

  .dashboard-card__display {
    font-size: 11px;
  }

  .dashboard-card__progress {
    height: 6px;
  }

  .bottom-tabs {
    bottom: max(8px, var(--tg-content-safe-area-inset-bottom, var(--tg-safe-area-inset-bottom, env(safe-area-inset-bottom))));
    gap: 4px;
    padding: 5px;
  }

  .bottom-tabs .tab-button {
    min-height: 50px;
    font-size: 11px;
  }

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

  .expense-actions {
    justify-items: start;
  }

  .expense-amount {
    text-align: left;
  }

  .button-row.compact {
    justify-content: flex-start;
  }

  .planned-header__top {
    align-items: flex-start;
  }

  .planned-header__top button {
    min-height: 38px;
    padding: 8px 11px;
  }

  .planned-summary-card > strong {
    font-size: 22px;
  }

  .settings-row,
  .timezone-control {
    grid-template-columns: 1fr;
  }

  .timezone-picker { grid-column: 1; }

}

.history-filters {
  margin-top: 14px;
  padding: 14px;
  border-top: 1px solid var(--line);
}

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

.history-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 12px 14px 0;
}

.history-search__field {
  position: relative;
  min-width: 0;
  display: block;
}

.history-search > button[type="submit"] {
  min-height: 42px;
  padding: 8px 12px;
}

.history-load-status {
  margin: 12px 14px;
  color: var(--muted);
  font-size: 14px;
}

.history-load-status button {
  margin-left: 8px;
}

#historyTab[data-history-load-state="loading"] #historySavedHeading,
#historyTab[data-history-load-state="loading"] #historyList,
#historyTab[data-history-load-state="loading"] #historyPeriodSummary,
#historyTab[data-history-load-state="loading"] #historyAnalytics,
#historyTab[data-history-load-state="error"] #historySavedHeading,
#historyTab[data-history-load-state="error"] #historyList,
#historyTab[data-history-load-state="error"] #historyPeriodSummary,
#historyTab[data-history-load-state="error"] #historyAnalytics {
  display: none;
}

.history-search__field input {
  width: 100%;
  min-height: 42px;
  padding: 9px 40px 9px 38px;
  border-radius: 12px;
}

.history-search__icon {
  position: absolute;
  left: 12px;
  top: 50%;
  z-index: 1;
  width: 18px;
  height: 18px;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.history-search__icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.history-search__clear {
  position: absolute;
  right: 6px;
  top: 50%;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  transform: translateY(-50%);
}

.history-filter-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.history-filter-current {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-period-row {
  display: grid;
  min-width: 0;
  gap: 8px;
}

.history-filter-chips {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  min-width: 0;
  gap: 8px;
  overflow-x: visible;
}

.history-filter-chip {
  min-width: 0;
  min-height: 34px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  padding: 7px 4px;
  border-radius: 10px;
  line-height: 1.15;
  cursor: pointer;
}

.history-filter-chip.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent);
}

.history-date-action {
  width: 100%;
  background: transparent;
  color: var(--accent);
  box-shadow: none;
}

.history-period-summary {
  margin-top: 12px;
}

.history-summary-card {
  display: grid;
  gap: 4px;
  border: 1px solid color-mix(in srgb, var(--accent) 24%, var(--line));
  border-radius: 16px;
  background: color-mix(in srgb, var(--accent-soft) 42%, var(--panel));
  padding: 12px;
}

.history-summary-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.history-summary-amount {
  color: var(--ink);
  font-size: 24px;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.history-summary-meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.history-analytics {
  margin-top: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}

.history-analytics > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 12px;
  cursor: pointer;
  list-style: none;
}

.history-analytics > summary::-webkit-details-marker { display: none; }

.history-analytics > summary > span:first-child {
  display: grid;
  gap: 2px;
}

.history-analytics > summary strong { font-size: 13px; }
.history-analytics > summary small { color: var(--muted); font-size: 11px; }
.history-analytics__chevron { color: var(--muted); font-size: 22px; transition: transform 160ms ease; }
.history-analytics[open] .history-analytics__chevron { transform: rotate(90deg); }
.history-analytics__body { border-top: 1px solid var(--line); padding: 14px 12px; }

.history-donut-layout {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
}

.history-donut {
  display: grid;
  place-items: center;
  width: 128px;
  aspect-ratio: 1;
  border-radius: 50%;
}

.history-donut > div {
  display: grid;
  place-items: center;
  width: 76px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--panel);
  text-align: center;
}

.history-donut strong { max-width: 70px; font-size: 14px; overflow-wrap: anywhere; }
.history-donut span { color: var(--muted); font-size: 9px; }
.history-category-ranking { display: grid; gap: 7px; }
.history-category-rank { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; font-size: 11px; }
.history-category-rank span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-category-rank span::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 50%; background: var(--category-color); }
.history-category-rank strong { white-space: nowrap; }
.history-top-expenses { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.history-top-expenses h3 { margin: 0 0 6px; font-size: 12px; }
.history-analytics-expense { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 6px 0; }
.history-analytics-expense .dashboard-expense-icon { width: 32px; height: 32px; border-radius: 9px; }
.history-analytics-expense .dashboard-expense-icon svg { width: 18px; height: 18px; }
.history-analytics-expense > span:nth-child(2) { display: grid; min-width: 0; }
.history-analytics-expense strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.history-analytics-expense small { color: var(--muted); font-size: 10px; }
.history-analytics-expense b { font-size: 11px; white-space: nowrap; }

.history-expense-row {
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  width: 100%;
  min-height: 64px;
  gap: 10px;
  padding: 10px 14px;
  border-top: 0;
  border-right: 0;
  border-left: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color 120ms ease, transform 120ms ease;
}

.history-expense-row:active {
  background: color-mix(in srgb, var(--accent) 9%, transparent);
  transform: scale(.995);
}

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

.history-expense-row .expense-main {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.history-expense-row .expense-meta {
  overflow-wrap: anywhere;
}

@media (max-width: 390px) {
  .history-filters { padding-inline: 10px; }
  .history-filter-chips { gap: 5px; }
  .history-filter-chip { font-size: 11px; padding-inline: 2px; }
  .history-donut-layout { grid-template-columns: 112px minmax(0, 1fr); gap: 10px; }
  .history-donut { width: 112px; }
  .history-donut > div { width: 68px; }
  .history-expense-row { grid-template-columns: 34px minmax(0, 1fr) auto; gap: 8px; }
  .history-expense-row .dashboard-expense-icon { width: 34px; height: 34px; }
}

.history-inbox-compact {
  margin: 12px 0 2px;
  border-radius: 14px;
  border: 1px solid #edc7d1;
  background: #fff7f8;
  overflow: hidden;
}

.history-inbox-compact .section-heading h3 {
  font-size: 14px;
  padding: 10px 12px;
  margin: 0;
  color: var(--ink);
}

.history-inbox-compact .compact-heading {
  padding-bottom: 0;
}

.quick-access-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.quick-access-entry__copy { display: grid; gap: 4px; }
.quick-access-entry__copy > span { color: var(--muted); font-size: 12px; font-weight: 500; line-height: 1.35; }
.quick-access-entry__chevron { color: var(--muted); font-size: 28px; font-weight: 400; line-height: 1; }

.history-inbox-summary {
  margin: 2px 12px 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.history-inbox-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  padding: 0 12px 12px;
}

.history-inbox-actions button {
  width: 100%;
  min-width: 0;
  white-space: normal;
  line-height: 1.2;
}

.history-review-progress {
  padding: 10px 12px 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.history-inbox-compact #inboxDrafts {
  border-top: 1px solid var(--line);
}

@media (max-width: 390px) {
  .history-inbox-actions { grid-template-columns: 1fr; }
}

.history-saved-heading {
  padding: 10px 14px 8px;
  border-bottom: 1px solid var(--line);
}

.history-saved-heading h3 {
  font-size: 14px;
  margin: 0;
  color: var(--ink);
}

.history-date-backdrop {
  position: fixed;
  inset: 0;
  z-index: 39;
  background: rgb(20 16 14 / 56%);
  backdrop-filter: blur(2px);
}

.history-date-sheet {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
  display: grid;
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  gap: 12px;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 24px 24px 0 0;
  background: var(--panel);
  padding: 10px 16px calc(16px + env(safe-area-inset-bottom));
  box-shadow: 0 -18px 48px rgb(0 0 0 / 24%);
  overscroll-behavior: contain;
}

.history-date-sheet.hidden,
.history-date-backdrop.hidden {
  display: none;
}

body.history-date-sheet-open {
  overflow: hidden;
}

.history-date-sheet__handle {
  width: 40px;
  height: 4px;
  margin: 0 auto;
  border-radius: 999px;
  background: var(--line);
}

.history-date-sheet__header,
.history-calendar__navigation {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.history-date-sheet__header > div {
  min-width: 0;
}

.history-date-sheet__header h2 {
  font-size: 19px;
}

.history-date-selection {
  margin-top: 4px;
  overflow: hidden;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-date-sheet__close,
.history-calendar__navigation button {
  flex: 0 0 auto;
  min-width: 40px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--ink);
  padding: 0;
}

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

.history-calendar__navigation strong {
  text-transform: capitalize;
}

.history-calendar__weekdays,
.history-calendar__grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.history-calendar__weekdays span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

.history-calendar__day {
  min-width: 0;
  min-height: 40px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  padding: 0;
}

.history-calendar__day.is-in-range {
  background: var(--accent-soft);
}

.history-calendar__day.is-start,
.history-calendar__day.is-end {
  border-radius: 12px;
  background: var(--accent-button);
  color: var(--accent-on);
}

.history-calendar__day.is-today:not(.is-start):not(.is-end) {
  box-shadow: inset 0 0 0 1px var(--accent);
}

.history-calendar__day:disabled {
  color: color-mix(in srgb, var(--muted) 48%, transparent);
  cursor: default;
}

.history-date-sheet__actions {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: 10px;
  background: var(--panel);
  padding-top: 4px;
}

.history-date-sheet__actions button {
  min-width: 0;
  min-height: 44px;
}

@media (min-width: 813px) {
  .history-date-sheet {
    right: calc((100vw - 812px) / 2);
    left: calc((100vw - 812px) / 2);
  }
}
