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

/* ============================================
   CSS VARIABLES
   ============================================ */
:root {
  --primary: #2563EB;
  --primary-light: #3B82F6;
  --primary-dark: #1E40AF;
  --secondary: #F0F7FF;
  --white: #ffffff;
  --success: #10B981;
  --danger: #EF4444;
  --warning: #F59E0B;
  --text-dark: #0F172A;
  --text-mid: #334155;
  --text-light: #64748B;
  --border: #E2E8F0;
  --bg: #F8FAFC;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.04);
  --card-shadow-hover: 0 4px 8px rgba(0,0,0,0.06), 0 12px 32px rgba(0,0,0,0.08);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text-dark);
  background: var(--bg);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.6;
  letter-spacing: -0.01em;
}

/* ============================================
   NAVBAR
   ============================================ */
.navbar {
  background: rgba(255,255,255,0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  gap: 16px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}

.nav-brand .brand-name {
  font-family: 'Playfair Display', serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary-dark);
  line-height: 1.2;
}

.nav-brand .brand-sub {
  font-size: 0.58rem;
  color: var(--text-light);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
  list-style: none;
  margin: 0 auto;
  padding: 0;
}

.nav-links a {
  text-decoration: none;
  color: var(--text-mid);
  font-weight: 500;
  font-size: 0.82rem;
  padding: 8px 14px;
  border-radius: 8px;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.nav-links a:hover { background: var(--secondary); color: var(--primary); }
.nav-links a.active { background: var(--secondary); color: var(--primary); font-weight: 600; }
.nav-links a.btn-nav { 
  background: var(--primary); 
  color: white; 
  padding: 8px 16px; 
  border-radius: 8px;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(37,99,235,0.25);
}
.nav-links a.btn-nav:hover { background: var(--primary-dark); color: white; }

.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  padding: 8px;
  border: none;
  background: none;
}
.hamburger span {
  display: block;
  width: 22px; height: 2px;
  background: var(--text-dark);
  border-radius: 2px;
  transition: var(--transition);
}

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

.auth-area span {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-mid);
  white-space: nowrap;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: -0.01em;
}

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

.btn-primary { background: var(--primary); color: white; box-shadow: 0 2px 8px rgba(37,99,235,0.3); }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 4px 16px rgba(37,99,235,0.4); }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #DC2626; }

.btn-warning { background: var(--warning); color: #1a1a1a; }
.btn-warning:hover { background: #D97706; color: white; }

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

.btn-sm { padding: 7px 14px; font-size: 0.8rem; border-radius: 8px; }
.btn-lg { padding: 14px 28px; font-size: 1rem; border-radius: var(--radius); }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ============================================
   BUTTON LOADING
   ============================================ */
.btn-loading {
  position: relative;
  pointer-events: none;
  opacity: 0.7;
}
.btn-loading::after {
  content: '';
  width: 14px;
  height: 14px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
  margin-left: 8px;
}

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

.card-body { padding: 24px; }
.card-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-header h3 { font-size: 0.95rem; font-weight: 600; color: var(--text-dark); display: flex; align-items: center; gap: 8px; }

/* ============================================
   FORMS
   ============================================ */
.form-group { margin-bottom: 18px; }
.form-label { 
  display: block; 
  font-weight: 600; 
  font-size: 0.82rem; 
  color: var(--text-mid); 
  margin-bottom: 6px; 
}
.form-control {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  color: var(--text-dark);
  background: var(--white);
  transition: var(--transition);
  outline: none;
}
.form-control:focus { 
  border-color: var(--primary-light); 
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1); 
}
.form-control::placeholder { color: #94A3B8; }
select.form-control { 
  cursor: pointer; 
  appearance: none; 
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); 
  background-repeat: no-repeat; 
  background-position: right 14px center; 
  padding-right: 44px; 
}

/* ============================================
   BADGES
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.73rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.badge-primary { background: rgba(59,130,246,0.1); color: var(--primary); }
.badge-success { background: rgba(16,185,129,0.1); color: #059669; }
.badge-danger { background: rgba(239,68,68,0.1); color: #DC2626; }
.badge-warning { background: rgba(245,158,11,0.1); color: #D97706; }
.badge-gray { background: #F1F5F9; color: #64748B; }

/* ============================================
   STATS CARD
   ============================================ */
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px 24px;
  border: 1px solid var(--border);
  box-shadow: var(--card-shadow);
  transition: var(--transition);
}
.stat-card .stat-icon { 
  width: 44px; height: 44px; 
  border-radius: 12px; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  font-size: 1.3rem; 
  margin-bottom: 12px; 
}
.stat-card .stat-value { font-size: 1.75rem; font-weight: 700; color: var(--text-dark); line-height: 1; }
.stat-card .stat-label { font-size: 0.78rem; color: var(--text-light); margin-top: 4px; font-weight: 500; }

/* ============================================
   TOAST
   ============================================ */
.toast-container { 
  position: fixed; top: 80px; right: 24px; z-index: 9999; 
  display: flex; flex-direction: column; gap: 10px; 
  max-width: 360px; 
}
.toast { 
  background: var(--white); 
  border-radius: var(--radius-sm); 
  box-shadow: 0 8px 32px rgba(0,0,0,0.12); 
  padding: 14px 18px; 
  display: flex; 
  align-items: flex-start; 
  gap: 12px; 
  animation: slideInRight 0.35s ease; 
  border-left: 4px solid var(--primary); 
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast-icon { font-size: 1.1rem; margin-top: 1px; flex-shrink: 0; }
.toast-body { flex: 1; }
.toast-title { font-weight: 600; font-size: 0.875rem; color: var(--text-dark); }
.toast-message { font-size: 0.8rem; color: var(--text-light); margin-top: 2px; }
.toast-close { cursor: pointer; color: var(--text-light); font-size: 1.1rem; background: none; border: none; padding: 0; line-height: 1; }

@keyframes slideInRight { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ============================================
   MODAL
   ============================================ */
.modal-overlay { 
  position: fixed; inset: 0; 
  background: rgba(15,23,42,0.4); 
  backdrop-filter: blur(4px);
  z-index: 9000; 
  display: flex; align-items: center; justify-content: center; 
  padding: 24px; 
  animation: fadeIn 0.2s ease; 
}
.modal-overlay.hidden { display: none; }
.modal { 
  background: var(--white); 
  border-radius: var(--radius-lg); 
  max-width: 460px; width: 100%; 
  box-shadow: 0 24px 64px rgba(0,0,0,0.15); 
  animation: popIn 0.3s cubic-bezier(0.68,-0.55,0.265,1.55); 
}
.modal-header { padding: 24px 24px 0; display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 1.05rem; font-weight: 700; }
.modal-body { padding: 20px 24px; }
.modal-footer { padding: 0 24px 24px; display: flex; gap: 10px; justify-content: flex-end; }
.modal-close { background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--text-light); padding: 4px; line-height: 1; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ============================================
   LOADING SPINNER
   ============================================ */
.spinner { 
  display: inline-block; width: 22px; height: 22px; 
  border: 2.5px solid rgba(37,99,235,0.2); 
  border-top-color: var(--primary); 
  border-radius: 50%; 
  animation: spin 0.7s linear infinite; 
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================
   SECTION HEADERS
   ============================================ */
.section-header { text-align: center; margin-bottom: 48px; }
.section-header .eyebrow { 
  display: inline-flex; align-items: center; gap: 8px; 
  font-size: 0.78rem; font-weight: 600; 
  color: var(--primary); 
  letter-spacing: 0.08em; text-transform: uppercase; 
  margin-bottom: 12px; 
}
.section-header h2 { 
  font-family: 'Playfair Display', serif; 
  font-size: 2rem; font-weight: 700; 
  color: var(--text-dark); margin-bottom: 12px; 
}
.section-header p { color: var(--text-light); max-width: 520px; margin: 0 auto; font-size: 0.95rem; }

/* ============================================
   PAGE HERO
   ============================================ */
.page-hero { 
  background: linear-gradient(135deg, #1E3A8A 0%, #2563EB 40%, #3B82F6 100%); 
  padding: 56px 24px; color: white; 
  position: relative; overflow: hidden; 
}
.page-hero::after {
  content: '';
  position: absolute;
  bottom: -60px; right: -60px;
  width: 250px; height: 250px;
  background: rgba(255,255,255,0.03);
  border-radius: 50%;
}
.page-hero::before {
  content: '';
  position: absolute;
  top: -30px; left: -30px;
  width: 150px; height: 150px;
  background: rgba(255,255,255,0.03);
  border-radius: 50%;
}
.page-hero-inner { max-width: 1200px; margin: 0 auto; position: relative; z-index: 1; }
.page-hero h1 { font-family: 'Playfair Display', serif; font-size: 2rem; font-weight: 700; margin-bottom: 8px; }
.page-hero p { opacity: 0.9; font-size: 1rem; font-weight: 400; }

/* ============================================
   LAYOUT
   ============================================ */
.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.container-sm { max-width: 720px; margin: 0 auto; padding: 0 24px; }
.section { padding: 64px 0; }

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }

.divider { height: 1px; background: var(--border); margin: 24px 0; }

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state { text-align: center; padding: 48px 24px; }
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 16px; animation: float 3s ease-in-out infinite; }
.empty-state h3 { font-size: 1.1rem; color: var(--text-mid); margin-bottom: 8px; font-weight: 600; }
.empty-state p { font-size: 0.875rem; color: var(--text-light); }

@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

/* ============================================
   FOOTER
   ============================================ */
.footer { background: #0F172A; color: white; padding: 48px 0 24px; }
.footer-inner { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.footer-brand .brand-name { font-family: 'Playfair Display', serif; font-size: 1.2rem; color: white; margin-bottom: 8px; }
.footer-brand p { font-size: 0.85rem; opacity: 0.6; max-width: 280px; }
.footer-bottom { 
  border-top: 1px solid rgba(255,255,255,0.08); 
  margin-top: 36px; padding-top: 20px; 
  display: flex; align-items: center; justify-content: space-between; 
  flex-wrap: wrap; gap: 12px; 
}
.footer-bottom p { font-size: 0.78rem; opacity: 0.5; }

/* ============================================
   PROGRESS BAR
   ============================================ */
.progress-bar { height: 8px; background: var(--border); border-radius: 99px; overflow: hidden; }
.progress-fill { 
  height: 100%; 
  background: linear-gradient(90deg, var(--primary), var(--primary-light)); 
  border-radius: 99px; 
  transition: width 0.5s ease; 
}

/* ============================================
   CURRENT ROW HIGHLIGHT
   ============================================ */
.current-row { background: #FEF9C3; }
[data-theme="dark"] .current-row { background: #1E3A8A !important; }

/* ============================================
   THEME TOGGLE
   ============================================ */
.theme-toggle { 
  position: fixed; bottom: 24px; right: 24px; 
  width: 46px; height: 46px; border-radius: 50%; 
  background: var(--white); 
  color: var(--text-dark);
  border: 1px solid var(--border);
  cursor: pointer; font-size: 1.1rem; 
  display: flex; align-items: center; justify-content: center; 
  box-shadow: var(--card-shadow); 
  transition: var(--transition); 
  z-index: 999; 
}
.theme-toggle:hover { transform: scale(1.08); box-shadow: var(--card-shadow-hover); }

/* ============================================
   SCROLLBAR
   ============================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94A3B8; }

/* ============================================
   DARK MODE
   ============================================ */
[data-theme="dark"] {
  --primary: #3B82F6;
  --primary-light: #60A5FA;
  --primary-dark: #1E40AF;
  --secondary: #1E293B;
  --white: #0F172A;
  --bg: #020617;
  --success: #34D399;
  --danger: #F87171;
  --warning: #FBBF24;
  --text-dark: #F1F5F9;
  --text-mid: #CBD5E1;
  --text-light: #94A3B8;
  --border: #1E293B;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.3);
  --card-shadow-hover: 0 8px 32px rgba(0,0,0,0.5);
}

[data-theme="dark"] body { background: var(--bg); color: #F1F5F9; }
[data-theme="dark"] .navbar { background: rgba(15,23,42,0.85); border-bottom-color: #1E293B; }
[data-theme="dark"] .nav-links a { color: #CBD5E1; }
[data-theme="dark"] .nav-links a:hover { background: #1E293B; color: #60A5FA; }
[data-theme="dark"] .nav-links a.active { background: #1E293B; color: #60A5FA; }
[data-theme="dark"] .nav-links a.btn-nav { background: var(--primary); color: white; }
[data-theme="dark"] .nav-brand .brand-name { color: #F1F5F9; }
[data-theme="dark"] .nav-brand .brand-sub { color: #94A3B8; }
[data-theme="dark"] .hamburger span { background: #CBD5E1; }
[data-theme="dark"] .card { background: #0F172A; border-color: #1E293B; }
[data-theme="dark"] .stat-card { background: #0F172A; border-color: #1E293B; }
[data-theme="dark"] .form-control { background: #0F172A; border-color: #1E293B; color: #F1F5F9; }
[data-theme="dark"] .form-control:focus { border-color: #60A5FA; }
[data-theme="dark"] .form-control::placeholder { color: #475569; }
[data-theme="dark"] select.form-control option { background: #1E293B; color: #F1F5F9; }
[data-theme="dark"] .modal { background: #0F172A; }
[data-theme="dark"] .modal-overlay { background: rgba(0,0,0,0.7); }
[data-theme="dark"] .toast { background: #0F172A; }
[data-theme="dark"] .footer { background: #020617; }
[data-theme="dark"] .page-hero { background: linear-gradient(135deg, #020617 0%, #1E3A8A 50%, #3B82F6 100%); }
[data-theme="dark"] .progress-bar { background: #1E293B; }
[data-theme="dark"] .badge-gray { background: #1E293B; color: #CBD5E1; }
[data-theme="dark"] .divider { background: #1E293B; }
[data-theme="dark"] .btn-outline { border-color: #334155; color: #CBD5E1; }
[data-theme="dark"] .btn-outline:hover { background: #1E293B; color: #60A5FA; border-color: #60A5FA; }
[data-theme="dark"] .theme-toggle { background: #1E293B; color: #F1F5F9; border-color: #334155; }
[data-theme="dark"] .auth-area span { color: #CBD5E1; }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #475569; }

/* Dark mode - inline background fixes */
[data-theme="dark"] section[style*="background: white"] { background: var(--bg) !important; }
[data-theme="dark"] section[style*="background: var(--secondary)"] { background: var(--bg) !important; }

/* ============================================
   RESPONSIVE
   ============================================ */

/* Tablet */
@media (max-width: 950px) {
  .nav-inner { flex-wrap: wrap; height: auto; padding: 10px 16px; }
  .nav-links { display: none; width: 100%; flex-direction: column; padding: 8px 0; gap: 2px; order: 3; }
  .nav-links.open { display: flex; }
  .nav-links a { width: 100%; padding: 10px 14px; }
  .hamburger { display: flex; }
  .auth-area { width: auto; order: 2; }
}

/* Mobile */
@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .section { padding: 40px 0; }
  .section-header h2 { font-size: 1.5rem; }
  .page-hero { padding: 40px 20px; }
  .page-hero h1 { font-size: 1.5rem; }
  .modal-footer { flex-direction: column; }
  .modal-footer .btn { width: 100%; }
  .auth-area { flex-wrap: wrap; gap: 4px; }
  .auth-area .btn { padding: 6px 10px; font-size: 0.73rem; }
}

/* Small Mobile */
@media (max-width: 600px) {
  .auth-area span { display: none; }
  .auth-area .btn { flex: 1; min-width: 0; }
  #confirmationCard a.btn,
  #confirmationCard button.btn {
    width: 100% !important;
    font-size: 0.78rem !important;
    padding: 12px 10px !important;
    white-space: normal !important;
    word-break: break-word;
    text-align: center;
  }
  
  /* ===== TRACKING "YOU" BADGE ===== */
.you-badge {
    display: inline-block;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    margin-left: 8px;
    animation: youPulse 2s ease-in-out infinite;
    vertical-align: middle;
}

@keyframes youPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(37,99,235,0.4); }
    50% { box-shadow: 0 0 0 8px rgba(37,99,235,0); }
}}