/* UI Cards */
.card {
  background: var(--bg-glass-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: transform var(--transition-normal), border-color var(--transition-normal), box-shadow var(--transition-normal);
}

.card:hover {
  border-color: var(--border-light);
}

/* Glass Stat Cards */
.stat-card {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-light);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.35);
}

/* Dynamic Spotlight Ambient Reflection on Cards */
.stat-card, .wallet-card, .loan-card, .category-card {
  --spotlight-x: 50%;
  --spotlight-y: 50%;
  --spotlight-opacity: 0;
  position: relative;
}

.stat-card::after, .wallet-card::after, .loan-card::after, .category-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(
    400px circle at var(--spotlight-x) var(--spotlight-y),
    rgba(99, 102, 241, 0.12),
    transparent 70%
  );
  opacity: var(--spotlight-opacity);
  pointer-events: none;
  transition: opacity 280ms var(--ease-out-quint);
  z-index: 1;
}

[data-theme="light"] .stat-card::after,
[data-theme="light"] .wallet-card::after,
[data-theme="light"] .loan-card::after,
[data-theme="light"] .category-card::after {
  background: radial-gradient(
    400px circle at var(--spotlight-x) var(--spotlight-y),
    rgba(79, 70, 229, 0.08),
    transparent 70%
  );
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--card-accent, var(--primary));
  opacity: 0.8;
}

.stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-label {
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.stat-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  color: var(--card-accent, var(--primary));
  transition: transform var(--transition-fast);
}

.stat-card:hover .stat-icon {
  transform: scale(1.08);
}

.stat-icon svg {
  width: 18px;
  height: 18px;
}

.stat-amount {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-main);
  word-break: break-all;
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
}

.stat-subtext {
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.7rem 1.25rem;
  border-radius: var(--radius-md);
  transition: transform var(--transition-instant), box-shadow var(--transition-fast), background var(--transition-fast), filter var(--transition-fast), border-color var(--transition-fast);
  cursor: pointer;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.96) !important;
}

/* Tactile Micro-Press Ripple */
.btn, .btn-circle, .btn-icon, .btn-icon-subtle, .segment-btn, .mobile-nav-link {
  position: relative;
  overflow: hidden;
}

.touch-ripple-effect {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.35) 0%, rgba(255, 255, 255, 0) 70%);
  transform: scale(0);
  animation: touchRippleAnim 420ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
  z-index: 10;
}

[data-theme="light"] .touch-ripple-effect {
  background: radial-gradient(circle, rgba(79, 70, 229, 0.22) 0%, rgba(79, 70, 229, 0) 70%);
}

@keyframes touchRippleAnim {
  0% {
    transform: scale(0);
    opacity: 0.6;
  }
  100% {
    transform: scale(1);
    opacity: 0;
  }
}

.btn svg {
  width: 18px;
  height: 18px;
}

.btn-primary {
  background: var(--primary-gradient);
  color: #fff;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover {
  transform: translateY(-1.5px);
  box-shadow: 0 6px 20px var(--primary-glow);
  filter: brightness(1.08);
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
}

.btn-secondary:hover {
  transform: translateY(-1.5px);
  background: var(--bg-surface-hover);
  border-color: var(--border-light);
}

.btn-outline-danger {
  background: transparent;
  color: var(--expense);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-outline-danger:hover {
  transform: translateY(-1.5px);
  background: var(--expense-subtle);
  border-color: var(--expense);
}

.btn-danger {
  background: var(--expense);
  color: #fff;
  box-shadow: 0 4px 14px var(--expense-glow);
}

.btn-danger:hover {
  background: var(--expense-hover);
  transform: translateY(-1.5px);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  background: var(--bg-surface-hover);
  color: var(--text-main);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 0.45rem 0.85rem;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  transition: transform var(--transition-instant), color var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast);
}

.btn-icon:hover {
  color: var(--text-main);
  background: var(--bg-surface-hover);
  border-color: var(--border-light);
  transform: scale(1.05);
}

.btn-icon:active {
  transform: scale(0.92);
}

.btn-icon.danger:hover {
  color: var(--expense);
  background: var(--expense-subtle);
  border-color: var(--expense);
}

/* Circular Action Buttons (Wallet & Category headers) */
.btn-circle {
  width: 36px;
  height: 36px;
  min-width: 36px;
  max-width: 36px;
  border-radius: 50% !important;
  padding: 0 !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  cursor: pointer;
  flex-shrink: 0;
  border: 1px solid transparent;
}

.btn-circle svg {
  width: 16px;
  height: 16px;
}

.btn-circle:hover {
  transform: scale(1.08);
}

.btn-circle:active {
  transform: scale(0.92);
}

.btn-circle.btn-primary {
  background: var(--primary-gradient);
  color: #ffffff;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-circle.btn-primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 6px 18px var(--primary-glow);
}

.btn-circle.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
}

.btn-circle.btn-secondary:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-light);
}

/* Touch Ergonomics: Ensure minimum 44x44px target on touch devices */
@media (pointer: coarse), (max-width: 768px) {
  .btn-circle,
  .btn-icon,
  .btn-icon-subtle,
  .btn-privacy-toggle,
  .btn-icon-ghost,
  .month-step-btn,
  .year-nav-btn {
    position: relative;
  }

  .btn-circle::before,
  .btn-icon::before,
  .btn-icon-subtle::before,
  .btn-privacy-toggle::before,
  .btn-icon-ghost::before,
  .month-step-btn::before,
  .year-nav-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    min-width: 44px;
    min-height: 44px;
    width: 100%;
    height: 100%;
    pointer-events: auto;
  }
}

/* Form Controls */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

@media (max-width: 480px) {
  .form-row-2 {
    grid-template-columns: 1fr;
    gap: 0;
  }
}

.form-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Remove number input spinner scroll arrows */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none !important;
  margin: 0 !important;
}

input[type="number"] {
  -moz-appearance: textfield !important;
  appearance: textfield !important;
}

/* Autocomplete Dropdown for Transaction Note */
.input-autocomplete-wrapper {
  position: relative;
  width: 100%;
}

.autocomplete-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 220px;
  overflow-y: auto;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 0.35rem;
}

.autocomplete-dropdown.hidden {
  display: none !important;
}

.autocomplete-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  gap: 0.5rem;
  font-size: 0.88rem;
  color: var(--text-main);
}

.autocomplete-item:hover,
.autocomplete-item.selected {
  background: rgba(99, 102, 241, 0.16);
  color: #ffffff;
}

.autocomplete-item-left {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
  flex: 1;
}

.autocomplete-item-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.autocomplete-item-text {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.autocomplete-item-text mark {
  background: transparent;
  color: #38bdf8;
  font-weight: 700;
}

.autocomplete-item-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

[data-theme="light"] .autocomplete-dropdown {
  background: #ffffff;
  border-color: #cbd5e1;
  box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.12), 0 8px 10px -6px rgba(15, 23, 42, 0.08);
}

[data-theme="light"] .autocomplete-item:hover,
[data-theme="light"] .autocomplete-item.selected {
  background: #e0e7ff;
  color: #3730a3;
}

[data-theme="light"] .autocomplete-item-text mark {
  color: #2563eb;
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.95rem;
  transition: all var(--transition-fast);
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: var(--bg-surface);
}

.form-control:user-invalid,
.form-control.is-invalid {
  border-color: var(--expense) !important;
  box-shadow: 0 0 0 3px var(--expense-glow) !important;
}

.form-control::placeholder {
  color: var(--text-dim);
}

select.form-control {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat !important;
  background-position: right 0.85rem center !important;
  background-size: 16px 16px !important;
  padding-right: 2.5rem;
  cursor: pointer;
}

select.form-control option {
  background-color: var(--bg-secondary);
  color: var(--text-main);
}

@media (max-width: 768px) {
  .form-control,
  select.form-control {
    font-size: 16px !important; /* Prevents iOS auto-zoom on focus */
    min-height: 44px;
  }
}

/* Modern Toggle Switch */
.modern-toggle {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.modern-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid var(--border-subtle);
  border-radius: 34px;
  transition: background-color 0.28s var(--ease-out-quint), border-color 0.25s ease, box-shadow 0.25s ease;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 20px;
  width: 20px;
  left: 2px;
  bottom: 2px;
  background: #ffffff;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.2s ease;
}

.modern-toggle input:checked + .toggle-slider {
  background: var(--primary-gradient);
  border-color: var(--primary);
  box-shadow: 0 0 14px var(--primary-glow);
}

.modern-toggle input:checked + .toggle-slider::before {
  transform: translateX(22px);
}

.modern-toggle input:focus-visible + .toggle-slider {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

[data-theme="light"] .toggle-slider {
  background: #e2e8f0;
  border-color: #cbd5e1;
}

[data-theme="light"] .toggle-slider::before {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.18);
}

/* Segmented Buttons / Tabs */
.segment-group {
  display: flex;
  background: var(--bg-secondary);
  padding: 0.3rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  gap: 0.25rem;
  position: relative;
}

.segment-btn {
  flex: 1;
  padding: 0.55rem;
  text-align: center;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: background-color var(--duration-fast) var(--ease-out-quint),
              color var(--duration-fast) var(--ease-out-quint),
              border-color var(--duration-fast) var(--ease-out-quint),
              transform var(--duration-instant) var(--ease-out-quint),
              box-shadow var(--duration-fast) var(--ease-out-quint);
  cursor: pointer;
  white-space: nowrap;
  position: relative;
  user-select: none;
}

.segment-btn:hover:not(.active) {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

[data-theme="light"] .segment-btn:hover:not(.active) {
  background: rgba(0, 0, 0, 0.04);
}

.segment-btn:active {
  transform: scale(0.95) !important;
}

.segment-btn.active {
  background: var(--bg-surface);
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
  transform: scale(1.02);
}

.segment-btn.active.expense {
  background: var(--expense-subtle);
  color: var(--expense);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.segment-btn.active.income {
  background: var(--income-subtle);
  color: var(--income);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.segment-btn.active.transfer {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.25);
}

[data-theme="light"] .segment-btn.active.transfer {
  background: #e0f2fe;
  color: #0284c7;
  border: 1px solid #bae6fd;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(4, 7, 13, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal-backdrop);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--duration-fast) var(--ease-out-quart), visibility var(--duration-fast);
  padding: 1rem;
}

.modal-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.modal-dialog {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  transform: translateY(14px) scale(0.97);
  transition: transform var(--duration-normal) var(--ease-out-expo);
  overflow: hidden;
  z-index: var(--z-modal);
}

.modal-backdrop.open .modal-dialog {
  transform: translateY(0) scale(1);
}

.modal-dialog form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.modal-header [data-modal-close]:hover svg {
  transform: rotate(90deg);
}

.modal-header [data-modal-close] svg {
  transition: transform var(--transition-fast);
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  flex: 1 1 auto;
  min-height: 0;
  max-height: calc(85dvh - 130px);
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  flex-shrink: 0;
  background: var(--bg-secondary);
  position: sticky;
  bottom: 0;
  z-index: 5;
}

/* Mobile Bottom Sheet Modal Adaptation */
@media (max-width: 640px) {
  .modal-backdrop {
    padding: 0;
    align-items: flex-end;
  }

  .modal-dialog {
    width: 100%;
    max-width: 100%;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    border-bottom: none;
    border-left: none;
    border-right: none;
    max-height: 85vh;
    max-height: 85dvh;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    position: relative;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.4);
    overflow: hidden;
  }

  .modal-dialog form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    max-height: calc(85dvh - 55px);
    overflow: hidden;
  }

  /* Grab Handle Bar for Bottom Sheet */
  .modal-dialog::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 38px;
    height: 4px;
    background: var(--border-light);
    border-radius: var(--radius-full);
    opacity: 0.7;
  }

  .modal-backdrop.open .modal-dialog {
    transform: translateY(0);
  }

  .modal-header {
    padding: 1.15rem 1.25rem 0.85rem;
    padding-top: 1.4rem;
    flex-shrink: 0;
  }

  .modal-body {
    padding: 1rem 1.25rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    flex: 1 1 auto;
    min-height: 0;
    max-height: calc(85dvh - 130px);
  }

  .modal-footer {
    padding: 0.85rem 1.25rem;
    padding-bottom: max(1rem, env(safe-area-inset-bottom, 0px));
    flex-shrink: 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-subtle);
    position: sticky;
    bottom: 0;
    z-index: 5;
  }

  .modal-footer .btn {
    flex: 1;
    min-height: 44px;
  }
}

/* Color & Icon Picker helpers */
.color-picker-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

.color-option {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.color-option:hover {
  transform: scale(1.15);
}

.color-option.selected {
  border-color: #fff;
  box-shadow: 0 0 0 2px var(--primary);
  transform: scale(1.1);
}

.icon-picker-grid, .emoji-picker-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.5rem;
  max-height: 160px;
  overflow-y: auto;
  padding: 0.6rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.icon-option, .emoji-option {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
  border: 1px solid transparent;
  transition: all var(--transition-fast);
}

.icon-option svg {
  width: 20px;
  height: 20px;
}

.icon-option:hover, .emoji-option:hover {
  background: var(--bg-surface-hover);
  color: var(--text-main);
  transform: scale(1.08);
}

.icon-option.selected, .emoji-option.selected {
  background: var(--primary-glow);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

/* Toasts */
#toast-container {
  position: fixed;
  bottom: 5.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  z-index: var(--z-toast);
  pointer-events: none;
}

@media (min-width: 992px) {
  #toast-container {
    bottom: 2rem;
    right: 2rem;
  }
}

.toast {
  pointer-events: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  color: var(--text-main);
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 280px;
  max-width: 380px;
  transform: translateX(100%);
  opacity: 0;
  transition: transform var(--transition-normal), opacity var(--transition-normal);
}

.toast.show {
  transform: translateX(0);
  opacity: 1;
}

.toast.success {
  border-left: 4px solid var(--income);
}

.toast.error {
  border-left: 4px solid var(--expense);
}

.toast.info {
  border-left: 4px solid var(--primary);
}

/* Empty State Card */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
}

.empty-state-icon svg {
  width: 32px;
  height: 32px;
}

.empty-state-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}

.empty-state-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  max-width: 300px;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-full);
}

.badge-income {
  background: var(--income-subtle);
  color: var(--income);
}

.badge-expense {
  background: var(--expense-subtle);
  color: var(--expense);
}

.badge-wallet {
  background: var(--bg-surface);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

/* ==========================================================================
   THEME COMPONENT OVERRIDES
   ========================================================================== */
[data-theme="light"] .card {
  background: #ffffff;
  border-color: #e2e8f0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .form-control {
  background-color: #ffffff;
  border-color: #cbd5e1;
  color: #0f172a;
}

[data-theme="light"] select.form-control {
  background-color: #ffffff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat !important;
  background-position: right 0.85rem center !important;
  background-size: 16px 16px !important;
}

[data-theme="light"] select.form-control option {
  background-color: #ffffff;
  color: #0f172a;
}

[data-theme="light"] .modal-dialog {
  background: #ffffff;
  border-color: #e2e8f0;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .tx-card {
  background: #ffffff;
  border-color: #e2e8f0;
}

[data-theme="light"] .tx-card:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

/* AMOLED Pitch Black Mode Overrides */
:root:not([data-theme="light"]) .card {
  background: #080b12;
  border-color: rgba(255, 255, 255, 0.14);
}

:root:not([data-theme="light"]) .tx-card {
  background: #080b12;
  border-color: rgba(255, 255, 255, 0.14);
}

:root:not([data-theme="light"]) .tx-card:hover {
  background: #101524;
  border-color: rgba(255, 255, 255, 0.24);
}

:root:not([data-theme="light"]) .modal-dialog {
  background: #080b12;
  border-color: rgba(255, 255, 255, 0.18);
}

/* ==========================================================================
   DELIGHT & GAMIFICATION SYSTEM
   ========================================================================== */

/* Counter pulse micro-interaction */
@keyframes counterPulse {
  0% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.04); filter: brightness(1.25); text-shadow: 0 0 12px var(--primary-glow); }
  100% { transform: scale(1); filter: brightness(1); }
}

.counter-pulse-active {
  animation: counterPulse 0.45s cubic-bezier(0.16, 1, 0.3, 1);
  display: inline-block;
}

/* Gamify Milestone & Streak Banner */
.gamify-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.35rem;
  margin-bottom: 1.25rem;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.08) 0%, rgba(99, 102, 241, 0.08) 100%);
  border: 1px solid rgba(56, 189, 248, 0.2);
  border-radius: var(--radius-xl);
  flex-wrap: wrap;
  gap: 1rem;
}

[data-theme="light"] .gamify-banner {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0e7ff 100%);
  border: 1px solid #bfdbfe;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.06);
}

@media (max-width: 580px) {
  .gamify-banner {
    flex-direction: column;
    align-items: stretch;
    padding: 0.85rem 1rem;
    gap: 0.85rem;
  }
  .gamify-left {
    justify-content: space-between;
    width: 100%;
  }
  .gamify-right {
    width: 100%;
    justify-content: space-between;
    gap: 0.75rem;
  }
  .gamify-progress-info {
    flex: 1;
    min-width: 0;
  }
}

.gamify-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.gamify-level-badge {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.level-icon {
  font-size: 1.85rem;
  line-height: 1;
  filter: drop-shadow(0 2px 8px rgba(245, 158, 11, 0.3));
}

.level-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.level-title {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.gamify-streak {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.streak-flame {
  display: inline-block;
  animation: flameWiggle 1.8s ease-in-out infinite alternate;
}

@keyframes flameWiggle {
  0% { transform: rotate(-4deg) scale(1); }
  100% { transform: rotate(5deg) scale(1.15); }
}

.gamify-right {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.gamify-progress-info {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 150px;
}

.gamify-badges-count {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

.gamify-progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-surface);
  border-radius: var(--radius-full);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

[data-theme="light"] .gamify-progress-bar {
  background: #cbd5e1;
}

.gamify-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #38bdf8, #818cf8);
  border-radius: var(--radius-full);
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Achievements Grid & Cards */
.achievements-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  max-height: 440px;
  overflow-y: auto;
  padding-right: 0.25rem;
}

@media (min-width: 520px) {
  .achievements-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.achievement-card {
  display: flex;
  gap: 0.85rem;
  padding: 0.95rem;
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  transition: all var(--transition-fast);
  position: relative;
}

[data-theme="light"] .achievement-card {
  background: #f8fafc;
  border-color: #e2e8f0;
}

.achievement-card.unlocked {
  border-color: var(--badge-color, var(--primary));
  box-shadow: 0 4px 16px -4px rgba(56, 189, 248, 0.2);
}

.achievement-card.unlocked:hover {
  transform: translateY(-2px);
}

.achievement-card.locked {
  opacity: 0.65;
  filter: grayscale(0.4);
}

.achievement-icon-wrap {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.achievement-content {
  flex: 1;
  min-width: 0;
}

.achievement-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.achievement-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-main);
}

.achievement-status-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-full);
  letter-spacing: 0.04em;
}

.achievement-status-badge.unlocked {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.achievement-status-badge.locked {
  background: var(--bg-secondary);
  color: var(--text-dim);
  border: 1px solid var(--border-subtle);
}

.achievement-desc {
  font-size: 0.77rem;
  color: var(--text-muted);
  line-height: 1.35;
  margin-bottom: 0.4rem;
}

.achievement-progress {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--primary);
}

/* App Cloud Sync Overlay */
.sync-loader-overlay {
  position: fixed;
  inset: 0;
  background: rgba(9, 13, 22, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

[data-theme="light"] .sync-loader-overlay {
  background: rgba(248, 250, 252, 0.88);
}

.sync-loader-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}

.sync-loader-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.sync-spinner {
  width: 42px;
  height: 42px;
  border: 3px solid rgba(99, 102, 241, 0.2);
  border-top-color: var(--primary, #6366f1);
  border-radius: 50%;
  animation: sync-spin 0.8s linear infinite;
}

.sync-text {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}

@keyframes sync-spin {
  to {
    transform: rotate(360deg);
  }
}
