:root {
  color-scheme: light;
  --ink: #14211d;
  --muted: #66756f;
  --paper: #f7f5ef;
  --panel: #ffffff;
  --line: #dcd8cd;
  --brand: #2f6f5e;
  --brand-strong: #18493d;
  --income: #1f8a58;
  --expense: #bd4b45;
  --warning: #c8811f;
  --shadow: 0 16px 40px rgba(22, 32, 27, 0.11);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(47, 111, 94, 0.18), rgba(247, 245, 239, 0) 330px),
    var(--paper);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 16px max(78px, env(safe-area-inset-bottom));
}

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

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

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--brand-strong);
  font-weight: 800;
}

.brand-title {
  margin: 0;
  font-size: 1.06rem;
  line-height: 1.15;
}

.brand-subtitle,
.eyebrow,
.muted,
.empty {
  color: var(--muted);
}

.brand-subtitle,
.eyebrow {
  margin: 0;
  font-size: 0.78rem;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

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

.month-switcher select {
  max-width: 180px;
}

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

.hero-band {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
  gap: 14px;
  align-items: stretch;
  margin-bottom: 14px;
}

.summary-panel,
.panel,
.onboarding {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.summary-panel {
  padding: 16px;
}

.summary-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.55rem, 4.5vw, 2.7rem);
  line-height: 1.02;
}

h2 {
  font-size: 1.2rem;
}

h3 {
  font-size: 1rem;
}

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

.balance-value {
  font-size: clamp(2.3rem, 13vw, 5.4rem);
  line-height: 0.92;
  font-weight: 850;
}

.balance-value.negative {
  color: var(--expense);
}

.quick-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

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

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

.budget-card {
  display: grid;
  align-content: start;
  gap: 9px;
  min-height: 150px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf6;
}

.budget-card span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.budget-card strong {
  font-size: clamp(1.7rem, 5vw, 2.7rem);
  line-height: 0.95;
}

.budget-card strong.negative {
  color: var(--expense);
}

.budget-card p {
  margin: 0;
  color: var(--muted);
}

.price-card {
  padding: 14px;
  border: 1px solid rgba(47, 111, 94, 0.18);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(47, 111, 94, 0.08), rgba(255, 255, 255, 0.9));
}

.price-card span,
.price-card p {
  display: block;
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.price-card strong {
  display: block;
  margin: 8px 0;
  font-size: clamp(1.7rem, 6vw, 2.6rem);
  line-height: 1;
}

.distribution-layout {
  display: grid;
  grid-template-columns: minmax(150px, 0.55fr) minmax(0, 1fr);
  gap: 16px;
  align-items: center;
}

.distribution-chart {
  display: grid;
  place-items: center;
  width: min(190px, 100%);
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, #fff 0 48%, transparent 49%),
    conic-gradient(var(--distribution));
}

.distribution-chart span {
  max-width: 92px;
  text-align: center;
  font-weight: 900;
}

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

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

.distribution-row strong,
.distribution-row span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.distribution-row span:last-child {
  color: var(--muted);
  font-weight: 800;
}

.distribution-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--dot-color);
}

.alert-list {
  display: grid;
  gap: 6px;
  margin: 12px 0 0;
}

.alert-list p {
  margin: 0;
  padding: 9px 10px;
  border: 1px solid rgba(200, 129, 31, 0.35);
  border-radius: 8px;
  color: #6c420b;
  background: #fff7e6;
  font-weight: 750;
}

.account-grid {
  display: grid;
  gap: 8px;
}

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

.account-card div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.account-card span {
  color: var(--muted);
}

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

.mini-section {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

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

.compact-tile {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.compact-tile strong,
.compact-tile p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 12px;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  text-align: left;
}

.history-card.active {
  border-color: var(--brand-strong);
  box-shadow: inset 4px 0 0 var(--brand-strong);
}

.history-card span,
.history-card strong {
  font-weight: 850;
}

.history-card small {
  color: var(--muted);
}

.stat {
  min-height: 92px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf6;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 1.35rem;
}

.panel {
  padding: 12px;
}

.panel-header,
.section-header,
.row-actions,
.nav-tabs,
.actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-header,
.section-header {
  justify-content: space-between;
  margin-bottom: 12px;
}

.nav-tabs {
  position: fixed;
  z-index: 20;
  right: 14px;
  bottom: max(14px, env(safe-area-inset-bottom));
  left: 14px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  width: min(560px, calc(100% - 28px));
  margin: 0 auto;
  padding: 7px;
  border: 1px solid rgba(220, 216, 205, 0.88);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 12px 30px rgba(20, 33, 29, 0.18);
  backdrop-filter: blur(14px);
}

.tab-button,
.secondary-button,
.primary-button,
.icon-button,
.danger-button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 750;
}

.tab-button {
  min-width: 0;
  padding: 0 8px;
  overflow: hidden;
  color: var(--muted);
  background: transparent;
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab-button.active {
  color: #fff;
  background: var(--brand-strong);
}

.premium-badge,
.premium-top-button {
  white-space: nowrap;
}

.premium-badge {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid rgba(47, 111, 94, 0.18);
  border-radius: 8px;
  color: var(--income);
  background: rgba(47, 111, 94, 0.08);
  font-weight: 800;
}

.primary-button {
  color: #fff;
  background: var(--brand-strong);
}

.secondary-button {
  color: var(--brand-strong);
  border-color: var(--line);
  background: #fff;
}

.danger-button {
  color: var(--expense);
  border-color: rgba(189, 75, 69, 0.22);
  background: #fff;
}

.danger-zone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(189, 75, 69, 0.22);
  border-radius: 8px;
  background: rgba(189, 75, 69, 0.06);
}

.danger-zone p {
  margin: 4px 0 0;
}

.icon-button {
  width: 42px;
  padding: 0;
  color: var(--ink);
  border-color: var(--line);
  background: #fff;
  font-size: 1.25rem;
}

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

.settings-grid {
  align-items: start;
}

.flow {
  display: grid;
  gap: 14px;
}

.progress-track {
  overflow: hidden;
  height: 12px;
  border-radius: 999px;
  background: #e8e4d9;
}

.progress-fill {
  width: var(--progress, 0%);
  height: 100%;
  border-radius: inherit;
  background: var(--brand);
}

.progress-fill.warning {
  background: var(--warning);
}

.progress-fill.danger {
  background: var(--expense);
}

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

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

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

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

.small-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 0.78rem;
}

.amount.income {
  color: var(--income);
}

.amount.expense {
  color: var(--expense);
}

.pill {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border-radius: 999px;
  padding: 0 10px;
  color: var(--brand-strong);
  background: #e4f0eb;
  font-size: 0.78rem;
  font-weight: 750;
}

.date-pill {
  min-width: 46px;
  text-align: center;
  color: var(--muted);
  font-weight: 800;
}

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

.setup-row {
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

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

.formula div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.formula-total {
  color: var(--brand-strong);
  font-size: 1.08rem;
}

.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.form-message {
  min-height: 22px;
  margin: 0;
  color: var(--expense);
  font-weight: 750;
}

.success-text {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid rgba(47, 111, 94, 0.18);
  border-radius: 8px;
  color: var(--income);
  background: rgba(47, 111, 94, 0.08);
  font-weight: 750;
}

.premium-subscription-panel {
  min-height: 100%;
}

.premium-validity {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid rgba(47, 111, 94, 0.2);
  border-radius: 8px;
  background: rgba(47, 111, 94, 0.08);
}

.premium-validity span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.premium-validity strong {
  color: var(--brand-strong);
  font-size: 1.35rem;
  line-height: 1.1;
}

.form-hint {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid rgba(47, 111, 94, 0.18);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(47, 111, 94, 0.07);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfaf6;
}

.segmented button {
  position: relative;
  z-index: 1;
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-weight: 850;
  pointer-events: auto;
}

.segmented button.active {
  color: #fff;
  background: var(--brand-strong);
}

.premium-dashboard {
  grid-column: 1 / -1;
}

.premium-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.premium-kpi,
.trend-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
}

.premium-kpi {
  display: grid;
  gap: 6px;
  padding: 12px;
}

.premium-kpi span,
.trend-header span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.premium-kpi strong {
  color: var(--ink);
  font-size: 1.35rem;
}

.premium-kpi small {
  font-weight: 800;
}

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

.trend-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  min-width: 0;
}

.trend-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.trend-header strong {
  white-space: nowrap;
}

.trend-bars {
  display: grid;
  grid-template-columns: repeat(12, minmax(4px, 1fr));
  align-items: end;
  gap: 4px;
  height: 82px;
  padding-top: 8px;
  border-bottom: 1px solid var(--line);
}

.trend-bars span {
  height: var(--bar-height);
  min-height: 4px;
  border-radius: 999px 999px 0 0;
  background: var(--brand);
}

.trend-card.income .trend-bars span {
  background: var(--income);
}

.trend-card.expense .trend-bars span {
  background: var(--expense);
}

.trend-months {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
}

.premium-comparison strong {
  text-align: right;
}
.premium-analysis-toggle {
  margin-bottom: 12px;
}

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

.stepper span {
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fff;
  font-size: 0.82rem;
  font-weight: 800;
  text-align: center;
}

.stepper span.active {
  color: #fff;
  border-color: var(--brand-strong);
  background: var(--brand-strong);
}

.stepper span.done {
  color: var(--brand-strong);
  background: #e4f0eb;
}

.setup-step {
  display: none;
}

.setup-step.active {
  display: grid;
  gap: 14px;
}

.wizard-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

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

.onboarding {
  width: min(760px, 100%);
  margin: 7vh auto 0;
  padding: 22px;
}

.onboarding h1 {
  margin: 10px 0 12px;
  font-size: clamp(2.2rem, 10vw, 4.8rem);
}

.modal-backdrop {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: grid;
  align-items: end;
  padding: 14px;
  background: rgba(20, 33, 29, 0.45);
}

.modal {
  width: min(680px, 100%);
  max-height: min(760px, calc(100vh - 28px));
  margin: 0 auto;
  overflow: auto;
  border-radius: 12px;
  padding: 18px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.26);
}

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

.modal-header .icon-button {
  position: relative;
  z-index: 3;
  flex: 0 0 auto;
}

.empty {
  margin: 0;
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfaf6;
}

.install-tip {
  display: none;
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid #bad7cb;
  border-radius: 8px;
  color: var(--brand-strong);
  background: #edf7f2;
}

.ios .install-tip {
  display: block;
}

@media (max-width: 840px) {
  .hero-band,
  .grid-two,
  .settings-grid,
  .budget-cards,
  .quick-stats {
    grid-template-columns: 1fr;
  }

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

  .summary-header {
    flex-direction: column;
  }

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

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

  .distribution-layout {
    grid-template-columns: 1fr;
  }

  .distribution-chart {
    justify-self: center;
  }

  .premium-kpis,
  .trend-grid {
    grid-template-columns: 1fr;
  }

  .trend-bars {
    height: 72px;
  }

  .premium-comparison div {
    align-items: flex-start;
    flex-direction: column;
  }

  .premium-comparison strong {
    text-align: left;
  }
}
