/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
  --green-900: #1b4332;
  --green-700: #2d6a4f;
  --green-600: #40916c;
  --green-400: #74c69d;
  --green-100: #d8f3dc;
  --green-50:  #f0faf4;

  --gray-900: #111827;
  --gray-700: #374151;
  --gray-500: #6b7280;
  --gray-300: #d1d5db;
  --gray-100: #f3f4f6;
  --gray-50:  #f9fafb;
  --white:    #ffffff;

  --red-500:  #ef4444;
  --red-50:   #fef2f2;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);

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

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

html { font-size: 16px; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--gray-900);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

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

/* ============================================================
   UTILITY
   ============================================================ */
.hidden { display: none !important; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  white-space: nowrap;
  text-decoration: none;
}

.btn:active { transform: translateY(1px); }

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

.btn-secondary {
  background: var(--gray-100);
  color: var(--gray-700);
}
.btn-secondary:hover { background: var(--gray-300); }

.btn-ghost {
  background: transparent;
  color: var(--gray-700);
}
.btn-ghost:hover { background: var(--gray-100); }

.btn-danger {
  background: var(--red-50);
  color: var(--red-500);
}
.btn-danger:hover { background: var(--red-500); color: var(--white); }

.btn-google {
  background: var(--white);
  color: var(--gray-700);
  border: 1.5px solid var(--gray-300);
  font-weight: 500;
}
.btn-google:hover { background: var(--gray-50); box-shadow: var(--shadow-sm); }

.btn-full { width: 100%; }

.btn-sm { padding: 6px 14px; font-size: 0.82rem; }

.btn-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}

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

/* ============================================================
   FORMS
   ============================================================ */
.form-group { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }

.form-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--gray-700);
}

.form-input {
  padding: 10px 14px;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--gray-900);
  transition: border-color 0.15s, box-shadow 0.15s;
  font-size: 0.9rem;
  min-width: 0;
  width: 100%;
}

input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type=number] { -moz-appearance: textfield; }
.form-input:focus {
  outline: none;
  border-color: var(--green-600);
  box-shadow: 0 0 0 3px rgba(64, 145, 108, 0.15);
}
.form-input::placeholder { color: var(--gray-500); }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* ============================================================
   ERROR BANNER
   ============================================================ */
.error-banner {
  background: var(--red-50);
  color: var(--red-500);
  border: 1px solid #fca5a5;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.87rem;
  margin-bottom: 12px;
}

/* ============================================================
   PROGRESS BAR
   ============================================================ */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--gray-100);
  border-radius: 99px;
  overflow: hidden;
}

.progress-bar-lg { height: 14px; }

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green-600), var(--green-400));
  border-radius: 99px;
  transition: width 0.5s ease;
}

.progress-fill.complete {
  background: linear-gradient(90deg, #16a34a, #4ade80);
}

/* ============================================================
   NAVBAR
   ============================================================ */
.navbar {
  height: 60px;
  background: var(--white);
  border-bottom: 1px solid var(--gray-200, #e5e7eb);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--green-900);
}

.navbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--green-100);
  display: none;
}
.user-avatar.visible { display: block; }

.user-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--gray-700);
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.app-page { background: var(--gray-50); min-height: 100vh; }

.main-content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 32px 64px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 32px;
}

.page-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 4px;
}

.page-subtitle {
  font-size: 0.9rem;
  color: var(--gray-500);
}

/* ============================================================
   GOALS GRID
   ============================================================ */
.goals-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.loading-state {
  color: var(--gray-500);
  font-size: 0.9rem;
  padding: 24px 0;
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 64px 24px;
  color: var(--gray-500);
}

.empty-state-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state h3 { font-size: 1.1rem; color: var(--gray-700); margin-bottom: 8px; }
.empty-state p { font-size: 0.9rem; margin-bottom: 20px; }

/* ============================================================
   GOAL CARD
   ============================================================ */
.goal-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.15s;
  border: 1.5px solid transparent;
  text-decoration: none;
  color: inherit;
  display: block;
}

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

.goal-card.complete { border-color: var(--green-100); background: var(--green-50); }

.goal-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 8px;
}

.goal-card-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-900);
  line-height: 1.3;
}

.goal-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 99px;
  white-space: nowrap;
  flex-shrink: 0;
}

.goal-badge-complete {
  background: var(--green-100);
  color: var(--green-700);
}

.goal-card-progress { margin-bottom: 10px; }

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

.goal-card-saved {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gray-900);
}

.goal-card-target {
  font-size: 0.82rem;
  color: var(--gray-500);
}

.goal-card-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 12px;
  font-size: 0.8rem;
  color: var(--gray-500);
  border-top: 1px solid var(--gray-100);
  padding-top: 10px;
}

.goal-card-meta span { font-weight: 500; }

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}

.modal {
  background: var(--white);
  border-radius: var(--radius-xl);
  padding: 24px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  position: relative;
}

.modal-sm { max-width: 360px; }

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

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--gray-900);
}

.modal-subtitle {
  color: var(--gray-500);
  font-size: 0.9rem;
  text-align: center;
  margin-bottom: 4px;
}

.modal-close {
  background: var(--gray-100);
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--gray-500);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.modal-close:hover { background: var(--gray-300); }

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

.modal-actions-center { justify-content: center; }

/* Goal preview in add-goal modal */
.goal-preview {
  background: var(--green-50);
  border: 1.5px solid var(--green-100);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
}

.goal-preview-item { display: flex; flex-direction: column; gap: 2px; }
.goal-preview-label { font-size: 0.78rem; color: var(--gray-500); }
.goal-preview-value { font-size: 1rem; font-weight: 700; color: var(--green-700); }

/* Celebrate modal */
.modal-celebrate { text-align: center; }
.celebrate-icon { font-size: 3.5rem; margin-bottom: 8px; }
.celebrate-goal-name {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--green-700);
  margin-bottom: 4px;
}
.celebrate-amount {
  font-size: 0.9rem;
  color: var(--gray-500);
  margin-bottom: 20px;
}

/* ============================================================
   AUTH PAGE
   ============================================================ */
.auth-page {
  background: var(--white);
  min-height: 100vh;
}

.auth-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
}

/* Hero side */
.auth-hero {
  background: linear-gradient(135deg, var(--green-900) 0%, var(--green-700) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 64px 56px;
  color: white;
}

.auth-hero-content {
  max-width: 440px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 48px;
  color: white;
}

.auth-hero h1 {
  font-size: 2.4rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 20px;
}

.auth-hero p {
  font-size: 1rem;
  color: rgba(255,255,255,0.75);
  line-height: 1.6;
  margin-bottom: 36px;
}

.hero-features-card {
  display: flex;
  align-items: stretch;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-md);
  padding: 16px;
  gap: 0;
}

.hero-feature {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
  flex: 1;
  padding: 0 16px;
  font-size: 0.82rem;
  color: rgba(255,255,255,0.85);
  line-height: 1.4;
}

.hero-feature-icon { font-size: 1.4rem; }

.hero-feature-divider {
  width: 1px;
  background: rgba(255,255,255,0.2);
  flex-shrink: 0;
}

/* Form side */
.auth-form-side {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 40px;
  background: var(--white);
}

.auth-card { width: 100%; max-width: 400px; }

.auth-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--gray-100);
  margin-bottom: 24px;
}

.auth-tab {
  flex: 1;
  background: none;
  border: none;
  padding: 12px 0;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--gray-500);
  cursor: pointer;
  position: relative;
  transition: color 0.15s;
}
.auth-tab::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--green-700);
  transform: scaleX(0);
  transition: transform 0.2s;
}
.auth-tab.active { color: var(--green-700); }
.auth-tab.active::after { transform: scaleX(1); }

.auth-divider {
  text-align: center;
  position: relative;
  margin: 18px 0;
  color: var(--gray-500);
  font-size: 0.82rem;
}
.auth-divider::before, .auth-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: calc(50% - 20px);
  height: 1px;
  background: var(--gray-300);
}
.auth-divider::before { left: 0; }
.auth-divider::after { right: 0; }

/* Screen Mockup */
.screen-mockup {
  margin: 24px 0;
  border: 6px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  line-height: 0;
}

.screen-mockup img {
  width: 100%;
  display: block;
}

/* ============================================================
   GOAL DETAIL PAGE
   ============================================================ */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--gray-500);
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 20px;
  transition: color 0.15s;
}
.back-link:hover { color: var(--green-700); }

.goal-header {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

.goal-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
}

.goal-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.goal-meta { font-size: 0.85rem; color: var(--gray-500); }

.goal-header-actions { display: flex; gap: 8px; }

.goal-progress-section { margin-bottom: 24px; }

.goal-progress-amounts {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}

.goal-saved-amount {
  font-size: 2rem;
  font-weight: 700;
  color: var(--gray-900);
}

.goal-target-amount {
  font-size: 1rem;
  color: var(--gray-500);
}

.goal-progress-stats {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--gray-500);
  margin-top: 6px;
}

.goal-stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  padding-top: 20px;
  border-top: 1px solid var(--gray-100);
}

.goal-stat { display: flex; flex-direction: column; gap: 4px; }
.goal-stat-label { font-size: 0.78rem; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.04em; }
.goal-stat-value { font-size: 0.95rem; font-weight: 600; color: var(--gray-900); }

/* Section cards */
.section-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 20px;
}

/* Chart */
.chart-container {
  height: 220px;
  position: relative;
}

/* Monthly log list */
.log-list { display: flex; flex-direction: column; gap: 1px; }

.log-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-100);
}
.log-item:last-child { border-bottom: none; }

.log-item-month {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--gray-900);
  min-width: 120px;
}

.log-item-amount {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gray-900);
}

.log-item-not-logged {
  font-size: 0.85rem;
  color: var(--gray-500);
  font-style: italic;
}

.log-item-actions { display: flex; gap: 8px; margin-left: auto; padding-left: 16px; }

/* ============================================================
   RESPONSIVE — MOBILE
   ============================================================ */
@media (max-width: 768px) {
  /* Navbar */
  .navbar { padding: 0 16px; }
  .user-name { display: none; }

  /* Main content */
  .main-content { padding: 20px 16px 48px; }

  /* Page header */
  .page-header {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }

  /* Goals grid — single column on mobile */
  .goals-grid { grid-template-columns: 1fr; }

  /* Goal card meta — keep on one line */
  .goal-card-meta { font-size: 0.78rem; }

  /* Goal detail stats row — 2 columns on mobile */
  .goal-stats-row { grid-template-columns: 1fr 1fr; gap: 12px; }

  /* Section cards */
  .section-card { padding: 16px; }
  .goal-header { padding: 16px; }

  /* Form row — stack on mobile */
  .form-row { grid-template-columns: 1fr; }

  /* Auth layout — stack vertically */
  .auth-layout { grid-template-columns: 1fr; }
  .auth-hero { padding: 40px 24px; min-height: auto; }
  .auth-form-side { padding: 32px 24px; }
  .auth-hero h1 { font-size: 1.8rem; }
  .screen-mockup { margin: 16px 0; }
}
