:root {
  color-scheme: light;
  --paper: #f4f5f6;
  --surface: #ffffff;
  --hero-surface: #e6edf2;
  --text: #202a32;
  --muted: #58666d;
  --edge: #e7ece9;
  --accent: #376d65;
  --green: var(--accent);
  --soft: #e5eee9;
  --negative: #a64139;
  --positive: #296844;
  --transfer: #575e70;
  --refund: #5d4f83;
  --expense-fill: #5276a0;
  --expense-track: #e0e8f2;
  --fund-fill: #766a8a;
  --fund-track: #eae6ef;
  --stroke-control: #818c86;
  --grocery-ink: #2e6951;
  --grocery-tint: #cfe8d8;
  --cafe-ink: #8d4f32;
  --cafe-tint: #f5d6c1;
  --shopping-ink: #5276a0;
  --shopping-tint: #e0e8f2;
  --home-ink: #72658e;
  --home-tint: #e9e5f1;
  --emergency-ink: #9a626f;
  --emergency-tint: #f1e2e5;
  --warning: #83532f;
  --warning-surface: #f8efe6;
  --control: #e9eeeb;
  --on-accent: #ffffff;
  --bar: var(--expense-fill);
  --plot: var(--accent);
  --benchmark: var(--muted);
  --safe: max(env(safe-area-inset-bottom, 0px), var(--app-inset-bottom, 0px),
    var(--tg-content-safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  --nav-gutter: max(14px, var(--safe));
  --sp-1: .25rem;
  --sp-2: .5rem;
  --sp-3: .75rem;
  --sp-4: 1rem;
  --sp-6: 1.5rem;
  --sp-8: 2rem;
  --type-caption: .8125rem;
  --type-body: 1rem;
  --type-value: 1.125rem;
  --type-title: 1.5rem;
  --type-balance: 2rem;
  --radius-small: .625rem;
  --radius-panel: 1.125rem;
  --radius-hero: 1.375rem;
  --icon-box: 2.25rem;
  --tap: 44px;
  --meter-h: 7px;
  font-family:
    -apple-system, BlinkMacSystemFont, "SF Pro Display", Inter, system-ui,
    sans-serif;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #141a23;
  --surface: #202936;
  --hero-surface: #26313e;
  --text: #f2f4f3;
  --muted: #b1bac0;
  --edge: #3a4146;
  --accent: #a3cdbf;
  --soft: #303b3b;
  --negative: #efa49d;
  --positive: #9fcdb3;
  --transfer: #b7bfce;
  --refund: #c8b8e3;
  --expense-fill: #a3bddc;
  --expense-track: #323f50;
  --fund-fill: #d6c9ed;
  --fund-track: #4e4959;
  --stroke-control: #747e82;
  --grocery-ink: #a0daba;
  --grocery-tint: #263f38;
  --cafe-ink: #f5c098;
  --cafe-tint: #4a342e;
  --shopping-ink: #a3bddc;
  --shopping-tint: #323f50;
  --home-ink: #b8aed3;
  --home-tint: #40394d;
  --emergency-ink: #d6a5ae;
  --emergency-tint: #4c373e;
  --warning: #d8aa81;
  --warning-surface: #332b27;
  --control: #30343b;
  --on-accent: #182720;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  color: var(--text);
  background: var(--paper);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}
button,
input {
  font: inherit;
}
button {
  cursor: pointer;
  color: inherit;
  border: 0;
  background: transparent;
}
button:disabled {
  opacity: 0.58;
  cursor: wait;
}
button:focus-visible,
input:focus-visible {
  outline: 3px solid var(--bar);
  outline-offset: 3px;
}
main {
  max-width: 760px;
  margin: auto;
}

#sync {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0;
  text-align: right;
}
main {
  padding: 13px 22px calc(112px + var(--safe));
}
h1,
h2,
h3,
p {
  margin: 0;
}
h1 {
  font-size: clamp(2rem, 6.2vw, 2.8rem);
  line-height: 1.12;
  letter-spacing: -0.03em;
  font-weight: 700;
  margin-bottom: 18px;
}
h2 {
  font-size: 1.25rem;
  letter-spacing: -0.03em;
  font-weight: 650;
  line-height: 1.2;
}
h3 {
  font-size: 1rem;
  font-weight: 600;
}
section {
  margin-bottom: 27px;
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.box,
.hero {
  padding: 16px 18px;
  background: var(--surface);
  border-radius: 20px;
}
.hero .muted {
  color: var(--muted);
}

.forecast-low {
  min-height: 42px;
  width: 100%;
  margin: 5px 0;
  border-radius: 12px;
  background: var(--paper);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}
.forecast-low.neg {
  color: var(--negative);
}
.daily-events {
  border-top: 1px solid var(--edge);
  margin-top: 8px;
  padding-top: 10px;
}
.daily-events h3,
.transfer-row h3 {
  font-size: 14px;
}
.transfer-row h3 {
  font-size: 1rem;
}
.transfer-row {
  padding-block: 12px;
}
.transfer-row + .transfer-row {
  border-top: 1px solid var(--edge);
}

.hero h2 {
  font-size: 15px;
  font-weight: 550;
  letter-spacing: 0;
}
.amount {
  font-size: clamp(34px, 8vw, 46px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.12;
  margin: 10px 0 3px;
  overflow-wrap: anywhere;
}
.muted,
.sub,
.empty {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
.empty {
  padding: 12px 0;
}
.sub {
  margin-top: 3px;
}
.pill,
.link {
  border-radius: 9px;
  font-size: 13px;
  font-weight: 630;
  padding: 7px 10px;
  min-height: 44px;
}
.pill {
  background: var(--soft);
  color: var(--green);
}
.link {
  color: var(--green);
  padding-left: 0;
}
.row,
.entry {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 12px 0;
  border-bottom: 1px solid var(--edge);
  width: 100%;
  text-align: left;
  min-width: 0;
}
.row:last-child,
.entry:last-child {
  border-bottom: 0;
}
.grow {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}
.num {
  font-weight: 630;
  white-space: nowrap;
  font-size: 0.95rem;
}
.income {
  color: var(--positive);
}
.neg {
  color: var(--negative);
}
.date-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--soft);
  color: var(--green);
  border-radius: 11px;
  min-width: 45px;
  padding: 6px;
}
.date-cell b {
  font-size: 18px;
  line-height: 1.1;
}
.date-cell small {
  font-size: 10px;
}
.compact {
  font-size: 13px;
}
.chart {
  width: 100%;
  height: clamp(176px, 27vh, 230px);
  display: block;
  touch-action: pan-y;
}
.analysis-card {
  overflow: hidden;
}

.analysis-card h2 {
  margin: 0 0 12px;
}
.analysis-amount {
  display: block;
  font-size: clamp(2rem, 9vw, 3rem);
  font-weight: 620;
  line-height: 1.12;
  letter-spacing: -0.055em;
  overflow-wrap: anywhere;
}
.analysis-comparison {
  font-size: 14px;
  line-height: 1.4;
  color: var(--muted);
  margin: 5px 0 14px;
}
.analysis-comparison.overspent {
  color: var(--negative);
}
.chart.analysis-plot {
  height: clamp(178px, 26vh, 240px);
}

.period-step {
  font-size: 24px;
  height: 44px;
  color: var(--green);
}
.period-step:disabled {
  opacity: 0.28;
  cursor: default;
}
.analysis-card .legend span:first-child::before {
  background: var(--plot);
}
.analysis-card .legend .dotted::before {
  border-color: var(--benchmark);
}
.chart-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.chart-range {
  width: 100%;
  height: 15px;
  margin: 3px 0;
  accent-color: var(--green);
}
.chart-range:not(:focus-visible) {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 0;
  overflow: hidden;
  clip-path: inset(50%);
  margin: 0;
}
.chart {
  cursor: crosshair;
  user-select: none;
  -webkit-user-select: none;
}
.chart-row {
  flex-wrap: wrap;
}
.hero .chart-range {
  accent-color: var(--accent);
}
.hero .chart-row {
  font-size: 12px;
  color: var(--muted);
}
.caption {
  font-size: 13px;
  line-height: 1.4;
  margin: 10px 0;
}

.month-dialog {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--edge);
  border-radius: 24px;
  padding: 23px;
  width: min(94vw, 448px);
  max-height: 85dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
}
dialog::backdrop {
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: none;
}
#close {
  font-size: 27px;
  line-height: 1;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 50%;
  background: var(--paper);
}
label {
  display: block;
  color: var(--muted);
  font-size: 13px;
}
input {
  width: 100%;
  margin: 5px 0 12px;
  padding: 11px 12px;
  border: 1px solid var(--edge);
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  min-height: 42px;
}
input[type="range"] {
  min-height: 32px;
  padding: 0;
}
.primary {
  background: var(--green);
  color: var(--surface);
  font-weight: 620;
  padding: 13px 17px;
  width: 100%;
  border-radius: 12px;
}
#error {
  margin: 12px 0;
  color: var(--negative);
  font-size: 13px;
}
#error:empty {
  display: none;
}
#notice:not(:empty) {
  margin: 0 0 16px;
  color: var(--green);
  font-size: 14px;
  background: var(--soft);
  padding: 11px;
  border-radius: 10px;
}
.split {
  border-bottom: 1px solid var(--edge);
  margin: 12px 0;
}
.split button {
  margin-bottom: 8px;
}
.locked button {
  margin-top: 12px;
}
@media (min-width: 690px) {
  main {
    padding-top: 23px;
  }
  .box,
  .hero {
    padding: 20px 22px;
  }
  .list {
    padding: 4px 22px;
  }
  .chart {
    height: 200px;
  }
}
@media (max-width: 360px) {
  main {
    padding-left: 13px;
    padding-right: 13px;
  }

  .box,
  .hero {
    padding: 15px;
  }
  .num {
    font-size: 13px;
  }
}
@media (max-width: 540px) {
  dialog {
    margin: auto 0 0;
    inset: auto 0 0;
    width: 100%;
    max-width: none;
    max-height: min(88dvh, var(--tg-viewport-height, 100dvh));
    border-radius: 20px 20px 0 0;
    padding: 18px 18px calc(18px + var(--safe));
  }
  input {
    font-size: 16px;
    min-width: 0;
  }
  .section-head h2 {
    min-width: 0;
    overflow-wrap: anywhere;
  }
}
@media (prefers-reduced-motion: no-preference) {
  #content {
    animation: appear 0.23s ease-out;
  }
  button {
    transition:
      background 0.18s,
      color 0.18s;
  }
  @keyframes appear {
    from {
      opacity: 0.6;
      transform: translateY(3px);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }
}

.choice,
.sheet-row,
.choice-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: left;
  gap: 12px;
  min-height: 48px;
  width: 100%;
  padding: 11px 15px;
  border-radius: 14px;
  background: var(--surface);
  font-size: 15px;
  font-weight: 550;
}
.choice {
  border: 1px solid var(--edge);
  margin: 5px 0 12px;
}
.sheet-row::after,
.choice::after {
  content: "›";
  color: var(--muted);
  font-size: 21px;
  line-height: 1;
}
.choice-row[aria-pressed="true"] {
  background: var(--soft);
  color: var(--green);
}
.choice-row[aria-pressed="true"]::after {
  content: "✓";
}
#content > .sheet-row,
#content > div > .sheet-row {
  margin: 6px 0;
}
.menu-list {
  padding: 2px 14px;
  margin: 15px 0;
}
.menu-list .sheet-row {
  padding-inline: 3px;
}
.menu-list .sheet-row + .sheet-row {
  border-top: 1px solid var(--edge);
  border-radius: 0;
}
.chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  max-width: 100%;
  padding: 3px 1px 6px;
  margin: 3px 0 12px;
}
.chip {
  border-radius: 999px;
  background: var(--paper);
  min-height: 40px;
  padding: 8px 13px;
  white-space: nowrap;
  color: var(--muted);
  font-size: 14px;
  font-weight: 560;
}
.chip[aria-pressed="true"] {
  background: var(--soft);
  color: var(--green);
}
.plan-balance,
.fund-label {
  color: var(--muted);
}
#fields > .sheet-row + .sheet-row {
  border-top: 1px solid var(--edge);
  border-radius: 0;
}
section > .link {
  margin: 3px 0;
}
#fields {
  min-width: 0;
}
@media (prefers-reduced-motion: no-preference) {
  dialog[open]:not(.closing) {
    animation: sheet-in 0.25s cubic-bezier(0.32, 0.72, 0, 1);
  }
  dialog[open]::backdrop {
    animation: veil-in 0.2s;
  }
  @keyframes sheet-in {
    from {
      transform: translateY(55px);
      opacity: 0;
    }
    to {
      transform: none;
      opacity: 1;
    }
  }
  @keyframes veil-in {
    from {
      opacity: 0;
    }
    to {
      opacity: 1;
    }
  }
}

body {
  font-size: 16px;
}
main {
  max-width: 680px;
  padding: max(
      18px,
      var(--app-inset-top, 0px),
      env(safe-area-inset-top, 0px),
      var(--tg-content-safe-area-inset-top, 0px),
      var(--tg-safe-area-inset-top, 0px)
    )
    max(
      16px,
      env(safe-area-inset-right, 0px),
      var(--tg-content-safe-area-inset-right, 0px)
    )
    calc(78px + var(--nav-gutter))
    max(
      16px,
      env(safe-area-inset-left, 0px),
      var(--tg-content-safe-area-inset-left, 0px)
    );
}
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 4px 0 20px;
}
.page-head h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: -0.045em;
}
#sync {
  font-size: 12px;
  max-width: 44%;
  line-height: 1.4;
}
#content {
  min-width: 0;
}
h2 {
  font-size: 19px;
  letter-spacing: -0.025em;
}
h3 {
  font-size: 15px;
  font-weight: 570;
}
section {
  margin: 22px 0;
}
section:first-child {
  margin-top: 0;
}
.box,
.hero {
  box-shadow: none;
  border-radius: 16px;
  padding: 15px 16px;
}
.list {
  padding: 0 14px;
}
.hero {
  margin: 0 0 18px;
}
.headline {
  padding: 5px 0 15px;
  border-bottom: 1px solid var(--edge);
  margin-bottom: 18px;
}
.headline .amount,
.hero .amount,
.analysis-amount {
  font-size: clamp(30px, 9vw, 40px);
  font-weight: 670;
  letter-spacing: -0.045em;
  line-height: 1.12;
}
.eyebrow {
  font-size: 15px;
  font-weight: 550;
  color: var(--muted);
  letter-spacing: 0;
}
.headline .link {
  padding-bottom: 0;
}
.observation {
  font-size: 16px;
  line-height: 1.5;
  margin: 10px 0 0;
}
.chevron {
  font-size: 19px;
  color: var(--muted);
  font-weight: 400;
}
.muted,
.sub,
.caption,
.empty,
.archive-side,
.legend,
label {
  font-size: 14px;
}
.row,
.entry {
  gap: 8px;
  min-height: 52px;
}
.num {
  font-size: 15px;
}
.entry .grow {
  overflow: hidden;
}
.sub.ellipsis {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row .sub,
.entry .sub {
  font-size: 14px;
}
.date-cell {
  min-width: 39px;
  padding: 5px 3px;
  background: none;
  color: var(--muted);
}
.date-cell b {
  font-size: 16px;
}
.date-cell small {
  font-size: 12px;
}
.daily-events {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  height: 26px;
  line-height: 22px;
  font-size: 14px;
  color: var(--muted);
  padding: 0;
  margin: 4px 0;
  border: 0;
}
.period-nav,
.inline-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.period-nav {
  margin: 4px 0;
}
.period-nav span {
  margin-right: auto;
  font-size: 14px;
  color: var(--muted);
}
.period-step {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--paper);
}
.inline-actions {
  flex-wrap: wrap;
  margin: 0 0 12px;
}
.chips {
  flex-wrap: wrap;
  overflow: visible;
  padding: 0;
  gap: 6px;
  margin: 0 0 14px;
}
.chip,
.pill,
.link {
  font-size: 14px;
  min-height: 44px;
}
.chip {
  background: var(--surface);
}
.chip[aria-pressed="true"],
.pill,
.choice-row[aria-pressed="true"] {
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  color: var(--green);
}
.primary {
  background: var(--accent);
  color: var(--on-accent);
}
.chip[aria-pressed="false"] {
  color: var(--muted);
}
.barline i[data-level="low"] {
  background: #bc740b;
}
.barline i[data-level="over"] {
  background: var(--negative);
}
nav {
  bottom: 0;
  left: 0;
  right: 0;
  transform: none;
  width: 100%;
  justify-content: center;
  gap: 0;
  padding: 4px max(4px, env(safe-area-inset-right)) var(--nav-gutter)
    max(4px, env(safe-area-inset-left));
  border: none;
  border-top: 1px solid var(--edge);
  border-radius: 0;
  box-shadow: none;
  background: var(--surface);
}
nav button {
  max-width: 140px;
  min-width: 0;
  min-height: 50px;
  font-size: 12px;
  line-height: 1.2;
  padding: 5px 1px;
}
nav [aria-current] {
  color: var(--accent);
  background: transparent;
}
nav [aria-current] svg {
  stroke-width: 2.1;
}
.filter-row {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: 8px;
  align-items: end;
  margin-bottom: 12px;
}
.filter-row label {
  min-width: 0;
}
.filter-row .choice,
.filter-row input {
  margin: 5px 0;
  min-height: 45px;
  max-width: 100%;
  font-size: 15px;
}
.filter-row input {
  min-width: 0;
}
.filter-row .choice {
  overflow-wrap: anywhere;
  line-height: 1.2;
  padding: 8px;
}
.operation .grow {
  overflow: hidden;
}
.operation h3 {
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}
#fields .metric span {
  min-width: 0;
}
#fields .metric span:last-child {
  text-align: right;
}
#fields h3:not(:first-child) {
  margin-top: 18px;
}
.menu-list {
  padding: 0 14px;
}
.menu-list .row:last-child {
  border-top: 1px solid var(--edge);
}
.box > .sheet-row {
  border-radius: 0;
}
.skeleton {
  min-height: 220px;
  display: grid;
  align-content: start;
  gap: 15px;
  padding: 18px 0;
}
.skeleton i {
  background: var(--edge);
  height: 18px;
  border-radius: 6px;
  width: 50%;
}
.skeleton i:nth-child(2) {
  height: 40px;
  width: 70%;
}
.skeleton i:nth-child(3) {
  height: 54px;
  width: 100%;
}
@media (prefers-reduced-motion: no-preference) {
  .skeleton i {
    animation: pulse 1.3s ease-in-out infinite alternate;
  }
  @keyframes pulse {
    to {
      opacity: 0.45;
    }
  }
}
@media (max-width: 360px) {
  main {
    padding-inline: 12px;
  }
  .box,
  .hero {
    padding: 12px;
  }
  .list {
    padding: 0 10px;
  }
  .row,
  .entry {
    gap: 6px;
  }
  .num {
    font-size: 14px;
  }
}

nav {
  position: fixed;
  z-index: 3;
  display: flex;
  align-items: center;
  background: var(--surface);
  backdrop-filter: none;
}
nav button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--muted);
  font-weight: 550;
}
nav button[aria-current] {
  color: var(--accent);
}
#sheet {
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--edge);
}
@media (min-width: 541px) {
  #sheet {
    width: min(94vw, 480px);
    max-height: 85dvh;
    padding: 24px;
    border-radius: 20px;
  }
}

body[data-view="budget"] main {
  max-width: 650px;
  padding-inline: max(16px, env(safe-area-inset-left, 0px), var(--tg-content-safe-area-inset-left, 0px))
    max(16px, env(safe-area-inset-right, 0px), var(--tg-content-safe-area-inset-right, 0px));
}
body[data-view="budget"] .page-head { margin: 0 0 var(--sp-4); }
body[data-view="budget"] #content {
  container: budget-view / inline-size;
  font-size: 1rem;
}
.page-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 var(--sp-3);
  min-width: 0;
}
body[data-view="budget"] .page-head h1 {
  font-size: var(--type-title);
  line-height: 1.2;
  font-weight: 680;
}
#budget-month {
  align-items: center;
  gap: var(--sp-2);
  min-height: var(--tap);
  padding: 0 var(--sp-1);
  color: var(--muted);
  font-size: .875rem;
  font-weight: 530;
}
#budget-month:not([hidden]) { display: inline-flex; }
#budget-month::after {
  content: "";
  width: 6px;
  height: 6px;
  margin: -3px 2px 0;
  border: solid currentColor;
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
}
body[data-view="budget"] section { margin: var(--sp-6) 0 0; }
body[data-view="budget"] .budget-hero:first-child { margin-block-start: 0; }
body[data-view="budget"] .section-head {
  align-items: baseline;
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
}
body[data-view="budget"] h2 {
  font-size: 1.1875rem;
  font-weight: 680;
  line-height: 1.3;
}
.budget-hero {
  padding: .375rem .875rem 0;
  background: var(--hero-surface);
  border-radius: 1.25rem;
}
.bank-pair {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(8rem, 100%), 1fr));
}
.account-half {
  display: flex;
  flex-direction: column;
  align-items: start;
  gap: .25rem;
  min-height: var(--tap);
  padding: .625rem .25rem;
  background: transparent;
  color: var(--text);
  text-align: start;
  overflow-wrap: anywhere;
}
.account-half-label {
  display: flex;
  align-items: center;
  gap: .375rem;
  font-size: .8125rem;
  line-height: 1.3;
  color: var(--muted);
}
.account-half-label svg { width: 15px; height: 15px; flex: none; }
.bank-amount {
  margin-top: auto;
  font-size: 1.25rem; line-height: 1.2; letter-spacing: -.035em;
  font-weight: 650; font-variant-numeric: tabular-nums;
}
.budget-risk {
  display: flex; align-items: center; gap: .5rem;
  width: 100%; min-height: var(--tap);
  padding: .375rem .25rem;
  border-top: 1px solid color-mix(in srgb, var(--text) 14%, transparent);
  color: var(--warning); font-size: .8125rem; font-weight: 550; text-align: left;
}
.budget-risk svg { width: 16px; height: 16px; flex: none; }
.budget-risk svg:last-child { margin-left: auto; }
.budget-operations { font-size: .875rem; display: flex; align-items: center; gap: .35rem; color: var(--accent); min-height: var(--tap); }
.budget-available {
  display: grid;
  gap: 4px;
  width: 100%;
  min-width: 0;
  padding: 18px;
  background: var(--surface);
  border-radius: 18px;
  text-align: left;
}
.available-label {
  font-size: 15px;
  font-weight: 580;
  line-height: 1.4;
}
.budget-available > strong {
  font-size: clamp(30px, 8vw, 38px);
  line-height: 1.15;
  letter-spacing: -.045em;
  overflow-wrap: anywhere;
}
.budget-available > small {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}
.budget-available .budget-warning, .budget-warning {
  display: block;
  margin-top: 8px;
  border-radius: 10px;
  padding: 9px 12px;
  background: var(--warning-surface);
  color: var(--warning);
  font-size: 14px;
  line-height: 1.4;
  font-weight: 560;
}
.budget-category-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(8.65rem, 100%), 1fr));
  gap: .625rem;
}
.budget-category {
  --ink: var(--expense-fill);
  --tint: var(--expense-track);
  min-width: 0;
  line-height: 1.3;
  color: var(--text);
  text-align: left;
  overflow-wrap: anywhere;
}
.budget-category[data-tone="grocery"] { --ink: var(--grocery-ink); --tint: var(--grocery-tint); }
.budget-category[data-tone="cafe"] { --ink: var(--cafe-ink); --tint: var(--cafe-tint); }
.budget-category[data-tone="shopping"] { --ink: var(--shopping-ink); --tint: var(--shopping-tint); }
.budget-category[data-tone="home"] { --ink: var(--home-ink); --tint: var(--home-tint); }
.budget-category[data-tone="emergency"] { --ink: var(--emergency-ink); --tint: var(--emergency-tint); }
.budget-category-list .budget-category {
  display: flex; flex-direction: column; align-items: stretch;
  padding: 1rem .875rem;
  border-radius: 1.375rem;
  background: var(--tint);
}
.tile-top { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .25rem; }
.category-icon,.fund-symbol {
  display: grid; place-items: center;
  width: 2rem; height: 2rem;
  border-radius: 50%; color: var(--ink);
  background: color-mix(in srgb, var(--surface) 64%, transparent);
}
.tile-period,.tile-status,.budget-category-usage {
  font-size: .8125rem; font-weight: 510;
  color: color-mix(in srgb, var(--text) 82%, var(--tint));
}
.category-name {
  margin: .625rem 0 .75rem;
  font-size: 1.0625rem; line-height: 1.22; letter-spacing: -.02em; font-weight: 650;
}
.tile-balance {
  display: flex; flex-direction: column-reverse; align-items: start;
  gap: .05rem; margin: auto 0 .7rem;
}
.budget-remainder {
  min-width: 0; max-width: 100%;
  font-size: clamp(1.55rem, 7.4vw, 2.25rem);
  line-height: 1.16; letter-spacing: -.043em; font-weight: 695;
  font-variant-numeric: tabular-nums;
}
.budget-category[data-state="exceeded"] .budget-remainder { color: var(--negative); }
.budget-category-usage { line-height: 1.35; }
.budget-progress {
  --track: color-mix(in srgb, var(--ink, var(--fund-fill)) 24%, var(--tint,var(--fund-track)));
  --fill: var(--ink,var(--fund-fill));
  appearance: none; width: 100%; height: var(--meter-h); display: block; border: none;
  border-radius: 999px; overflow: hidden; color: var(--fill); background: var(--track);
}
.budget-category .budget-progress { margin-top: .5rem; }
.budget-progress::-webkit-progress-bar { background: var(--track); }
.budget-progress::-webkit-progress-value { border-radius: 99px; background: var(--fill); }
.budget-progress::-moz-progress-bar { border-radius: 99px; background: var(--fill); }
.pending-group { margin-top: 1.125rem; }
.pending-group h3 {
  font-size: .875rem; font-weight: 600;
  color: var(--muted); margin: 0 0 .3rem;
}
.pending-category {
  display: flex; align-items: center; width: 100%; min-height: var(--tap);
  padding: .35rem .125rem; gap: .625rem;
}
.pending-category .category-icon { background: var(--tint); width: 1.75rem; height: 1.75rem; }
.pending-category .category-name { margin: 0; font-size: .9375rem; font-weight: 550; }
.pending-category > svg { margin-left: auto; width: 14px; height: 14px; flex: none; color: var(--muted); }
.budget-fund-grid { display: grid; padding: 0 .875rem; background: var(--surface); border-radius: 1.25rem; }
.budget-fund {
  display: grid; align-items: center; gap: .15rem .65rem;
  grid-template-columns: auto minmax(0,1fr) auto;
  padding: .875rem 0; text-align: left; color: var(--text); overflow-wrap: anywhere;
}
.budget-fund + .budget-fund { border-top: 1px solid var(--edge); }
.fund-symbol { grid-column: 1; grid-row: 1 / span 2; background: var(--fund-track); color: var(--fund-fill); }
.fund-name { grid-column: 2; grid-row: 1; font-size: .9375rem; line-height: 1.25; font-weight: 600; }
.fund-amount { grid-column: 3; grid-row: 1; font-size: 1.0625rem; font-weight: 650; letter-spacing: -.025em; }
.budget-fund small { grid-column: 2/-1; color: var(--muted); font-size: .8125rem; line-height: 1.4; }
.budget-fund .budget-progress { grid-column: 2/-1; margin-top: .45rem; }
.budget-footer { margin: var(--sp-4) 0; }
.budget-sync { color: var(--muted); font-size: .8125rem; }
@container budget-view (max-width: 17em) {
  .budget-fund { grid-template-columns: auto minmax(0,1fr); }
  .fund-amount { grid-column: 2; grid-row: 2; }
}
#sheet {
  max-height: min(88dvh,var(--tg-viewport-height,100dvh));
  border: 0;
  padding: 0;
  background: var(--surface);
  color: var(--text);
  overscroll-behavior: contain;
  overflow: auto;
}
#sheet::backdrop {
  background: rgba(14,22,25,.40);
  backdrop-filter: none;
}
#editor {
  padding: 0 max(18px,env(safe-area-inset-right),var(--tg-content-safe-area-inset-right,0px))
    calc(20px + var(--safe)) max(18px,env(safe-area-inset-left),var(--tg-content-safe-area-inset-left,0px));
}
#editor > .section-head {
  position: sticky;
  top: 0;
  z-index: 1;
  gap: 12px;
  padding: 12px 0 8px;
  margin: 0;
  background: var(--surface);
}
#sheet-title { font-size: 21px; line-height: 1.3; }
#close {
  color: var(--muted);
  background: var(--control);
}
#fields .metric {
  display: grid;
  grid-template-columns: minmax(0,1fr) minmax(0,auto);
  align-items: baseline;
  gap: 16px;
  padding: 12px 0;
  line-height: 1.45;
  font-size: 15px;
}
.metric-label { color: var(--muted); }
.metric-value {
  max-width: 46vw;
  text-align: right;
  font-weight: 590;
  overflow-wrap: anywhere;
}
#fields .metric-total,
#fields .metric-lead {
  padding: 15px 0;
}
#fields .metric-total { border-top: 1px solid var(--edge); }
#fields .metric-lead { border-bottom: 1px solid var(--edge); }
.metric-total .metric-label,
.metric-lead .metric-label {
  color: var(--text);
  font-weight: 590;
}
.metric-total .metric-value,
.metric-lead .metric-value {
  font-size: clamp(20px,5vw,25px);
  line-height: 1.2;
  letter-spacing: -.035em;
}
#fields .metric-warning {
  background: var(--warning-surface);
  border-radius: 10px;
  padding: 10px 12px;
}
.metric-warning > * { color: var(--warning); }
#sheet .primary {
  margin-top: 14px;
  min-height: 48px;
  background: var(--accent);
  color: var(--on-accent);
}
#sheet .caption { color: var(--muted); line-height: 1.5; }
.budget-account-group { margin-block: 12px; }
.budget-account-group h3 { color: var(--muted); font-size: 14px; margin-bottom: 4px; }
.budget-account-group .row { min-height: 54px; }
.budget-account-group .num { max-width: 50%; white-space: normal; overflow-wrap: anywhere; text-align: right; }
.account-more { min-height: 44px; color: var(--accent); font-weight: 580; }
#appearance {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 var(--tap);
  min-height: var(--tap);
  padding: 0;
  border-radius: 50%;
  color: var(--muted);
  background: var(--surface);
}
#appearance svg { width: 20px; height: 20px; }
#appearance-dialog {
  color: var(--text);
  background: var(--surface);
  border: 0;
  max-width: min(100%, 420px);
  width: 100%;
  border-radius: 18px;
  padding: 18px;
}
#appearance-dialog .section-head { margin-bottom: 10px; }
.appearance-close {
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  color: var(--muted);
  background: var(--control);
  font-size: 24px;
}
@media (max-width: 540px) {
  #appearance-dialog {
    max-width: none;
    border-radius: 18px 18px 0 0;
    padding-bottom: max(18px, var(--safe));
  }
}
button.budget-warning {
  width: 100%;
  min-height: 44px;
  text-align: left;
}
.operation h3, .operation .operation-meta {
  white-space: normal;
  overflow-wrap: anywhere;
  overflow: visible;
  text-overflow: clip;
}
.operation[data-kind="income"] .num { color: var(--positive); }
.operation[data-kind="transfer"] .num { color: var(--transfer); }
.operation[data-kind="refund"] .num { color: var(--refund); }
