/* =============================================
   FinançasPRO - Main CSS
   Mobile-first, Modern, Premium Design
   ============================================= */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ============ CSS VARIABLES ============ */
:root {
  /* Primary Colors */
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #818cf8;
  --primary-bg: rgba(99, 102, 241, 0.1);

  /* Semantic Colors */
  --income: #10b981;
  --income-bg: rgba(16, 185, 129, 0.12);
  --expense: #ef4444;
  --expense-bg: rgba(239, 68, 68, 0.12);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.12);
  --info: #3b82f6;
  --info-bg: rgba(59, 130, 246, 0.12);

  /* Light Theme */
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --bg-card: #ffffff;
  --bg-modal: #ffffff;
  --bg-input: #f8fafc;
  --bg-nav: #ffffff;
  --bg-header: #ffffff;
  --bg-overlay: rgba(0, 0, 0, 0.5);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-tertiary: #94a3b8;
  --text-inverse: #ffffff;

  --border: #e2e8f0;
  --border-focus: #6366f1;
  --divider: #f1f5f9;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.05);
  --shadow-md: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
  --shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.08), 0 10px 10px -5px rgba(0,0,0,0.03);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --radius-xl: 24px;
  --radius-full: 999px;

  --nav-height: 68px;
  --header-height: 60px;
  --transition: 0.2s ease;
  --transition-slow: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #1e293b;
  --bg-card: #1e293b;
  --bg-modal: #1e293b;
  --bg-input: #0f172a;
  --bg-nav: #1e293b;
  --bg-header: #1e293b;
  --bg-overlay: rgba(0, 0, 0, 0.75);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;
  --text-inverse: #0f172a;

  --border: #334155;
  --border-focus: #818cf8;
  --divider: #1e293b;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.4);
  --shadow-md: 0 10px 15px -3px rgba(0,0,0,0.4);
  --shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.5);
}

/* ============ RESET & BASE ============ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
img { max-width: 100%; height: auto; }
button { cursor: pointer; border: none; background: none; }

/* ============ SCROLLBAR ============ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* ============ LOCK SCREEN ============ */
#lock-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, var(--primary-dark) 0%, #7c3aed 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 2rem;
}

#lock-screen .lock-logo {
  width: 80px;
  height: 80px;
  background: rgba(255,255,255,0.15);
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  margin-bottom: 1.5rem;
  backdrop-filter: blur(10px);
}

#lock-screen h2 {
  color: white;
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

#lock-screen p {
  color: rgba(255,255,255,0.7);
  margin-bottom: 2rem;
}

.pin-dots {
  display: flex;
  gap: 12px;
  margin-bottom: 2rem;
}

.pin-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.5);
  transition: all 0.2s;
}

.pin-dot.filled {
  background: white;
  border-color: white;
  transform: scale(1.1);
}

.pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 280px;
}

.pin-key {
  aspect-ratio: 1;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 50%;
  color: white;
  font-size: 1.5rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
  backdrop-filter: blur(5px);
  -webkit-tap-highlight-color: transparent;
}

.pin-key:active { transform: scale(0.92); background: rgba(255,255,255,0.25); }
.pin-key.empty { background: transparent; border-color: transparent; pointer-events: none; }
.pin-key.delete { font-size: 1.2rem; }

/* ============ APP LAYOUT ============ */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}

/* ============ HEADER ============ */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 1rem;
  gap: 0.75rem;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.header-logo {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: white;
  flex-shrink: 0;
}

.header-title {
  flex: 1;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.header-subtitle {
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--text-tertiary);
  display: block;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 1rem;
  transition: all var(--transition);
  background: var(--bg-tertiary);
}

.header-btn:hover { background: var(--primary-bg); color: var(--primary); }

/* ============ MAIN CONTENT ============ */
.app-main {
  flex: 1;
  padding: 1rem 1rem calc(var(--nav-height) + 1rem);
  overflow-y: auto;
  overflow-x: hidden;
}

/* ============ BOTTOM NAV ============ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: var(--nav-height);
  background: var(--bg-nav);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 0.5rem;
  z-index: 100;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 0.5rem 0.25rem;
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  transition: all var(--transition);
  cursor: pointer;
  position: relative;
}

.nav-item.active {
  color: var(--primary);
}

.nav-item.active .nav-icon {
  background: var(--primary-bg);
  color: var(--primary);
}

.nav-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  transition: all var(--transition);
}

.nav-label {
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  line-height: 1;
}

.nav-item.add-btn .nav-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: white;
  border-radius: var(--radius);
  font-size: 1.3rem;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
}

/* ============ SECTIONS ============ */
.section { display: none; }
.section.active { display: block; animation: fadeIn 0.25s ease; }

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

/* ============ PAGE HEADER ============ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.page-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
}

.page-subtitle {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ============ CARDS ============ */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  padding: 1rem 1.25rem 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--divider);
}

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

.card-body { padding: 1.25rem; }
.card-footer {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--divider);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ============ STAT CARDS ============ */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition);
}

.stat-card:active { transform: scale(0.98); }

.stat-card.full-width {
  grid-column: 1 / -1;
}

.stat-card.income { border-left: 3px solid var(--income); }
.stat-card.expense { border-left: 3px solid var(--expense); }
.stat-card.pending { border-left: 3px solid var(--warning); }
.stat-card.overdue { border-left: 3px solid var(--expense); }
.stat-card.balance { border-left: 3px solid var(--primary); }

.stat-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.stat-card.income .stat-icon { background: var(--income-bg); color: var(--income); }
.stat-card.expense .stat-icon { background: var(--expense-bg); color: var(--expense); }
.stat-card.pending .stat-icon { background: var(--warning-bg); color: var(--warning); }
.stat-card.overdue .stat-icon { background: var(--expense-bg); color: var(--expense); }
.stat-card.balance .stat-icon { background: var(--primary-bg); color: var(--primary); }

.stat-label {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-value {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.stat-value.income { color: var(--income); }
.stat-value.expense { color: var(--expense); }
.stat-value.negative { color: var(--expense); }
.stat-value.warning { color: var(--warning); }

.stat-change {
  font-size: 0.65rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 3px;
}

.stat-change.up { color: var(--income); }
.stat-change.down { color: var(--expense); }

/* ============ BALANCE HERO ============ */
.balance-hero {
  background: linear-gradient(135deg, var(--primary-dark) 0%, #7c3aed 60%, #9333ea 100%);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  color: white;
  position: relative;
  overflow: hidden;
  margin-bottom: 1rem;
  box-shadow: 0 8px 32px rgba(99, 102, 241, 0.35);
}

.balance-hero::before {
  content: '';
  position: absolute;
  top: -40px;
  right: -40px;
  width: 160px;
  height: 160px;
  background: rgba(255,255,255,0.06);
  border-radius: 50%;
}

.balance-hero::after {
  content: '';
  position: absolute;
  bottom: -50px;
  left: -20px;
  width: 120px;
  height: 120px;
  background: rgba(255,255,255,0.04);
  border-radius: 50%;
}

.balance-label {
  font-size: 0.75rem;
  font-weight: 500;
  opacity: 0.75;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.35rem;
}

.balance-amount {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 1.25rem;
  position: relative;
  z-index: 1;
}

.balance-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  position: relative;
  z-index: 1;
}

.balance-item {
  flex: 1;
  background: rgba(255,255,255,0.1);
  border-radius: var(--radius);
  padding: 0.75rem;
  backdrop-filter: blur(10px);
}

.balance-item-label {
  font-size: 0.65rem;
  font-weight: 500;
  opacity: 0.7;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 4px;
}

.balance-item-value {
  font-size: 0.95rem;
  font-weight: 700;
}

/* ============ CHART CONTAINER ============ */
.chart-container {
  position: relative;
  width: 100%;
  height: 200px;
  margin-bottom: 0.5rem;
}

.chart-container.tall { height: 260px; }
.chart-container.short { height: 160px; }

/* ============ TRANSACTION LIST ============ */
.transactions-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.transaction-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
}

.transaction-item:active { transform: scale(0.99); background: var(--bg-tertiary); }

.transaction-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

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

.transaction-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.transaction-meta {
  font-size: 0.7rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 2px;
}

.transaction-amount {
  font-size: 0.95rem;
  font-weight: 700;
  text-align: right;
  flex-shrink: 0;
}

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

.transaction-status {
  font-size: 0.6rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: block;
  margin-top: 3px;
  width: fit-content;
}

.status-paid { background: var(--income-bg); color: var(--income); }
.status-pending { background: var(--warning-bg); color: var(--warning); }
.status-overdue { background: var(--expense-bg); color: var(--expense); }

/* ============ FILTERS ============ */
.filters-bar {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.filters-bar::-webkit-scrollbar { display: none; }

.filter-chip {
  flex-shrink: 0;
  padding: 0.4rem 0.875rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 500;
  border: 1.5px solid var(--border);
  color: var(--text-secondary);
  background: var(--bg-card);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.filter-chip:hover { border-color: var(--primary); color: var(--primary); }
.filter-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

/* ============ SEARCH BAR ============ */
.search-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 1rem;
  margin-bottom: 1rem;
  transition: border-color var(--transition);
}

.search-bar:focus-within { border-color: var(--primary); }

.search-bar i { color: var(--text-tertiary); font-size: 0.875rem; }

.search-bar input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 0.875rem;
}

.search-bar input::placeholder { color: var(--text-tertiary); }

/* ============ SECTION DIVIDER ============ */
.section-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1rem 0 0.75rem;
}

.section-divider-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.section-divider-line {
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  transition: all var(--transition);
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover { box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45); }

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1.5px solid var(--border);
}

.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }

.btn-success {
  background: linear-gradient(135deg, #059669, #10b981);
  color: white;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
}

.btn-danger {
  background: linear-gradient(135deg, #dc2626, #ef4444);
  color: white;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.3);
}

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text-secondary);
}

.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 0.875rem 1.5rem;
  font-size: 1rem;
  border-radius: var(--radius-md);
}

.btn-sm {
  padding: 0.4rem 0.875rem;
  font-size: 0.775rem;
  border-radius: var(--radius-sm);
}

.btn-block { width: 100%; }

/* ============ FAB BUTTON ============ */
.fab {
  position: fixed;
  bottom: calc(var(--nav-height) + 1rem);
  right: 1rem;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 24px rgba(99, 102, 241, 0.45);
  z-index: 50;
  cursor: pointer;
  transition: all var(--transition);
}

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

/* ============ MODALS ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 500;
  display: flex;
  align-items: flex-end;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-modal);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  max-height: 95vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  padding-bottom: env(safe-area-inset-bottom);
}

.modal-overlay.active .modal {
  transform: translateY(0);
}

.modal-handle {
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0.75rem auto 0;
}

.modal-header {
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 0.875rem;
  transition: all var(--transition);
}

.modal-close:hover { background: var(--expense-bg); color: var(--expense); }

.modal-body { padding: 1.25rem; }
.modal-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.75rem;
}

.modal-footer .btn { flex: 1; }

/* Full modal */
.modal.modal-full {
  border-radius: 0;
  max-height: 100vh;
  height: 100vh;
}

/* ============ FORMS ============ */
.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-size: 0.775rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.4rem;
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--transition);
  -webkit-appearance: none;
}

.form-control:focus { border-color: var(--primary); }
.form-control::placeholder { color: var(--text-tertiary); }

textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

.form-control-icon {
  position: relative;
}

.form-control-icon .form-control {
  padding-left: 2.5rem;
}

.form-control-icon .icon {
  position: absolute;
  left: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  font-size: 0.875rem;
  pointer-events: none;
}

/* Type Toggle */
.type-toggle {
  display: flex;
  background: var(--bg-tertiary);
  border-radius: var(--radius);
  padding: 3px;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
}

.type-toggle-btn {
  flex: 1;
  padding: 0.6rem;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.type-toggle-btn.active-income {
  background: var(--income);
  color: white;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.type-toggle-btn.active-expense {
  background: var(--expense);
  color: white;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

/* ============ CREDIT CARDS ============ */
.credit-card {
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  color: white;
  position: relative;
  overflow: hidden;
  margin-bottom: 0.75rem;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  transition: transform var(--transition);
}

.credit-card:active { transform: scale(0.98); }

.credit-card::before {
  content: '';
  position: absolute;
  top: -30px;
  right: -30px;
  width: 150px;
  height: 150px;
  background: rgba(255,255,255,0.08);
  border-radius: 50%;
}

.credit-card::after {
  content: '';
  position: absolute;
  bottom: -40px;
  left: -20px;
  width: 120px;
  height: 120px;
  background: rgba(255,255,255,0.05);
  border-radius: 50%;
}

.credit-card .card-name {
  font-size: 0.8rem;
  font-weight: 600;
  opacity: 0.8;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.credit-card .card-chip {
  width: 32px;
  height: 24px;
  background: rgba(255,255,255,0.25);
  border-radius: 5px;
  position: relative;
  z-index: 1;
}

.credit-card .card-limit-info {
  position: relative;
  z-index: 1;
}

.credit-card .card-limit-label {
  font-size: 0.65rem;
  opacity: 0.7;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.credit-card .card-limit-value {
  font-size: 1.1rem;
  font-weight: 700;
}

.credit-card .card-details {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  position: relative;
  z-index: 1;
}

.credit-card .card-detail-label {
  font-size: 0.6rem;
  opacity: 0.65;
  text-transform: uppercase;
}

.credit-card .card-detail-value {
  font-size: 0.8rem;
  font-weight: 600;
}

.card-gradient-1 { background: linear-gradient(135deg, #667eea, #764ba2); }
.card-gradient-2 { background: linear-gradient(135deg, #f093fb, #f5576c); }
.card-gradient-3 { background: linear-gradient(135deg, #4facfe, #00f2fe); }
.card-gradient-4 { background: linear-gradient(135deg, #43e97b, #38f9d7); }
.card-gradient-5 { background: linear-gradient(135deg, #fa709a, #fee140); }
.card-gradient-6 { background: linear-gradient(135deg, #a18cd1, #fbc2eb); }
.card-gradient-7 { background: linear-gradient(135deg, #fccb90, #d57eeb); }
.card-gradient-8 { background: linear-gradient(135deg, #0f2027, #203a43, #2c5364); }

.card-usage-bar {
  height: 4px;
  background: rgba(255,255,255,0.2);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 0.5rem;
}

.card-usage-fill {
  height: 100%;
  background: white;
  border-radius: 2px;
  transition: width 0.5s ease;
}

/* ============ PROGRESS BAR ============ */
.progress-bar {
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.5s ease;
}

.progress-fill.primary { background: linear-gradient(90deg, var(--primary), var(--primary-light)); }
.progress-fill.income { background: linear-gradient(90deg, #059669, #10b981); }
.progress-fill.expense { background: linear-gradient(90deg, #dc2626, #ef4444); }
.progress-fill.warning { background: linear-gradient(90deg, #d97706, #f59e0b); }

/* ============ GOAL CARDS ============ */
.goal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 0.75rem;
  box-shadow: var(--shadow-sm);
}

.goal-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.goal-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  background: var(--primary-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.goal-info { flex: 1; }
.goal-name { font-size: 0.9rem; font-weight: 700; color: var(--text-primary); }
.goal-deadline { font-size: 0.7rem; color: var(--text-secondary); margin-top: 2px; }

.goal-amounts {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.goal-current { font-size: 0.9rem; font-weight: 700; color: var(--primary); }
.goal-target { font-size: 0.75rem; color: var(--text-secondary); }
.goal-percent { font-size: 0.8rem; font-weight: 700; color: var(--text-primary); }

/* ============ CALENDAR ============ */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 1rem;
}

.calendar-header-day {
  text-align: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  padding: 0.5rem 0;
}

.calendar-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  font-size: 0.8rem;
  color: var(--text-primary);
  padding: 0.25rem;
}

.calendar-day:hover { background: var(--bg-tertiary); }
.calendar-day.today { background: var(--primary); color: white; font-weight: 700; }
.calendar-day.other-month { color: var(--text-tertiary); }
.calendar-day.has-events::after {
  content: '';
  position: absolute;
  bottom: 3px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--primary);
}

.calendar-day.today.has-events::after { background: white; }
.calendar-day.has-expense::after { background: var(--expense); }
.calendar-day.has-income::after { background: var(--income); }

/* ============ SETTINGS ============ */
.settings-section {
  margin-bottom: 1.5rem;
}

.settings-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0 0.25rem;
  margin-bottom: 0.5rem;
}

.settings-item {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.875rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.4rem;
  cursor: pointer;
  transition: all var(--transition);
}

.settings-item:hover { border-color: var(--primary); }
.settings-item:active { transform: scale(0.99); }

.settings-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.settings-info { flex: 1; }
.settings-label { font-size: 0.875rem; font-weight: 600; color: var(--text-primary); }
.settings-desc { font-size: 0.7rem; color: var(--text-secondary); margin-top: 1px; }

.settings-action { color: var(--text-tertiary); font-size: 0.8rem; }

/* Toggle switch */
.toggle {
  width: 46px;
  height: 26px;
  background: var(--border);
  border-radius: var(--radius-full);
  position: relative;
  cursor: pointer;
  transition: background var(--transition);
  flex-shrink: 0;
}

.toggle.active { background: var(--primary); }

.toggle::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  transition: transform var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle.active::after { transform: translateX(20px); }

/* ============ CATEGORY GRID ============ */
.category-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.category-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 0.75rem 0.4rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  border: 2px solid transparent;
}

.category-item:hover { transform: scale(1.02); }
.category-item.selected { border-color: var(--primary); }

.category-item-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.category-item-name {
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.2;
}

/* ============ TABS ============ */
.tabs {
  display: flex;
  background: var(--bg-tertiary);
  border-radius: var(--radius);
  padding: 3px;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
}

.tab-btn {
  flex: 1;
  padding: 0.55rem 0.5rem;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.775rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
}

.tab-btn.active {
  background: var(--bg-card);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* ============ EMPTY STATE ============ */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-secondary);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.4;
}

.empty-state-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.empty-state-desc {
  font-size: 0.825rem;
  line-height: 1.6;
}

/* ============ ALERTS ============ */
.alert {
  padding: 0.875rem 1rem;
  border-radius: var(--radius);
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  font-size: 0.825rem;
}

.alert-icon { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }
.alert-content { flex: 1; }
.alert-title { font-weight: 600; margin-bottom: 2px; }

.alert-warning { background: var(--warning-bg); color: #92400e; border: 1px solid rgba(245,158,11,0.25); }
.alert-danger { background: var(--expense-bg); color: #991b1b; border: 1px solid rgba(239,68,68,0.25); }
.alert-success { background: var(--income-bg); color: #065f46; border: 1px solid rgba(16,185,129,0.25); }
.alert-info { background: var(--info-bg); color: #1e40af; border: 1px solid rgba(59,130,246,0.25); }

[data-theme="dark"] .alert-warning { color: #fbbf24; }
[data-theme="dark"] .alert-danger { color: #f87171; }
[data-theme="dark"] .alert-success { color: #34d399; }
[data-theme="dark"] .alert-info { color: #60a5fa; }

/* ============ TOAST ============ */
.toast-container {
  position: fixed;
  top: calc(var(--header-height) + 0.75rem);
  left: 50%;
  transform: translateX(-50%);
  z-index: 9000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: calc(100% - 2rem);
  max-width: 440px;
  pointer-events: none;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: var(--shadow-md);
  animation: slideDown 0.3s ease;
  pointer-events: all;
  font-size: 0.85rem;
  font-weight: 500;
}

.toast.success { border-left: 3px solid var(--income); }
.toast.error { border-left: 3px solid var(--expense); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.info { border-left: 3px solid var(--primary); }

.toast-icon { font-size: 1rem; }
.toast.success .toast-icon { color: var(--income); }
.toast.error .toast-icon { color: var(--expense); }
.toast.warning .toast-icon { color: var(--warning); }
.toast.info .toast-icon { color: var(--primary); }

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============ BADGE ============ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-primary { background: var(--primary-bg); color: var(--primary); }
.badge-income { background: var(--income-bg); color: var(--income); }
.badge-expense { background: var(--expense-bg); color: var(--expense); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }

/* ============ INSTALLMENT BADGE ============ */
.installment-badge {
  font-size: 0.65rem;
  background: var(--primary-bg);
  color: var(--primary);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

/* ============ DATE NAV ============ */
.date-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.875rem;
  margin-bottom: 1rem;
}

.date-nav-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition);
}

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

.date-nav-label {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: capitalize;
}

/* ============ LOADING ============ */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

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

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

/* ============ ICON COLOR PICKER ============ */
.color-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.color-option {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  transition: transform var(--transition);
  border: 2px solid transparent;
}

.color-option:hover { transform: scale(1.1); }
.color-option.selected { border-color: white; box-shadow: 0 0 0 2px var(--text-primary); }

/* ============ REPORT ROWS ============ */
.report-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--divider);
}

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

.report-row-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.report-row-info { flex: 1; min-width: 0; }
.report-row-name { font-size: 0.85rem; font-weight: 600; color: var(--text-primary); }
.report-row-bar { margin-top: 4px; }
.report-row-amount { font-size: 0.875rem; font-weight: 700; color: var(--text-primary); text-align: right; }
.report-row-pct { font-size: 0.7rem; color: var(--text-secondary); text-align: right; margin-top: 2px; }

/* ============ SWIPE ACTIONS ============ */
.swipeable {
  position: relative;
  overflow: hidden;
}

.swipe-actions {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: stretch;
}

.swipe-action {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 1rem;
  color: white;
  font-size: 1rem;
  cursor: pointer;
}

.swipe-action.edit { background: var(--primary); }
.swipe-action.delete { background: var(--expense); }

/* ============ MONTH SUMMARY ============ */
.month-summary {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.month-summary-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  text-align: center;
}

.month-summary-item .label {
  font-size: 0.6rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.month-summary-item .value {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* ============ INPUT PREFIX ============ */
.input-group {
  display: flex;
  align-items: stretch;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-input);
  transition: border-color var(--transition);
}

.input-group:focus-within { border-color: var(--primary); }

.input-prefix, .input-suffix {
  padding: 0.75rem 0.875rem;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  border: none;
}

.input-group .form-control {
  border: none;
  border-radius: 0;
  flex: 1;
}

.input-group .form-control:focus { border-color: transparent; }

/* ============ RECURRING BADGE ============ */
.recurring-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-bg);
  padding: 2px 7px;
  border-radius: var(--radius-full);
}

/* ============ NOTIFICATION BELL ============ */
.notif-bell {
  position: relative;
}

.notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  background: var(--expense);
  color: white;
  font-size: 0.55rem;
  font-weight: 700;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}

/* ============ RESPONSIVE ============ */
@media (min-width: 480px) {
  #app {
    box-shadow: var(--shadow-lg);
    border-radius: 0;
  }
}

@media (max-width: 360px) {
  .category-grid { grid-template-columns: repeat(3, 1fr); }
  .stats-grid { grid-template-columns: 1fr; }
}

/* ============ SAFE AREA ============ */
@supports (padding: max(0px)) {
  .bottom-nav {
    padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
    height: calc(var(--nav-height) + env(safe-area-inset-bottom));
  }
  
  .app-main {
    padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 1rem);
  }
}

/* ============ ANIMATIONS ============ */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.animate-pulse { animation: pulse 2s ease infinite; }

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

.skeleton {
  background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-card) 50%, var(--bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

/* ============ MISC ============ */
.divider {
  height: 1px;
  background: var(--border);
  margin: 1rem 0;
}

.text-income { color: var(--income) !important; }
.text-expense { color: var(--expense) !important; }
.text-warning { color: var(--warning) !important; }
.text-primary-c { color: var(--primary) !important; }
.text-muted { color: var(--text-secondary) !important; }
.text-sm { font-size: 0.8rem; }
.text-xs { font-size: 0.7rem; }
.font-bold { font-weight: 700; }
.font-medium { font-weight: 500; }

.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.w-full { width: 100%; }
