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

:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --secondary: #8b5cf6;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-light: #64748b;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
}

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

.screen {
  display: none;
}

.screen.active {
  display: block;
}

/* ===== AUTH SCREEN ===== */
.auth-container {
  max-width: 420px;
  margin: 100px auto;
  padding: 40px;
  background: var(--card-bg);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.auth-container h1 {
  font-size: 2.5rem;
  margin-bottom: 8px;
  color: var(--primary);
}

.subtitle {
  color: var(--text-light);
  margin-bottom: 32px;
}

.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

.auth-tab {
  flex: 1;
  padding: 12px;
  border: 2px solid var(--border);
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 500;
  transition: all 0.2s;
}

.auth-tab.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.auth-form {
  display: none;
}

.auth-form.active {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  transition: border-color 0.2s;
  font-family: inherit;
}

select.category-select {
  cursor: pointer;
  background: white;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
}

textarea {
  resize: vertical;
}

.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 2px solid var(--border);
}

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

.btn-add {
  background: var(--bg);
  color: var(--primary);
  padding: 8px 16px;
  font-size: 14px;
  margin-top: 12px;
}

.btn-add:hover {
  background: var(--primary);
  color: white;
}

.error-message {
  color: var(--danger);
  font-size: 14px;
  min-height: 20px;
}

/* ===== NAVBAR ===== */
.navbar {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 16px 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

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

.nav-content h1 {
  font-size: 1.5rem;
  color: var(--primary);
}

.nav-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: 2px solid var(--border);
  background: transparent;
  border-radius: 8px;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s;
}

.icon-btn:hover {
  background: var(--bg);
  border-color: var(--primary);
}

.date-input {
  padding: 8px 12px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
}

.username-display {
  padding: 8px 16px;
  background: var(--bg);
  border-radius: 8px;
  font-weight: 500;
  color: var(--primary);
}

/* ===== MAIN CONTENT ===== */
.main-content {
  padding: 24px 0;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

.streak-card {
  background: linear-gradient(135deg, var(--warning), var(--danger));
  color: white;
  padding: 16px 24px;
  border-radius: 12px;
  text-align: center;
  font-size: 24px;
  font-weight: bold;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

#streak-count {
  font-size: 32px;
}

.card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 32px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s;
}

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

.section-title {
  font-size: 1.75rem;
  margin-bottom: 24px;
  color: var(--primary);
  border-bottom: 2px solid var(--border);
  padding-bottom: 12px;
}

.section-subtitle {
  color: var(--text-light);
  font-size: 14px;
  margin-top: -16px;
  margin-bottom: 20px;
}

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

.section-header .section-title {
  margin-bottom: 0;
}

.subsection-title {
  font-size: 1.1rem;
  margin-bottom: 12px;
  color: var(--text);
  font-weight: 600;
}

/* ===== TABS ===== */
.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  background: var(--card-bg);
  padding: 8px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  flex-wrap: wrap;
}

.tab-btn {
  flex: 1;
  min-width: 150px;
  padding: 12px 16px;
  border: 2px solid transparent;
  background: transparent;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-light);
}

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

.tab-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.3s ease-out;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: var(--text);
}

.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
}

.gratefuls-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.grateful-input {
  border-left: 3px solid var(--primary) !important;
  transition: all 0.2s;
}

.grateful-input:focus {
  border-left-color: var(--secondary) !important;
  background: #faf5ff;
}

/* ===== MILESTONES ===== */
.milestones-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.milestone-item {
  background: var(--bg);
  border-radius: 12px;
  padding: 20px;
  border-left: 4px solid var(--primary);
  transition: all 0.2s;
}

.milestone-item:hover {
  box-shadow: var(--shadow);
  transform: translateX(4px);
}

.milestone-item.completed {
  border-left-color: var(--success);
  opacity: 0.8;
}

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

.milestone-checkbox {
  width: 24px;
  height: 24px;
  cursor: pointer;
  accent-color: var(--success);
}

.milestone-title {
  flex: 1;
  font-size: 16px;
  font-weight: 600;
  border: none;
  background: transparent;
  padding: 4px 8px;
}

.milestone-delete {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--danger);
  color: white;
  border-radius: 6px;
  cursor: pointer;
  font-size: 18px;
  opacity: 0;
  transition: opacity 0.2s;
}

.milestone-item:hover .milestone-delete {
  opacity: 1;
}

.milestone-delete:hover {
  background: #dc2626;
}

.milestone-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.milestone-date,
.milestone-progress {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.milestone-date label,
.milestone-progress label {
  font-size: 12px;
  color: var(--text-light);
  font-weight: 500;
}

.milestone-date input,
.milestone-progress input {
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
}

.milestone-progress-bar {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 8px;
}

.milestone-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  transition: width 0.3s;
  border-radius: 4px;
}

.milestone-notes {
  width: 100%;
  min-height: 60px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}

.checklist-section {
  margin-bottom: 28px;
}

.checklist {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.checkbox-label:hover {
  background: #e0e7ff;
  transform: translateX(4px);
}

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

.checkbox-label input[type="checkbox"]:checked + span {
  text-decoration: line-through;
  opacity: 0.6;
}

.checkbox-label span {
  flex: 1;
  font-size: 15px;
  transition: all 0.2s;
}

.checklist-edit-btn {
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: var(--primary);
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  opacity: 0;
  transition: opacity 0.2s;
  padding: 0;
  margin-left: auto;
}

.checkbox-label:hover .checklist-edit-btn {
  opacity: 1;
}

.checklist-edit-btn:hover {
  background: var(--primary);
  color: white;
}

.checklist-delete-btn {
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: var(--danger);
  border-radius: 4px;
  cursor: pointer;
  font-size: 18px;
  opacity: 0;
  transition: opacity 0.2s;
  padding: 0;
  margin-left: 4px;
}

.checkbox-label:hover .checklist-delete-btn {
  opacity: 1;
}

.checklist-delete-btn:hover {
  background: var(--danger);
  color: white;
}

/* ===== TASK LIST ===== */
.task-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.task-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg);
  border-radius: 8px;
  transition: all 0.2s;
}

.task-item:hover {
  background: #e0e7ff;
}

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

.task-item input[type="text"] {
  flex: 1;
  border: none;
  background: transparent;
  padding: 4px 8px;
}

.task-item.completed input[type="text"] {
  text-decoration: line-through;
  opacity: 0.6;
}

.task-item .delete-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: var(--danger);
  color: white;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  opacity: 0;
  transition: opacity 0.2s;
}

.task-item:hover .delete-btn {
  opacity: 1;
}

.task-item .delete-btn:hover {
  background: #dc2626;
}

.task-item .rollover-badge {
  background: var(--warning);
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

/* ===== SAVE INDICATOR ===== */
.save-indicator {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--success);
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s;
  pointer-events: none;
}

.save-indicator.show {
  opacity: 1;
  transform: translateY(0);
}

/* ===== MODAL ===== */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--card-bg);
  border-radius: 16px;
  max-width: 900px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px;
  border-bottom: 2px solid var(--border);
}

.modal-header h2 {
  color: var(--primary);
}

.close-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: var(--bg);
  border-radius: 8px;
  font-size: 24px;
  cursor: pointer;
  transition: all 0.2s;
}

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

.modal-body {
  padding: 24px;
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  padding: 24px;
  border-radius: 12px;
  text-align: center;
  box-shadow: var(--shadow);
}

.stat-value {
  font-size: 2.5rem;
  font-weight: bold;
  margin-bottom: 8px;
}

.stat-label {
  font-size: 14px;
  opacity: 0.9;
}

.charts-section {
  margin-bottom: 32px;
}

.charts-section h3 {
  margin-bottom: 16px;
  color: var(--text);
}

#weekly-chart,
#health-chart {
  background: var(--bg);
  padding: 20px;
  border-radius: 8px;
  min-height: 200px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .nav-content {
    flex-direction: column;
  }

  .nav-controls {
    width: 100%;
    justify-content: center;
  }

  .card {
    padding: 20px;
  }

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

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

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card {
  animation: fadeIn 0.4s ease-out;
}

/* ===== YESTERDAY'S FOCUS ===== */
.yesterday-focus-box {
  background: linear-gradient(135deg, #e0e7ff, #ddd6fe);
  border-left: 4px solid var(--primary);
  padding: 16px;
  border-radius: 8px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  font-style: italic;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ===== ADMIN PANEL ===== */
.admin-users-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-user-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background: var(--bg);
  border-radius: 8px;
  border-left: 4px solid var(--primary);
  transition: all 0.2s;
}

.admin-user-card:hover {
  transform: translateX(4px);
  box-shadow: var(--shadow);
}

.admin-user-card.pending {
  border-left-color: var(--warning);
}

.admin-user-card.approved {
  border-left-color: var(--success);
}

.admin-user-card.admin {
  border-left-color: var(--secondary);
  background: linear-gradient(135deg, #faf5ff, #f3e8ff);
}

.admin-user-info {
  flex: 1;
}

.admin-user-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.admin-user-meta {
  font-size: 13px;
  color: var(--text-light);
}

.admin-user-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  margin-left: 8px;
}

.admin-user-badge.pending {
  background: #fef3c7;
  color: #92400e;
}

.admin-user-badge.approved {
  background: #d1fae5;
  color: #065f46;
}

.admin-user-badge.admin {
  background: #e9d5ff;
  color: #6b21a8;
}

.admin-user-actions {
  display: flex;
  gap: 8px;
}

.admin-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.admin-btn-approve {
  background: var(--success);
  color: white;
}

.admin-btn-approve:hover {
  background: #059669;
  transform: translateY(-1px);
}

.admin-btn-reject {
  background: var(--danger);
  color: white;
}

.admin-btn-reject:hover {
  background: #dc2626;
  transform: translateY(-1px);
}

.admin-btn-make-admin {
  background: var(--secondary);
  color: white;
}

.admin-btn-make-admin:hover {
  background: #7c3aed;
  transform: translateY(-1px);
}

.admin-empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-light);
}

.admin-empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}
