/* ============================================================
   FlowTrack — Daily Activity Tracker
   Modern Dark/Light UI with Glassmorphism
   ============================================================ */

/* ---------- CSS Custom Properties ---------- */
:root {
  /* Dark theme (default) */
  --bg-primary:      #0d0d1a;
  --bg-secondary:    #12122a;
  --bg-tertiary:     #1a1a35;
  --bg-card:         rgba(255,255,255,0.04);
  --bg-card-hover:   rgba(255,255,255,0.07);
  --bg-glass:        rgba(255,255,255,0.05);
  --border:          rgba(255,255,255,0.08);
  --border-focus:    rgba(99,179,237,0.6);

  --text-primary:    #f0f0ff;
  --text-secondary:  #8888aa;
  --text-muted:      #555577;

  --accent-teal:     #00d4aa;
  --accent-purple:   #a78bfa;
  --accent-blue:     #60a5fa;
  --accent-orange:   #fb923c;
  --accent-pink:     #f472b6;
  --accent-green:    #4ade80;
  --accent-red:      #f87171;

  --gradient-primary: linear-gradient(135deg, #00d4aa, #60a5fa);
  --gradient-purple:  linear-gradient(135deg, #a78bfa, #ec4899);

  --sidebar-width:   240px;
  --sidebar-collapsed: 68px;
  --topbar-height:   64px;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-pill: 999px;

  --shadow-sm:  0 2px 8px rgba(0,0,0,0.3);
  --shadow-md:  0 4px 20px rgba(0,0,0,0.4);
  --shadow-lg:  0 8px 40px rgba(0,0,0,0.5);
  --shadow-glow-teal:   0 0 24px rgba(0,212,170,0.25);
  --shadow-glow-purple: 0 0 24px rgba(167,139,250,0.25);

  --transition: 0.2s ease;
  --transition-slow: 0.35s cubic-bezier(0.4,0,0.2,1);

  --font: 'Inter', system-ui, sans-serif;
}

[data-theme="light"] {
  --bg-primary:      #f0f4ff;
  --bg-secondary:    #e8edf8;
  --bg-tertiary:     #dfe6f5;
  --bg-card:         rgba(255,255,255,0.8);
  --bg-card-hover:   rgba(255,255,255,0.95);
  --bg-glass:        rgba(255,255,255,0.65);
  --border:          rgba(99,102,241,0.12);
  --border-focus:    rgba(99,102,241,0.5);

  --text-primary:    #1e1b4b;
  --text-secondary:  #5c5c8a;
  --text-muted:      #9898b8;

  --shadow-sm:  0 2px 8px rgba(99,102,241,0.08);
  --shadow-md:  0 4px 20px rgba(99,102,241,0.12);
  --shadow-lg:  0 8px 40px rgba(99,102,241,0.16);
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  display: flex;
  overflow: hidden;
  transition: background-color var(--transition-slow), color var(--transition-slow);
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, textarea, select { font-family: inherit; }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ---------- SIDEBAR ---------- */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width var(--transition-slow);
  overflow: hidden;
  position: relative;
  z-index: 100;
}

.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-badge { display: none; }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: var(--gradient-primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-glow-teal);
}

.logo-icon svg { width: 18px; height: 18px; color: #fff; }

.logo-text {
  font-size: 1.1rem;
  font-weight: 700;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  white-space: nowrap;
}

.sidebar-toggle {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: var(--transition);
  flex-shrink: 0;
}

.sidebar-toggle:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.sidebar-toggle svg { width: 18px; height: 18px; }

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  transition: var(--transition);
  position: relative;
  white-space: nowrap;
}

.nav-item:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--bg-glass);
  color: var(--accent-teal);
  box-shadow: inset 0 0 0 1px rgba(0,212,170,0.2);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--accent-teal);
  border-radius: 999px;
}

.nav-icon { width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.nav-icon svg { width: 18px; height: 18px; }
.nav-label { font-size: 0.875rem; font-weight: 500; }

.nav-badge {
  margin-left: auto;
  background: var(--accent-teal);
  color: #000;
  font-size: 0.7rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

.nav-badge:empty { display: none; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}

.theme-toggle-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.theme-icon { display: flex; color: var(--text-secondary); }
.theme-icon svg { width: 18px; height: 18px; }

.toggle-switch { position: relative; display: inline-block; width: 44px; height: 24px; cursor: pointer; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-tertiary);
  border-radius: 999px;
  border: 1px solid var(--border);
  transition: var(--transition);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 3px; top: 3px;
  background: var(--text-secondary);
  border-radius: 50%;
  transition: var(--transition);
}

.toggle-switch input:checked + .toggle-slider { background: var(--accent-teal); border-color: var(--accent-teal); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); background: #fff; }

/* ---------- MAIN CONTENT ---------- */
.main-content {
  flex: 1;
  height: 100vh;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-primary);
}

/* ---------- TOPBAR ---------- */
.topbar {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  flex-shrink: 0;
  gap: 16px;
}

.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

.mobile-menu-btn {
  display: none;
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  align-items: center;
  justify-content: center;
}

.mobile-menu-btn svg { width: 20px; height: 20px; }

.page-title { font-size: 1.1rem; font-weight: 700; }
.page-date { font-size: 0.75rem; color: var(--text-secondary); margin-top: 1px; }

.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 10px;
  width: 16px; height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 7px 14px 7px 34px;
  color: var(--text-primary);
  font-size: 0.85rem;
  width: 200px;
  transition: var(--transition);
  outline: none;
}

.search-input:focus {
  border-color: var(--border-focus);
  background: var(--bg-card-hover);
  box-shadow: 0 0 0 3px rgba(99,179,237,0.1);
  width: 240px;
}

.icon-btn {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  background: var(--bg-card);
  transition: var(--transition);
}

.icon-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--border-focus);
}

.icon-btn svg { width: 16px; height: 16px; }

.topbar-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 4px;
}

/* ---------- GOOGLE DRIVE UI ---------- */
.drive-connect-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.drive-connect-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--border-focus);
}

.drive-connected-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.drive-sync-status {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  transition: var(--transition);
  cursor: default;
  white-space: nowrap;
}
.drive-sync-status[data-state="synced"] {
  background: rgba(0, 212, 170, 0.12);
  color: var(--accent-teal);
  border-color: rgba(0, 212, 170, 0.3);
}
.drive-sync-status[data-state="syncing"] {
  background: rgba(96, 165, 250, 0.12);
  color: var(--accent-blue);
  border-color: rgba(96, 165, 250, 0.3);
}
.drive-sync-status[data-state="error"] {
  background: rgba(248, 113, 113, 0.12);
  color: var(--accent-red);
  border-color: rgba(248, 113, 113, 0.3);
}

.drive-sync-status .sync-spin {
  display: inline-block;
}
.drive-sync-status .sync-spin.spinning {
  animation: spinCw 0.8s linear infinite;
}
@keyframes spinCw {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* Drive setup modal extras */
.drive-setup-info {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.6;
}
.drive-setup-info code {
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.82em;
  color: var(--accent-teal);
}
.drive-setup-steps h4 {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 10px;
}
.setup-steps-list {
  padding-left: 20px;
  font-size: 0.84rem;
  color: var(--text-secondary);
  line-height: 1.9;
}
.setup-steps-list a {
  color: var(--accent-blue);
  text-decoration: none;
}
.setup-steps-list a:hover { text-decoration: underline; }
.setup-origin-hint {
  display: inline-block;
  margin-top: 3px;
  font-family: monospace;
  font-size: 0.82rem;
  color: var(--accent-purple);
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 7px;
}
.form-hint {
  font-size: 0.77rem;
  color: var(--text-muted);
  margin-top: 5px;
}

/* ---------- VIEWS ---------- */
.view {
  display: none;
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  animation: fadeIn 0.25s ease;
}

.view.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- DASHBOARD ---------- */
.quote-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.quote-icon { color: var(--accent-teal); font-size: 1rem; flex-shrink: 0; }
.quote-text  { font-size: 0.875rem; color: var(--text-secondary); font-style: italic; line-height: 1.5; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 80px; height: 80px;
  border-radius: 50%;
  opacity: 0.06;
  transform: translate(20px, -20px);
}

.stat-card[data-accent="teal"]   .stat-icon { color: var(--accent-teal); }
.stat-card[data-accent="teal"]::after   { background: var(--accent-teal); }
.stat-card[data-accent="purple"] .stat-icon { color: var(--accent-purple); }
.stat-card[data-accent="purple"]::after { background: var(--accent-purple); }
.stat-card[data-accent="blue"]   .stat-icon { color: var(--accent-blue); }
.stat-card[data-accent="blue"]::after   { background: var(--accent-blue); }
.stat-card[data-accent="orange"] .stat-icon { color: var(--accent-orange); }
.stat-card[data-accent="orange"]::after { background: var(--accent-orange); }

.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); background: var(--bg-card-hover); }

.stat-icon { width: 42px; height: 42px; border-radius: var(--radius-md); background: var(--bg-tertiary); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-icon svg { width: 20px; height: 20px; }
.stat-value { display: block; font-size: 1.7rem; font-weight: 800; line-height: 1; }
.stat-label { font-size: 0.75rem; color: var(--text-secondary); margin-top: 3px; display: block; }

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.dash-panel {
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.dash-panel.wide { grid-column: 1 / -1; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.panel-header h3 { font-size: 0.95rem; font-weight: 600; }

.progress-pct {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--accent-teal);
}

.progress-bar-wrap { margin-bottom: 16px; }

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--gradient-primary);
  border-radius: 999px;
  transition: width 0.5s cubic-bezier(0.4,0,0.2,1);
}

.task-preview-list { display: flex; flex-direction: column; gap: 8px; }

.task-preview-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  font-size: 0.825rem;
  transition: var(--transition);
}

.task-preview-item:hover { background: var(--bg-card-hover); }

.task-preview-check {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}

.task-preview-item.done .task-preview-check {
  background: var(--accent-teal);
  border-color: var(--accent-teal);
}

.task-preview-item.done .task-preview-check::after {
  content: '✓';
  color: #fff;
  font-size: 10px;
  font-weight: 700;
}

.task-preview-item.done .task-preview-title { text-decoration: line-through; opacity: 0.5; }

.habit-streak-list { display: flex; flex-direction: column; gap: 10px; }

.habit-streak-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  font-size: 0.825rem;
}

.habit-streak-emoji { font-size: 1.1rem; }

.habit-streak-info { flex: 1; }
.habit-streak-name { font-weight: 500; }
.habit-streak-sub { color: var(--text-muted); font-size: 0.75rem; margin-top: 2px; }

.habit-streak-badge {
  background: var(--gradient-primary);
  color: #000;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
}

/* ---------- TASKS VIEW ---------- */
.view-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.filter-row { display: flex; gap: 8px; flex-wrap: wrap; }

.filter-chip {
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  transition: var(--transition);
}

.filter-chip:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.filter-chip.active { background: var(--accent-teal); border-color: var(--accent-teal); color: #000; font-weight: 600; }

.category-filter .select-input {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  color: var(--text-primary);
  font-size: 0.8rem;
  outline: none;
  transition: var(--transition);
}

.select-input:focus { border-color: var(--border-focus); }

.task-list { display: flex; flex-direction: column; gap: 10px; }

.task-card {
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  transition: var(--transition);
  cursor: grab;
  box-shadow: var(--shadow-sm);
  animation: slideIn 0.2s ease;
  position: relative;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.task-card:hover { background: var(--bg-card-hover); transform: translateX(2px); }
.task-card.sortable-ghost { opacity: 0.4; }
.task-card.sortable-chosen { box-shadow: var(--shadow-lg); transform: scale(1.01); }

.task-card.done {
  opacity: 0.6;
}

.task-card.done .task-title { text-decoration: line-through; }

.task-check {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border);
  flex-shrink: 0;
  margin-top: 2px;
  cursor: pointer;
  transition: var(--transition);
  display: flex; align-items: center; justify-content: center;
}

.task-check:hover { border-color: var(--accent-teal); }
.task-card.done .task-check { background: var(--accent-teal); border-color: var(--accent-teal); }
.task-card.done .task-check::after { content:'✓'; color:#fff; font-size:11px; font-weight:700; }

.task-body { flex: 1; min-width: 0; }

.task-title { font-size: 0.9rem; font-weight: 500; margin-bottom: 4px; }

.task-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 6px; }

.task-tag {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.priority-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}

.priority-badge.high   { background: rgba(248,113,113,0.15); color: var(--accent-red); }
.priority-badge.medium { background: rgba(251,191,36,0.15);  color: #fbbf24; }
.priority-badge.low    { background: rgba(74,222,128,0.15);  color: var(--accent-green); }

.task-due {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.task-due.overdue { color: var(--accent-red); }

.task-actions { display: flex; gap: 4px; flex-shrink: 0; opacity: 0; transition: var(--transition); }
.task-card:hover .task-actions { opacity: 1; }

.task-action-btn {
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: var(--transition);
}

.task-action-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.task-action-btn.delete:hover { color: var(--accent-red); }
.task-action-btn svg { width: 14px; height: 14px; }

.task-drag-handle {
  color: var(--text-muted);
  cursor: grab;
  padding: 4px;
  display: flex;
  align-items: center;
  opacity: 0;
  transition: var(--transition);
}

.task-card:hover .task-drag-handle { opacity: 1; }
.task-drag-handle svg { width: 14px; height: 14px; }

/* ---------- HABITS VIEW ---------- */
.habits-today, .habits-stats, .habits-weekly {
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.habit-list { display: flex; flex-direction: column; gap: 10px; }

.habit-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: var(--transition);
  position: relative;
}

.habit-item:hover { background: var(--bg-card-hover); }
.habit-item.completed { opacity: 0.7; }
.habit-item.completed .habit-name { text-decoration: line-through; }

.habit-emoji { font-size: 1.3rem; width: 32px; text-align: center; }

.habit-info { flex: 1; }
.habit-name { font-size: 0.875rem; font-weight: 500; }
.habit-sub  { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }

.habit-counter {
  display: flex;
  align-items: center;
  gap: 6px;
}

.habit-counter-btn {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}

.habit-counter-btn:hover { background: var(--accent-teal); border-color: var(--accent-teal); color: #000; }

.habit-count-val {
  font-size: 0.85rem;
  font-weight: 600;
  min-width: 30px;
  text-align: center;
  color: var(--text-secondary);
}

.habit-actions { display: flex; gap: 4px; opacity: 0; transition: var(--transition); }
.habit-item:hover .habit-actions { opacity: 1; }

.habit-action-btn {
  width: 26px; height: 26px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: var(--transition);
}

.habit-action-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.habit-action-btn.delete:hover { color: var(--accent-red); }
.habit-action-btn svg { width: 13px; height: 13px; }

/* Streak Board */
.streak-board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.streak-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.streak-emoji { font-size: 1.4rem; }
.streak-info  { flex: 1; }
.streak-name  { font-size: 0.825rem; font-weight: 600; }
.streak-val   { font-size: 1.4rem; font-weight: 800; color: var(--accent-teal); }
.streak-lbl   { font-size: 0.7rem; color: var(--text-muted); }

/* ---------- CALENDAR VIEW ---------- */
.calendar-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
}

.calendar-main {
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.calendar-header h3 { font-size: 1rem; font-weight: 700; }

.cal-nav-btn {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}

.cal-nav-btn:hover { background: var(--bg-card-hover); border-color: var(--border-focus); }
.cal-nav-btn svg { width: 14px; height: 14px; }

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 8px;
}

.cal-weekdays span {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 6px 0;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.cal-day {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  border: 1px solid transparent;
}

.cal-day:hover { background: var(--bg-card-hover); }
.cal-day.empty { cursor: default; }
.cal-day.today { background: rgba(0,212,170,0.1); color: var(--accent-teal); font-weight: 700; border-color: var(--accent-teal); }
.cal-day.selected { background: var(--accent-teal); color: #000; font-weight: 700; }
.cal-day.has-tasks::after { content:''; position:absolute; bottom:4px; width:4px; height:4px; border-radius:50%; background: var(--accent-purple); }
.cal-day.completed-day::after { background: var(--accent-teal); }
.cal-day.other-month { opacity: 0.3; }

.cal-day-score {
  font-size: 0.6rem;
  color: var(--accent-teal);
  margin-top: 1px;
}

.calendar-sidebar {
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.cal-day-tasks { display: flex; flex-direction: column; gap: 8px; }

.cal-task-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  font-size: 0.8rem;
  border-left: 3px solid var(--accent-teal);
}

.cal-task-item.done { opacity: 0.5; }
.cal-task-item.done .cal-task-title { text-decoration: line-through; }

.cal-add-btn {
  margin-top: 12px;
  width: 100%;
  padding: 8px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px dashed var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.cal-add-btn:hover { background: var(--bg-card-hover); color: var(--accent-teal); border-color: var(--accent-teal); }

/* ---------- POMODORO VIEW ---------- */
.pomodoro-container {
  display: grid;
  grid-template-columns: 1fr 320px;
  grid-template-rows: auto auto;
  gap: 20px;
  max-width: 900px;
  margin: 0 auto;
}

.pomodoro-card {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  box-shadow: var(--shadow-md);
  grid-row: 1 / 3;
}

.pomo-mode-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-card);
  border-radius: 999px;
  padding: 4px;
}

.pomo-tab {
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: var(--transition);
}

.pomo-tab.active { background: var(--gradient-primary); color: #000; font-weight: 700; }

.pomo-timer-wrap {
  position: relative;
  width: 220px; height: 220px;
  display: flex; align-items: center; justify-content: center;
}

.pomo-ring {
  position: absolute;
  inset: 0;
  transform: rotate(-90deg);
  width: 100%; height: 100%;
}

.pomo-ring-bg {
  fill: none;
  stroke: var(--bg-tertiary);
  stroke-width: 6;
}

.pomo-ring-progress {
  fill: none;
  stroke: url(#pomoGradient);
  stroke-width: 6;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.5s ease;
}

.pomo-time {
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: -2px;
  z-index: 1;
}

.pomo-controls {
  display: flex;
  align-items: center;
  gap: 16px;
}

.pomo-btn {
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  transition: var(--transition);
}

.pomo-btn.primary {
  width: 56px; height: 56px;
  background: var(--gradient-primary);
  color: #000;
  box-shadow: var(--shadow-glow-teal);
}

.pomo-btn.primary:hover { transform: scale(1.08); box-shadow: 0 0 32px rgba(0,212,170,0.4); }

.pomo-btn.secondary {
  width: 42px; height: 42px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.pomo-btn.secondary:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.pomo-btn svg { width: 22px; height: 22px; }
.pomo-btn.secondary svg { width: 18px; height: 18px; }

.pomo-sessions { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.pomo-sessions span { font-size: 0.8rem; color: var(--text-secondary); }

.pomo-dots { display: flex; gap: 8px; }

.pomo-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  transition: var(--transition);
}

.pomo-dot.done { background: var(--accent-teal); border-color: var(--accent-teal); }
.pomo-dot.active { background: var(--accent-purple); border-color: var(--accent-purple); box-shadow: 0 0 8px rgba(167,139,250,0.5); }

.pomo-task-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  padding: 8px 16px;
  background: var(--bg-card);
  border-radius: 999px;
  border: 1px solid var(--border);
}

.pomo-task-label svg { width: 14px; height: 14px; color: var(--accent-teal); }

.pomo-stats-wrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pomo-stat-card {
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
}

.pomo-stat-val { font-size: 1.5rem; font-weight: 800; color: var(--accent-teal); }
.pomo-stat-lbl { font-size: 0.78rem; color: var(--text-secondary); }

.pomo-settings-panel {
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}

.pomo-settings-panel h4 { font-size: 0.875rem; font-weight: 600; margin-bottom: 14px; }

.pomo-setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.pomo-setting-row label { font-size: 0.8rem; color: var(--text-secondary); }

.pomo-setting-input {
  width: 64px;
  padding: 4px 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.85rem;
  text-align: center;
  outline: none;
}

.pomo-setting-input:focus { border-color: var(--border-focus); }

/* ---------- INSIGHTS VIEW ---------- */
.insights-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.insight-card {
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.insight-card.wide { grid-column: 1 / -1; }

.weekly-score-display {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px 0;
}

.score-ring-wrap {
  position: relative;
  width: 120px; height: 120px;
  display: flex; align-items: center; justify-content: center;
}

.score-ring {
  position: absolute;
  inset: 0;
  transform: rotate(-90deg);
  width: 100%; height: 100%;
}

.score-ring-bg { fill: none; stroke: var(--bg-tertiary); stroke-width: 8; }
.score-ring-fill {
  fill: none;
  stroke: var(--accent-teal);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s ease;
}

.score-ring-text {
  position: relative;
  text-align: center;
  z-index: 1;
}

.score-ring-text span { font-size: 1.6rem; font-weight: 800; display: block; }
.score-ring-text small { font-size: 0.7rem; color: var(--text-muted); }

/* ---------- FAB ---------- */
.fab-wrap {
  position: fixed;
  bottom: 28px;
  right: 28px;
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-end;
  gap: 8px;
  z-index: 200;
}

.fab {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--gradient-primary);
  color: #000;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-glow-teal), var(--shadow-md);
  transition: var(--transition);
}

.fab:hover { transform: scale(1.1) rotate(45deg); box-shadow: 0 0 32px rgba(0,212,170,0.45), var(--shadow-lg); }
.fab svg { width: 22px; height: 22px; transition: transform var(--transition); }

.fab-menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
  transform: translateY(10px) scale(0.96);
  opacity: 0;
  pointer-events: none;
  transition: var(--transition-slow);
}

.fab-menu.open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: all;
}

.fab-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 8px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-primary);
  font-size: 0.825rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  transition: var(--transition);
  white-space: nowrap;
}

.fab-item:hover { background: var(--bg-card-hover); border-color: var(--accent-teal); color: var(--accent-teal); }
.fab-item svg { width: 16px; height: 16px; }

/* ---------- MODALS ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  z-index: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: min(480px, calc(100vw - 32px));
  box-shadow: var(--shadow-lg);
  transform: translateY(20px) scale(0.97);
  transition: transform var(--transition-slow), opacity var(--transition-slow);
  opacity: 0;
  max-height: calc(100vh - 64px);
  overflow-y: auto;
}

.modal-overlay.open .modal {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.modal.modal-sm { width: min(360px, calc(100vw - 32px)); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}

.modal-header h2 { font-size: 1.05rem; font-weight: 700; }

.modal-close {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}

.modal-close:hover { background: var(--bg-card-hover); color: var(--text-primary); }

.modal-body { padding: 20px 24px; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 24px 20px;
}

/* ---------- FORMS ---------- */
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-label { display: block; font-size: 0.8rem; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }
.required { color: var(--accent-red); }

.form-input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.875rem;
  outline: none;
  transition: var(--transition);
}

.form-input:focus { border-color: var(--border-focus); background: var(--bg-card-hover); box-shadow: 0 0 0 3px rgba(99,179,237,0.1); }

.form-textarea {
  resize: vertical;
  min-height: 72px;
  line-height: 1.5;
}

/* ---------- BUTTONS ---------- */
.btn {
  padding: 8px 18px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary {
  background: var(--gradient-primary);
  color: #000;
}

.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: var(--shadow-glow-teal); }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.btn-ghost:hover { background: var(--bg-card); color: var(--text-primary); }

.btn-danger {
  background: rgba(248,113,113,0.15);
  border: 1px solid var(--accent-red);
  color: var(--accent-red);
}

.btn-danger:hover { background: var(--accent-red); color: #fff; }

/* ---------- TOASTS ---------- */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
  pointer-events: none;
}

.toast {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px 18px;
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn 0.3s cubic-bezier(0.4,0,0.2,1);
  backdrop-filter: blur(12px);
  pointer-events: all;
  white-space: nowrap;
}

.toast.hide { animation: toastOut 0.3s ease forwards; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(-10px) scale(0.95); }
}

.toast.success { border-color: var(--accent-teal); }
.toast.error   { border-color: var(--accent-red); }
.toast.info    { border-color: var(--accent-blue); }
.toast.warning { border-color: #fbbf24; }

.toast-icon { font-size: 1rem; }

/* ---------- EMPTY STATE ---------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 32px 16px;
  color: var(--text-muted);
}

.empty-icon { font-size: 2.5rem; opacity: 0.5; }
.empty-state p { font-size: 0.85rem; }

/* ---------- MOBILE OVERLAY ---------- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
  }

  .sidebar.mobile-open {
    transform: translateX(0);
    width: var(--sidebar-width) !important;
  }

  .sidebar.mobile-open .logo-text,
  .sidebar.mobile-open .nav-label,
  .sidebar.mobile-open .nav-badge { display: flex !important; }

  .sidebar-overlay { display: block; }

  .main-content { width: 100%; }

  .mobile-menu-btn { display: flex; }

  .search-input { width: 140px; }
  .search-input:focus { width: 160px; }

  .dashboard-grid { grid-template-columns: 1fr; }
  .dash-panel.wide { grid-column: auto; }

  .calendar-layout { grid-template-columns: 1fr; }

  .pomodoro-container {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }

  .pomodoro-card { grid-row: auto; }

  .insights-grid { grid-template-columns: 1fr; }
  .insight-card.wide { grid-column: auto; }

  .stats-grid { grid-template-columns: 1fr 1fr; }

  .view { padding: 16px; }
  .topbar { padding: 0 16px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .filter-row { gap: 6px; }
  .filter-chip { padding: 4px 10px; font-size: 0.75rem; }
  .pomo-time { font-size: 2.5rem; }
}

/* ---------- CHART.JS OVERRIDE ---------- */
canvas { max-width: 100%; }

/* ---------- GRADIENT DEFS (SVG) ---------- */
svg defs { display: none; }
