/* ==========================================================================
   CSS DESIGN SYSTEM: HABITFLOW (MINIMALIST DAILY HABIT TRACKER)
   ========================================================================== */

/* --- CSS Variables & Palettes --- */
:root {
  /* Common Core Styles */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-display: 'Outfit', var(--font-sans);
  
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-full: 9999px;
  
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);

  /* Color System Constants */
  --indigo: #6366f1;
  --emerald: #10b981;
  --amber: #f59e0b;
  --rose: #f43f5e;
  --violet: #8b5cf6;
  
  --indigo-soft: rgba(99, 102, 241, 0.12);
  --emerald-soft: rgba(16, 185, 129, 0.12);
  --amber-soft: rgba(245, 158, 11, 0.12);
  --rose-soft: rgba(244, 63, 94, 0.12);
  --violet-soft: rgba(139, 92, 246, 0.12);
}

/* --- Dark Theme Variables --- */
html[data-theme="dark"] {
  --bg-primary: #0b0f19;
  --bg-secondary: #111827;
  
  --bg-card: rgba(17, 24, 39, 0.65);
  --border-color: rgba(255, 255, 255, 0.06);
  --border-focus: rgba(99, 102, 241, 0.5);
  
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --card-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5), 
                 inset 0 1px 1px rgba(255, 255, 255, 0.05);
  --modal-shadow: 0 20px 50px -12px rgba(0, 0, 0, 0.8), 
                  0 0 1px rgba(255, 255, 255, 0.1) inset;
  --overlay-bg: rgba(3, 7, 18, 0.8);
  
  --active-tab-bg: rgba(255, 255, 255, 0.06);
  --active-tab-text: #f3f4f6;
  --control-btn-hover: rgba(255, 255, 255, 0.08);

  /* Heatmap Colors (Dark Theme) */
  --heatmap-empty: #1f2937;
  --heatmap-l1: #064e3b;
  --heatmap-l2: #047857;
  --heatmap-l3: #10b981;
  --heatmap-l4: #34d399;
}

/* --- Light Theme Variables --- */
html[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #f1f5f9;
  
  --bg-card: rgba(255, 255, 255, 0.75);
  --border-color: rgba(0, 0, 0, 0.06);
  --border-focus: rgba(99, 102, 241, 0.4);
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  
  --card-shadow: 0 10px 30px -10px rgba(15, 23, 42, 0.05),
                 0 1px 3px rgba(0, 0, 0, 0.02);
  --modal-shadow: 0 20px 50px -12px rgba(15, 23, 42, 0.15),
                  0 0 1px rgba(0, 0, 0, 0.05) inset;
  --overlay-bg: rgba(15, 23, 42, 0.4);
  
  --active-tab-bg: rgba(15, 23, 42, 0.06);
  --active-tab-text: #0f172a;
  --control-btn-hover: rgba(0, 0, 0, 0.05);

  /* Heatmap Colors (Light Theme) */
  --heatmap-empty: #e2e8f0;
  --heatmap-l1: #d1fae5;
  --heatmap-l2: #a7f3d0;
  --heatmap-l3: #34d399;
  --heatmap-l4: #059669;
}

/* --- Global Resets & Typography --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  overflow-x: hidden;
  transition: background-color var(--transition-normal), color var(--transition-normal);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.02em;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* --- Layout Structure --- */
.app-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  min-height: 100vh;
}

/* --- Header Section --- */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

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

.logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--indigo) 0%, var(--violet) 100%);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.logo-text h1 {
  font-size: 1.5rem;
  line-height: 1.2;
}

.logo-text .tagline {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 400;
}

.header-date {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--text-primary);
  background: var(--bg-card);
  padding: 0.5rem 1.25rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  box-shadow: var(--card-shadow);
}

.header-controls {
  display: flex;
  gap: 0.5rem;
}

.control-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--card-shadow);
  transition: all var(--transition-fast);
}

.control-btn:hover {
  background: var(--control-btn-hover);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

/* Theme Icon Visibility Toggles */
html[data-theme="dark"] .sun-icon { display: block; }
html[data-theme="dark"] .moon-icon { display: none; }
html[data-theme="light"] .sun-icon { display: none; }
html[data-theme="light"] .moon-icon { display: block; }

/* --- Metrics Grid --- */
.metrics-grid {
  display: grid;
  grid-template-columns: 2fr 3fr;
  gap: 1.5rem;
}

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

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--card-shadow);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1rem;
}

.metric-info {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

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

.metric-value {
  font-family: var(--font-display);
  font-size: 2.25rem;
  font-weight: 600;
  line-height: 1;
}

.progress-bar-container {
  width: 100%;
  height: 8px;
  background: var(--bg-secondary);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--indigo) 0%, var(--emerald) 100%);
  border-radius: var(--radius-full);
  transition: width var(--transition-slow) cubic-bezier(0.1, 0.8, 0.2, 1);
}

.mini-stats {
  flex-direction: row;
  justify-content: space-around;
  text-align: center;
  align-items: center;
}

.mini-stat-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.mini-stat-item:not(:last-child) {
  border-right: 1px solid var(--border-color);
}

.mini-stat-value {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--text-primary);
}

.mini-stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* --- Main Layout Grid --- */
.dashboard-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.9fr);
  gap: 2rem;
  align-items: start;
}

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

/* --- Common Components (Buttons, Inputs) --- */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  gap: 1rem;
}

.section-header h2 {
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text-primary);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
}

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

.btn-primary:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

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

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

.w-full { width: 100%; }
.text-center { text-align: center; }
.cursor-pointer { cursor: pointer; }

/* --- Quick-Add Presets --- */
.quick-add-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.65rem 1rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--card-shadow);
  flex-wrap: wrap;
}

.quick-add-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.quick-add-chips {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  flex: 1;
}

.quick-chip {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: all var(--transition-fast);
}

.quick-chip:hover {
  background: var(--control-btn-hover);
  color: var(--text-primary);
  border-color: var(--text-muted);
  transform: translateY(-1px);
}

.quick-chip:active {
  transform: translateY(0);
}

/* --- Habit Filter Bar --- */
.filter-bar {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
  scrollbar-width: none; /* Firefox */
}

.filter-bar::-webkit-scrollbar {
  display: none; /* Safari & Chrome */
}

.filter-tag {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.filter-tag:hover {
  border-color: var(--text-muted);
  color: var(--text-primary);
}

.filter-tag.active {
  background: var(--text-primary);
  color: var(--bg-primary);
  border-color: var(--text-primary);
}

/* --- Habit Checklist Item Card --- */
.habits-checklist {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.habit-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  box-shadow: var(--card-shadow);
  transition: transform var(--transition-normal), border-color var(--transition-normal), box-shadow var(--transition-normal);
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.habit-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background-color: var(--habit-color, var(--indigo));
  opacity: 0.8;
}

.habit-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px -10px rgba(0, 0, 0, 0.15);
  border-color: var(--text-muted);
}

.habit-left {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1;
}

/* Custom Checkbox Container */
.habit-checkbox-container {
  position: relative;
  display: inline-block;
  width: 26px;
  height: 26px;
}

.habit-checkbox-container input {
  opacity: 0;
  width: 0;
  height: 0;
}

.checkbox-checkmark {
  position: absolute;
  top: 0;
  left: 0;
  height: 26px;
  width: 26px;
  background-color: transparent;
  border: 2px solid var(--text-muted);
  border-radius: 50%;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.checkbox-checkmark svg {
  color: white;
  width: 14px;
  height: 14px;
  opacity: 0;
  transform: scale(0.6);
  transition: all var(--transition-fast);
}

.habit-checkbox-container input:checked + .checkbox-checkmark {
  background-color: var(--habit-color, var(--indigo));
  border-color: var(--habit-color, var(--indigo));
}

.habit-checkbox-container input:checked + .checkbox-checkmark svg {
  opacity: 1;
  transform: scale(1);
}

/* Hover Checkbox Effect */
.habit-item:hover .checkbox-checkmark {
  border-color: var(--habit-color, var(--indigo));
}

.habit-info-group {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.habit-name {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text-primary);
  transition: color var(--transition-normal), text-decoration var(--transition-normal);
}

.habit-item.completed .habit-name {
  text-decoration: line-through;
  color: var(--text-muted);
}

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

.habit-item.completed .habit-desc {
  color: var(--text-muted);
  opacity: 0.7;
}

.habit-meta-badges {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.35rem;
}

.badge {
  font-size: 0.7rem;
  font-weight: 500;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  text-transform: capitalize;
}

.badge-time {
  background: var(--bg-secondary);
  color: var(--text-secondary);
}

.badge-streak {
  background: var(--habit-color-soft, var(--indigo-soft));
  color: var(--habit-color, var(--indigo));
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

.badge-streak svg {
  width: 10px;
  height: 10px;
  fill: currentColor;
}

/* Actions Menu Trigger */
.habit-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.habit-action-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.habit-action-btn:hover {
  background: var(--control-btn-hover);
  color: var(--text-primary);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  background: var(--bg-card);
  border: 1.5px dashed var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* --- Analytics Styles --- */
.analytics-layout {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.habit-selector-container {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.field-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.field-label.required::after {
  content: ' *';
  color: var(--rose);
}

.form-select, .form-input {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.9rem;
  font-family: inherit;
  transition: all var(--transition-fast);
  outline: none;
  width: 100%;
}

.form-select:focus, .form-input:focus {
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px var(--border-focus);
}

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

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

.insight-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--card-shadow);
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.insight-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.streak-icon { background: var(--amber-soft); color: var(--amber); }
.max-streak-icon { background: var(--indigo-soft); color: var(--indigo); }
.rate-icon { background: var(--emerald-soft); color: var(--emerald); }

.insight-details {
  display: flex;
  flex-direction: column;
}

.insight-title {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.insight-value {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
}

.analytics-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--card-shadow);
}

.analytics-card h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  color: var(--text-primary);
}

/* Weekly Strip Grid */
.weekly-strip {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.weekly-day {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 0.25rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
}

.weekly-day:hover {
  background: var(--control-btn-hover);
  border-color: var(--text-muted);
}

.weekly-day.is-today {
  box-shadow: 0 0 0 1.5px var(--text-secondary);
}

.weekly-day-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.weekly-day.completed .weekly-day-name {
  color: var(--text-primary);
}

.weekly-day-num {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
}

.weekly-day-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.weekly-day-dot svg {
  width: 10px;
  height: 10px;
  color: #fff;
  opacity: 0;
}

.weekly-day.completed {
  background: var(--habit-color-soft, var(--indigo-soft));
}

.weekly-day.completed .weekly-day-dot {
  background-color: var(--habit-color, var(--indigo));
  border-color: var(--habit-color, var(--indigo));
}

.weekly-day.completed .weekly-day-dot svg {
  opacity: 1;
}

/* GitHub Heatmap Grid */
.heatmap-card {
  overflow: hidden;
}

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

.heatmap-year {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.heatmap-scroll-container {
  overflow-x: auto;
  margin: 0 -1.5rem;
  padding: 0 1.5rem;
  scrollbar-width: thin;
}

.heatmap-wrapper {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.5rem;
  min-width: 680px; /* Force minimum width to avoid squishing */
  padding-bottom: 0.5rem;
}

.heatmap-days-labels {
  display: grid;
  grid-template-rows: repeat(7, 10px);
  gap: 3px;
  font-size: 8px;
  color: var(--text-muted);
  text-transform: uppercase;
  padding-top: 13px; /* Align with layout grid top */
}

.heatmap-days-labels span:nth-child(1) { grid-row: 2; } /* Wed */
.heatmap-days-labels span:nth-child(2) { grid-row: 4; } /* Wed */
.heatmap-days-labels span:nth-child(3) { grid-row: 6; } /* Fri */

.heatmap-grid {
  display: grid;
  grid-template-flow: column;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, 10px);
  grid-auto-columns: 10px;
  gap: 3px;
}

.heatmap-cell {
  width: 10px;
  height: 10px;
  background-color: var(--heatmap-empty);
  border-radius: 1.5px;
  transition: all var(--transition-fast);
  cursor: pointer;
  position: relative;
}

.heatmap-cell:hover {
  transform: scale(1.3);
  z-index: 10;
  box-shadow: 0 0 4px rgba(0,0,0,0.3);
}

/* Tooltip container for hover state info */
.heatmap-cell[data-tooltip]::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%) scale(0.85);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-xs);
  font-size: 9px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
  box-shadow: var(--card-shadow);
  z-index: 20;
}

.heatmap-cell:hover::before {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

/* Heatmap Completion Levels */
.heatmap-cell.level-0 { background-color: var(--heatmap-empty); }
.heatmap-cell.level-1 { background-color: var(--heatmap-l1); }
.heatmap-cell.level-2 { background-color: var(--heatmap-l2); }
.heatmap-cell.level-3 { background-color: var(--heatmap-l3); }
.heatmap-cell.level-4 { background-color: var(--heatmap-l4); }

.heatmap-legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  font-size: 9px;
  color: var(--text-muted);
  margin-top: 1rem;
}

.legend-box {
  width: 9px;
  height: 9px;
  border-radius: 1px;
}

.legend-box.level-0 { background-color: var(--heatmap-empty); }
.legend-box.level-1 { background-color: var(--heatmap-l1); }
.legend-box.level-2 { background-color: var(--heatmap-l2); }
.legend-box.level-3 { background-color: var(--heatmap-l3); }
.legend-box.level-4 { background-color: var(--heatmap-l4); }

/* --- Modal Base --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--overlay-bg);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 500px;
  width: 100%;
  box-shadow: var(--modal-shadow);
  transform: scale(0.95) translateY(10px);
  transition: transform var(--transition-normal);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

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

.modal-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color var(--transition-fast);
}

.modal-close-btn:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-row {
  display: flex;
  gap: 1rem;
}

.flex-1 { flex: 1; }

/* Custom Weekday Multi-Selector */
.weekday-selector {
  display: flex;
  justify-content: space-between;
  gap: 0.25rem;
}

.weekday-chip {
  flex: 1;
  position: relative;
  text-align: center;
}

.weekday-chip input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.weekday-chip span {
  display: block;
  padding: 0.5rem 0;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.weekday-chip input:checked + span {
  background-color: var(--text-primary);
  color: var(--bg-primary);
  border-color: var(--text-primary);
}

.weekday-chip:hover span {
  border-color: var(--text-muted);
}

/* Color Dot Palette Selector */
.color-palette-selector {
  display: flex;
  gap: 0.75rem;
}

.color-dot {
  position: relative;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
}

.color-dot input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.dot-inner {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  transition: transform var(--transition-fast);
  border: 2px solid transparent;
}

.color-indigo .dot-inner  { background-color: var(--indigo); }
.color-emerald .dot-inner { background-color: var(--emerald); }
.color-amber .dot-inner   { background-color: var(--amber); }
.color-rose .dot-inner    { background-color: var(--rose); }
.color-violet .dot-inner  { background-color: var(--violet); }

/* Selection state border styling */
.color-dot input:checked + .dot-inner {
  transform: scale(0.85);
  box-shadow: 0 0 0 2px var(--bg-primary), 0 0 0 4px var(--text-primary);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

/* Backup Modal Specifics */
.modal-text {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 0.5rem;
}

.backup-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.import-divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  margin: 0.25rem 0;
}

.import-divider::before, .import-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border-color);
}

.import-divider span {
  padding: 0 0.75rem;
}

/* --- PWA Install Button Animation --- */
#install-pwa-btn {
  animation: pulse-indigo 2.5s infinite;
}

@keyframes pulse-indigo {
  0% {
    box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.7);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(99, 102, 241, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(99, 102, 241, 0);
  }
}

/* --- Mobile Responsive Enhancements --- */
@media (max-width: 480px) {
  .app-container {
    padding: 1.5rem 1rem;
    gap: 1.5rem;
  }
  
  .logo-text h1 {
    font-size: 1.3rem;
  }
  
  .header-date {
    font-size: 0.95rem;
    padding: 0.4rem 1rem;
    order: 4; /* push to new line if wrapped */
    width: 100%;
    text-align: center;
    margin-top: 0.5rem;
  }
  
  .metric-value {
    font-size: 1.75rem;
  }
  
  .mini-stat-value {
    font-size: 1.35rem;
  }
  
  .weekly-day-num {
    font-size: 0.85rem;
  }
  
  .weekly-day-dot {
    width: 16px;
    height: 16px;
  }
  
  .weekly-day-dot svg {
    width: 8px;
    height: 8px;
  }
  
  .modal-card {
    border-radius: var(--radius-md);
  }
}

/* --- Expiry Notification Banner --- */
.expiry-banner {
  background-color: var(--amber-soft);
  color: var(--amber);
  border-bottom: 1px solid rgba(245, 158, 11, 0.2);
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  width: 100%;
  position: sticky;
  top: 0;
  z-index: 99;
  backdrop-filter: blur(8px);
}

.expiry-banner.warning-red {
  background-color: var(--rose-soft);
  color: var(--rose);
  border-bottom: 1px solid rgba(244, 63, 94, 0.2);
}

.expiry-banner.critical-flash {
  background-color: #f43f5e;
  color: #ffffff;
  border-bottom: 1px solid #f43f5e;
  animation: banner-flash 1.5s infinite;
}

@keyframes banner-flash {
  0% { opacity: 0.95; }
  50% { opacity: 0.75; }
  100% { opacity: 0.95; }
}

.banner-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.banner-btn {
  background: var(--text-primary);
  color: var(--bg-primary);
  border: none;
  border-radius: var(--radius-xs);
  padding: 0.25rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition-fast);
}

.banner-btn:hover {
  opacity: 0.9;
}

.expiry-banner.critical-flash .banner-btn {
  background: #ffffff;
  color: #f43f5e;
}

.mr-auto {
  margin-right: auto;
}

/* Clickable session badge hover feedback */
#dashboard-session-badge {
  transition: all var(--transition-fast);
}

#dashboard-session-badge:hover {
  filter: brightness(1.15);
  transform: scale(1.03);
}

#dashboard-session-badge:active {
  transform: scale(0.98);
}
