/* ═══════════════════════════════════════════════
   FinBot — Dark Finance UI
   ═══════════════════════════════════════════════ */

:root {
  /* Base colors — dark theme */
  --bg: #0a0a0c;
  --bg-card: #1c1c1e;
  --bg-card-elevated: #2c2c2e;
  --bg-card-hover: #3a3a3c;
  --text-primary: #ffffff;
  --text-secondary: #8e8e93;
  --text-tertiary: #636366;
  --border: rgba(255, 255, 255, 0.08);

  /* Accent colors */
  --color-income: #30d158;
  --color-expense: #ff453a;
  --color-planned: #ff9f0a;
  --color-accent: #5e5ce6;
  --color-paid: #30d158;

  /* Telegram theme (fallbacks) */
  --tg-btn: var(--tg-theme-button-color, #5e5ce6);
  --tg-btn-text: var(--tg-theme-button-text-color, #fff);

  /* Spacing */
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --nav-height: 64px;
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --radius-xl: 24px;
}

/* ── Light theme ── */
[data-theme="light"] {
  --bg: #f2f2f7;
  --bg-card: #ffffff;
  --bg-card-elevated: #e5e5ea;
  --bg-card-hover: #d1d1d6;
  --text-primary: #000000;
  --text-secondary: #6e6e73;
  --text-tertiary: #aeaeb2;
  --border: rgba(0, 0, 0, 0.08);
  --color-income: #28a745;
  --color-expense: #dc3545;
  --color-planned: #e68a00;
  --color-accent: #5e5ce6;
  --color-paid: #28a745;
}

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

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.47;
  color: var(--text-primary);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

button {
  font: inherit;
  border: none;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* ── Loading ── */
.loading-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
  transition: background 0.3s;
}

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.hidden {
  display: none !important;
}

/* ── Main Content ── */
.main-content {
  padding: 16px 16px 0;
  max-width: 480px;
  margin: 0 auto;
  animation: fadeIn 0.35s ease-out;
}

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

/* ══════════════════════════════
   Header / Greeting
   ══════════════════════════════ */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0 20px;
}

.header-text {
  display: flex;
  flex-direction: column;
}

.header-greeting {
  font-size: 16px;
  color: var(--text-secondary);
  font-weight: 400;
}

.header-name {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.header-settings-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-card);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, color 0.2s;
}

.header-settings-btn:active {
  background: var(--bg-card-elevated);
  color: var(--text-primary);
}

/* ══════════════════════════════
   Balance Card
   ══════════════════════════════ */
.balance-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 24px 20px 20px;
  margin-bottom: 24px;
}

.balance-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.balance-amount {
  font-size: 42px;
  font-weight: 700;
  letter-spacing: -1.5px;
  line-height: 1.1;
  margin-bottom: 4px;
  transition: color 0.3s;
}

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

.balance-updated {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 20px;
}

.balance-row {
  display: flex;
  align-items: flex-start;
  gap: 24px;
}

.balance-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex: 1;
}

.balance-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}

.balance-dot.income {
  background: var(--color-income);
}

.balance-dot.expense {
  background: var(--color-expense);
}

.balance-item-content {
  display: flex;
  flex-direction: column;
}

.balance-item-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.balance-item-value {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.balance-item.income .balance-item-value {
  color: var(--color-income);
}

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

.balance-item-period {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

/* ══════════════════════════════
   Sections
   ══════════════════════════════ */
.section {
  margin-bottom: 24px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
  margin-bottom: 12px;
}

.section-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.section-link {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 4px 8px;
}

.section-link:active {
  opacity: 0.6;
}

.badge {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-planned);
  background: rgba(255, 159, 10, 0.15);
  padding: 4px 12px;
  border-radius: 20px;
  cursor: pointer;
}

.badge:empty {
  display: none;
}

/* ══════════════════════════════
   Planned Payments — Horizontal Cards
   ══════════════════════════════ */
.planned-scroll {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 0 4px 8px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.planned-scroll::-webkit-scrollbar {
  display: none;
}

.planned-card {
  flex: 0 0 auto;
  width: 150px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 14px;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  transition: transform 0.15s;
}

.planned-card:active {
  transform: scale(0.97);
}

.planned-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.planned-card-type {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.planned-card-day {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
}

.planned-card-day.today {
  background: var(--color-accent);
  color: #fff;
}

.planned-card-day.overdue {
  background: rgba(255, 69, 58, 0.2);
  color: var(--color-expense);
}

.planned-card-title {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.planned-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
}

.planned-card-amount {
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
}

.planned-card-check {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  transition: all 0.25s;
  cursor: pointer;
  flex-shrink: 0;
}

.planned-card-check:hover {
  border-color: var(--color-paid);
}

.planned-card-check:active {
  transform: scale(0.85);
}

.planned-card-check svg {
  width: 14px;
  height: 14px;
  opacity: 0.3;
}

.planned-card.paying {
  animation: cardPayOut 0.4s ease-in forwards;
}

@keyframes cardPayOut {
  0% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.95); }
  100% { opacity: 0; transform: scale(0.8); width: 0; padding: 0; margin: 0; min-width: 0; }
}

.planned-empty-text {
  font-size: 14px;
  color: var(--text-tertiary);
  padding: 16px 4px;
}

/* ══════════════════════════════
   Operations List — Grouped by date
   ══════════════════════════════ */
.operations-groups {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.ops-date-separator {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  padding: 8px 4px 6px;
  text-transform: capitalize;
}

.ops-date-separator:first-child {
  padding-top: 0;
}

.ops-group {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 10px;
}

/* ── Swipe-to-delete container ── */
.op-swipe-container {
  position: relative;
  overflow: hidden;
  contain: paint;
}

.op-swipe-container:not(:last-child) .op-item::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 56px;
  right: 16px;
  height: 0.5px;
  background: var(--border);
}

.op-edit-action {
  position: absolute;
  top: 0;
  right: 70px;
  bottom: 0;
  width: 70px;
  background: var(--color-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  cursor: pointer;
}

.op-edit-action:active {
  opacity: 0.85;
}

.op-delete-action {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 70px;
  background: var(--color-expense);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  cursor: pointer;
}

.op-delete-action:active {
  opacity: 0.85;
}

/* Match parent ops-group border-radius on first/last swipe items */
.op-swipe-container:first-child .op-delete-action {
  border-top-right-radius: var(--radius-lg);
}

.op-swipe-container:last-child .op-delete-action {
  border-bottom-right-radius: var(--radius-lg);
}

.op-swipe-container:first-child .op-item {
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
}

.op-swipe-container:last-child .op-item {
  border-bottom-left-radius: var(--radius-lg);
  border-bottom-right-radius: var(--radius-lg);
}

.op-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  position: relative;
  background: var(--bg-card);
  will-change: transform;
  transform: translateX(0);
  z-index: 1;
}

.op-item:active {
  background: var(--bg-card-hover);
}

.op-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.op-icon.income {
  background: rgba(48, 209, 88, 0.12);
}

.op-icon.expense {
  background: rgba(255, 69, 58, 0.12);
}

.op-icon.planned {
  background: rgba(255, 159, 10, 0.12);
}

.op-icon.savings_deposit,
.op-icon.savings_withdraw {
  background: rgba(94, 92, 230, 0.12);
}

.op-icon.other {
  background: rgba(142, 142, 147, 0.12);
}

.op-info {
  flex: 1;
  min-width: 0;
}

.op-title {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.op-subtitle {
  font-size: 12px;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.op-category-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.op-amount {
  font-size: 16px;
  font-weight: 700;
  text-align: right;
  flex-shrink: 0;
  white-space: nowrap;
}

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

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

.op-amount-detail {
  font-size: 11px;
  color: var(--text-tertiary);
  text-align: right;
}

.operations-empty {
  padding: 20px;
  text-align: center;
}

.operations-empty-text {
  font-size: 14px;
  color: var(--text-tertiary);
}

/* ══════════════════════════════
   Bottom Navigation Bar
   ══════════════════════════════ */
.nav-spacer {
  height: calc(var(--nav-height) + var(--safe-bottom) + 40px);
}

.nav-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--nav-height) + var(--safe-bottom) + 16px);
  padding-bottom: calc(var(--safe-bottom) + 8px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 90;
  padding-left: 16px;
  padding-right: 16px;
  pointer-events: none;
  background: none;
}

.nav-bar-pill {
  display: flex;
  align-items: center;
  justify-content: space-evenly;
  width: 100%;
  max-width: 380px;
  height: 64px;
  background: var(--bg-card);
  border-radius: 32px;
  padding: 0 8px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15), 0 1px 4px rgba(0, 0, 0, 0.1);
  pointer-events: auto;
  position: relative;
}

[data-theme="light"] .nav-bar-pill {
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08), 0 1px 4px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .modal-overlay {
  background: rgba(0, 0, 0, 0.3);
}

[data-theme="light"] .onboarding-overlay {
  background: rgba(0, 0, 0, 0.4);
}

.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 48px;
  border-radius: 12px;
  color: var(--text-tertiary);
  transition: color 0.2s, background 0.2s;
  padding: 0;
  gap: 2px;
}

.nav-btn span {
  display: block;
  font-size: 10px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
}

.nav-btn.active {
  color: var(--color-accent);
}

.nav-btn:active {
  opacity: 0.6;
}

.fab-add {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7B78E8 0%, #5856D6 50%, #4845C7 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: 0 4px 20px rgba(94, 92, 230, 0.4);
  transition: transform 0.2s, box-shadow 0.2s;
  flex-shrink: 0;
  margin-top: -20px;
  position: relative;
  z-index: 1;
}

.fab-add:active {
  transform: scale(0.9);
  box-shadow: 0 2px 10px rgba(94, 92, 230, 0.2);
}

/* ══════════════════════════════
   Transaction Page
   ══════════════════════════════ */
.txn-page-section {
  margin-bottom: 20px;
}

.txn-page-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  padding-left: 4px;
}

.txn-submit-btn {
  width: 100%;
  padding: 16px;
  border-radius: var(--radius-md);
  background: var(--color-accent);
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  margin-top: 8px;
  transition: opacity 0.2s, transform 0.2s;
}

.txn-submit-btn:disabled {
  opacity: 0.4;
}

.txn-submit-btn:active:not(:disabled) {
  transform: scale(0.98);
}

/* ══════════════════════════════
   Modals (Pay + Add Transaction)
   ══════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeOverlay 0.2s ease-out;
}

@keyframes fadeOverlay {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-sheet {
  width: 100%;
  max-width: 480px;
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: 0 4px 40px rgba(0, 0, 0, 0.3);
  padding: 12px 20px 20px;
  margin: 16px;
  animation: modalPop 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}

@keyframes modalPop {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-handle {
  width: 36px;
  height: 5px;
  border-radius: 3px;
  background: var(--bg-card-hover);
  margin: 0 auto 16px;
}

.modal-title {
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 4px;
}

.modal-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 20px;
}

.modal-input-wrap {
  margin-bottom: 16px;
}

.modal-input {
  width: 100%;
  padding: 14px 16px;
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card-elevated);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s;
  -webkit-appearance: none;
}

.modal-input:focus {
  border-color: var(--color-accent);
}

.modal-input.text-left {
  text-align: left;
  font-size: 16px;
  font-weight: 500;
}

.modal-actions {
  display: flex;
  gap: 10px;
}

.modal-btn {
  flex: 1;
  padding: 14px;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  transition: transform 0.15s, opacity 0.15s;
}

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

.modal-btn.cancel {
  background: var(--bg-card-elevated);
  color: var(--text-primary);
}

.modal-btn.confirm {
  background: var(--color-accent);
  color: #fff;
}

.modal-btn.confirm:disabled {
  opacity: 0.4;
}

/* ── Transaction Type Toggle ── */
.txn-type-toggle {
  display: flex;
  gap: 0;
  margin-bottom: 20px;
  background: var(--bg-card-elevated);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.txn-type-btn {
  flex: 1;
  padding: 10px 0;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  border-radius: 10px;
  transition: all 0.25s;
  color: var(--text-secondary);
}

.txn-type-btn.active {
  background: var(--color-accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(94, 92, 230, 0.3);
}

/* ── Category chips ── */
.category-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
  max-height: 220px;
  overflow-y: auto;
}

.category-chip {
  padding: 6px 12px;
  border-radius: 18px;
  font-size: 12px;
  font-weight: 500;
  background: var(--bg-card-elevated);
  color: var(--text-primary);
  border: 1.5px solid transparent;
  transition: all 0.2s;
}

.category-chip.selected {
  border-color: var(--color-accent);
  background: rgba(94, 92, 230, 0.15);
  color: #a5a3f7;
}

.category-chip:active {
  transform: scale(0.95);
}

.category-chip-add {
  border: 1.5px dashed var(--text-tertiary);
  background: transparent;
  color: var(--text-secondary);
}

/* ══════════════════════════════
   Tab Pages
   ══════════════════════════════ */
.tab-content {
  padding: 16px 16px 0;
  max-width: 480px;
  margin: 0 auto;
  animation: fadeIn 0.35s ease-out;
}

.tab-page-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 20px;
  padding-top: 8px;
}

/* ── Category list items ── */
.cat-list {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.cat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  position: relative;
}

.cat-list > .cat-item:not(:last-child)::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 56px;
  right: 16px;
  height: 0.5px;
  background: var(--border);
}

.cat-item-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  background: rgba(94, 92, 230, 0.12);
}

.cat-item-icon.expense { background: rgba(255, 69, 58, 0.12); }
.cat-item-icon.income { background: rgba(48, 209, 88, 0.12); }
.cat-item-icon.savings { background: rgba(255, 159, 10, 0.12); }
.cat-item-icon.planned { background: rgba(255, 159, 10, 0.12); }

.cat-item-info {
  flex: 1;
  min-width: 0;
}

.cat-item-name {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cat-item-detail {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.cat-item-right {
  text-align: right;
  flex-shrink: 0;
}

.cat-item-amount {
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
}

.cat-item-amount.expense { color: var(--text-primary); }
.cat-item-amount.expense.over { color: var(--color-expense); }
.cat-item-amount.income { color: var(--color-income); }

.cat-item-sub {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.cat-empty {
  font-size: 14px;
  color: var(--text-tertiary);
  padding: 20px;
  text-align: center;
}

/* ── Limit progress bar ── */
.limit-bar {
  height: 4px;
  background: var(--bg-card-elevated);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}

.limit-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s ease;
}

.limit-bar-fill.ok { background: var(--color-income); }
.limit-bar-fill.warn { background: var(--color-planned); }
.limit-bar-fill.over { background: var(--color-expense); }

/* ── Savings goal progress ── */
.savings-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.savings-bar {
  flex: 1;
  height: 6px;
  background: var(--bg-card-elevated);
  border-radius: 3px;
  overflow: hidden;
}

.savings-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--color-planned);
  transition: width 0.4s ease;
}

.savings-pct {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-planned);
  min-width: 35px;
  text-align: right;
}

/* ══════════════════════════════
   Analytics Tab
   ══════════════════════════════ */
.analytics-period-row {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.analytics-type-btn {
  flex: 1;
  padding: 10px 0;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  border-radius: 10px;
  transition: all 0.25s;
  color: var(--text-secondary);
}

.analytics-type-btn.active {
  background: var(--color-accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(94, 92, 230, 0.3);
}

.analytics-month-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.analytics-month-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 0 12px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  min-width: 0;
}

.analytics-month-scroll::-webkit-scrollbar { display: none; }

/* Correction toggle — subtle ± icon */
.analytics-correction-toggle {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 50%;
  margin-top: 2px;
  transition: background 0.2s, opacity 0.2s;
  opacity: 0.35;
}

.analytics-correction-toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.analytics-correction-icon {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-secondary);
  line-height: 1;
}

.analytics-correction-toggle:has(input:checked) {
  opacity: 1;
  background: var(--bg-card);
}

.analytics-correction-toggle:has(input:checked) .analytics-correction-icon {
  color: var(--color-accent);
}

.analytics-month-btn {
  flex: 0 0 auto;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  background: var(--bg-card);
  color: var(--text-secondary);
  transition: all 0.2s;
  white-space: nowrap;
}

.analytics-month-btn.active {
  background: var(--color-accent);
  color: #fff;
}

.analytics-content {
  margin-top: 8px;
}

.analytics-summary-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
}

.analytics-total {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -1px;
  margin-bottom: 4px;
}

.analytics-total.income { color: var(--color-income); }

.analytics-meta {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-bottom: 16px;
}

.analytics-stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.analytics-stat {
  background: var(--bg-card-elevated);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.analytics-stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.analytics-stat-value {
  font-size: 18px;
  font-weight: 700;
}

/* ── Category breakdown in analytics ── */
/* ── Donut Chart ── */
.analytics-chart-wrap {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 16px auto 24px;
}

.analytics-donut-chart {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.analytics-chart-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.analytics-chart-total {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
}

.analytics-chart-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.analytics-cat-list {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 16px;
}

.analytics-cat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  position: relative;
}

.analytics-cat-item:not(:last-child)::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 16px;
  right: 16px;
  height: 0.5px;
  background: var(--border);
}

.analytics-cat-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.analytics-cat-rank {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-tertiary);
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.analytics-cat-info {
  flex: 1;
  min-width: 0;
}

.analytics-cat-name {
  font-size: 14px;
  font-weight: 600;
}

.analytics-cat-bar {
  height: 3px;
  background: var(--bg-card-elevated);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}

.analytics-cat-bar-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--color-accent);
}

.analytics-cat-amount {
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
  text-align: right;
}

.analytics-cat-pct {
  font-size: 11px;
  color: var(--text-tertiary);
  text-align: right;
  margin-top: 2px;
}

/* ── Comparison card ── */
.analytics-comparison {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.comparison-arrow {
  font-size: 24px;
}

.comparison-info {
  flex: 1;
}

.comparison-label {
  font-size: 12px;
  color: var(--text-tertiary);
}

.comparison-value {
  font-size: 16px;
  font-weight: 700;
}

.comparison-value.up { color: var(--color-expense); }
.comparison-value.down { color: var(--color-income); }

/* ── Budget progress card (analytics expenses) ── */
.analytics-budget-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
}

.analytics-budget-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.analytics-budget-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 600;
}

.analytics-budget-total {
  font-size: 15px;
  font-weight: 700;
}

.analytics-budget-bar {
  height: 8px;
  background: var(--bg-card-elevated);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 10px;
}

.analytics-budget-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
}

.analytics-budget-bar-fill.ok { background: var(--color-income); }
.analytics-budget-bar-fill.warn { background: var(--color-planned); }
.analytics-budget-bar-fill.over { background: var(--color-expense); }

.analytics-budget-details {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.analytics-budget-spent { font-weight: 600; }

.analytics-budget-breakdown {
  display: flex;
  gap: 12px;
}

.analytics-budget-part {
  font-size: 11px;
  color: var(--text-tertiary);
}

/* ══════════════════════════════
   Settings Page
   ══════════════════════════════ */
.settings-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0 20px;
  line-height: 36px;
}

.settings-header .tab-page-title {
  line-height: 36px;
  padding-top: 0;
}

.settings-back-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-card);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}

.settings-back-btn:active {
  background: var(--bg-card-elevated);
}

.settings-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.settings-budget-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.settings-budget-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.settings-budget-value {
  font-size: 18px;
  font-weight: 700;
}

.settings-action-btn {
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  background: var(--color-accent);
  color: #fff;
  transition: transform 0.15s;
}

.settings-action-btn:active {
  transform: scale(0.95);
}

.settings-list {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.settings-toggle-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  position: relative;
}

.settings-toggle-item:not(:last-child)::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 16px;
  right: 16px;
  height: 0.5px;
  background: var(--border);
}

.settings-toggle-info {
  flex: 1;
}

.settings-toggle-label {
  font-size: 15px;
  font-weight: 600;
}

.settings-toggle-desc {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

/* Toggle switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 30px;
  flex-shrink: 0;
}

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

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--bg-card-elevated);
  border-radius: 30px;
  transition: background 0.3s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 24px;
  width: 24px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.3s;
}

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

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

/* Settings menu items */
.settings-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 16px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
  position: relative;
  transition: background 0.15s;
}

.settings-menu-item:active {
  background: var(--bg-card-hover);
}

.settings-menu-item:not(:last-child)::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 16px;
  right: 16px;
  height: 0.5px;
  background: var(--border);
}

.settings-menu-item svg {
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.settings-menu-item.danger span {
  color: var(--color-expense);
}

.settings-menu-item.danger-full {
  color: var(--color-expense);
}

.settings-menu-item.danger-full span {
  color: var(--color-expense);
  font-weight: 600;
}

/* Settings limit item */
.settings-limit-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  position: relative;
}

.settings-limit-item:not(:last-child)::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 16px;
  right: 16px;
  height: 0.5px;
  background: var(--border);
}

.settings-limit-name {
  font-size: 15px;
  font-weight: 500;
}

.settings-limit-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

.settings-limit-value.has-limit {
  color: var(--text-primary);
}

/* ══════════════════════════════
   Onboarding
   ══════════════════════════════ */
.onboarding-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.3s ease;
  overflow-y: auto;
}

.onboarding-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 28px 20px 20px;
  text-align: center;
  max-width: 380px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}

.onboarding-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.onboarding-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
}

.onboarding-text {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.onboarding-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 20px;
}

.onboarding-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--bg-card-elevated);
  transition: all 0.3s;
}

.onboarding-dot.active {
  background: var(--color-accent);
  width: 20px;
  border-radius: 4px;
}

.onboarding-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.onboarding-btn {
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  transition: all 0.2s;
}

.onboarding-btn.primary {
  background: var(--color-accent);
  color: #fff;
  flex: 1;
}

.onboarding-btn.primary:disabled {
  opacity: 0.5;
}

.onboarding-btn.secondary {
  color: var(--text-secondary);
}

/* ── Onboarding interactive fields ── */
.ob-field {
  margin-bottom: 20px;
  text-align: left;
}

.ob-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-align: center;
}

.ob-input {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--bg-card-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.ob-input:focus {
  border-color: var(--color-accent);
}

.ob-hint {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 6px;
  text-align: center;
}

/* ── Toggle group (Шаблон / Свои) ── */
.ob-toggle-group {
  display: flex;
  gap: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 16px;
  background: var(--bg-card-elevated);
}

.ob-toggle-btn {
  flex: 1;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

.ob-toggle-btn.active {
  background: var(--color-accent);
  color: #fff;
}

/* ── Category chips ── */
.ob-cat-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  justify-content: center;
}

.ob-cat-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 20px;
  background: var(--bg-card-elevated);
  color: var(--text-primary);
  font-size: 13px;
}

.ob-cat-chip.template {
  background: var(--bg-card-elevated);
  color: var(--text-secondary);
}

.ob-cat-remove {
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 16px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
}

.ob-cat-remove:hover {
  color: var(--color-expense);
}

/* ── Manual section ── */
.ob-manual-section {
  margin-bottom: 8px;
}

.ob-input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.ob-input-row .ob-input {
  flex: 1;
}

.ob-add-btn {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  background: var(--color-accent);
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  line-height: 1;
  flex-shrink: 0;
}

.ob-empty-hint {
  font-size: 13px;
  color: var(--text-tertiary);
  padding: 12px;
}

/* ── Theme selection ── */
.ob-theme-group {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 20px;
}

.ob-theme-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 20px;
  border-radius: var(--radius-sm);
  background: var(--bg-card-elevated);
  color: var(--text-secondary);
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 13px;
  font-weight: 600;
  min-width: 80px;
}

.ob-theme-btn.active {
  border-color: var(--color-accent);
  color: var(--text-primary);
}

.ob-theme-icon {
  font-size: 28px;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ══════════════════════════════
   Utilities
   ══════════════════════════════ */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-elevated) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: 8px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ══════════════════════════════
   Category swipe-to-delete & edit
   ══════════════════════════════ */
.cat-swipe-container {
  position: relative;
  overflow: hidden;
  contain: paint;
}

.cat-swipe-container:not(:last-child) .cat-item::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 56px;
  right: 16px;
  height: 0.5px;
  background: var(--border);
}

.cat-delete-action {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 80px;
  background: var(--color-expense);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

/* Match parent cat-list border-radius on first/last items */
.cat-swipe-container:first-child .cat-delete-action {
  border-top-right-radius: var(--radius-lg);
}

.cat-swipe-container:last-child .cat-delete-action {
  border-bottom-right-radius: var(--radius-lg);
}

.cat-delete-action:active {
  opacity: 0.85;
}

.cat-swipe-container .cat-item {
  background: var(--bg-card);
  will-change: transform;
  transform: translateX(0);
  z-index: 1;
}

.cat-edit-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-tertiary);
  border-radius: 50%;
  transition: background 0.2s;
  margin-left: 4px;
}

.cat-edit-btn:active {
  background: var(--bg-card-hover);
}

/* ── Category edit modal sections ── */
.cat-edit-section {
  margin-bottom: 16px;
}

.cat-edit-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.cat-edit-limit-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cat-edit-limit-remove {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  color: var(--color-expense);
  background: rgba(255, 69, 58, 0.12);
  white-space: nowrap;
  transition: opacity 0.2s;
}

.cat-edit-limit-remove:active {
  opacity: 0.7;
}

/* ══════════════════════════════
   Planned card — header right area
   ══════════════════════════════ */
.planned-card-header-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ══════════════════════════════
   Theme Selector
   ══════════════════════════════ */
.theme-selector {
  display: flex;
  gap: 0;
  padding: 4px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
}

.theme-option {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px;
  border-radius: var(--radius-sm);
  transition: all 0.25s;
  color: var(--text-secondary);
}

.theme-option.active {
  background: var(--color-accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(94, 92, 230, 0.3);
}

.theme-option-icon {
  font-size: 22px;
}

.theme-option-label {
  font-size: 12px;
  font-weight: 600;
}

/* ── Light theme icon backgrounds ── */
[data-theme="light"] .op-icon.income { background: rgba(40, 167, 69, 0.12); }
[data-theme="light"] .op-icon.expense { background: rgba(220, 53, 69, 0.12); }
[data-theme="light"] .op-icon.planned { background: rgba(230, 138, 0, 0.12); }
[data-theme="light"] .cat-item-icon.expense { background: rgba(220, 53, 69, 0.12); }
[data-theme="light"] .cat-item-icon.income { background: rgba(40, 167, 69, 0.12); }
[data-theme="light"] .cat-item-icon.savings { background: rgba(230, 138, 0, 0.12); }
[data-theme="light"] .cat-item-icon.planned { background: rgba(230, 138, 0, 0.12); }
[data-theme="light"] .planned-card-day { background: rgba(0, 0, 0, 0.06); }
[data-theme="light"] .skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-elevated) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
}

/* ══════════════════════════════
   Currency Selector
   ══════════════════════════════ */
.currency-selector {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  padding: 4px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
}

.currency-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 4px;
  border-radius: var(--radius-sm);
  transition: all 0.25s;
  color: var(--text-secondary);
}

.currency-option.active {
  background: var(--color-accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(94, 92, 230, 0.3);
}

.currency-option-symbol {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2;
}

.currency-option-label {
  font-size: 10px;
  font-weight: 600;
}

/* ══════════════════════════════
   Balance Eye Button (privacy)
   ══════════════════════════════ */
.balance-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.balance-label-row .balance-label {
  margin-bottom: 0;
}

.balance-eye-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  border-radius: 50%;
  transition: color 0.2s, background 0.2s;
}

.balance-eye-btn:active {
  background: var(--bg-card-elevated);
  color: var(--text-secondary);
}

.blurred .balance-amount,
.blurred .balance-item-value,
.blurred .op-amount,
.blurred .analytics-total,
.blurred .analytics-stat-value,
.blurred .analytics-cat-amount,
.blurred .comparison-value,
.blurred .analytics-budget-total,
.blurred .analytics-budget-spent,
.blurred .analytics-budget-remaining,
.blurred .planned-card-amount,
.blurred .cat-item-amount,
.blurred .settings-budget-value {
  filter: blur(10px);
  user-select: none;
  transition: filter 0.2s;
}

/* ══════════════════════════════
   Mobile keyboard modal fix
   ══════════════════════════════ */
@supports (height: 100dvh) {
  .modal-overlay {
    height: 100dvh;
  }
}

.modal-overlay.keyboard-open {
  align-items: flex-start;
  padding-top: 10vh;
}

.modal-overlay.keyboard-open .modal-sheet {
  max-height: 60vh;
}

/* ══════════════════════════════
   Planned payments add button
   ══════════════════════════════ */
.planned-add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 16px;
  margin-top: 16px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  color: var(--color-accent);
  font-size: 15px;
  font-weight: 600;
  transition: background 0.2s;
}

.planned-add-btn:active {
  background: var(--bg-card-elevated);
}

.planned-add-btn svg {
  flex-shrink: 0;
}

/* ══════════════════════════════
   Modal scroll lock
   ══════════════════════════════ */
body.modal-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
}

/* ══════════════════════════════
   Category Manager (full page)
   ══════════════════════════════ */
.catmanager-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
}

.catmanager-name {
  font-size: 15px;
  font-weight: 500;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.catmanager-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.catmanager-rename-btn {
  color: var(--color-accent);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: background 0.2s;
}

.catmanager-rename-btn:active {
  background: var(--bg-card-elevated);
}

.catmanager-del-btn {
  color: var(--color-expense);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: background 0.2s;
}

.catmanager-del-btn:active {
  background: var(--bg-card-elevated);
}

.catmanager-add-section {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 16px 0;
  position: sticky;
  bottom: 0;
  background: var(--bg);
  z-index: 10;
}

.catmanager-save-btn {
  padding: 14px 20px;
  background: var(--color-accent);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  transition: transform 0.15s;
}

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

/* ══════════════════════════════
   Savings Tab
   ══════════════════════════════ */
.savings-goal-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 10px;
}

.savings-goal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.savings-goal-title {
  font-size: 16px;
  font-weight: 600;
}

.savings-goal-actions {
  display: flex;
  gap: 6px;
}

.savings-goal-action-btn {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  transition: transform 0.15s;
}

.savings-goal-action-btn:active {
  transform: scale(0.95);
}

.savings-goal-action-btn.deposit {
  background: rgba(48, 209, 88, 0.15);
  color: var(--color-income);
}

.savings-goal-action-btn.withdraw {
  background: rgba(255, 69, 58, 0.15);
  color: var(--color-expense);
}

.savings-goal-action-btn.adjust {
  background: rgba(94, 92, 230, 0.15);
  color: var(--color-accent);
}

.savings-goal-action-btn.delete {
  background: rgba(255, 69, 58, 0.1);
  color: var(--color-expense);
}

.savings-goal-amounts {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.savings-goal-saved {
  font-size: 20px;
  font-weight: 700;
}

.savings-goal-target {
  font-size: 14px;
  color: var(--text-secondary);
}

.savings-goal-bar {
  height: 6px;
  background: var(--bg-card-elevated);
  border-radius: 3px;
  overflow: hidden;
}

.savings-goal-bar-fill {
  height: 100%;
  background: var(--color-accent);
  border-radius: 3px;
  transition: width 0.3s;
}

.savings-add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 16px;
  margin-top: 16px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  color: var(--color-accent);
  font-size: 15px;
  font-weight: 600;
  transition: background 0.2s;
}

.savings-add-btn:active {
  background: var(--bg-card-elevated);
}

/* ══════════════════════════════
   History page
   ══════════════════════════════ */
.history-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 0;
}

.history-page-btn {
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  background: var(--bg-card);
  color: var(--text-primary);
  transition: background 0.2s;
}

.history-page-btn.active {
  background: var(--color-accent);
  color: #fff;
}

.history-page-btn:disabled {
  opacity: 0.3;
}

/* ══════════════════════════════
   Operation comment line
   ══════════════════════════════ */
.op-comment {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}

/* ── Operation Detail Modal ── */
.op-detail-header {
  text-align: center;
  padding: 8px 0 16px;
}

.op-detail-header .op-icon {
  margin: 0 auto 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.op-detail-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
}

.op-detail-amount {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

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

.op-detail-date {
  font-size: 13px;
  color: var(--text-secondary);
}

.op-detail-comment {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 8px;
  font-style: italic;
}

.op-detail-delete-btn {
  width: 100%;
  padding: 12px;
  text-align: center;
  color: var(--color-expense);
  font-size: 15px;
  font-weight: 600;
  margin-top: 8px;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
}

.op-detail-delete-btn:active {
  background: var(--bg-card-elevated);
}
