:root {
  --primary: #7c3aed;
  --primary-hover: #6d28d9;
  --secondary: #3b82f6;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #10b981;
  --warning: #f59e0b;
  --bg-dark: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #243244;
  --border: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.3), 0 2px 4px -1px rgba(0,0,0,0.2);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.4), 0 4px 6px -2px rgba(0,0,0,0.3);
  --transition: all 0.2s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

#app { min-height: 100vh; }

/* Auth Screen */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}

.auth-card h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.subtitle { color: var(--text-muted); margin-bottom: 24px; font-size: 0.9rem; }

.error-msg {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid var(--danger);
  color: #fca5a5;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 0.85rem;
  display: none;
}
.error-msg.visible { display: block; }

.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
}

input, textarea, select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.95rem;
  transition: var(--transition);
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.2);
}

textarea { resize: vertical; font-family: inherit; }

/* Buttons */
.btn {
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-secondary {
  background: var(--bg-dark);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border: 1px solid var(--danger);
}
.btn-danger:hover { background: var(--danger); color: white; }

.btn-small {
  padding: 4px 10px;
  font-size: 0.8rem;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-weight: 500;
}

/* Auth toggle */
.auth-toggle {
  text-align: center;
  margin-top: 20px;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.auth-toggle a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

/* App Shell */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-header {
  padding: 24px 20px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-header h2 { font-size: 1.1rem; font-weight: 700; }

.trip-badge {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 10px;
  background: var(--primary);
  color: white;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.nav-menu {
  flex: 1;
  overflow-y: auto;
  padding: 12px 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: var(--transition);
  margin-bottom: 2px;
}

.nav-item:hover {
  background: var(--bg-card-hover);
  color: var(--text);
}

.nav-item.active {
  background: rgba(124, 58, 237, 0.15);
  color: #c4b5fd;
}

.nav-icon { font-size: 1.1rem; width: 24px; text-align: center; }

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

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 0.9rem;
}

.user-name { font-weight: 600; font-size: 0.85rem; }
.user-email { font-size: 0.75rem; color: var(--text-dim); }

.logout-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
}
.logout-btn:hover { color: var(--danger); background: rgba(239,68,68,0.1); }

/* Main Content */
.main-content {
  margin-left: 260px;
  flex: 1;
  padding: 32px;
  max-width: calc(100% - 260px);
}

/* Page Header */
.page-header {
  margin-bottom: 28px;
}
.page-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 4px;
}
.page-header p { color: var(--text-muted); font-size: 0.9rem; }
.page-header .btn { margin-top: 12px; }

/* Back Link */
.back-link {
  display: inline-block;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  margin-bottom: 16px;
  transition: var(--transition);
}
.back-link:hover { color: var(--text); }

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: var(--transition);
}
.card:hover { border-color: var(--primary); }

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.card-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}
.card-value {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 4px;
}
.card-delta {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
  background: rgba(124, 58, 237, 0.2);
  color: #c4b5fd;
}

/* Dashboard Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}

.trip-card {
  cursor: pointer;
  position: relative;
}
.trip-card .badge {
  position: absolute;
  top: 16px;
  right: 16px;
}

/* Section Placeholder */
.section-placeholder {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.section-placeholder .icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.5;
}
.section-placeholder h3 {
  font-size: 1.25rem;
  margin-bottom: 8px;
  color: var(--text);
}

/* Form Card */
.form-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 800px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

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

.inline-form {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
  background: var(--bg-card);
  padding: 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.inline-form input,
.inline-form select {
  width: auto;
  min-width: 140px;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}

.tab-btn {
  padding: 10px 18px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
}

.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  color: #c4b5fd;
  border-bottom-color: var(--primary);
}

/* Timeline */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
  padding-left: 28px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 12px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  display: flex;
  gap: 16px;
  padding: 16px 0;
  position: relative;
}

.timeline-dot {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  position: absolute;
  left: -28px;
  top: 18px;
}

.timeline-content {
  flex: 1;
}
.timeline-content strong {
  display: block;
  font-size: 1rem;
  margin-bottom: 4px;
}
.timeline-content .muted {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Destinations */
.destinations-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.destination-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: var(--transition);
}

.destination-card:hover {
  border-color: var(--primary);
}

.dest-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.dest-number {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 0.8rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.dest-name {
  font-size: 1.1rem;
  font-weight: 600;
}

.dest-dates {
  margin-left: auto;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.dest-details {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.dest-highlights,
.dest-notes {
  font-size: 0.9rem;
  margin-top: 8px;
  padding: 8px 12px;
  background: rgba(124, 58, 237, 0.08);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--primary);
}

.dest-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

/* Packing */
.packing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.packing-category {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.packing-category h4 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.packing-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
}

.packing-item:last-child { border-bottom: none; }

.packing-item.packed {
  opacity: 0.5;
}

.packing-item.packed span {
  text-decoration: line-through;
}

.pack-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  cursor: pointer;
}

.pack-checkbox input[type="checkbox"] {
  width: 18px; height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* Budget */
.budget-summary {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table thead {
  background: var(--bg-card);
}

.data-table th,
.data-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.data-table tr:hover {
  background: var(--bg-card-hover);
}

/* Journal */
.journal-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 20px;
}

.journal-entry {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: var(--transition);
}

.journal-entry:hover {
  border-color: var(--primary);
}

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

.journal-header strong {
  font-size: 1.1rem;
  color: var(--text);
}

.journal-date {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.journal-mood,
.journal-weather {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.journal-content {
  font-size: 0.95rem;
  line-height: 1.7;
  margin-top: 8px;
  white-space: pre-wrap;
}

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

/* Members */
.members-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 20px;
}

.member-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
}

.member-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--secondary);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 1rem;
  flex-shrink: 0;
}

.member-info {
  flex: 1;
}

.member-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.member-role {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: capitalize;
}

/* Invite section */
.invite-section {
  margin: 20px 0;
}

/* Share section */
.share-section {
  margin-top: 20px;
}

/* Loading */
.loading-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  color: var(--text-muted);
}

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

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

/* Responsive */
@media (max-width: 768px) {
  .app-shell {
    flex-direction: column;
  }

  /* Sidebar becomes a slide-out overlay */
  .sidebar {
    width: 100%;
    position: relative;
    top: auto; left: auto; bottom: auto;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    z-index: 100;
  }

  .sidebar.collapsed {
    display: none;
  }

  .sidebar.expanded {
    display: flex;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100%;
    height: 100vh;
    background: var(--bg-card);
    z-index: 200;
    padding-top: 60px;
  }

  .sidebar.expanded .sidebar-header {
    position: absolute;
    top: 0; left: 0; right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
  }

  .sidebar.expanded .sidebar-header h2 {
    font-size: 1rem;
  }

  .mobile-menu-btn {
    display: block;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 150;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
  }

  .mobile-close-btn {
    display: block;
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px;
  }

  .main-content {
    margin-left: 0;
    max-width: 100%;
    padding: 16px;
    padding-top: 60px;
  }

  .page-header h1 {
    font-size: 1.4rem;
  }

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

  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    gap: 2px;
    padding-bottom: 2px;
  }

  .tab-btn {
    padding: 8px 12px;
    font-size: 0.8rem;
    white-space: nowrap;
    flex-shrink: 0;
  }

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

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

  .inline-form {
    flex-direction: column;
    align-items: stretch;
  }

  .inline-form input,
  .inline-form select {
    width: 100%;
  }

  .dest-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .dest-dates {
    margin-left: 0;
  }

  .dest-details {
    gap: 8px;
  }

  .timeline {
    padding-left: 24px;
  }

  .timeline-dot {
    left: -24px;
    width: 20px;
    height: 20px;
    font-size: 0.7rem;
  }

  .journal-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .budget-summary {
    grid-template-columns: repeat(2, 1fr);
  }

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

  .data-table {
    font-size: 0.8rem;
  }

  .data-table th,
  .data-table td {
    padding: 8px 10px;
  }

  .auth-card {
    padding: 24px;
    margin: 0 12px;
  }

  .share-timeline {
    padding-left: 32px;
  }

  .share-timeline-number {
    left: -32px;
    width: 24px;
    height: 24px;
    font-size: 0.75rem;
  }

  .share-hero {
    padding: 24px 16px;
  }

  .share-hero h1 {
    font-size: 1.5rem;
  }

  .share-stats {
    gap: 16px;
  }

  .share-stat-num {
    font-size: 1.25rem;
  }

  .share-packing-grid {
    grid-template-columns: 1fr;
  }

  .share-table {
    font-size: 0.8rem;
  }

  .share-table th,
  .share-table td {
    padding: 8px 10px;
  }
}

/* Desktop: hide mobile buttons, force sidebar visible */
@media (min-width: 769px) {
  .mobile-menu-btn,
  .mobile-close-btn {
    display: none !important;
  }
  .sidebar.collapsed,
  .sidebar.expanded {
    display: flex !important;
    position: fixed !important;
    top: 0; left: 0; bottom: 0;
    width: 260px;
    height: 100vh;
    padding-top: 0;
  }
  .sidebar.expanded .sidebar-header,
  .sidebar.collapsed .sidebar-header {
    position: static;
    display: block;
    padding: 24px 20px 16px;
  }
}
