:root {
  --accent-color: #9b87f5;
  --accent-light: #c4b5fd;
  --accent-dark: #7c3aed;
  --pink-accent: #f472b6;
  --bg-primary: #faf8ff;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --text-primary: #1f1f3d;
  --text-secondary: #64648b;
  --text-muted: #9ca3af;
  --border-color: #e5e7eb;
  --shadow-sm: 0 1px 3px rgba(155, 135, 245, 0.1);
  --shadow-md: 0 4px 12px rgba(155, 135, 245, 0.15);
  --shadow-lg: 0 8px 24px rgba(155, 135, 245, 0.2);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
}

.dark-mode {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-card: #1f2849;
  --text-primary: #f0f0ff;
  --text-secondary: #a5a5c4;
  --text-muted: #6b6b8d;
  --border-color: #2d3a5f;
}

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

body {
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  transition: background 0.3s ease, color 0.3s ease;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  background: linear-gradient(135deg, var(--accent-color) 0%, var(--pink-accent) 100%);
  padding: 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
}

.header-content {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-emoji {
  font-size: 2rem;
  animation: bounce 2s infinite;
}

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

.header-title h1 {
  font-size: 1.5rem;
  font-weight: 800;
  color: white;
  text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.sparkle {
  font-size: 1.25rem;
  animation: sparkle 1.5s ease-in-out infinite;
}

@keyframes sparkle {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.2); }
}

.dark-mode-toggle {
  background: rgba(255,255,255,0.2);
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.25rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.dark-mode-toggle:hover {
  background: rgba(255,255,255,0.3);
  transform: scale(1.1);
}

.tab-nav {
  display: flex;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab-btn {
  flex: 1;
  padding: 1rem;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  border-bottom: 3px solid transparent;
}

.tab-btn.active {
  color: var(--accent-color);
  border-bottom-color: var(--accent-color);
  background: linear-gradient(180deg, transparent 0%, rgba(155, 135, 245, 0.05) 100%);
}

.tab-btn:hover:not(.active) {
  color: var(--text-primary);
  background: rgba(155, 135, 245, 0.05);
}

.app-main {
  flex: 1;
  max-width: 800px;
  margin: 0 auto;
  padding: 1.5rem;
  width: 100%;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

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

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  transition: all 0.2s ease;
  border: 1px solid var(--border-color);
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.stat-icon {
  font-size: 2rem;
  background: linear-gradient(135deg, rgba(155, 135, 245, 0.15) 0%, rgba(244, 114, 182, 0.15) 100%);
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-content h3 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--accent-color);
}

.stat-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.next-service {
  grid-column: span 2;
  background: linear-gradient(135deg, var(--accent-color) 0%, var(--pink-accent) 100%);
  color: white;
}

.next-service .stat-icon {
  background: rgba(255,255,255,0.2);
}

.next-service h3, .next-service .stat-label {
  color: rgba(255,255,255,0.9);
}

.next-service .stat-value {
  color: white;
}

.next-service .empty-message {
  color: rgba(255,255,255,0.9);
  font-size: 1rem;
}

@media (max-width: 600px) {
  .next-service {
    grid-column: span 1;
  }
}

.mileage-input {
  background: transparent;
  border: none;
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--accent-color);
  width: 100%;
  font-family: inherit;
}

.mileage-input:focus {
  outline: none;
}

.mileage-unit {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.car-preview {
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.car-emoji-large {
  font-size: 3.5rem;
  margin-bottom: 0.5rem;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.section-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-color) 0%, var(--pink-accent) 100%);
  color: white;
  border: none;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-content {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-content h3 {
  font-size: 1.25rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 1rem;
  background: var(--bg-secondary);
  color: var(--text-primary);
  transition: all 0.2s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(155, 135, 245, 0.15);
}

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

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
}

.form-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
}

.form-actions button {
  flex: 1;
}

.appointments-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-secondary);
}

.empty-emoji {
  font-size: 3rem;
  display: block;
  margin-bottom: 1rem;
}

.empty-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.appointment-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--service-color);
  transition: all 0.2s ease;
}

.appointment-card:hover {
  box-shadow: var(--shadow-md);
}

.appointment-card.completed {
  opacity: 0.6;
}

.appointment-header {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.service-icon {
  font-size: 1.75rem;
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, rgba(155, 135, 245, 0.1) 0%, rgba(244, 114, 182, 0.1) 100%);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

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

.appointment-info h4 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

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

.appointment-location {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.status-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.badge-upcoming { background: #dbeafe; color: #1e40af; }
.badge-soon { background: #fef3c7; color: #92400e; }
.badge-overdue { background: #fee2e2; color: #991b1b; }
.badge-completed { background: #d1fae5; color: #065f46; }

.appointment-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.action-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 1rem;
}

.action-btn:hover {
  background: var(--bg-primary);
  transform: scale(1.1);
}

.action-btn.complete-btn:hover {
  background: #d1fae5;
}

.action-btn.delete-btn:hover {
  background: #fee2e2;
}

.car-profile-section h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
}

.car-profile-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}

.emoji-selector {
  margin-bottom: 1.5rem;
}

.emoji-selector label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.emoji-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.emoji-btn {
  width: 48px;
  height: 48px;
  font-size: 1.5rem;
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
}

.emoji-btn:hover {
  transform: scale(1.1);
}

.emoji-btn.selected {
  border-color: var(--accent-color);
  background: linear-gradient(135deg, rgba(155, 135, 245, 0.15) 0%, rgba(244, 114, 182, 0.15) 100%);
}

.color-picker-wrapper {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.color-picker-wrapper input[type="color"] {
  width: 48px;
  height: 48px;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  padding: 0;
}

.color-picker-wrapper span {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.data-actions {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
}

.data-actions h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text-secondary);
}

.app-footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.app-footer a {
  color: var(--accent-color);
  text-decoration: none;
  font-weight: 600;
}

.app-footer a:hover {
  text-decoration: underline;
}

.confetti-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 9999;
}

.confetti-particle {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  animation: confetti-fall 1.5s ease-out forwards;
}

@keyframes confetti-fall {
  0% {
    top: -10px;
    opacity: 1;
    transform: rotate(0deg) scale(1);
  }
  100% {
    top: 100vh;
    opacity: 0;
    transform: rotate(720deg) scale(0);
  }
}