/* ============================================
   FINANCEIRO APP - Design System
   ============================================ */

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

/* ---------- CSS Variables ---------- */
:root {
  --bg-primary: #06060f;
  --bg-secondary: #0d0d1a;
  --bg-card: rgba(255, 255, 255, 0.04);
  --bg-card-hover: rgba(255, 255, 255, 0.07);
  --bg-glass: rgba(255, 255, 255, 0.06);
  --border-glass: rgba(255, 255, 255, 0.08);
  --border-glass-hover: rgba(255, 255, 255, 0.15);

  --text-primary: #f0f0f5;
  --text-secondary: #8888a0;
  --text-muted: #55556a;

  --accent-green: #10b981;
  --accent-green-glow: rgba(16, 185, 129, 0.25);
  --accent-green-soft: rgba(16, 185, 129, 0.12);
  --accent-red: #ef4444;
  --accent-red-soft: rgba(239, 68, 68, 0.12);
  --accent-yellow: #f59e0b;
  --accent-yellow-soft: rgba(245, 158, 11, 0.12);
  --accent-blue: #3b82f6;
  --accent-blue-soft: rgba(59, 130, 246, 0.12);
  --accent-purple: #8b5cf6;
  --accent-purple-soft: rgba(139, 92, 246, 0.12);
  --accent-cyan: #06b6d4;
  --accent-cyan-soft: rgba(6, 182, 212, 0.12);

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

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px var(--accent-green-glow);

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --transition-slow: 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

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

/* Background animated gradient */
body::before {
  content: '';
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(ellipse at 20% 50%, rgba(16, 185, 129, 0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(59, 130, 246, 0.03) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(139, 92, 246, 0.03) 0%, transparent 50%);
  z-index: 0;
  animation: bgFloat 20s ease-in-out infinite;
}

@keyframes bgFloat {

  0%,
  100% {
    transform: translate(0, 0);
  }

  33% {
    transform: translate(-2%, 1%);
  }

  66% {
    transform: translate(2%, -1%);
  }
}

/* ---------- Layout ---------- */
.app-container {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 100px;
}

/* ---------- Header ---------- */
.app-header {
  text-align: center;
  padding: 32px 0 40px;
  animation: fadeInDown 0.6s ease;
}

.app-header h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--accent-green) 0%, var(--accent-cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 4px;
}

.app-header .subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 400;
}

.month-selector {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
  flex: 1;
  position: relative;
  z-index: 501;
}

.month-selector button {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  font-size: 1rem;
}

.month-selector button:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-glass-hover);
  color: var(--text-primary);
}

.month-selector .current-month {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  min-width: 180px;
  text-align: center;
}

/* ---------- Top Navigation ---------- */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 500;
  background: var(--bg-primary);
  /* Changed from var(--bg-main) to var(--bg-primary) as --bg-main is not defined */
  border-bottom: 1px solid var(--border-glass);
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ---------- Sidebar Menu ---------- */
.sidebar-overlay {
  display: flex;
  /* Override when active */
  visibility: hidden;
  opacity: 0;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  transition: all var(--transition-normal);
}

.sidebar-overlay.active {
  visibility: visible;
  opacity: 1;
}

.sidebar-menu {
  position: fixed;
  top: 0;
  left: -320px;
  bottom: 0;
  width: 280px;
  max-width: 80vw;
  background: var(--bg-card);
  border-right: 1px solid var(--border-glass);
  z-index: 1001;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
  transition: left var(--transition-normal);
}

.sidebar-menu.active {
  left: 0;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

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

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--bg-glass);
  border-radius: var(--radius-md);
  margin-bottom: 24px;
}

.user-avatar {
  font-size: 1.5rem;
  background: var(--bg-main);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.sidebar-user .user-email {
  font-size: 0.9rem;
  color: var(--text-secondary);
  word-break: break-all;
}

.sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.sidebar-actions button {
  background: transparent;
  border: none;
  color: var(--text-primary);
  text-align: left;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all var(--transition-fast);
}

.sidebar-actions button:hover {
  background: var(--bg-glass-hover);
}

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid var(--border-glass);
  padding-top: 16px;
}

.sidebar-footer button {
  width: 100%;
  justify-content: center;
}

/* ---------- Navigation ---------- */
.nav-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 4px;
  margin-bottom: 32px;
  animation: fadeInUp 0.5s ease 0.1s both;
}

.nav-tab {
  flex: 1;
  padding: 10px 16px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-normal);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}

.nav-tab:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
}

.nav-tab.active {
  background: var(--accent-green);
  color: #fff;
  font-weight: 600;
  box-shadow: var(--shadow-glow);
}

.nav-tab .tab-icon {
  font-size: 1rem;
}

/* ---------- Section ---------- */
.section {
  display: none;
  animation: fadeInUp 0.4s ease;
}

.section.active {
  display: block;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-title .icon {
  font-size: 1.3rem;
}

/* ---------- Summary Cards (Dashboard) ---------- */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.summary-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 20px;
  backdrop-filter: blur(10px);
  transition: all var(--transition-normal);
  animation: fadeInUp 0.5s ease both;
}

.summary-card:nth-child(1) {
  animation-delay: 0.1s;
}

.summary-card:nth-child(2) {
  animation-delay: 0.15s;
}

.summary-card:nth-child(3) {
  animation-delay: 0.2s;
}

.summary-card:nth-child(4) {
  animation-delay: 0.25s;
}

.summary-card:hover {
  border-color: var(--border-glass-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.summary-card .card-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.summary-card .card-value {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.summary-card .card-detail {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.summary-card.income .card-value {
  color: var(--accent-green);
}

.summary-card.expenses .card-value {
  color: var(--accent-red);
}

.summary-card.balance .card-value {
  color: var(--accent-blue);
}

.summary-card.balance.negative .card-value {
  color: var(--accent-red);
}

.summary-card.goals .card-value {
  color: var(--accent-purple);
}

.card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  margin-bottom: 12px;
}

.income .card-icon {
  background: var(--accent-green-soft);
}

.expenses .card-icon {
  background: var(--accent-red-soft);
}

.balance .card-icon {
  background: var(--accent-blue-soft);
}

.goals .card-icon {
  background: var(--accent-purple-soft);
}

/* ---------- Income Section ---------- */
.income-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.income-item {
  display: grid;
  grid-template-columns: 40px 1fr auto auto;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  transition: all var(--transition-normal);
  animation: fadeInUp 0.3s ease both;
  position: relative;
  z-index: 1;
}

.income-item:hover,
.income-item:focus-within {
  border-color: var(--border-glass-hover);
  background: var(--bg-card-hover);
  z-index: 10 !important;
}

.income-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--accent-green-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

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

.income-name {
  font-weight: 500;
  font-size: 0.9rem;
}

.income-day {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.income-value {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--accent-green);
  text-align: right;
  min-width: 100px;
}

/* ---------- Expense Table ---------- */
.expense-section {
  margin-bottom: 28px;
}

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

.expense-section-header h3 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.expense-section-header .section-total {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-red);
}

.expense-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.expense-item {
  display: grid;
  grid-template-columns: 40px 1fr auto auto auto;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  transition: all var(--transition-normal);
  animation: fadeInUp 0.3s ease both;
  position: relative;
  /* ensure z-index applies */
  z-index: 1;
}

.expense-item:hover,
.expense-item:focus-within {
  border-color: var(--border-glass-hover);
  background: var(--bg-card-hover);
  z-index: 10;
  /* Bring hovered row to front so dropdown overlaps rows below */
}

.expense-item.inactive {
  opacity: 0.4;
}

.expense-item .toggle-btn {
  width: 36px;
  height: 20px;
  border-radius: var(--radius-full);
  border: none;
  background: var(--text-muted);
  cursor: pointer;
  position: relative;
  transition: all var(--transition-fast);
}

.expense-item .toggle-btn.active {
  background: var(--accent-green);
}

.expense-item .toggle-btn::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  transition: transform var(--transition-fast);
}

.expense-item .toggle-btn.active::after {
  transform: translateX(16px);
}

.expense-name {
  font-weight: 500;
  font-size: 0.9rem;
}

.expense-name .installment {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 6px;
}

.expense-due {
  font-size: 0.78rem;
  color: var(--text-secondary);
  text-align: right;
  min-width: 60px;
}

.expense-value {
  font-weight: 600;
  font-size: 0.9rem;
  text-align: right;
  min-width: 90px;
}

.expense-actions {
  display: flex;
  gap: 4px;
}

.expense-actions button {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  font-size: 0.85rem;
}

.expense-actions button:hover {
  color: var(--text-primary);
  background: var(--bg-glass);
}

.expense-actions button.delete:hover {
  color: var(--accent-red);
}

/* ---------- Shopping List ---------- */
.shopping-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.shopping-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  transition: all var(--transition-normal);
  animation: fadeInUp 0.3s ease both;
  position: relative;
  z-index: 1;
}

.shopping-item:hover,
.shopping-item:focus-within {
  border-color: var(--border-glass-hover);
  background: var(--bg-card-hover);
  z-index: 10 !important;
}

.shopping-item.bought {
  opacity: 0.4;
}

.shopping-item.bought .shopping-name {
  text-decoration: line-through;
}

.shopping-checkbox {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 2px solid var(--text-muted);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  flex-shrink: 0;
  font-size: 0.75rem;
  color: transparent;
}

.shopping-checkbox:hover {
  border-color: var(--accent-green);
}

.shopping-checkbox.checked {
  background: var(--accent-green);
  border-color: var(--accent-green);
  color: white;
}

.shopping-name {
  flex: 1;
  font-weight: 500;
  font-size: 0.9rem;
}

.shopping-value {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-secondary);
  min-width: 80px;
  text-align: right;
}

.shopping-actions {
  display: flex;
  gap: 4px;
}

.shopping-actions button {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  font-size: 0.85rem;
}

.shopping-actions button:hover {
  color: var(--text-primary);
  background: var(--bg-glass);
}

.shopping-actions button.delete:hover {
  color: var(--accent-red);
}

/* ---------- Goals ---------- */
.goals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.goal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: all var(--transition-normal);
  animation: fadeInUp 0.5s ease both;
  position: relative;
  overflow: hidden;
}

.goal-card:nth-child(1) {
  animation-delay: 0.1s;
}

.goal-card:nth-child(2) {
  animation-delay: 0.15s;
}

.goal-card:nth-child(3) {
  animation-delay: 0.2s;
}

.goal-card:nth-child(4) {
  animation-delay: 0.25s;
}

.goal-card:hover {
  border-color: var(--border-glass-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.goal-card .goal-icon {
  font-size: 2rem;
  margin-bottom: 12px;
}

.goal-card .goal-name {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.goal-card .goal-target {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.goal-progress-bar {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: 8px;
}

.goal-progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--accent-green), var(--accent-cyan));
  transition: width 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.goal-progress-text {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.goal-saved {
  font-weight: 600;
  color: var(--accent-green);
}

.goal-card .goal-actions {
  margin-top: 16px;
  display: flex;
  gap: 8px;
}

.goal-card .goal-actions button {
  flex: 1;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-glass);
  background: var(--bg-glass);
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.goal-card .goal-actions button:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--border-glass-hover);
}

.goal-card .goal-actions button.primary {
  background: var(--accent-green-soft);
  color: var(--accent-green);
  border-color: transparent;
}

.goal-card .goal-actions button.primary:hover {
  background: var(--accent-green);
  color: white;
}

.goal-card.completed {
  border-color: var(--accent-green);
}

.goal-card.completed::after {
  content: '✓';
  position: absolute;
  top: 16px;
  right: 16px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-green);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
}

/* ---------- Add Button ---------- */
.add-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px;
  border: 2px dashed var(--border-glass);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-normal);
  margin-top: 12px;
}

.add-button:hover {
  border-color: var(--accent-green);
  color: var(--accent-green);
  background: var(--accent-green-soft);
}

/* ---------- Modal ---------- */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-xl);
  padding: 32px;
  max-width: 440px;
  width: 90%;
  animation: modalIn 0.3s ease;
  max-height: 90vh;
  overflow-y: auto;
}

.modal h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 20px;
}

.modal-field {
  margin-bottom: 16px;
}

.modal-field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.modal-field input,
.modal-field select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  transition: border-color var(--transition-fast);
  outline: none;
}

.modal-field input:focus,
.modal-field select:focus {
  border-color: var(--accent-green);
}

.modal-field select {
  background-color: var(--bg-card);
  color: var(--text-primary);
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23f0f0f5' 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;
  background-position: right 14px center;
  background-size: 16px;
  cursor: pointer;
}

.modal-field select option {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}

.modal-field input::placeholder {
  color: var(--text-muted);
}

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.modal-actions button {
  flex: 1;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
}

.btn-cancel {
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border-glass) !important;
}

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

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

.btn-save:hover {
  background: #0ea572;
  box-shadow: var(--shadow-glow);
}

/* ---------- Dashboard Expense Preview ---------- */
.dash-expense-preview {
  margin-top: 8px;
}

.dash-expense-preview h3 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}

.dash-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dash-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  font-size: 0.83rem;
}

.dash-item .dash-name {
  color: var(--text-secondary);
  font-weight: 400;
}

.dash-item .dash-value {
  font-weight: 600;
  color: var(--text-primary);
}

/* ---------- Animations ---------- */
@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .app-container {
    padding: 16px 12px 100px;
  }

  .app-header h1 {
    font-size: 1.5rem;
  }

  .nav-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .nav-tab {
    padding: 8px 12px;
    font-size: 0.75rem;
  }

  .nav-tab .tab-label {
    display: none;
  }

  .nav-tab .tab-icon {
    font-size: 1.1rem;
  }

  .summary-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .summary-card {
    padding: 14px;
  }

  .summary-card .card-value {
    font-size: 1.2rem;
  }

  .expense-item {
    grid-template-columns: 36px 1fr auto;
    gap: 8px;
    padding: 10px 12px;
  }

  .expense-due {
    display: none;
  }

  .expense-actions {
    display: none;
  }

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

@media (max-width: 480px) {
  .summary-grid {
    grid-template-columns: 1fr;
  }
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* ---------- Paid Badge ---------- */
.paid-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.paid-badge.paid {
  background: var(--accent-green-soft);
  color: var(--accent-green);
}

.paid-badge.pending {
  background: var(--accent-yellow-soft);
  color: var(--accent-yellow);
}

.paid-badge.overdue {
  background: var(--accent-red-soft);
  color: var(--accent-red);
}

/* ---------- Income Section ---------- */
.income-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 32px;
}

.income-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  transition: all var(--transition-normal);
}

.income-item:hover {
  border-color: var(--accent-green);
  background: var(--bg-card-hover);
}

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

.income-info {
  flex: 1;
}

.income-name {
  font-weight: 600;
  font-size: 0.9rem;
}

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

.income-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-green);
}

/* ---------- Empty State ---------- */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

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

/* ---------- Item Notes ---------- */
.item-notes {
  font-size: 0.73rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 2px;
  font-style: italic;
}

/* ---------- Priority Badges ---------- */
.priority-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  flex-shrink: 0;
}

.priority-high {
  background: var(--accent-red-soft);
  color: var(--accent-red);
}

.priority-medium {
  background: var(--accent-yellow-soft);
  color: var(--accent-yellow);
}

.priority-low {
  background: var(--accent-green-soft);
  color: var(--accent-green);
}

/* ---------- Dashboard Due Dates ---------- */
.dash-due {
  display: inline-block;
  margin-left: 8px;
  font-size: 0.7rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
  padding: 1px 7px;
  border-radius: var(--radius-full);
  font-weight: 500;
}

.dash-due.overdue {
  background: var(--accent-red-soft);
  color: var(--accent-red);
  font-weight: 600;
}

.dash-due.due-soon {
  background: var(--accent-yellow-soft);
  color: var(--accent-yellow);
  font-weight: 600;
}

/* ---------- Login Screen ---------- */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  position: relative;
  z-index: 1;
  padding: 20px;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-xl);
  padding: 40px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  backdrop-filter: blur(16px);
  animation: modalIn 0.5s ease;
}

.login-icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

.login-title {
  font-size: 1.8rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent-green) 0%, var(--accent-cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 4px;
}

.login-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 28px;
}

.login-form .modal-field {
  text-align: left;
}

.login-btn {
  width: 100%;
  padding: 14px;
  font-size: 1rem;
  font-weight: 600;
  margin-top: 8px;
  background: linear-gradient(135deg, var(--accent-green), #27ae60);
  border: none;
  box-shadow: 0 4px 15px rgba(46, 204, 113, 0.2);
  transition: all var(--transition-normal);
}

.login-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(46, 204, 113, 0.3);
  filter: brightness(1.1);
}

.login-btn:active {
  transform: translateY(0);
}

.login-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 16px 0;
  color: var(--text-muted);
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border-glass);
}

.login-divider span {
  padding: 0 10px;
  font-size: 0.8rem;
  text-transform: uppercase;
}

.google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 10px;
  background: white;
  color: #3c4043;
  border: 1px solid #dadce0;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.google-btn:hover {
  background: #f8f9fa;
}

.google-btn img {
  width: 18px;
  height: 18px;
}

.login-link {
  color: var(--accent-green);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 500;
  transition: opacity 0.2s;
}

.login-link:hover {
  text-decoration: underline;
  opacity: 0.8;
}

.login-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 12px;
}

.login-success-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

.login-message p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.login-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.login-loading p {
  color: var(--text-muted);
  font-size: 0.85rem;
}

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

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

/* ---------- Header Top ---------- */
.header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.header-top>div:nth-child(2) {
  text-align: center;
  flex: 1;
}

.user-menu {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  min-width: 100px;
}

.user-email {
  font-size: 0.7rem;
  color: var(--text-muted);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-btn {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.logout-btn:hover {
  background: var(--accent-red-soft);
  color: var(--accent-red);
  border-color: var(--accent-red);
}

@media (max-width: 768px) {
  .header-top {
    flex-direction: column;
    align-items: center;
    gap: 12px;
  }

  .header-top>div:first-child {
    display: none;
  }

  .user-menu {
    flex-direction: row;
    align-items: center;
    min-width: auto;
  }
}

/* ---------- Activity Log ---------- */
.activity-log {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.log-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  transition: all var(--transition-normal);
}

.log-item:hover {
  border-color: var(--border-glass-hover);
  background: var(--bg-card-hover);
}

.log-action {
  font-size: 1.1rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.log-info {
  flex: 1;
}

.log-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.log-text strong {
  color: var(--text-primary);
}

.log-name {
  color: var(--accent-green);
  font-weight: 500;
}

.log-detail {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.log-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ---------- Actions Menu Dropdown ---------- */
.actions-container {
  position: relative;
  display: flex;
  justify-content: flex-end;
}

.btn-actions {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.btn-actions:hover {
  background: var(--bg-glass);
  color: var(--text-primary);
}

.actions-menu {
  position: absolute;
  right: 0;
  top: 100%;
  background-color: #1a1f2e !important;
  background: #1a1f2e !important;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
  border-radius: var(--radius-md);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.8) !important;
  z-index: 9999 !important;
  min-width: 150px;
  display: none;
  overflow: hidden;
  margin-top: 4px;
  opacity: 1 !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

.note-icon {
  cursor: pointer;
  font-size: 1rem;
  transition: transform var(--transition-fast);
}

.note-icon:hover {
  transform: scale(1.2);
}

/* ---------- Custom Popup ---------- */
.popup-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 9999;
  justify-content: center;
  align-items: center;
}

.popup-overlay.active {
  display: flex;
  animation: popupFadeIn 0.2s ease-out;
}

@keyframes popupFadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.popup-box {
  background: #1a1f2e;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  padding: 28px 24px 20px;
  max-width: 400px;
  width: 90%;
  text-align: center;
  animation: popupSlideUp 0.25s ease-out;
}

@keyframes popupSlideUp {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.popup-icon {
  font-size: 2.2rem;
  margin-bottom: 12px;
}

.popup-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.popup-message {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 20px;
  white-space: pre-wrap;
  word-break: break-word;
}

.popup-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.popup-actions button {
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition-fast);
}

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

.popup-btn-confirm:hover {
  background: #0ea572;
}

.popup-btn-cancel {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
}

.popup-btn-cancel:hover {
  background: rgba(255, 255, 255, 0.14);
  color: var(--text-primary);
}

.popup-btn-ok {
  background: var(--accent-blue);
  color: #fff;
  min-width: 100px;
}

.popup-btn-ok:hover {
  background: #3370d6;
}

.actions-menu.active {
  display: block;
  animation: slideIn 0.2s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.actions-menu button {
  width: 100%;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border-glass);
  color: var(--text-secondary);
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.actions-menu button:last-child {
  border-bottom: none;
}

.actions-menu button:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
}

.actions-menu button.delete:hover {
  color: var(--accent-red);
}

/* ---------- Text Truncation ---------- */
.ellipsis {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.item-notes-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  max-width: 100%;
  display: inline-block;
  vertical-align: middle;
}

@media (max-width: 600px) {
  .expense-row {
    grid-template-columns: 1fr auto auto;
    /* Name, Value, Actions */
    gap: 8px;
  }

  .expense-row>div:nth-child(2),
  /* Venc. skip */
  .expense-row>div:nth-child(3) {
    /* Cat. skip */
    display: none;
  }

  .expense-name {
    max-width: 180px;
  }

  .shopping-item {
    padding: 10px 12px;
  }

  .shopping-name {
    flex: 1;
    min-width: 0;
  }

  .item-notes {
    max-width: 150px;
  }
}

/* ---------- Chatbot Widget ---------- */
.chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-green) 0%, var(--accent-cyan) 100%);
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(16, 185, 129, 0.4);
  z-index: 999;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 28px rgba(16, 185, 129, 0.6);
}

.chat-widget {
  position: fixed;
  bottom: 90px;
  right: 24px;
  width: 380px;
  max-height: 500px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-xl);
  backdrop-filter: blur(20px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  z-index: 1000;
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: chatIn 0.3s ease;
}

.chat-widget.active {
  display: flex;
}

@keyframes chatIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(6, 182, 212, 0.1));
  border-bottom: 1px solid var(--border-glass);
  font-weight: 600;
  font-size: 0.9rem;
}

.chat-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px;
  transition: color 0.2s;
}

.chat-close:hover {
  color: var(--text-primary);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 340px;
  min-height: 200px;
}

.chat-msg {
  display: flex;
  gap: 8px;
  animation: fadeInUp 0.3s ease;
}

.chat-msg.user {
  justify-content: flex-end;
}

.chat-msg.bot {
  justify-content: flex-start;
}

.chat-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.83rem;
  line-height: 1.5;
  word-wrap: break-word;
}

.chat-msg.user .chat-bubble {
  background: linear-gradient(135deg, var(--accent-green), var(--accent-cyan));
  color: white;
  border-bottom-right-radius: 4px;
}

.chat-msg.bot .chat-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 2px 0;
}

.chat-suggestions button {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
  font-size: 0.72rem;
  padding: 5px 10px;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: all 0.2s;
}

.chat-suggestions button:hover {
  background: var(--accent-green-soft);
  border-color: var(--accent-green);
  color: var(--accent-green);
}

.chat-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border-glass);
  background: var(--bg-card);
}

.chat-input-area input {
  flex: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-full);
  padding: 8px 14px;
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 0.83rem;
  outline: none;
  transition: border-color 0.2s;
}

.chat-input-area input:focus {
  border-color: var(--accent-green);
}

.chat-input-area input::placeholder {
  color: var(--text-muted);
}

.chat-input-area button {
  background: linear-gradient(135deg, var(--accent-green), var(--accent-cyan));
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
  flex-shrink: 0;
}

.chat-input-area button:hover {
  transform: scale(1.1);
}

/* Chat bubble list formatting */
.chat-bubble ul {
  margin: 6px 0 2px 0;
  padding-left: 16px;
}

.chat-bubble li {
  margin-bottom: 3px;
  font-size: 0.8rem;
}

.chat-bubble strong {
  color: var(--accent-green);
}

/* Responsive chat */
@media (max-width: 480px) {
  .chat-widget {
    width: calc(100% - 16px);
    right: 8px;
    bottom: 80px;
    max-height: 70vh;
  }

  .chat-fab {
    bottom: 16px;
    right: 16px;
    width: 48px;
    height: 48px;
    font-size: 1.3rem;
  }
}

/* ---------- Form Select Overrides ---------- */
select {
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-glass);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  width: 100%;
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  cursor: pointer;
}

select:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 2px rgba(0, 240, 255, 0.15);
}

select option {
  background-color: #1a1b1f;
  /* dark fallback */
  color: #ffffff;
}