:root {
  --bg: #f4efe2;
  --surface: rgba(255, 252, 245, 0.86);
  --surface-strong: #fffdf7;
  --ink: #1e2a20;
  --muted: #607062;
  --line: rgba(18, 53, 36, 0.12);
  --brand: #123524;
  --brand-soft: #d9e8d6;
  --income: #1d7a46;
  --expense: #b5452d;
  --fixed: #c86a1f;
  --variable: #a84535;
  --shadow: 0 20px 50px rgba(18, 53, 36, 0.08);
  --radius: 24px;
  --radius-sm: 16px;
}

* {
  box-sizing: border-box;
}

html {
  background:
    radial-gradient(circle at top, rgba(217, 232, 214, 0.9), transparent 32%),
    linear-gradient(180deg, #fbf8f0 0%, var(--bg) 100%);
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Aptos", "Segoe UI Variable", "Segoe UI", sans-serif;
  min-height: 100vh;
  background: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(100%, 560px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 16px calc(92px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0 18px;
  backdrop-filter: blur(18px);
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

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

.topbar__logout {
  margin: 0;
}

.topbar__brand h1,
.hero-card h2,
.panel h2,
.panel h3 {
  margin: 0;
}

.topbar__logo {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.page-content {
  display: grid;
  gap: 16px;
}

.pwa-banner {
  margin: 0 0 16px;
  padding: 12px 14px;
  color: var(--brand);
  background: rgba(217, 232, 214, 0.68);
  border: 1px solid rgba(18, 53, 36, 0.12);
  border-radius: 16px;
  line-height: 1.45;
}

.hero-card,
.panel,
.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.hero-card {
  display: grid;
  gap: 18px;
  padding: 24px;
}

.hero-copy {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.hero-balance {
  padding: 18px;
  border-radius: 20px;
  color: white;
  background: linear-gradient(135deg, #123524, #1d7a46);
}

.hero-balance.negative {
  background: linear-gradient(135deg, #742d1f, #b5452d);
}

.hero-balance span {
  display: block;
  font-size: 0.85rem;
  opacity: 0.88;
}

.hero-balance strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.8rem, 4vw, 2.4rem);
}

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

.stat-card {
  padding: 18px;
}

.stat-card span,
.panel__header span,
.transaction-item p {
  color: var(--muted);
}

.stat-card strong {
  display: block;
  margin-top: 10px;
  font-size: 1.15rem;
}

.stat-card.income strong,
.value.positive {
  color: var(--income);
}

.stat-card.expense strong,
.value.negative {
  color: var(--expense);
}

.panel {
  padding: 20px;
}

.panel--tight {
  padding: 20px 20px 24px;
}

.login-card {
  width: min(100%, 460px);
  margin: 6vh auto 0;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.login-card__intro {
  margin-bottom: 20px;
}

.login-card__intro h2 {
  margin: 0 0 10px;
}

.login-card__intro p:last-child {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

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

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

.panel__heading {
  min-width: 0;
}

.month-switcher {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
}

.month-switcher__label {
  text-align: center;
}

.month-switcher__label strong {
  text-transform: capitalize;
}

.distribution {
  display: grid;
  gap: 18px;
}

.distribution-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.distribution-tab,
.distribution-card {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.42);
  cursor: pointer;
}

.distribution-tab {
  padding: 10px 14px;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 700;
}

.distribution-tab.is-active {
  color: white;
  background: linear-gradient(135deg, var(--brand), #1d7a46);
  border-color: transparent;
}

.distribution-view {
  display: none;
}

.distribution-view.is-active {
  display: block;
}

.distribution-card {
  width: 100%;
  padding: 14px;
  border-radius: 18px;
  text-align: left;
}

.distribution--categories {
  gap: 14px;
}

.distribution__row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.meter {
  height: 12px;
  background: rgba(18, 53, 36, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.meter__fill {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.meter__fill--fixed {
  background: linear-gradient(90deg, #f0a24a, var(--fixed));
}

.meter__fill--variable {
  background: linear-gradient(90deg, #df8f77, var(--variable));
}

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

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

.projection-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.48);
  border: 1px solid var(--line);
  border-radius: 18px;
}

.projection-metrics {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.projection-metric {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 12px;
}

.projection-metric span,
.projection-balance span {
  color: var(--muted);
  font-size: 0.82rem;
}

.projection-metric strong,
.projection-balance strong {
  font-size: 0.95rem;
}

.projection-metric--income {
  background: rgba(29, 122, 70, 0.08);
}

.projection-metric--income strong {
  color: var(--income);
}

.projection-metric--expense {
  background: rgba(181, 69, 45, 0.08);
}

.projection-metric--expense strong {
  color: var(--expense);
}

.projection-balance {
  display: grid;
  justify-items: end;
  gap: 6px;
  min-width: 110px;
}

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

.transaction-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.transaction-item strong {
  display: block;
  margin-bottom: 4px;
}

.value {
  font-weight: 700;
  white-space: nowrap;
}

.empty-state {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.form-grid {
  display: grid;
  gap: 14px;
}

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

.field label {
  font-size: 0.92rem;
  font-weight: 600;
}

.field input {
  width: 100%;
  padding: 14px 16px;
  color: var(--ink);
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 16px;
  outline: none;
}

.field input:focus {
  border-color: rgba(18, 53, 36, 0.38);
  box-shadow: 0 0 0 4px rgba(18, 53, 36, 0.08);
}

.checkbox-field {
  display: flex;
  align-items: start;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.checkbox-field input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
}

.checkbox-field span {
  color: var(--ink);
  line-height: 1.45;
}

.category-suggestions {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}

.category-suggestions__label {
  font-size: 0.82rem;
  font-weight: 700;
}

.category-suggestions--income .category-suggestions__label {
  color: var(--income);
}

.category-suggestions--expense .category-suggestions__label {
  color: var(--expense);
}

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

.category-chip {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  font-size: 0.85rem;
  font-weight: 600;
}

.category-chip--income {
  color: var(--income);
  background: rgba(29, 122, 70, 0.1);
  border-color: rgba(29, 122, 70, 0.16);
}

.category-chip--expense {
  color: var(--expense);
  background: rgba(181, 69, 45, 0.1);
  border-color: rgba(181, 69, 45, 0.16);
}

.category-badge {
  display: inline-flex;
  margin-top: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.category-badge--income {
  color: var(--income);
  background: rgba(29, 122, 70, 0.1);
}

.category-badge--expense {
  color: var(--expense);
  background: rgba(181, 69, 45, 0.1);
}

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

.primary-button,
.ghost-button,
.install-button {
  appearance: none;
  border: 0;
  cursor: pointer;
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.primary-button,
.install-button {
  padding: 14px 18px;
  color: white;
  background: linear-gradient(135deg, var(--brand), #1d7a46);
  border-radius: 16px;
  font-weight: 700;
}

.primary-button--link {
  display: inline-flex;
  justify-content: center;
}

.ghost-button {
  padding: 10px 14px;
  color: var(--expense);
  background: rgba(181, 69, 45, 0.08);
  border-radius: 12px;
  font-weight: 600;
}

.ghost-button--edit {
  color: #155eef;
  background: rgba(21, 94, 239, 0.12);
}

.ghost-button--delete {
  color: #b42318;
  background: rgba(180, 35, 24, 0.12);
}

.ghost-button--logout {
  color: var(--brand);
  background: rgba(18, 53, 36, 0.1);
}

.form-error {
  margin: 0;
  color: #b42318;
  font-weight: 600;
}

.ghost-button--link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.primary-button:hover,
.ghost-button:hover,
.install-button:hover {
  transform: translateY(-1px);
}

.form-actions {
  display: grid;
  gap: 10px;
}

.transaction-actions {
  display: grid;
  justify-items: end;
  gap: 10px;
}

.transaction-actions__buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.transaction-actions__buttons form {
  margin: 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 700;
  white-space: nowrap;
}

.pill--income {
  color: var(--income);
  background: rgba(29, 122, 70, 0.12);
}

.pill--fixed {
  color: var(--fixed);
  background: rgba(200, 106, 31, 0.12);
}

.pill--variable {
  color: var(--variable);
  background: rgba(168, 69, 53, 0.12);
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(100%, 560px);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: rgba(255, 249, 240, 0.92);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.bottom-nav__item {
  padding: 12px 6px;
  color: var(--muted);
  text-align: center;
  font-size: 0.82rem;
  border-radius: 14px;
}

.bottom-nav__item.is-active {
  color: white;
  background: linear-gradient(135deg, var(--brand), #1d7a46);
}

.offline-panel {
  padding-top: 28px;
}

@media (max-width: 520px) {
  .field--split,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .month-switcher {
    grid-template-columns: 1fr;
  }

  .panel__header,
  .transaction-item {
    align-items: start;
  }

  .transaction-item,
  .projection-item {
    flex-direction: column;
  }

  .transaction-actions {
    width: 100%;
    justify-items: start;
  }

  .transaction-actions__buttons {
    flex-wrap: wrap;
  }
}
