/* =====================================================
   SaveMy75 - CSS Design System
   Mobile-first PWA styling with light/dark themes
   ===================================================== */

/* CSS Custom Properties */
:root {
  /* Colors - Light Theme */
  --primary: #2541B2;
  --primary-dark: #1a3090;
  --primary-light: #3b5bd9;
  --background: #f8f9fc;
  --surface: #ffffff;
  --surface-elevated: #ffffff;
  --text-primary: #1a1a2e;
  --text-secondary: #666680;
  --text-muted: #9999aa;
  --border: #e0e4ec;
  --shadow: rgba(0, 0, 0, 0.04);
  --shadow-strong: rgba(0, 0, 0, 0.08);
  --accent-gold: #f5a623;
  --accent-red: #e53935;
  --accent-green: #43a047;
  --overlay: rgba(0, 0, 0, 0.5);

  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 2rem;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;

  /* Border Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 180ms ease;
  --transition-slow: 400ms ease;

  /* Layout */
  --header-height: 48px;
  --menu-width: 280px;
  --max-content-width: 500px;
}

/* Dark Theme */
[data-theme="dark"] {
  --background: #0d1117;
  --surface: #161b22;
  --surface-elevated: #1c2128;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --border: #30363d;
  --shadow: rgba(0, 0, 0, 0.4);
  --shadow-strong: rgba(0, 0, 0, 0.6);
  --overlay: rgba(0, 0, 0, 0.7);
  --primary-light: #4b6fe6;
  --accent-green: #3fb950;
  --accent-red: #f85149;
  --accent-gold: #d29922;
}

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

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

body {
  font-family: var(--font-family);
  background-color: var(--background);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background-color var(--transition-base), color var(--transition-base);
}

#app {
  min-height: 100vh;
}

/* Page Management */
.page {
  display: none;
  min-height: 100vh;
}

.page.active {
  display: flex;
  flex-direction: column;
}

.view {
  display: none;
  padding: var(--space-md);
  padding-bottom: var(--space-lg);
  animation: fadeIn var(--transition-base);
}

.view.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =====================================================
   INTRO ANIMATION OVERLAY
   ===================================================== */
.intro-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--background);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

[data-theme="dark"] .intro-overlay {
  background: #0d1117;
}

.intro-overlay.hiding {
  opacity: 0;
  transform: scale(1.05);
  pointer-events: none;
}

.intro-overlay.hidden-complete {
  display: none !important;
}

.intro-content {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.intro-glass-card {
  text-align: center;
  padding: var(--space-2xl) var(--space-xl);
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  max-width: 340px;
  width: 90%;
  animation: introCardIn 0.8s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  opacity: 0;
  transform: translateY(30px) scale(0.95);
}

[data-theme="light"] .intro-glass-card {
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(37, 65, 178, 0.1);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.08);
}

@keyframes introCardIn {
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.intro-logo {
  width: 80px;
  height: 80px;
  margin: 0 auto var(--space-lg);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: transparent;
  border: none;
  box-shadow: none;
  animation: introLogoIn 0.6s cubic-bezier(0.22, 1, 0.36, 1) 0.3s forwards;
  opacity: 0;
  transform: scale(0.7);
}

@keyframes introLogoIn {
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.intro-logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: var(--radius-lg);
  border: none;
  outline: none;
  display: block;
}

.intro-title {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: var(--space-sm);
  animation: introFadeUp 0.5s ease 0.6s forwards;
  opacity: 0;
  transform: translateY(10px);
}

.intro-title-gradient {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

[data-theme="dark"] .intro-title-gradient {
  background: linear-gradient(135deg, #60a5fa, #93c5fd);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.intro-tagline {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-lg);
  animation: introFadeUp 0.5s ease 0.9s forwards;
  opacity: 0;
  transform: translateY(10px);
}

.intro-tap-hint {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  animation: introFadeUp 0.5s ease 1.2s forwards, introPulse 2s ease-in-out 2.5s infinite;
  opacity: 0;
  transform: translateY(10px);
}

@keyframes introFadeUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes introPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Intro background orbs */
.intro-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  pointer-events: none;
  animation: introOrbFloat 6s ease-in-out infinite alternate;
}

.intro-orb-1 {
  width: 300px;
  height: 300px;
  background: rgba(37, 65, 178, 0.15);
  top: 10%;
  left: 10%;
  animation-delay: 0s;
}

.intro-orb-2 {
  width: 250px;
  height: 250px;
  background: rgba(59, 130, 246, 0.12);
  bottom: 15%;
  right: 10%;
  animation-delay: -2s;
}

.intro-orb-3 {
  width: 200px;
  height: 200px;
  background: rgba(139, 92, 246, 0.1);
  top: 40%;
  right: 30%;
  animation-delay: -4s;
}

@keyframes introOrbFloat {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(20px, -30px) scale(1.15); }
}

/* =====================================================
   LOGIN PAGE
   ===================================================== */
#login-page {
  background: linear-gradient(180deg, var(--surface) 0%, var(--background) 100%);
  justify-content: center;
  align-items: center;
  padding: var(--space-lg) var(--space-xl);
  overflow-y: auto;
  min-height: 100vh;
  min-height: 100dvh;
}

[data-theme="dark"] #login-page {
  background: linear-gradient(180deg, var(--surface) 0%, var(--background) 100%);
}

.login-container {
  width: 100%;
  max-width: 400px;
  text-align: center;
  padding: 0 var(--space-lg);
}

/* Mobile optimization */
@media (max-width: 480px) {
  .login-container {
    max-width: 100%;
    padding: 0 var(--space-md);
  }
}

.logo-section {
  margin-bottom: var(--space-2xl);
  animation: fadeInDown 0.6s ease-out;
}

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

.logo-icon {
  width: 90px;
  height: 90px;
  margin: 0 auto var(--space-md);
  content: url('icons/Savemy75_clean_bg.svg');
  border-radius: var(--radius-lg);
  display: block;
  object-fit: contain;
  overflow: hidden;
  border: none;
  outline: none;
  box-shadow: 0 4px 12px rgba(37, 65, 178, 0.1);
  background: transparent;
  transition: transform var(--transition-base);
}

.logo-icon:hover {
  transform: scale(1.05);
}

/* Mobile logo sizing */
@media (max-width: 375px) {
  .logo-icon {
    width: 75px;
    height: 75px;
  }
}

[data-theme="dark"] .logo-icon {
  content: url('icons/Savemy75_drawer_dark.svg');
  box-shadow: 0 4px 12px rgba(75, 111, 230, 0.15);
}

.logo-text {
  font-size: 32px;
  font-weight: 600;
  color: var(--primary);
  letter-spacing: -0.5px;
  margin-top: var(--space-xs);
}

/* Mobile logo text sizing */
@media (max-width: 375px) {
  .logo-text {
    font-size: 28px;
  }
}

[data-theme="dark"] .logo-text {
  color: #e6edf3;
}

.login-form-section {
  margin-top: var(--space-2xl);
  animation: fadeInUp 0.7s ease-out;
}

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

.login-subtitle {
  font-size: var(--font-size-base);
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}

.login-highlight {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: var(--space-2xl);
  line-height: 1.3;
}

/* Mobile text sizing */
@media (max-width: 375px) {
  .login-subtitle {
    font-size: 14px;
  }
  
  .login-highlight {
    font-size: 16px;
    margin-bottom: var(--space-xl);
  }
}

#login-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.input-group input {
  width: 100%;
  padding: 16px 20px;
  font-size: 16px;
  font-family: var(--font-family);
  border: 2px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  color: var(--text-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), transform 0.2s;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

/* Mobile input optimization */
@media (max-width: 375px) {
  .input-group input {
    padding: 14px 18px;
    font-size: 16px; /* Prevent zoom on iOS */
  }
}

.input-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 65, 178, 0.1);
  transform: scale(1.005);
}

[data-theme="dark"] .input-group input:focus {
  box-shadow: 0 0 0 4px rgba(75, 111, 230, 0.2);
}

.input-group input::placeholder {
  color: var(--text-muted);
}

.login-btn.primary-btn {
  width: 100%;
  height: 52px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-lg);
  font-size: 17px;
  font-weight: 600;
  font-family: var(--font-family);
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-top: var(--space-lg);
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(37, 65, 178, 0.2);
}

/* Mobile button optimization */
@media (max-width: 375px) {
  .login-btn.primary-btn {
    height: 48px;
    font-size: 16px;
  }
}

.login-btn.primary-btn:hover {
  filter: brightness(1.1);
  transform: scale(1.015);
  box-shadow: 0 8px 24px rgba(37, 65, 178, 0.3);
}

.login-btn.primary-btn:active {
  transform: scale(0.98);
}

/* Login Progress Bar */
.login-progress-container {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  margin-top: var(--space-lg);
  opacity: 1;
  transition: opacity var(--transition-base);
}

.login-progress-container.hidden {
  display: none;
  opacity: 0;
}

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

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  border-radius: var(--radius-full);
  width: 0%;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 12px rgba(37, 65, 178, 0.5);
  position: relative;
  overflow: hidden;
}

.progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

.progress-text {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  text-align: center;
  font-weight: 500;
}

.login-hint {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  text-align: center;
  margin-top: var(--space-md);
  animation: fadeIn 600ms ease-out forwards;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* =====================================================
   APP HEADER
   ===================================================== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-sm);
}

.menu-btn,
.theme-btn {
  width: 44px;
  height: 44px;
  background: transparent;
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

.menu-btn:hover,
.theme-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.menu-btn svg,
.theme-btn svg,
.theme-btn-menu svg {
  width: 24px;
  height: 24px;
  stroke: white;
  color: white;
}

.header-title {
  font-size: var(--font-size-xl);
  font-weight: 600;
  color: white;
  letter-spacing: -0.3px;
}

/* Theme toggle icons - show moon in light mode (to switch to dark), sun in dark mode (to switch to light) */
.theme-btn .sun-icon,
.theme-btn-menu .sun-icon {
  display: none;
}

.theme-btn .moon-icon,
.theme-btn-menu .moon-icon {
  display: block;
}

[data-theme="dark"] .theme-btn .sun-icon,
[data-theme="dark"] .theme-btn-menu .sun-icon {
  display: block;
}

[data-theme="dark"] .theme-btn .moon-icon,
[data-theme="dark"] .theme-btn-menu .moon-icon {
  display: none;
}

/* Ensure drawer menu theme icon is always white (menu header is always blue) */
.theme-btn-menu {
  color: white !important;
}

.theme-btn-menu svg {
  stroke: white !important;
  color: white !important;
}

[data-theme="dark"] .theme-btn,
[data-theme="dark"] .theme-btn-menu {
  color: white !important;
}

[data-theme="dark"] .theme-btn svg,
[data-theme="dark"] .theme-btn-menu svg {
  color: white !important;
}

/* =====================================================
   SIDE MENU
   ===================================================== */
.menu-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-base), visibility var(--transition-base);
}

.menu-overlay.active {
  opacity: 1;
  visibility: visible;
}

.side-menu {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--menu-width);
  max-width: 85vw;
  background: var(--surface);
  z-index: 300;
  transform: translateX(-100%);
  transition: transform var(--transition-base);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.side-menu.active {
  transform: translateX(0);
}

.menu-header {
  background: var(--primary);
  padding: var(--space-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: white;
}

.menu-label {
  font-size: var(--font-size-sm);
  font-weight: 500;
}

.theme-btn-menu {
  width: 36px;
  height: 36px;
  background: transparent;
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.theme-btn-menu svg {
  width: 20px;
  height: 20px;
  stroke: white;
  color: white;
}

.menu-logo {
  padding: var(--space-md) var(--space-lg);
  text-align: center;
}

.menu-logo .logo-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: none;
  outline: none;
  box-shadow: none;
  background: transparent;
}

.menu-logo-text {
  display: block;
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--primary);
  margin-top: var(--space-sm);
}

[data-theme="dark"] .menu-logo-text {
  color: #e6edf3;
}

.menu-user-info {
  padding: var(--space-md) var(--space-lg);
}

.menu-user-name {
  font-size: var(--font-size-base);
  font-weight: 700;
  color: var(--text-primary);
}

.menu-user-roll {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-top: 2px;
}

.menu-toggle-group {
  padding: var(--space-md) var(--space-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.toggle-label {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.toggle-switch {
  position: relative;
  width: 48px;
  height: 26px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background 200ms ease-out;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 200ms cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.toggle-switch input:checked+.toggle-slider {
  background: var(--primary);
}

.toggle-switch input:checked+.toggle-slider::before {
  transform: translateX(22px);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  pointer-events: none;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  opacity: 0;
  transform: translateY(12px);
  animation: toastIn 200ms ease-out forwards;
  pointer-events: auto;
  max-width: 220px;
}

.toast.hiding {
  animation: toastOut 200ms ease-in forwards;
}

@keyframes toastIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateY(-8px);
  }
}

.toast-title {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.toast-message {
  font-size: 0.75rem;
  color: var(--text-muted);
}

[data-theme="dark"] .toast {
  background: var(--surface-elevated);
  border-color: var(--border);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

.menu-nav {
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  flex: 1;
}

.menu-nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-lg);
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: 500;
  font-family: var(--font-family);
  cursor: pointer;
  transition: all 150ms ease-out;
}

.menu-nav-item:hover {
  background: rgba(37, 65, 178, 0.08);
  border-color: var(--primary);
}

.menu-nav-item.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

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

.nav-icon svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
}

.menu-nav-item.active .nav-icon svg {
  stroke: white;
}

/* Menu Actions (Settings + Logout) */
.menu-actions {
  padding: var(--space-lg);
  display: flex;
  gap: var(--space-sm);
  align-items: stretch;
}

.settings-btn {
  width: 44px;
  height: 44px;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 150ms ease-out;
  flex-shrink: 0;
}

.settings-btn svg {
  width: 20px;
  height: 20px;
}

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

[data-theme="dark"] .settings-btn {
  background: var(--surface-elevated);
  border-color: var(--border);
  color: var(--text-muted);
}

[data-theme="dark"] .settings-btn:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.logout-btn {
  flex: 1;
  height: 44px;
  padding: 0 var(--space-lg);
  background: transparent;
  border: 1px solid var(--accent-red);
  color: var(--accent-red);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: 500;
  font-family: var(--font-family);
  cursor: pointer;
  transition: all 150ms ease-out;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logout-btn:hover {
  background: rgba(229, 57, 53, 0.05);
}

/* =====================================================
   DASHBOARD
   ===================================================== */
.app-content {
  flex: 1;
  max-width: var(--max-content-width);
  margin: 0 auto;
  width: 100%;
}

.welcome-card {
  background: var(--surface);
  border-radius: 16px;
  padding: var(--space-md) var(--space-lg);
  margin-bottom: var(--space-sm);
  border: 1px solid var(--border);
  box-shadow: none;
}

/* Welcome header with refresh button */
.welcome-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

.welcome-header-text {
  flex: 1;
  text-align: center;
}

.refresh-btn {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--surface-elevated);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.refresh-btn:hover {
  color: var(--primary);
  border-color: var(--primary);
  background: rgba(37, 65, 178, 0.05);
}

.refresh-btn:active {
  transform: scale(0.92);
}

.refresh-btn svg {
  width: 18px;
  height: 18px;
}

.refresh-btn.refreshing svg {
  animation: spin 1s linear infinite;
}

.refresh-btn.refreshing {
  opacity: 0.6;
  pointer-events: none;
}

/* Skeleton loading styles */
.skeleton {
  background: linear-gradient(90deg, var(--border) 25%, rgba(255,255,255,0.05) 37%, var(--border) 63%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

[data-theme="dark"] .skeleton {
  background: linear-gradient(90deg, var(--border) 25%, rgba(255,255,255,0.08) 37%, var(--border) 63%);
  background-size: 200% 100%;
}

@keyframes skeletonShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.stat-value.skeleton {
  display: inline-block;
  width: 60px;
  height: 28px;
  color: transparent;
}

/* Stale data indicator */
.stale-data-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--font-size-xs);
  color: var(--accent-gold);
  background: rgba(245, 166, 35, 0.08);
  border: 1px solid rgba(245, 166, 35, 0.2);
  border-radius: var(--radius-full);
  padding: 2px 10px;
  margin-top: var(--space-xs);
}

.welcome-text {
  font-size: var(--font-size-lg);
  font-weight: 500;
  color: var(--text-primary);
}

.welcome-text span#user-name {
  font-weight: 700;
}

.wave-emoji {
  margin-right: var(--space-xs);
  opacity: 0.6;
}

.roll-number {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-top: 4px;
  text-align: center;
}

.attendance-card {
  background: var(--surface);
  border-radius: 16px;
  padding: var(--space-md) var(--space-lg);
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.section-title {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.section-icon {
  width: 20px;
  height: 20px;
  color: var(--primary);
}

.chart-emoji {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chart-emoji svg {
  width: 20px;
  height: 20px;
  stroke: var(--primary);
}

.stats-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.stat-card {
  background: var(--background);
  border-radius: 16px;
  padding: var(--space-md) var(--space-lg);
  text-align: center;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  transition: transform 150ms ease-out, box-shadow 150ms ease-out;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.stat-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.stat-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--space-xs);
}

.stat-value {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--text-primary);
}

.stat-value.percentage {
  color: var(--accent-green);
}

.stat-card.highlight .stat-value {
  color: var(--accent-green);
}

/* =====================================================
   CALCULATORS
   ===================================================== */
.calculator-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 2px 8px var(--shadow);
  border: 1px solid var(--border);
}

[data-theme="dark"] .calculator-card {
  background: var(--surface);
  border-color: var(--border);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.calc-header {
  background: var(--primary);
  color: white;
  padding: var(--space-md) var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.calc-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.calc-icon svg {
  width: 24px;
  height: 24px;
  stroke: var(--primary);
}

.calc-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
}

.calc-content {
  padding: var(--space-lg) var(--space-lg);
  text-align: center;
}

.calc-subtitle {
  font-size: var(--font-size-xl);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-xl);
}

.lightning {
  color: var(--accent-gold);
}

/* Slider - Pin style with value above track */
.slider-container {
  margin-bottom: var(--space-lg);
  padding: 0 var(--space-md);
  position: relative;
}

/* Pin/Balloon that shows the value */
.slider-pin {
  position: relative;
  width: 100%;
  height: 60px;
  display: flex;
  justify-content: center;
  margin-bottom: var(--space-sm);
}

.slider-pin .slider-value {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: left 0.1s ease;
}

.slider-pin .slider-value {
  background: var(--primary);
  color: white;
  padding: 10px 14px;
  border-radius: 50%;
  font-size: var(--font-size-sm);
  font-weight: 700;
  min-width: 48px;
  min-height: 48px;
  text-align: center;
  box-shadow: 0 4px 12px var(--shadow-strong);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Pin pointer (triangle pointing down) */
.slider-pin .slider-value::after {
  content: '';
  position: absolute;
  bottom: -12px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 14px solid var(--primary);
}

.slider-track {
  position: relative;
  padding-top: 24px;
}

.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  background: linear-gradient(90deg, var(--primary) 0%, var(--border) 0%);
  border-radius: var(--radius-full);
  outline: none;
  cursor: pointer;
  position: relative;
  z-index: 2;
}

/* Webkit (Chrome, Safari) slider thumb - invisible, we use the pin */
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  background: transparent;
  border: none;
  cursor: pointer;
}

/* Firefox slider thumb */
.slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  background: transparent;
  border: none;
  cursor: pointer;
}

/* Calculate Button */
.calculate-btn {
  padding: var(--space-md) var(--space-2xl);
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-xl);
  font-size: var(--font-size-base);
  font-weight: 600;
  font-family: var(--font-family);
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 0 4px 12px var(--shadow-strong);
}

.calculate-btn:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px var(--shadow-strong);
}

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

/* Results */
.calc-results {
  margin-top: var(--space-2xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-sm) 0;
}

.result-label {
  font-size: var(--font-size-base);
  color: var(--text-secondary);
}

.result-value {
  padding: var(--space-sm) var(--space-lg);
  background: var(--primary);
  border: 2px solid var(--primary);
  border-radius: var(--radius-xl);
  font-size: var(--font-size-base);
  font-weight: 600;
  color: white;
  min-width: 80px;
}

.result-value.negative {
  background: var(--accent-red);
  border-color: var(--accent-red);
  color: white;
}

.result-value.highlight-pill {
  background: var(--accent-gold);
  border-color: var(--accent-gold);
  color: white;
}

.result-note {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border);
}

/* Success/Failure Result Cards */
.success-card {
  background: rgba(72, 187, 120, 0.1);
  border: 2px solid var(--accent-green);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
}

.failure-card {
  background: rgba(229, 62, 62, 0.1);
  border: 2px solid var(--accent-red);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
}

.result-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
  font-size: var(--font-size-lg);
  font-weight: 700;
}

.result-header.success {
  color: var(--accent-green);
}

.result-header.failure {
  color: var(--accent-red);
}

.result-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.result-icon svg {
  width: 24px;
  height: 24px;
}

.result-header.success .result-icon svg {
  stroke: var(--accent-green);
}

.result-header.failure .result-icon svg {
  stroke: var(--accent-red);
}

.result-body {
  padding-left: var(--space-sm);
}

.highlight-green {
  background: var(--accent-green) !important;
  border-color: var(--accent-green) !important;
}

.failure-message {
  color: var(--text-secondary);
  font-size: var(--font-size-base);
  line-height: 1.5;
}

/* Max Attendance Info */
.calc-description {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-lg);
  text-align: center;
}

.max-attendance-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md);
  background: var(--background);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-lg);
}

.max-label {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.max-value {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--primary);
}

/* Settings Page */
.settings-group {
  margin-bottom: var(--space-xl);
}

.settings-label {
  display: block;
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
}

.settings-description {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
}

.settings-input-group {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.settings-input {
  flex: 1;
  padding: var(--space-md);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--text-primary);
  background: var(--surface);
  outline: none;
  transition: border-color var(--transition-fast);
}

.settings-input:focus {
  border-color: var(--primary);
}

.settings-unit {
  font-size: var(--font-size-base);
  color: var(--text-secondary);
}

.settings-saved-message {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
  padding: var(--space-md);
  background: rgba(72, 187, 120, 0.1);
  border-radius: var(--radius-md);
  color: var(--accent-green);
  font-weight: 600;
}

.success-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* success-icon svg {
  width: 20px;
  height: 20px;
  stroke: var(--accent-green);
}

/* =====================================================
   ABSENCE IMPACT REDESIGN
   ===================================================== */

/* Card Container */
.absence-card {
  padding: 0;
  overflow: hidden;
}

/* Header Section */
.absence-header {
  padding: var(--space-lg) var(--space-xl);
  border-bottom: 1px solid var(--border);
  background: rgba(37, 65, 178, 0.02);
}

[data-theme="dark"] .absence-header {
  background: rgba(22, 27, 34, 0.5);
  border-color: var(--border);
}

/* Ensure consistent dark-mode card backgrounds across all views */
[data-theme="dark"] .welcome-card,
[data-theme="dark"] .attendance-card {
  background: var(--surface);
  border-color: var(--border);
}

[data-theme="dark"] .stat-card {
  background: var(--background);
}

[data-theme="dark"] .heatmap-container {
  background: var(--surface);
  border-color: var(--border);
}

[data-theme="dark"] .qs-card {
  background: var(--surface);
  border-color: var(--border);
}

[data-theme="dark"] .day-detail-panel {
  background: var(--surface);
  border-color: var(--border);
}

.absence-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
}

.absence-subtitle {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin: 0;
}

/* Input Section */
.absence-input-section {
  padding: var(--space-xl);
  text-align: center;
}

.input-label {
  display: block;
  font-size: var(--font-size-base);
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
}

.input-subtext {
  display: block;
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  opacity: 0.7;
  margin-bottom: var(--space-lg);
}

/* Numeric Stepper */
.stepper-container {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-xs);
}

[data-theme="dark"] .stepper-container {
  background: rgba(22, 27, 34, 0.6);
  border-color: var(--border);
}

.stepper-btn {
  width: 44px;
  height: 44px;
  border: none;
  background: var(--background);
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

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

.stepper-btn:active {
  transform: scale(0.9);
}

.stepper-btn svg {
  width: 20px;
  height: 20px;
}

.stepper-input {
  width: 60px;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  background: transparent;
  border: none;
  font-family: var(--font-family);
  -moz-appearance: textfield;
  appearance: textfield;
}

.stepper-input::-webkit-outer-spin-button,
.stepper-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Action Button */
.impact-calculate-btn {
  display: block;
  width: calc(100% - var(--space-xl) * 2);
  margin: 0 var(--space-xl) var(--space-xl);
  padding: var(--space-md) var(--space-xl);
  font-size: var(--font-size-base);
  font-weight: 600;
  font-family: var(--font-family);
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.impact-calculate-btn:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 12px rgba(37, 65, 178, 0.25);
}

.impact-calculate-btn:active {
  transform: scale(0.98);
}

/* Results Section */
.impact-results {
  padding: 0 var(--space-xl) var(--space-xl);
}

.impact-baseline {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  text-align: center;
  margin-bottom: var(--space-md);
  opacity: 0.7;
}

.impact-summary-card {
  background: rgba(100, 116, 139, 0.06);
  border: 1px solid rgba(100, 116, 139, 0.12);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
}

[data-theme="dark"] .impact-summary-card {
  background: rgba(22, 27, 34, 0.5);
  border-color: var(--border);
}

.impact-summary-card .summary-title {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.3px;
  margin-bottom: var(--space-md);
}

.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-sm) 0;
}

.summary-row+.summary-row {
  border-top: 1px solid rgba(100, 116, 139, 0.08);
}

[data-theme="dark"] .summary-row+.summary-row {
  border-color: rgba(48, 54, 61, 0.6);
}

.summary-label {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.summary-value {
  font-size: 1.125rem;
  font-weight: 700;
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
}

.summary-value.impact-negative {
  color: #dc6b6b;
}

/* Value animation (applied after instant update) */
.summary-value.animate-value {
  animation: valueUpdate 250ms ease-out;
}

@keyframes valueUpdate {
  0% {
    opacity: 0.6;
    transform: translateY(-2px);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.summary-value.impact-final {
  color: var(--text-primary);
}

.summary-value.impact-final.healthy {
  color: #22c55e;
}

.summary-value.impact-final.warning {
  color: #f59e0b;
}

.summary-value.impact-final.danger {
  color: #ef4444;
}

/* Contextual Insight */
.impact-insight {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  text-align: center;
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px dashed var(--border);
}

/* =====================================================
   RESPONSIVE DESIGN
   ===================================================== */

/* Tablet and up */
@media (min-width: 768px) {
  :root {
    --max-content-width: 600px;
  }

  .stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }

  .stats-grid .stat-card:last-child {
    grid-column: span 2;
  }

  .result-item {
    justify-content: center;
    gap: var(--space-xl);
  }
}

/* Desktop */
@media (min-width: 1024px) {
  :root {
    --max-content-width: 700px;
    --header-height: 70px;
  }

  .app-header {
    padding: 0 var(--space-xl);
  }

  .header-title {
    font-size: var(--font-size-2xl);
  }

  .view {
    padding: var(--space-xl) var(--space-2xl);
  }

  .welcome-card,
  .attendance-card,
  .calculator-card {
    border-radius: var(--radius-xl);
  }

  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .stats-grid .stat-card:last-child {
    grid-column: auto;
  }

  .calc-content {
    padding: var(--space-2xl);
  }
}

/* Large Desktop */
@media (min-width: 1440px) {
  :root {
    --max-content-width: 800px;
  }
}

/* =====================================================
   UTILITIES & ANIMATIONS
   ===================================================== */
.loading {
  opacity: 0.7;
  pointer-events: none;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

.loading .stat-value {
  animation: pulse 1.5s infinite;
}

/* Smooth scrolling */
html {
  scroll-behavior: smooth;
}

/* Hide scrollbar but keep functionality */
.side-menu::-webkit-scrollbar {
  width: 0;
}

/* Warning Card */
.warning-card {
  background: rgba(229, 57, 53, 0.1);
  border: 2px solid var(--accent-red);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-top: var(--space-md);
  text-align: left;
}

.result-header.warning {
  color: var(--accent-red);
}

.result-header.warning .result-icon svg {
  stroke: var(--accent-red);
}

.warning-message {
  color: var(--text-primary);
  font-size: var(--font-size-base);
  line-height: 1.5;
}

/* =====================================================
   BUFFER COUNTER REDESIGN (Premium UI)
   ===================================================== */

/* Card & Header Updates */
.calculator-card.buffer-card {
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  border: 1px solid var(--border);
  overflow: visible;
  transition: background-color var(--transition-base), box-shadow var(--transition-base);
}

[data-theme="dark"] .calculator-card.buffer-card {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.calc-header.minimal-header {
  background: transparent;
  padding: var(--space-lg) var(--space-lg) var(--space-xs);
  justify-content: center;
  border-bottom: none;
}

.calc-title.muted-title {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
  opacity: 0.7;
}

.calc-content.buffer-content {
  padding: var(--space-md) var(--space-xl) var(--space-xl);
}

/* Threshold Display - Fixed Height Container */
.threshold-display-group {
  text-align: center;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
}

.threshold-label {
  display: block;
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--primary);
  margin-bottom: var(--space-xs);
}

[data-theme="dark"] .threshold-label {
  color: #7aa2f7;
}

.threshold-value {
  display: block;
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
  letter-spacing: -1.5px;
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
}

/* Enhanced Slider - Clear Separation */
.enhanced-slider-container {
  position: relative;
  padding: var(--space-md) var(--space-xs);
  margin-bottom: var(--space-lg);
  height: 70px;
  margin-top: 0;
}

.slider.gradient-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--border);
  outline: none;
  transition: background 0.45s cubic-bezier(0.22, 1, 0.36, 1);
  cursor: pointer;
  position: relative;
  z-index: 2;
}

/* Chrome/Safari Thumb */
.slider.gradient-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: white;
  border: 2px solid var(--primary);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.06);
  cursor: grab;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
  margin-top: -10px;
}

.slider.gradient-slider:active::-webkit-slider-thumb {
  transform: scale(1.3);
  box-shadow: 0 0 0 10px rgba(37, 65, 178, 0.1);
  cursor: grabbing;
}

[data-theme="dark"] .slider.gradient-slider::-webkit-slider-thumb {
  background: var(--primary);
  border-color: #e6edf3;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .slider.gradient-slider:active::-webkit-slider-thumb {
  box-shadow: 0 0 0 8px rgba(122, 162, 247, 0.15);
}

/* Firefox Thumb */
.slider.gradient-slider::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: white;
  border: 2px solid var(--primary);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  cursor: grab;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.slider-markers {
  position: absolute;
  top: 45px;
  left: 0;
  right: 0;
  height: 0;
  pointer-events: none;
  z-index: 1;
}

.marker {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  opacity: 0.6;
  transition: color var(--transition-base), opacity var(--transition-base);
}

.marker:nth-child(1) { left: 20%; }
.marker:nth-child(2) { left: 30%; }
.marker:nth-child(3) { left: 40%; }
.marker:nth-child(4) { left: 50%; }
.marker:nth-child(5) { left: 60%; }
.marker:nth-child(6) { left: 70%; }
.marker:nth-child(7) { left: 80%; }

.marker.active {
  color: var(--primary);
  font-weight: 700;
  opacity: 1;
}

[data-theme="dark"] .marker.active {
  color: #7aa2f7;
}

/* Buffer Info Box (Edge Case Message) */
.buffer-info-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-xl) var(--space-lg);
  background: rgba(100, 116, 139, 0.08);
  border: 1px solid rgba(100, 116, 139, 0.2);
  border-radius: var(--radius-lg);
  text-align: center;
}

[data-theme="dark"] .buffer-info-box {
  background: rgba(22, 27, 34, 0.5);
  border-color: var(--border);
}

.info-box-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(100, 116, 139, 0.1);
  border-radius: 50%;
  color: var(--text-secondary);
}

.info-box-icon svg {
  width: 24px;
  height: 24px;
}

.info-box-text {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  line-height: 1.6;
  max-width: 280px;
}

/* Insight Text */
.insight-text {
  height: 24px;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: var(--space-xl);
  font-style: italic;
  opacity: 0.9;
  transition: opacity var(--transition-base);
}

/* Premium Button */
.premium-btn {
  width: 100%;
  height: 50px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-xl);
  font-size: var(--font-size-lg);
  font-weight: 600;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all var(--transition-base);
  box-shadow: 0 2px 8px rgba(37, 65, 178, 0.15);
}

.premium-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(37, 65, 178, 0.2);
  filter: brightness(1.1);
}

.premium-btn:active {
  transform: scale(0.99);
}

/* Button Loading State */
.premium-btn.loading .btn-text {
  opacity: 0;
}

.loader-spinner {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  width: 24px;
  height: 24px;
  margin: -12px 0 0 -12px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 1s ease-in-out infinite;
}

.premium-btn.loading .loader-spinner {
  display: block;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Result Reveal Animation */
.calc-results-reveal {
  margin-top: var(--space-xl);
  animation: slideUpFade 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUpFade {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Circular Chart Layout */
.results-visual-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
  align-items: center;
  margin-bottom: var(--space-lg);
}

.result-circle-container {
  display: flex;
  justify-content: center;
}

.circular-chart {
  position: relative;
  display: inline-block;
  width: 140px;
  height: 140px;
}

.circular-chart-svg {
  display: block;
  max-width: 100%;
  max-height: 100%;
}

.circle-bg {
  fill: none;
  stroke: var(--border);
  stroke-width: 2.5;
}

[data-theme="dark"] .circle-bg {
  stroke: var(--border);
  opacity: 0.5;
}

.circle-val {
  fill: none;
  stroke: var(--accent-gold);
  stroke-width: 2.5;
  stroke-linecap: round;
  transition: stroke-dasharray 1s ease-out;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
}

.circle-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.circle-number {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.circle-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Stat Block */
.result-stat-block {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: var(--space-md);
  background: var(--background);
  border-radius: var(--radius-lg);
  height: 100px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.03);
}

[data-theme="dark"] .result-stat-block {
  background: var(--background);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.stat-block-label {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}

.stat-block-value {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* Assumption & Summary */
.assumption-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-bottom: var(--space-md);
}

.assumption-icon {
  width: 16px;
  height: 16px;
  stroke: var(--text-muted);
  opacity: 0.8;
  display: flex;
  align-items: center;
}

.assumption-icon svg {
  width: 100%;
  height: 100%;
}

.summary-line {
  text-align: center;
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  font-weight: 500;
  padding: var(--space-sm);
  background: rgba(37, 65, 178, 0.05);
  border-radius: var(--radius-md);
  border: 1px solid rgba(37, 65, 178, 0.1);
  opacity: 0;
  animation: fadeIn 0.5s ease forwards 0.3s;
}

[data-theme="dark"] .summary-line {
  background: rgba(37, 65, 178, 0.12);
  border-color: rgba(37, 65, 178, 0.25);
  color: #7aa2f7;
}

.summary-line.risk-alert {
  background: rgba(245, 101, 101, 0.08);
  border-color: rgba(245, 101, 101, 0.15);
  color: var(--text-secondary);
  font-weight: 500;
}

[data-theme="dark"] .summary-line.risk-alert {
  background: rgba(248, 81, 73, 0.08);
  border-color: rgba(248, 81, 73, 0.18);
  color: var(--text-secondary);
}

/* =====================================================
   TARGET CALCULATOR REDESIGN (Premium UI)
   ===================================================== */

.calculator-card.target-card {
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  border: 1px solid var(--border);
  overflow: visible;
}

[data-theme="dark"] .calculator-card.target-card {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.calc-content.target-content {
  padding: var(--space-md) var(--space-xl) var(--space-xl);
}

/* Max Reachable Card - Unified Card */
.max-reach-box {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: rgba(37, 65, 178, 0.04);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(37, 65, 178, 0.1);
  margin-bottom: var(--space-xl);
}

[data-theme="dark"] .max-reach-box {
  background: rgba(22, 27, 34, 0.6);
  border-color: var(--border);
}

.max-reach-box.centered-card {
  flex-direction: row;
  text-align: left;
  justify-content: flex-start;
  gap: var(--space-md);
  padding: var(--space-lg);
}

.max-reach-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  color: var(--primary);
  margin-bottom: var(--space-xs);
}

[data-theme="dark"] .max-reach-icon {
  background: var(--background);
  color: #7aa2f7;
}

.max-reach-icon svg {
  width: 24px;
  height: 24px;
}

.max-reach-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.max-reach-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  margin-bottom: 4px;
}

.max-reach-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}

[data-theme="dark"] .max-reach-value {
  color: #7aa2f7;
}

/* Main Target Display */
.target-selection-area {
  margin-bottom: var(--space-2xl);
  text-align: center;
}

.section-label {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-md);
}

.huge-target-display {
  font-size: 4rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: var(--space-xl);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  letter-spacing: -2px;
}

.huge-target-display .percent-symbol {
  font-size: 1.5rem;
  margin-top: 10px;
  color: var(--text-secondary);
  opacity: 0.6;
}

/* Slider Customization - Optically Centered */
.target-slider-container.centered-slider {
  padding: 0 var(--space-xs);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  margin-bottom: var(--space-md);
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Results Grid */
.results-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.result-metric-card {
  background: var(--background);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  border: 1px solid transparent;
  transition: all var(--transition-base);
}

[data-theme="dark"] .result-metric-card {
  background: var(--background);
}

.primary-metric {
  background: rgba(72, 187, 120, 0.08);
  border-color: rgba(72, 187, 120, 0.3);
}

[data-theme="dark"] .primary-metric {
  background: rgba(63, 185, 80, 0.1);
  border-color: rgba(63, 185, 80, 0.2);
}

.metric-icon {
  margin-bottom: var(--space-md);
  color: var(--text-secondary);
  width: 24px;
  height: 24px;
}

.primary-metric .metric-icon {
  color: var(--accent-green);
}

.metric-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

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

.metric-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

.metric-value.big-figure {
  font-size: 2.25rem;
  color: var(--accent-green);
}

.target-note {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: var(--space-md);
}


/* Achieved View (Success State) */
.achieved-card {
  background: rgba(72, 187, 120, 0.1);
  border: 1px solid rgba(72, 187, 120, 0.25);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
}

.achieved-icon {
  width: 56px;
  height: 56px;
  background: var(--accent-green);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 4px 12px rgba(67, 160, 71, 0.3);
  margin-bottom: var(--space-xs);
}

.achieved-icon svg {
  width: 28px;
  height: 28px;
  stroke: white;
  stroke-width: 3;
}

.achieved-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent-green);
}

.achieved-message {
  font-size: 1rem;
  color: var(--text-primary);
  line-height: 1.5;
  max-width: 280px;
}

[data-theme="dark"] .achieved-message {
  color: var(--text-primary);
}


/* Failure View */
.failure-message-box {
  background: rgba(229, 62, 62, 0.05);
  border: 1px solid rgba(229, 62,  62, 0.2);
  border-radius: var(--radius-lg);
  padding: var(--space-xl) var(--space-lg);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
}

.warning-icon-large {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(229, 62, 62, 0.1);
  color: var(--accent-red);
  display: flex;
  align-items: center;
  justify-content: center;
}

.warning-icon-large svg {
  width: 32px;
  height: 32px;
}

.failure-text {
  color: var(--accent-red);
  font-weight: 600;
  font-size: 1rem;
}

/* =====================================================
   ACCESSIBILITY
   ===================================================== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Enhanced focus indicators */
*:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

button:focus-visible {
  box-shadow: 0 0 0 4px rgba(37, 65, 178, 0.25);
}

[data-theme="dark"] *:focus-visible {
  outline-color: #7aa2f7;
}

[data-theme="dark"] button:focus-visible {
  box-shadow: 0 0 0 4px rgba(122, 162, 247, 0.25);
}

/* =====================================================
   TREND INDICATOR
   ===================================================== */
.trend-indicator {
  margin-top: var(--space-xs);
  font-size: var(--font-size-xs);
  font-weight: 600;
  min-height: 20px;
}

.trend-up {
  color: var(--accent-green);
  display: inline-flex;
  align-items: center;
  gap: 2px;
  animation: fadeSlideUp 0.4s ease-out;
}

.trend-down {
  color: var(--accent-red);
  display: inline-flex;
  align-items: center;
  gap: 2px;
  animation: fadeSlideUp 0.4s ease-out;
}

.trend-stable {
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 2px;
  animation: fadeSlideUp 0.4s ease-out;
}

.trend-new {
  color: var(--primary);
  font-weight: 500;
  font-size: var(--font-size-xs);
  animation: fadeSlideUp 0.4s ease-out;
}

.trend-indicator small {
  opacity: 0.7;
  font-weight: 500;
  margin-left: 2px;
}

/* =====================================================
   LAST REFRESHED TIMESTAMP
   ===================================================== */
.last-refreshed {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-top: var(--space-xs);
  opacity: 0.7;
}

/* =====================================================
   SMART INSIGHTS CARDS
   ===================================================== */
.insights-section {
  margin-top: var(--space-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.insight-card {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  animation: insightSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

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

@keyframes insightSlideIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.insight-card.insight-warning {
  border-left: 3px solid var(--accent-gold);
  background: rgba(245, 166, 35, 0.04);
}

.insight-card.insight-danger {
  border-left: 3px solid var(--accent-red);
  background: rgba(229, 57, 53, 0.04);
}

.insight-card.insight-positive {
  border-left: 3px solid var(--accent-green);
  background: rgba(67, 160, 71, 0.04);
}

.insight-card.insight-info {
  border-left: 3px solid var(--primary);
  background: rgba(37, 65, 178, 0.04);
}

[data-theme="dark"] .insight-card.insight-warning {
  background: rgba(245, 166, 35, 0.08);
}

[data-theme="dark"] .insight-card.insight-danger {
  background: rgba(229, 57, 53, 0.08);
}

[data-theme="dark"] .insight-card.insight-positive {
  background: rgba(67, 160, 71, 0.08);
}

[data-theme="dark"] .insight-card.insight-info {
  background: rgba(37, 65, 178, 0.08);
}

.insight-icon {
  flex-shrink: 0;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
}

.insight-icon .insight-svg {
  width: 20px;
  height: 20px;
}

.insight-card.insight-warning .insight-svg {
  color: var(--accent-gold);
}

.insight-card.insight-danger .insight-svg {
  color: var(--accent-red);
}

.insight-card.insight-positive .insight-svg {
  color: var(--accent-green);
}

.insight-card.insight-info .insight-svg {
  color: var(--primary);
}

.insight-body {
  flex: 1;
  min-width: 0;
}

.insight-title {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.insight-text-detail {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
}

/* =====================================================
   STAGGERED STAT ANIMATIONS
   ===================================================== */
.stat-card {
  animation: statEntrance 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.stat-card:nth-child(1) { animation-delay: 0ms; }
.stat-card:nth-child(2) { animation-delay: 80ms; }
.stat-card:nth-child(3) { animation-delay: 160ms; }

@keyframes statEntrance {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* =====================================================
   ENHANCED MICRO-INTERACTIONS
   ===================================================== */

/* Button press ripple effect */
.calculate-btn,
.premium-btn,
.impact-calculate-btn,
.login-btn.primary-btn {
  position: relative;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

.calculate-btn:active,
.premium-btn:active,
.impact-calculate-btn:active,
.login-btn.primary-btn:active {
  transform: scale(0.97);
  transition: transform 80ms ease;
}

/* Stepper button enhanced interaction */
.stepper-btn:active {
  transform: scale(0.9);
  transition: transform 80ms ease;
}

/* Card hover lift effect */
.stat-card,
.insight-card,
.welcome-card,
.attendance-card {
  -webkit-tap-highlight-color: transparent;
}

/* Menu nav items press effect */
.menu-nav-item:active {
  transform: scale(0.97);
  transition: transform 80ms ease;
}

/* Slider thumb enhanced touch area (larger invisible hit zone) */
.slider.gradient-slider::-webkit-slider-thumb {
  width: 32px;
  height: 32px;
}

/* Toggle switch improved touch target */
.toggle-switch {
  min-width: 48px;
  min-height: 32px;
  padding: 3px;
}

/* =====================================================
   VIEW TRANSITION ANIMATION (smoother page switches)
   ===================================================== */
@keyframes fadeSlideUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.view.active {
  animation: fadeSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* =====================================================
   MENU OPEN — PREVENT BODY SCROLL
   ===================================================== */
body.menu-open {
  overflow: hidden;
}

/* =====================================================
   SUCCESS CELEBRATION (subtle)
   ===================================================== */
@keyframes celebratePulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.achieved-card {
  animation: slideUpFade 0.5s ease-out, celebratePulse 0.6s ease-out 0.5s;
}

.achieved-icon {
  animation: celebratePulse 0.8s ease-out 0.3s;
}

/* =====================================================
   HISTORY VIEW — GitHub-style Attendance Heatmap
   ===================================================== */

.history-card {
  margin-bottom: var(--space-lg);
}

/* Loading State */
.history-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl) var(--space-lg);
  gap: var(--space-md);
}

.history-loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.history-loading-text {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

/* Empty State */
.history-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--space-2xl) var(--space-lg);
  gap: var(--space-md);
}

.history-empty-state .empty-icon {
  font-size: 3rem;
}

.history-empty-state h4 {
  font-size: var(--font-size-lg);
  color: var(--text-primary);
  margin: 0;
}

.history-empty-state p {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin: 0;
  max-width: 260px;
}

/* ── Heatmap Container ── */
.heatmap-container {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
}

.graph-title {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-md);
}

.legend-label {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

.heatmap-scroll-wrapper {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}

/* Hide scrollbar but keep functionality */
.heatmap-scroll-wrapper::-webkit-scrollbar {
  height: 0;
  display: none;
}

/* Day labels (Mon, Wed, Fri) */
.heatmap-day-labels {
  display: grid;
  grid-template-rows: repeat(7, 13px);
  gap: 3px;
  padding-top: 20px; /* align with grid (below month labels) */
  flex-shrink: 0;
}

.heatmap-day-labels span {
  font-size: 9px;
  color: var(--text-muted);
  line-height: 13px;
  text-align: right;
  padding-right: 4px;
  white-space: nowrap;
}

/* Grid area (month labels + cells) */
.heatmap-grid-area {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Month labels */
.heatmap-month-labels {
  display: grid;
  grid-template-columns: repeat(14, 13px);
  gap: 3px;
  height: 16px;
  margin-bottom: 4px;
}

.heatmap-month-labels span {
  font-size: 9px;
  color: var(--text-muted);
  line-height: 16px;
  white-space: nowrap;
}

/* The actual grid of cells */
.heatmap-grid {
  display: grid;
  grid-template-rows: repeat(7, 13px);
  grid-auto-flow: column;
  grid-auto-columns: 13px;
  gap: 3px;
}

/* ── Heatmap Cells ── */
.heatmap-cell {
  width: 13px;
  height: 13px;
  border-radius: 2px;
  cursor: pointer;
  transition: transform 0.1s ease, outline-color 0.1s ease;
  outline: 1px solid transparent;
  outline-offset: -1px;
}

.heatmap-cell:hover {
  transform: scale(1.3);
  outline-color: var(--text-secondary);
  z-index: 2;
}

.heatmap-cell:active {
  transform: scale(1.1);
}

/* Level colors — Light theme (GitHub-green style) */
.heatmap-level-0 {
  background-color: #ebedf0;
}
.heatmap-level-1 {
  background-color: #9be9a8;
}
.heatmap-level-2 {
  background-color: #40c463;
}
.heatmap-level-3 {
  background-color: #30a14e;
}
.heatmap-level-4 {
  background-color: #216e39;
}

.heatmap-absent {
  background-color: #ff6b6b;
  border: 1px solid #e53935;
}

.heatmap-no-data {
  background-color: #ebedf0;
  opacity: 0.4;
}

.heatmap-weekend {
  background-color: transparent;
  border: 1px dashed var(--border);
  opacity: 0.3;
  cursor: default;
}

.heatmap-weekend:hover {
  transform: none;
  outline-color: tran
  
}

.heatmap-future {
  background: none;
  cursor: default;
}

.heatmap-future:hover {
  transform: none;
}

/* Level colors — Dark theme */
[data-theme="dark"] .heatmap-level-0 {
  background-color: #1c2128;
}
[data-theme="dark"] .heatmap-level-1 {
  background-color: #0e4429;
}
[data-theme="dark"] .heatmap-level-2 {
  background-color: #006d32;
}
[data-theme="dark"] .heatmap-level-3 {
  background-color: #26a641;
}
[data-theme="dark"] .heatmap-level-4 {
  background-color: #39d353;
}

[data-theme="dark"] .heatmap-absent {
  background-color: #c62828;
  border-color: #e53935;
}

[data-theme="dark"] .heatmap-no-data {
  background-color: #1c2128;
  opacity: 0.4;
}

[data-theme="dark"] .heatmap-weekend {
  border-color: var(--border);
}

/* ── Legend ── */
.heatmap-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  margin-top: var(--space-md);
}

.heatmap-legend .legend-squares {
  display: flex;
  gap: 3px;
}

.heatmap-legend .legend-square {
  width: 13px;
  height: 13px;
  border-radius: 2px;
}

/* ── Tooltip ── */
.heatmap-tooltip {
  position: fixed;
  pointer-events: none;
  background: var(--text-primary);
  color: var(--background);
  font-size: 11px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  transform: translate(-50%, -100%) translateY(-4px);
  transition: opacity 0.12s ease;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.heatmap-tooltip.visible {
  opacity: 1;
}

/* ── Quick Stats ── */
.history-quick-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.qs-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-sm) var(--space-xs);
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.qs-value {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--text-primary);
}

.qs-label {
  font-size: 10px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 2px;
}

.qs-good {
  color: var(--accent-green);
}

.qs-bad {
  color: var(--accent-red);
}

/* ── Day Detail Panel ── */
.day-detail-panel {
  position: relative;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
  animation: slideUp 0.2s ease;
}

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

.day-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-sm);
}

.day-detail-header h4 {
  font-size: var(--font-size-base);
  font-weight: 600;
  margin: 0;
}

.day-detail-pct {
  font-size: var(--font-size-lg);
  font-weight: 700;
}

.day-detail-pct.good { color: var(--accent-green); }
.day-detail-pct.warn { color: var(--accent-gold); }
.day-detail-pct.bad { color: var(--accent-red); }

.day-detail-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: var(--space-sm);
}

.day-detail-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.4s ease;
}

.day-detail-summary {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin: 0 0 var(--space-sm);
}

.day-detail-subjects {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

.day-subject {
  font-size: var(--font-size-xs);
  padding: 3px 8px;
  border-radius: var(--radius-full);
  background: var(--surface);
  border: 1px solid var(--border);
}

.day-subject.present {
  border-color: rgba(67, 160, 71, 0.3);
  background: rgba(67, 160, 71, 0.08);
}

.day-subject.absent {
  border-color: rgba(229, 57, 53, 0.3);
  background: rgba(229, 57, 53, 0.08);
}

.day-detail-close {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  width: 28px;
  height: 28px;
  border: none;
  background: var(--surface);
  border-radius: var(--radius-full);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.day-detail-close:hover {
  background: var(--border);
}

/* ── Password Modal ── */
.password-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: fadeIn 0.15s ease;
  padding: var(--space-lg);
}

.password-modal-overlay.closing {
  animation: fadeOut 0.15s ease forwards;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

.password-modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  max-width: 340px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.2s ease;
}

.password-modal h4 {
  font-size: var(--font-size-lg);
  margin: 0 0 var(--space-sm);
  color: var(--text-primary);
}

.password-modal p {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin: 0 0 var(--space-lg);
  line-height: 1.5;
}

.password-modal-input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-base);
  font-family: var(--font-family);
  background: var(--background);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition-fast);
  margin-bottom: var(--space-lg);
}

.password-modal-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 65, 178, 0.1);
}

.password-modal-actions {
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
}

.password-modal-cancel {
  padding: 10px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  font-family: var(--font-family);
  cursor: pointer;
}

.password-modal-cancel:hover {
  background: var(--border);
}

.password-modal-confirm {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: white;
  font-size: var(--font-size-sm);
  font-weight: 600;
  font-family: var(--font-family);
  cursor: pointer;
}

.password-modal-confirm:hover {
  filter: brightness(1.1);
}

/* ── History Actions ── */
.history-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.history-actions .calculate-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
}

.history-actions .primary-btn {
  background: var(--primary);
  color: white;
  border: none;
}

.history-actions .primary-btn:hover {
  filter: brightness(1.1);
}

.history-actions .secondary-btn {
  background: var(--surface-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.history-actions .secondary-btn:hover {
  background: var(--border);
}

.history-message {
  padding: var(--space-md);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  text-align: center;
}

.history-message.error {
  background: rgba(229, 57, 53, 0.1);
  color: var(--accent-red);
  border: 1px solid rgba(229, 57, 53, 0.2);
}

.history-message.info {
  background: rgba(37, 65, 178, 0.1);
  color: var(--primary);
  border: 1px solid rgba(37, 65, 178, 0.2);
}

.graph-note {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  text-align: center;
  margin-top: var(--space-sm);
}

/* ── Streak Section — History View ── */
.history-streak-section {
    margin-top: var(--space-md);
    padding: var(--space-md);
    background: var(--surface-elevated);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

[data-theme="dark"] .history-streak-section {
    background: var(--card-bg);
    border-color: var(--border);
}

.streak-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: var(--space-sm);
}

.streak-flame {
    display: flex;
    align-items: center;
}

.streak-title {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.streak-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-sm);
}

.streak-stat-card {
    text-align: center;
    padding: var(--space-sm) var(--space-xs);
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--border);
    transition: all var(--transition-fast);
}

[data-theme="dark"] .streak-stat-card {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.06);
}

.streak-stat-card.streak-active {
    border-color: rgba(249, 115, 22, 0.3);
    background: rgba(249, 115, 22, 0.05);
}

[data-theme="dark"] .streak-stat-card.streak-active {
    border-color: rgba(249, 115, 22, 0.25);
    background: rgba(249, 115, 22, 0.08);
}

.streak-stat-card.streak-inactive {
    opacity: 0.6;
}

.streak-stat-value {
    display: block;
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.streak-stat-card.streak-active .streak-stat-value {
    color: #f97316;
}

.streak-stat-label {
    display: block;
    font-size: 10px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

.streak-stat-unit {
    display: block;
    font-size: 10px;
    color: var(--text-muted);
    opacity: 0.7;
}

.streak-encourage {
    margin: var(--space-sm) 0 0 0;
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.4;
}

.streak-encourage.streak-motivate {
    color: var(--text-muted);
    font-style: italic;
}

/* Privacy Assurance Box */
.login-privacy-box {
  margin-top: var(--space-xl);
  padding: var(--space-lg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-secondary);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  transition: all var(--transition-base);
}

[data-theme="dark"] .login-privacy-box {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.1);
}

.login-privacy-box:hover {
  border-color: var(--primary-light);
  background: var(--surface);
  box-shadow: 0 2px 12px rgba(37, 65, 178, 0.08);
}

[data-theme="dark"] .login-privacy-box:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(75, 111, 230, 0.4);
  box-shadow: 0 2px 12px rgba(75, 111, 230, 0.15);
}

.privacy-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #4ade80, #22c55e);
  border-radius: var(--radius-md);
  padding: 6px;
}

.privacy-icon svg {
  width: 20px;
  height: 20px;
  stroke: white;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
}

.privacy-text {
  flex: 1;
  font-size: var(--font-size-sm);
  line-height: 1.5;
  color: var(--text-secondary);
}

.privacy-text span {
  display: block;
}

/* Mobile responsiveness for privacy box */
@media (max-width: 375px) {
  .login-privacy-box {
    padding: var(--space-md);
    gap: var(--space-sm);
  }
  
  .privacy-icon {
    width: 28px;
    height: 28px;
  }
  
  .privacy-icon svg {
    width: 18px;
    height: 18px;
  }
  
  .privacy-text {
    font-size: 12px;
  }
}