:root {
  /* Colors */
  --primary-gradient: linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%);
  --primary-solid: #6366F1;
  --bg-body: #F3F4F6;
  --bg-card: #FFFFFF;
  --text-main: #1F2937;
  --text-muted: #6B7280;
  --border-light: #E5E7EB;
  
  /* Status Colors */
  --success-bg: #D1FAE5;
  --success-text: #065F46;
  --warning-bg: #FEF3C7;
  --warning-text: #92400E;
  --info-bg: #DBEAFE;
  --info-text: #1E40AF;
  --danger-bg: #FEE2E2;
  --danger-text: #991B1B;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;

  /* UI Elements */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --nav-height: 80px;
}

* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  margin: 0;
  padding: 0;
  padding-bottom: var(--nav-height); /* Space for bottom nav */
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

/* Layout Utilities */
.container {
  max-width: 600px; /* Constrain for mobile app feel on desktop */
  margin: 0 auto;
  padding: var(--space-md);
  width: 100%;
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.w-full { width: 100%; }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }

/* Typography */
h1, h2, h3, h4 { margin: 0; font-weight: 700; }
h1 { font-size: 24px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
.text-sm { font-size: 14px; }
.text-xs { font-size: 12px; }
.text-muted { color: var(--text-muted); }
.font-bold { font-weight: 600; }

/* Components: Header */
.app-header {
  background: var(--bg-card);
  padding: var(--space-md);
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--shadow-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: #E0E7FF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: var(--primary-solid);
}

.avatar.lg { width: 64px; height: 64px; font-size: 24px; }

/* Components: Cards */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-md);
  transition: transform 0.2s;
}

.card:active {
  transform: scale(0.98);
}

/* Components: Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-size: 14px;
  transition: all 0.2s;
  width: auto;
}

.btn-primary {
  background: var(--primary-gradient);
  color: white;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-secondary {
  background: white;
  border: 1px solid var(--border-light);
  color: var(--text-main);
}

.btn-danger {
  background-color: var(--danger-bg);
  color: var(--danger-text);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-full {
  width: 100%;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
}

/* Floating Action Button */
.fab {
  position: fixed;
  bottom: calc(var(--nav-height) + 16px);
  right: 16px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary-gradient);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
  z-index: 50;
  cursor: pointer;
}

/* Badges */
.badge {
  padding: 4px 8px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  display: inline-block;
}

.badge-success { background: var(--success-bg); color: var(--success-text); }
.badge-warning { background: var(--warning-bg); color: var(--warning-text); }
.badge-info { background: var(--info-bg); color: var(--info-text); }
.badge-danger { background: var(--danger-bg); color: var(--danger-text); }

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  height: var(--nav-height);
  display: flex;
  justify-content: space-around;
  align-items: center;
  border-top: 1px solid var(--border-light);
  padding-bottom: 10px; /* Safe area for iOS home bar */
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 10px;
  gap: 4px;
  width: 20%;
}

.nav-item.active {
  color: var(--primary-solid);
  font-weight: 600;
}

.nav-icon {
  width: 24px;
  height: 24px;
  background: #E5E7EB;
  border-radius: 6px;
}

.nav-item.active .nav-icon {
  background: var(--primary-solid);
}

/* Stat Grid */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.stat-card {
  background: white;
  padding: var(--space-md);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-main);
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
}

/* Mini Chart */
.chart-container {
  height: 150px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding-top: 20px;
  gap: 8px;
}

.chart-bar {
  flex: 1;
  background: var(--primary-solid);
  opacity: 0.2;
  border-radius: 4px 4px 0 0;
  transition: height 0.3s;
  position: relative;
}

.chart-bar.active {
  opacity: 1;
  background: var(--primary-gradient);
}

/* Inputs & Forms */
.form-group { margin-bottom: var(--space-md); }
.form-label { display: block; margin-bottom: 8px; font-weight: 600; font-size: 14px; }
.form-input, .form-select {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  font-size: 16px;
  background: white;
}
.form-input:focus { border-color: var(--primary-solid); outline: none; }

/* Image Placeholders */
.placeholder-image {
  background-color: #E5E7EB;
  width: 100%;
  height: 150px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 8px;
  overflow: hidden;
}

.placeholder-thumb {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  background-color: #E5E7EB;
  flex-shrink: 0;
}

/* Tab Group */
.tab-group {
  display: flex;
  background: #E5E7EB;
  padding: 4px;
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
}

.tab-item {
  flex: 1;
  text-align: center;
  padding: 8px;
  font-size: 13px;
  border-radius: 8px;
  color: var(--text-muted);
  font-weight: 600;
  cursor: pointer;
}

.tab-item.active {
  background: white;
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
}

/* Timeline */
.timeline {
  position: relative;
  padding-left: 24px;
  margin-top: 20px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #E5E7EB;
}

.timeline-item {
  position: relative;
  margin-bottom: 24px;
}

.timeline-dot {
  position: absolute;
  left: -21px;
  top: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  border: 2px solid var(--border-light);
  z-index: 1;
}

.timeline-item.completed .timeline-dot {
  background: var(--success-text);
  border-color: var(--success-text);
}

.timeline-item.active .timeline-dot {
  background: var(--primary-solid);
  border-color: var(--primary-solid);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2);
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 24px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}
input:checked + .slider { background-color: var(--primary-solid); }
input:checked + .slider:before { transform: translateX(20px); }

/* Filters */
.filter-scroll {
  display: flex;
  overflow-x: auto;
  gap: 8px;
  padding-bottom: 8px;
  margin-bottom: 16px;
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.filter-scroll::-webkit-scrollbar { display: none; }

.filter-chip {
  padding: 6px 16px;
  border-radius: 20px;
  background: white;
  border: 1px solid var(--border-light);
  font-size: 13px;
  white-space: nowrap;
}

.filter-chip.active {
  background: var(--text-main);
  color: white;
  border-color: var(--text-main);
}

/* Settings Menu */
.menu-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  background: white;
}
.menu-item:last-child { border-bottom: none; }
.menu-icon { width: 24px; height: 24px; background: #E5E7EB; border-radius: 6px; margin-right: 12px; }
.p-0 { padding: 0 !important; }
.overflow-hidden { overflow: hidden; }
