*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --green: #10B981;
  --green-light: #d1fae5;
  --green-dark: #065f46;
  --red: #EF4444;
  --red-light: #fee2e2;
  --accent: #6366F1;
  --bg: #f5f5f5;
  --surface: #ffffff;
  --text: #212121;
  --text-secondary: #616161;
  --border: #e0e0e0;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

[data-theme="dark"] {
  --green: #34D399;
  --green-light: #064e3b;
  --green-dark: #6EE7B7;
  --red: #F87171;
  --red-light: #450a0a;
  --bg: #0F0F0F;
  --surface: #1A1A1A;
  --text: #F3F4F6;
  --text-secondary: #9CA3AF;
  --border: #262626;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 36px rgba(0, 0, 0, 0.6);
}

[data-theme="dark"] .auth-page {
  background: linear-gradient(160deg, #022c22 0%, #1A1A1A 40%, #0F0F0F 100%);
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  line-height: 1.5;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

body.no-nav {
  padding-bottom: 0;
}

input,
select,
button,
textarea {
  font-family: inherit;
  font-size: inherit;
}

/* ---- Auth pages (centered card) ---- */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 1.5rem;
  background: linear-gradient(160deg, #d1fae5 0%, #a7f3d0 40%, #6ee7b7 100%);
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  box-shadow: var(--shadow-lg);
}

.auth-card h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--green-dark);
  margin-bottom: 0.25rem;
}

.auth-card .subtitle {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
}

/* ---- Nav bar ---- */
.nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 0.5rem;
}

.nav-title {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--green-dark);
  white-space: nowrap;
}

.nav-actions {
  display: flex;
  gap: 0.5rem;
}

.desktop-nav {
  display: none;
  gap: 0.25rem;
  align-items: center;
}

.desktop-nav a {
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.desktop-nav a:hover {
  background: var(--bg);
}

.desktop-nav a.active {
  color: var(--accent);
  background: var(--green-light);
}

.nav-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}

.nav-btn:hover {
  background: var(--bg);
}

.nav-btn.primary {
  background: var(--green);
  color: white;
  border-color: var(--green);
}

.nav-btn.primary:hover {
  background: var(--green-dark);
}

.nav-mobile-only {
  display: initial;
}

/* ---- Bottom tab bar ---- */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  padding: 0.25rem 0;
  padding-bottom: max(0.25rem, env(safe-area-inset-bottom, 0));
  z-index: 100;
}

.tab-bar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  padding: 0.4rem 0;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.65rem;
  font-weight: 500;
  transition: color 0.15s;
}

.tab-bar a.active {
  color: var(--accent);
}

.tab-bar a .tab-icon {
  font-size: 1.25rem;
  line-height: 1;
}

/* ---- Layout ---- */
.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 1rem 1rem 5rem;
}

.page.auth-page {
  max-width: 100%;
  padding: 1.5rem;
}

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
  animation: cardIn 300ms cubic-bezier(0.16, 1, 0.3, 1);
}

.card h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.card h3 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

/* ---- Form elements ---- */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.3rem;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s;
  -webkit-appearance: none;
  appearance: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--green-light);
}

.form-group textarea {
  resize: vertical;
  min-height: 60px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.7rem 1.25rem;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: transform 100ms, background 0.15s;
  -webkit-appearance: none;
  appearance: none;
  min-width: 100px;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--green);
  color: white;
}

.btn-primary:hover {
  background: var(--green-dark);
}

.btn-block {
  width: 100%;
}

.btn-outline {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-outline:hover {
  background: var(--bg);
}

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
}

/* ---- Alert / Toast ---- */
.toast {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--red);
  color: white;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  z-index: 200;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  max-width: 90vw;
  text-align: center;
}

.toast.show {
  opacity: 1;
  pointer-events: auto;
}

.toast.success {
  background: var(--green);
}

/* ---- Chart containers ---- */
.chart-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 1rem;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}

.chart-tab {
  flex: 1;
  padding: 0.5rem;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--surface);
  color: var(--text-secondary);
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.chart-tab.active {
  background: var(--accent);
  color: white;
}

/* ---- Type toggle (Expense / Income) ---- */
.type-toggle {
  display: flex;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}

.type-btn {
  flex: 1;
  padding: 0.55rem;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--surface);
  color: var(--text-secondary);
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.type-btn.active {
  background: var(--accent);
  color: white;
}

/* ---- Savings overview ---- */
.net-flow {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

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

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

/* ---- Donut legend ---- */
.donut-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.75rem;
}

.donut-legend-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.7rem;
  cursor: pointer;
  padding: 0.2rem 0.45rem;
  border-radius: 99px;
  transition: background 0.15s;
  border: 1px solid transparent;
}

.donut-legend-item:hover {
  background: var(--bg);
}

.donut-legend-item.dimmed {
  opacity: 0.35;
}

.donut-legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* ---- Clear filters ---- */
.clear-filters {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.7rem;
  padding: 0.25rem 0.6rem;
  border-radius: 99px;
  border: 1px dashed var(--red);
  background: none;
  color: var(--red);
  cursor: pointer;
  margin-bottom: 0.5rem;
  transition: background 0.15s;
}

.clear-filters:hover {
  background: var(--red-light);
}

/* ---- Overview segmented control ---- */
.overview-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 1rem;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}

.overview-tab {
  flex: 1;
  padding: 0.45rem;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--surface);
  color: var(--text-secondary);
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.overview-tab.active {
  background: var(--accent);
  color: white;
}

.chart-total {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.25rem;
}

.chart-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.chart-wrap {
  position: relative;
  width: 100%;
  margin-bottom: 0.5rem;
}

.chart-wrap canvas {
  width: 100% !important;
  max-height: 300px;
}

/* ---- Balance check result ---- */
.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.result-grid .result-item.highlight {
  grid-column: 1 / -1;
}

.result-item {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  text-align: center;
}

.result-item .result-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.result-item .result-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.result-item.highlight {
  background: var(--green-light);
  border: 2px solid var(--green);
}

.result-item.highlight .result-value {
  color: var(--green-dark);
}

.result-summary {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
  padding: 0.75rem;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

/* ---- Spending row ---- */
.spend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.spend-row:last-child {
  border-bottom: none;
}

.spend-row .spend-amount,
.tx-row .spend-amount {
  font-weight: 600;
  color: var(--red);
  white-space: nowrap;
}

.spend-row .spend-amount.income,
.tx-row .spend-amount.income {
  color: var(--green);
}

/* ---- Transaction color toggle ---- */
[data-tx-colors="off"] .spend-row .spend-amount,
[data-tx-colors="off"] .spend-row .spend-amount.income,
[data-tx-colors="off"] .tx-row .spend-amount,
[data-tx-colors="off"] .tx-row .spend-amount.income {
  color: var(--text);
}

.spend-row .spend-meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.spend-category {
  display: inline-block;
  background: var(--bg);
  padding: 0.15rem 0.5rem 0.15rem 0.65rem;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

/* ---- Empty state ---- */
.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-secondary);
}

.empty-state .empty-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  opacity: 0.5;
}

.empty-state p {
  font-size: 0.875rem;
}

/* ---- Check-in history ---- */
.history-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.history-row:last-child {
  border-bottom: none;
}

.history-date {
  color: var(--text-secondary);
  font-size: 0.75rem;
}

/* ---- Auth toggle link ---- */
.auth-toggle {
  text-align: center;
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.auth-toggle a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

/* ---- Misc ---- */
.text-center {
  text-align: center;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.mt-1 {
  margin-top: 0.5rem;
}

.mt-2 {
  margin-top: 1rem;
}

.mb-1 {
  margin-bottom: 0.5rem;
}

.mb-2 {
  margin-bottom: 1rem;
}

.currency {
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
}

.loading {
  opacity: 0.6;
  pointer-events: none;
}

/* ---- Quick-add FAB ---- */
.fab {
  position: fixed;
  bottom: 5rem;
  right: max(1.25rem, calc((100% - 640px) / 2 + 1.25rem));
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 1.6rem;
  border: none;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
  transition: transform 0.1s, background 0.15s;
}

.fab:active {
  transform: scale(0.92);
}

.fab:hover {
  background: var(--green);
}

@media (min-width: 640px) {
  .fab {
    bottom: 1.5rem;
  }
}

/* ---- Danger zone in settings ---- */
.danger-zone {
  border: 1px solid var(--red);
  border-radius: var(--radius);
  padding: 1rem;
  margin-top: 1rem;
}

.danger-zone h3 {
  color: var(--red);
}

/* ---- Responsive ---- */
@media (min-width: 640px) {
  .tab-bar {
    display: none;
  }

  .page {
    padding-bottom: 2rem;
  }

  body {
    padding-bottom: 0;
  }

  .nav {
    padding: 0.75rem 2rem;
  }

  .desktop-nav {
    display: flex;
    gap: 0.25rem;
  }

  .nav-mobile-only {
    display: none !important;
  }

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

  .result-grid .result-item.highlight {
    grid-column: auto;
  }
}

  .cat-chips-wrap {
    display: flex;
    align-items: center;
    gap: 0.25rem;
  }

  .cat-chips-wrap::after {
    display: none;
  }

  .cat-scroll-arrow {
    display: flex;
  }

/* ---- Category chips ---- */
.cat-chips-wrap { position: relative; }
.cat-chips-wrap::after {
  content: "";
  position: absolute; top: 0; right: 0; bottom: 0.5rem; width: 24px;
  background: linear-gradient(to right, transparent, var(--surface));
  pointer-events: none;
}

.cat-chips {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 0.5rem;
  padding: 0.25rem 0 0.5rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.cat-chips::-webkit-scrollbar {
  display: none;
}

.cat-chip {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.5rem 0.75rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  min-width: 60px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  user-select: none;
}

.cat-chip.selected {
  border-color: var(--green);
  background: var(--green-light);
  color: var(--green-dark);
}

.cat-chip .cat-emoji {
  font-size: 1.3rem;
  line-height: 1;
}

.cat-chip-add {
  border-style: dashed;
  color: var(--text-secondary);
}

/* ---- Category scroll arrows (desktop) ---- */
.cat-scroll-arrow {
  display: none;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 0.65rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  padding: 0;
  line-height: 1;
}

.cat-scroll-arrow:active {
  background: var(--bg);
}

.cat-scroll-arrow.hidden {
  visibility: hidden;
  pointer-events: none;
}

/* ---- Collapsible section ---- */
.collapse-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.5rem 0;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
}

.collapse-toggle .arrow {
  transition: transform 0.2s;
  font-size: 0.7rem;
}

.collapse-toggle.open .arrow {
  transform: rotate(90deg);
}

.collapse-body {
  display: none;
  padding-bottom: 0.5rem;
}

.collapse-body.open {
  display: block;
}

/* ---- Swipe row (touch devices) ---- */
.tx-row {
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
}

.tx-row:last-child {
  border-bottom: none;
}

.tx-row .swipe-bg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

.tx-row .swipe-bg span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 100%;
  font-size: 0.7rem;
  font-weight: 700;
  color: white;
}

.tx-row .swipe-bg .bg-edit {
  background: var(--green);
  margin-left: auto;
}

.tx-row .swipe-bg .bg-delete {
  background: var(--red);
}

.tx-row .tx-content {
  position: relative;
  z-index: 1;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.75rem;
  transition: transform 0.2s ease;
  touch-action: pan-y;
  min-height: 3.2rem;
}

.tx-row .tx-content:active {
  transition: none;
}

/* ---- Row actions (hover on desktop) ---- */
@media (hover: hover) and (pointer: fine) {
  .tx-row .tx-actions {
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.15s;
  }

  .tx-row:hover .tx-actions {
    opacity: 1;
  }
}

.tx-actions {
  display: flex;
  gap: 0.25rem;
}

.tx-action-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.5rem;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s;
  color: var(--text);
}

.tx-action-btn:hover {
  background: var(--bg);
}

.tx-action-btn.danger:hover {
  background: var(--red-light);
  border-color: var(--red);
}

/* ---- Search & Filter ---- */
.search-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.search-bar input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
}

.search-bar input:focus {
  outline: none;
  border-color: var(--accent);
}

.filter-chips {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.filter-chip {
  padding: 0.3rem 0.65rem;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.filter-chip.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* ---- Confirm dialog ---- */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 1rem;
}

.dialog-box {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 320px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}

.dialog-box p {
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.dialog-box .dialog-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

/* ---- Settings toggle ---- */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
}

.toggle-switch {
  position: relative;
  width: 48px;
  height: 26px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 13px;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--accent);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(22px);
}

/* ---- Custom category creator ---- */
.cat-create-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.cat-create-row input {
  flex: 1;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  background: var(--surface);
  color: var(--text);
}

.cat-create-row input:focus {
  outline: none;
  border-color: var(--green);
}

.cat-create-row .emoji-pick {
  width: 38px;
  padding: 0.4rem;
  font-size: 1.1rem;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
}

.cat-create-row input.cat-emoji {
  width: 48px;
  padding: 0.5rem 0.3rem;
  font-size: 1.1rem;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  flex-shrink: 0;
}

.cat-create-row input.cat-emoji:focus {
  outline: none;
  border-color: var(--green);
}

/* ---- Recurring form ---- */
.recurring-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0;
}

.recurring-toggle-row span {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.recurring-options {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.freq-chips {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

.freq-chip {
  flex: 1;
  padding: 0.45rem;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.freq-chip.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* ---- Budget Pace ---- */
.budget-progress {
  width: 100%;
  height: 12px;
  background: var(--bg);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 0.75rem;
}

.budget-progress-fill {
  height: 100%;
  border-radius: 6px;
  background: var(--green);
  transition: width 0.3s ease;
}

.budget-progress-fill.warning {
  background: #ff9800;
}

.budget-progress-fill.over {
  background: var(--red);
}

.budget-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.5rem;
}

.budget-stat {
  text-align: center;
}

.budget-stat .stat-value {
  font-size: 1.1rem;
  font-weight: 700;
}

.budget-stat .stat-label {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stat-positive { color: var(--green); }
.stat-negative { color: var(--red); }
.stat-neutral  { color: var(--text); }

/* ---- Projected Month End ---- */
.projected-total {
  font-size: 1.5rem;
  font-weight: 700;
}

.projected-total.positive { color: var(--green); }
.projected-total.negative { color: var(--red); }

.projected-meta {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

/* ---- Recurring management row ---- */
.rec-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
}

.rec-row:last-child {
  border-bottom: none;
}

.rec-row.rec-paused-row {
  opacity: 0.45;
}

.rec-row-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  flex: 1;
}

.rec-emoji {
  font-size: 1.3rem;
  flex-shrink: 0;
}

.rec-row-cat {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.rec-paused {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 700;
  color: #f59e0b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-left: 0.35rem;
  padding: 0.1rem 0.3rem;
  border: 1px solid #f59e0b;
  border-radius: 4px;
}

.rec-row-meta {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-top: 0.15rem;
}

.rec-row-covers {
  font-size: 0.65rem;
  color: var(--text-secondary);
  opacity: 0.75;
  margin-top: 0.1rem;
}

.rec-freq-badge {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
}

.rec-row-right {
  text-align: right;
  flex-shrink: 0;
}

.rec-actions {
  display: flex;
  gap: 0.2rem;
  margin-top: 0.3rem;
  justify-content: flex-end;
}

.whatsnew-entry {
  margin-bottom: 1.25rem;
  padding-left: 0.75rem;
  border-left: 2px solid var(--border);
}
.whatsnew-entry:last-child { margin-bottom: 0; }

.whatsnew-date {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent, #7c9cff);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.4rem;
}

.whatsnew-list {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.whatsnew-list li { margin-bottom: 0.3rem; }

.copy-hint {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.5rem;
  margin-bottom: 0;
}
