/* ============================================
   LyfSy - Design System & Base Styles
   ============================================ */

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

/* ----------------------
   CSS Variables - Light Theme
   ---------------------- */
:root {
  --font-body: 'Plus Jakarta Sans', sans-serif;
  --font-display: 'Sora', sans-serif;

  /* Colors */
  --bg: #F7F8FC;
  --bg-card: #FFFFFF;
  --bg-sidebar: #FFFFFF;
  --bg-hover: #F0F2F8;
  --bg-active: #EEF0FF;

  --text: #0D0F1A;
  --text-muted: #6B7280;
  --text-light: #9CA3AF;
  --text-sidebar: #374151;

  --border: #E5E7EB;
  --border-light: #F3F4F6;

  --primary: #5B5FEF;
  --primary-light: #EEF0FF;
  --primary-dark: #4347CC;
  --primary-text: #FFFFFF;

  --blue: #3B82F6;
  --green: #10B981;
  --orange: #F59E0B;
  --red: #EF4444;
  --purple: #8B5CF6;
  --pink: #EC4899;
  --teal: #14B8A6;
  --muted: #D1D5DB;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);
  --shadow-md: 0 10px 15px -3px rgba(0,0,0,0.07), 0 4px 6px -2px rgba(0,0,0,0.04);
  --shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.08), 0 10px 10px -5px rgba(0,0,0,0.03);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --sidebar-width: 240px;
  --topbar-height: 64px;

  --transition: 0.2s ease;
}

/* ----------------------
   Dark Theme
   ---------------------- */
[data-theme="dark"] {
  --bg: #0F1117;
  --bg-card: #1A1D27;
  --bg-sidebar: #13151F;
  --bg-hover: #1E2130;
  --bg-active: #252840;

  --text: #F3F4F6;
  --text-muted: #9CA3AF;
  --text-light: #6B7280;
  --text-sidebar: #D1D5DB;

  --border: #2A2D3E;
  --border-light: #1E2130;

  --primary: #6366F1;
  --primary-light: #1E2040;
  --primary-dark: #4F52CC;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.3);
  --shadow-md: 0 10px 15px -3px rgba(0,0,0,0.3);
  --shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.4);
}

/* ----------------------
   Reset & Base
   ---------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition), color var(--transition);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: none; }

img { max-width: 100%; }

/* ----------------------
   Typography
   ---------------------- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }
h4 { font-size: 1rem; }

.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.75rem; }
.text-lg { font-size: 1.1rem; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

/* ----------------------
   Layout
   ---------------------- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ----------------------
   Sidebar
   ---------------------- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition), background var(--transition);
}

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-mark {
  width: 34px; height: 34px;
  background: var(--primary);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.logo-text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  letter-spacing: -0.02em;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  overflow-y: auto;
}

.nav-section-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-light);
  padding: 8px 10px 4px;
  margin-top: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-sidebar);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 2px;
  position: relative;
  text-decoration: none;
}

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

.nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
}

.nav-icon {
  width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  background: var(--primary);
  color: white;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  min-width: 18px;
  text-align: center;
}

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

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
}

.sidebar-user:hover { background: var(--bg-hover); }

.user-avatar {
  width: 32px; height: 32px;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
}

.user-avatar img { width: 100%; height: 100%; object-fit: cover; }

.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 0.8rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-plan { font-size: 0.68rem; color: var(--text-muted); }

/* ----------------------
   Main Content
   ---------------------- */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ----------------------
   Topbar
   ---------------------- */
.topbar {
  height: var(--topbar-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  flex: 1;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Hidden by default on desktop, shown via media query on mobile */
#mobile-menu-btn { display: none; }
#ai-fab { display: none; }

/* ----------------------
   Page Content
   ---------------------- */
.page-content {
  flex: 1;
  padding: 24px;
  max-width: 1400px;
  width: 100%;
}

/* ----------------------
   Cards
   ---------------------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}

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

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

.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

/* ----------------------
   Stat Cards
   ---------------------- */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  margin-bottom: 4px;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.stat-change {
  font-size: 0.75rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 3px;
}

.stat-change.up { color: var(--green); }
.stat-change.down { color: var(--red); }

/* ----------------------
   Buttons
   ---------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(91,95,239,0.35); }

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

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 7px 12px;
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }

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

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); width: 36px; height: 36px; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ----------------------
   Forms
   ---------------------- */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 13px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(91,95,239,0.12);
}

.form-control::placeholder { color: var(--text-light); }

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

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

.form-hint { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 0.75rem; color: var(--red); margin-top: 4px; }

/* ----------------------
   Grid
   ---------------------- */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ----------------------
   Flex utilities
   ---------------------- */
.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-4 { gap: 4px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-24 { gap: 24px; }
.flex-1 { flex: 1; }

/* ----------------------
   Badges & Tags
   ---------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-green { background: #D1FAE5; color: #059669; }
.badge-orange { background: #FEF3C7; color: #D97706; }
.badge-red { background: #FEE2E2; color: #DC2626; }
.badge-purple { background: #EDE9FE; color: #7C3AED; }
.badge-blue { background: #DBEAFE; color: #2563EB; }
.badge-gray { background: var(--bg-hover); color: var(--text-muted); }

/* ----------------------
   Progress Bar
   ---------------------- */
.progress {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: var(--radius-full);
  transition: width 0.5s ease;
}

.progress-bar.green { background: var(--green); }
.progress-bar.orange { background: var(--orange); }
.progress-bar.red { background: var(--red); }

/* ----------------------
   Modal
   ---------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 28px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  transform: scale(0.96) translateY(10px);
  transition: transform var(--transition);
}

.modal-overlay.open .modal {
  transform: scale(1) translateY(0);
}

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

.modal-title { font-size: 1.05rem; font-weight: 700; }

.modal-close {
  width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 18px;
  background: transparent;
  border: none;
  transition: background var(--transition);
}
.modal-close:hover { background: var(--bg-hover); }

/* ----------------------
   Toast Notifications
   ---------------------- */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  min-width: 260px;
  max-width: 360px;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideInRight 0.3s ease;
  font-size: 0.875rem;
  font-weight: 500;
}

.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
.toast.info { border-left: 3px solid var(--primary); }

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

/* ----------------------
   Empty State
   ---------------------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  gap: 12px;
}

.empty-state-icon { font-size: 48px; line-height: 1; }
.empty-state-title { font-size: 1rem; font-weight: 600; }
.empty-state-text { font-size: 0.875rem; color: var(--text-muted); max-width: 300px; }

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

.tab {
  padding: 10px 16px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all var(--transition);
}

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

/* ----------------------
   Dropdown
   ---------------------- */
.dropdown { position: relative; display: inline-block; }

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  min-width: 160px;
  z-index: 200;
  overflow: hidden;
  display: none;
}

.dropdown-menu.open { display: block; animation: fadeInDown 0.15s ease; }

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  font-size: 0.875rem;
  color: var(--text);
  cursor: pointer;
  transition: background var(--transition);
}

.dropdown-item:hover { background: var(--bg-hover); }
.dropdown-item.danger { color: var(--red); }
.dropdown-divider { height: 1px; background: var(--border); }

/* ----------------------
   Checkbox & Radio
   ---------------------- */
.checkbox-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.checkbox-wrap input[type="checkbox"] {
  width: 17px; height: 17px;
  border-radius: 4px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* ----------------------
   Tour Tooltip
   ---------------------- */
.tour-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 9998;
  pointer-events: none;
}

.tour-tooltip {
  position: fixed;
  z-index: 9999;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  max-width: 300px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

.tour-tooltip h4 { margin-bottom: 6px; }
.tour-tooltip p { font-size: 0.875rem; color: var(--text-muted); margin-bottom: 16px; }
.tour-actions { display: flex; gap: 8px; justify-content: flex-end; }
.tour-step { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 8px; }

/* ----------------------
   Morning Check-in
   ---------------------- */
.checkin-modal .modal { max-width: 520px; }

.mood-selector {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.mood-option {
  flex: 1;
  min-width: 60px;
  padding: 10px 6px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  font-size: 0.75rem;
  font-weight: 600;
}

.mood-option:hover { border-color: var(--primary); background: var(--primary-light); }
.mood-option.selected { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }
.mood-option .emoji { font-size: 1.5rem; display: block; margin-bottom: 4px; }

/* ----------------------
   Kanban / Task List
   ---------------------- */
.task-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  transition: all var(--transition);
  cursor: pointer;
}

.task-item:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); }
.task-item.done { opacity: 0.55; }
.task-item.done .task-title { text-decoration: line-through; }

.task-check {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 2px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.task-check:hover { border-color: var(--green); }
.task-check.checked { background: var(--green); border-color: var(--green); color: white; font-size: 11px; }

.task-body { flex: 1; min-width: 0; }
.task-title { font-size: 0.875rem; font-weight: 500; margin-bottom: 3px; }
.task-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.task-date { font-size: 0.75rem; color: var(--text-muted); display: flex; align-items: center; gap: 3px; }
.task-priority-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }

/* ----------------------
   Routine Item
   ---------------------- */
.routine-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  transition: all var(--transition);
}

.routine-icon {
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.routine-body { flex: 1; }
.routine-title { font-size: 0.9rem; font-weight: 600; }
.routine-meta { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }

.streak-badge {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--orange);
}

/* ----------------------
   Finance
   ---------------------- */
.transaction-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
}

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

.transaction-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.transaction-body { flex: 1; }
.transaction-name { font-size: 0.875rem; font-weight: 500; }
.transaction-date { font-size: 0.75rem; color: var(--text-muted); }
.transaction-amount { font-size: 0.9rem; font-weight: 700; }
.transaction-amount.income { color: var(--green); }
.transaction-amount.expense { color: var(--red); }

/* ----------------------
   Scrollbar
   ---------------------- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-light); }

/* ----------------------
   Utilities
   ---------------------- */
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-4 { margin-bottom: 4px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.p-0 { padding: 0 !important; }
.w-full { width: 100%; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.rounded-full { border-radius: var(--radius-full) !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.visible { display: block !important; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }


/* ============================================
   RESPONSIVE & MOBILE — Single Clean Block
   ============================================ */

/* --- Tablet --- */

/* ================================================================
   LYFSY — RESPONSIVE & MOBILE STYLES
   Single clean block. No conflicts. No duplicates.
   ================================================================ */

/* ── Desktop sidebar width at smaller screens ── */
/* ================================================================
   LYFSY — COMPLETE RESPONSIVE SYSTEM (iOS-safe)
   ================================================================ */

/* ── 1. Global box model + overflow prevention ── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { overflow-x: hidden; -webkit-overflow-scrolling: touch; }
img, video, iframe, svg { max-width: 100%; }

/* ── 2. Base hidden states ── */
#mobile-menu-btn { display: none; }
#ai-fab          { display: none; }

/* ── 3. Desktop sidebar default ── */
@media (min-width: 769px) {
  #mobile-menu-btn     { display: none !important; }
  #ai-fab              { display: none !important; }
  #sidebar-overlay     { display: none !important; }
  .main-content        { margin-left: var(--sidebar-width); }
}

/* ── 4. Tablet ── */
@media (min-width: 769px) and (max-width: 1024px) {
  :root { --sidebar-width: 200px; }
  .nav-label { font-size: .78rem; }
}

/* ── 5. Mobile: 768px and below ── */
@media (max-width: 768px) {

  /* Sidebar: off-canvas drawer */
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0; right: auto;
    width: 280px !important;
    /* Use translate instead of left:-280px for smoother iOS performance */
    transform: translate3d(-100%, 0, 0);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9000;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    /* Force GPU layer for smooth animation on iOS */
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
  }

  /* Open state — JS adds .open class */
  .sidebar.open {
    transform: translate3d(0, 0, 0);
    box-shadow: 4px 0 32px rgba(0,0,0,0.22);
  }

  /* Show all sidebar elements inside drawer */
  .sidebar .nav-label       { display: block !important; }
  .sidebar .nav-pro-badge   { display: flex !important; }
  .sidebar .nav-section-label { display: block !important; }
  .sidebar .sidebar-logo    { display: flex !important; }
  .sidebar .sidebar-footer  { display: flex !important; }

  /* Backdrop overlay */
  #sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.52);
    z-index: 8999;
    /* iOS: backdrop-filter blurs content behind */
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    /* hidden by default — JS shows/hides */
    display: none;
  }

  /* Prevent body scroll when menu open — applied by JS */
  body.menu-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    /* Fix for iOS Safari momentum scroll resetting position */
    top: var(--scroll-y, 0);
  }

  /* Hamburger */
  #mobile-menu-btn { display: flex !important; }

  /* Main content: no left margin */
  .main-content {
    margin-left: 0 !important;
    width: 100%;
    min-width: 0;
    overflow-x: hidden;
  }

  /* Topbar */
  .topbar { padding: 0 12px; height: 54px; gap: 8px; }
  .topbar-title { font-size: .9rem; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; }
  .topbar-actions { gap: 6px; }
  .topbar-actions .upgrade-btn { display: none !important; }

  /* Page content */
  .page-content { padding: 12px 12px 32px; overflow-x: hidden; }

  /* All grids → 1 column */
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  /* Inline style grids — catch every variant */
  [style*="grid-template-columns"],
  [style*="display: grid"],
  [style*="display:grid"] {
    grid-template-columns: 1fr !important;
  }

  /* Stat cards */
  .stat-card { padding: 14px 12px; }
  .stat-value { font-size: 1.4rem !important; }
  .stat-icon { width: 34px !important; height: 34px !important; font-size: 1rem !important; }

  /* Cards */
  .card { padding: 14px 12px; border-radius: 12px; overflow: hidden; }

  /* MODALS: slide up from bottom — iOS-safe */
  .modal-overlay {
    align-items: flex-end !important;
    padding: 0 !important;
    /* Fix iOS scroll within modal */
    -webkit-overflow-scrolling: touch;
  }
  .modal {
    border-radius: 20px 20px 0 0 !important;
    max-width: 100% !important;
    width: 100% !important;
    max-height: 90dvh !important; /* dvh = dynamic viewport height, fixes iOS toolbar */
    max-height: 90vh !important;  /* fallback for older iOS */
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    margin: 0 !important;
    padding: 20px 16px 32px !important;
    /* Safe area for iPhone notch/home bar */
    padding-bottom: max(32px, env(safe-area-inset-bottom, 32px)) !important;
  }

  /* Forms: MUST be 16px+ on iOS to prevent auto-zoom */
  input, select, textarea, .form-control {
    font-size: 16px !important;
    max-width: 100%;
    -webkit-appearance: none; /* Normalize iOS styling */
    appearance: none;
    border-radius: 10px; /* iOS rounds inputs */
  }
  select { background-image: none; } /* Remove iOS default arrow if custom */

  /* Buttons: minimum touch target 44px (Apple HIG) */
  .btn { min-height: 44px; -webkit-tap-highlight-color: transparent; }
  .btn-sm { min-height: 36px; }
  .btn-icon { min-height: 40px; min-width: 40px; }

  /* Tables */
  .card table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-wrap  { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table th:nth-child(n+5), table td:nth-child(n+5) { display: none; }

  /* Toast: position above content + safe area */
  #toast-container {
    bottom: max(16px, env(safe-area-inset-bottom, 16px)) !important;
    right: 12px; left: 12px; max-width: 100%;
  }
  .toast { max-width: 100%; }

  /* Auth pages */
  .auth-left { display: none !important; }
  .auth-right { width: 100%; min-height: 100svh; display: flex; align-items: center; justify-content: center; }
  .auth-form-wrap { padding: 28px 20px !important; max-width: 100% !important; width: 100% !important; }

  /* Register page */
  .auth-panel { display: none !important; }
  .auth-form-panel { padding: 24px 16px !important; min-height: 100svh; }
  .auth-form-inner { max-width: 100%; }

  /* Profile page two-col grid */
  [style*="grid-template-columns:280px"] { grid-template-columns: 1fr !important; }

  /* Rewards page — prevent overflow */
  .card [style*="font-family:monospace"] { font-size: .78rem !important; word-break: break-all; }

  /* AI page */
  #chat-msgs { height: 320px !important; }

  /* Bottom safe area for all pages */
  .page-content { padding-bottom: max(32px, env(safe-area-inset-bottom, 32px)) !important; }

  /* AI floating action button */
  #ai-fab {
    display: flex !important;
    position: fixed;
    bottom: max(20px, env(safe-area-inset-bottom, 20px));
    right: 16px;
    width: 52px; height: 52px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    font-size: 1.4rem;
    border: none;
    box-shadow: 0 4px 20px rgba(91,95,239,.45);
    cursor: pointer;
    z-index: 200;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
  }
}

/* ── 6. Very small phones ── */
@media (max-width: 390px) {
  .page-content { padding: 10px 10px 28px; }
  .topbar { padding: 0 10px; }
  .card { padding: 12px 10px; }
  .modal { padding: 16px 12px 28px !important; }
}

/* ── 7. Touch devices — no hover effects ── */
@media (hover: none) and (pointer: coarse) {
  .btn:active           { opacity: .8; transform: scale(.97); }
  .nav-item:active      { background: var(--bg-hover); }
  .card:hover           { box-shadow: var(--shadow-sm); transform: none; }
  .task-item:hover      { border-color: var(--border); transform: none; }
  .pick-card:active     { border-color: var(--primary); background: var(--primary-light); }
  .plan-label:active    { border-color: var(--primary); background: var(--primary-light); }
}

/* ── 8. Dashboard grid ── */
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.mb-16 { margin-bottom: 16px; }
.stat-denom { font-size: .85rem; color: var(--text-muted); }
.stat-sub   { font-size: .72rem; color: var(--text-muted); margin-top: 3px; }
@keyframes fire { 0%,100%{transform:scale(1)} 50%{transform:scale(1.2)} }

/* ── 9. Hero banner ── */
.dash-hero { margin-bottom: 20px; }
.dash-hero-inner {
  border-radius: var(--radius-xl); padding: 22px 24px; color: white;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
}
.dash-hero-title { font-family: var(--font-display); font-size: 1.3rem; font-weight: 800; margin-bottom: 4px; }
.dash-hero-sub   { opacity: .85; font-size: .875rem; }
.dash-hero-streak { margin-top: 8px; font-size: .78rem; opacity: .9; }
.dash-hero-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.dash-hero-btn {
  background: rgba(255,255,255,.18); color: white;
  border: 1px solid rgba(255,255,255,.3); padding: 7px 14px;
  border-radius: 8px; font-size: .83rem; font-weight: 600; cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center; gap: 4px;
  white-space: nowrap; -webkit-tap-highlight-color: transparent;
}
  .dash-hero-title { font-size: 1.05rem; }
  .dash-hero-sub { font-size: .82rem; }
}
