/*
 * Mworld CRM - Modern Design System (2025-2026)
 * Features: Card-based layouts, glassmorphism, dual theme support,
 * responsive design, smooth animations, and improved accessibility.
 */

/* ===== CSS Variables - Research-Based 2025-2026 Palettes ===== */
:root {
  /* Primary Blue - Main brand color */
  --primary-50: #eff6ff;
  --primary-100: #dbeafe;
  --primary-200: #bfdbfe;
  --primary-300: #93c5fd;
  --primary-400: #60a5fa;
  --primary-500: #3b82f6;
  --primary-600: #2563eb;
  --primary-700: #1d4ed8;
  --primary-800: #1e40af;
  --primary-900: #1e3a8a;

  /* Secondary Purple - Accents */
  --secondary-50: #f5f3ff;
  --secondary-100: #ede9fe;
  --secondary-200: #ddd6fe;
  --secondary-300: #c4b5fd;
  --secondary-400: #a78bfa;
  --secondary-500: #8b5cf6;
  --secondary-600: #7c3aed;
  --secondary-700: #6d28d9;
  --secondary-800: #5b21b6;
  --secondary-900: #4c1d95;

  /* Accent Teal */
  --accent-50: #f0fdfa;
  --accent-100: #ccfbf1;
  --accent-200: #99f6e4;
  --accent-300: #5eead4;
  --accent-400: #2dd4bf;
  --accent-500: #14b8a6;
  --accent-600: #0d9488;
  --accent-700: #0f766e;
  --accent-800: #115e59;
  --accent-900: #134e4a;

  /* Semantic Colors */
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  --info: #3b82f6;

  /* LIGHT MODE - Professional Slate Grays */
  --bg-main: #ffffff;
  --bg-card: #f8fafc;
  --bg-secondary: #f1f5f9;
  --bg-accent: #e2e8f0;
  --bg-glass: rgba(255, 255, 255, 0.7);

  /* Light Mode Text - Slate Blue-Grays */
  --text-primary: #1e293b;
  --text-secondary: #475569;
  --text-tertiary: #64748b;
  --text-muted: #94a3b8;
  --text-inverse: #ffffff;

  /* Light Mode Borders */
  --border-primary: #e2e8f0;
  --border-secondary: #cbd5e1;
  --border-accent: #3b82f6;

  /* Gray Scale - Light Mode */
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;

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

  /* Borders & Shadows */
  --border-radius: 8px;
  --border-radius-lg: 12px;
  --border-radius-xl: 16px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.15);
  --shadow-glass: 0 8px 32px rgba(0, 0, 0, 0.1);

  /* Transitions */
  --transition: 0.2s ease;
  --transition-fast: 0.15s ease;
  --transition-slow: 0.3s ease;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, monospace;

  /* Fallbacks for compatibility */
  --bg-primary: var(--bg-main);
  --bg-secondary: var(--bg-secondary);
  --bg-tertiary: var(--bg-accent);
  --text-primary: var(--text-primary);
  --text-secondary: var(--text-secondary);
  --text-tertiary: var(--text-tertiary);
  --border-color: var(--border-primary);
}
/* ===== Reset & Base ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-main);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== Layout ===== */
.container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--spacing-lg);
}

.container-fluid {
  width: 100%;
  padding: 0 var(--spacing-lg);
}

.row {
  display: flex;
  flex-wrap: wrap;
  margin: 0 calc(-1 * var(--spacing-md));
}

.col {
  flex: 1;
  padding: 0 var(--spacing-md);
}

.col-md-1 { flex: 0 0 8.333%; max-width: 8.333%; padding: 0 var(--spacing-md); }
.col-md-2 { flex: 0 0 16.667%; max-width: 16.667%; padding: 0 var(--spacing-md); }
.col-md-3 { flex: 0 0 25%; max-width: 25%; padding: 0 var(--spacing-md); }
.col-md-4 { flex: 0 0 33.333%; max-width: 33.333%; padding: 0 var(--spacing-md); }
.col-md-5 { flex: 0 0 41.667%; max-width: 41.667%; padding: 0 var(--spacing-md); }
.col-md-6 { flex: 0 0 50%; max-width: 50%; padding: 0 var(--spacing-md); }
.col-md-7 { flex: 0 0 58.333%; max-width: 58.333%; padding: 0 var(--spacing-md); }
.col-md-8 { flex: 0 0 66.667%; max-width: 66.667%; padding: 0 var(--spacing-md); }
.col-md-9 { flex: 0 0 75%; max-width: 75%; padding: 0 var(--spacing-md); }
.col-md-10 { flex: 0 0 83.333%; max-width: 83.333%; padding: 0 var(--spacing-md); }
.col-md-11 { flex: 0 0 91.667%; max-width: 91.667%; padding: 0 var(--spacing-md); }
.col-md-12 { flex: 0 0 100%; max-width: 100%; padding: 0 var(--spacing-md); }

/* ===== Glassmorphism Card ===== */
.card {
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-glass);
  padding: var(--spacing-xl);
  margin-bottom: var(--spacing-lg);
  transition: all var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-xl);
  transform: translateY(-2px);
}

.card-header {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--spacing-lg);
  padding-bottom: var(--spacing-md);
  border-bottom: 1px solid var(--border-color);
}

.card-body {
  padding: var(--spacing-md) 0;
}

.card-footer {
  padding-top: var(--spacing-md);
  border-top: 1px solid var(--border-color);
  margin-top: var(--spacing-lg);
}

/* ===== Bento Grid Layout ===== */
.bento-grid {
  display: grid;
  gap: var(--spacing-lg);
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.bento-item {
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  padding: var(--spacing-xl);
  transition: all var(--transition);
}

.bento-item:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-4px);
}

.bento-item.span-2 { grid-column: span 2; }
.bento-item.span-3 { grid-column: span 3; }

/* ===== Typography ===== */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.2;
  color: var(--text-primary);
  margin-bottom: var(--spacing-md);
}

h1 { font-size: 2.5rem; letter-spacing: -0.02em; }
h2 { font-size: 2rem; letter-spacing: -0.01em; }
h3 { font-size: 1.75rem; }
h4 { font-size: 1.5rem; }
h5 { font-size: 1.25rem; }
h6 { font-size: 1rem; }

p {
  margin-bottom: var(--spacing-md);
  color: var(--text-secondary);
}

a {
  color: var(--primary-600);
  text-decoration: none;
  transition: color var(--transition-fast);
}

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

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.5;
  border-radius: var(--border-radius);
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

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

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

.btn-primary {
  background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
  color: white;
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-600), var(--primary-700));
  color: white;
  text-decoration: none;
}

.btn-secondary {
  background: var(--gray-100);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--gray-200);
  color: var(--text-primary);
  text-decoration: none;
}

.btn-outline {
  background: transparent;
  color: var(--primary-600);
  border: 1px solid var(--primary-300);
}

.btn-outline:hover {
  background: var(--primary-50);
  color: var(--primary-700);
  text-decoration: none;
}

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

.btn-info:hover {
  background: var(--primary-700);
  color: white;
  text-decoration: none;
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
}

.btn-group {
  display: inline-flex;
  gap: var(--spacing-sm);
}

/* ===== Forms ===== */
.form-control,
.form-select {
  width: 100%;
  padding: 0.625rem 0.875rem;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  transition: all var(--transition);
}

.form-control:focus,
.form-select:focus {
  outline: none;
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: var(--spacing-sm);
}

/* ===== Tables ===== */
.table-responsive {
  overflow-x: auto;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-sm);
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-primary);
}

.table thead {
  background: linear-gradient(135deg, var(--gray-50), var(--gray-100));
}

.table th {
  padding: var(--spacing-md) var(--spacing-lg);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
}

.table td {
  padding: var(--spacing-md) var(--spacing-lg);
  font-size: 0.875rem;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color);
}

.table tbody tr {
  transition: background-color var(--transition-fast);
}

.table tbody tr:hover {
  background-color: var(--gray-50);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table-striped tbody tr:nth-of-type(odd) {
  background-color: var(--bg-secondary);
}

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1;
  border-radius: 9999px;
  letter-spacing: 0.025em;
}

.bg-primary { background: var(--primary-500); color: white; }
.bg-info { background: var(--info); color: white; }
.bg-success { background: var(--success); color: white; }
.bg-warning { background: var(--warning); color: white; }
.bg-danger { background: var(--error); color: white; }
.bg-secondary { background: var(--gray-500); color: white; }

/* ===== Utility Classes ===== */
.d-flex { display: flex; }
.justify-content-between { justify-content: space-between; }
.justify-content-center { justify-content: center; }
.align-items-center { align-items: center; }
.align-items-start { align-items: flex-start; }
.gap-1 { gap: var(--spacing-sm); }
.gap-2 { gap: var(--spacing-md); }
.gap-3 { gap: var(--spacing-lg); }
.mb-1 { margin-bottom: var(--spacing-sm); }
.mb-2 { margin-bottom: var(--spacing-md); }
.mb-3 { margin-bottom: var(--spacing-lg); }
.mb-4 { margin-bottom: var(--spacing-xl); }
.mt-2 { margin-top: var(--spacing-md); }
.mt-3 { margin-top: var(--spacing-lg); }
.mt-4 { margin-top: var(--spacing-xl); }
.p-2 { padding: var(--spacing-md); }
.p-3 { padding: var(--spacing-lg); }
.p-4 { padding: var(--spacing-xl); }
.text-center { text-align: center; }
.text-muted { color: var(--text-secondary); }
.text-small { font-size: 0.875rem; }
.fw-bold { font-weight: 600; }
.fw-normal { font-weight: 400; }
.w-100 { width: 100%; }

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

.fade-in {
  animation: fadeIn var(--transition-slow) ease-out;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .container { padding: 0 var(--spacing-md); }

  .col-md-1, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6,
  .col-md-7, .col-md-8, .col-md-9, .col-md-10, .col-md-11, .col-md-12 {
    flex: 0 0 100%;
    max-width: 100%;
  }

  h1 { font-size: 2rem; }
  h2 { font-size: 1.75rem; }
  h3 { font-size: 1.5rem; }

  .table th,
  .table td {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 0.75rem;
  }

  .btn {
    width: 100%;
    margin-bottom: var(--spacing-sm);
  }

  .btn-group {
    flex-direction: column;
    width: 100%;
  }
}

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

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  margin-left: 260px;
  transition: margin-left var(--transition);
}

/* ===== Sidebar ===== */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 260px;
  height: 100vh;
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: transform var(--transition), width var(--transition);
  overflow-y: auto;
  overflow-x: hidden;
}

/* Sidebar Header - Logo & Brand */
.sidebar-header {
  padding: var(--spacing-lg);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  background: linear-gradient(135deg, var(--primary-500), var(--accent-500));
}

.sidebar-logo {
  width: 40px;
  height: 40px;
  background: #ffffff;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 1.25rem;
  color: var(--primary-500);
  box-shadow: var(--shadow-md);
  flex-shrink: 0;
}

.sidebar-brand {
  flex: 1;
  min-width: 0;
}

.sidebar-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: #ffffff;
  margin: 0;
  letter-spacing: -0.5px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-subtitle {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.95);
  margin: 0;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sidebar Navigation */
.sidebar-nav {
  flex: 1;
  padding: var(--spacing-lg);
  overflow-y: auto;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: 0.75rem 1rem;
  margin-bottom: var(--spacing-sm);
  border-radius: var(--border-radius);
  color: var(--text-secondary);
  text-decoration: none;
  transition: all var(--transition);
  font-weight: 500;
  font-size: 0.9375rem;
}

.sidebar-nav-item:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
  text-decoration: none;
  transform: translateX(4px);
}

.sidebar-nav-item-active {
  background: var(--primary-50);
  color: var(--primary-600);
  font-weight: 600;
}

html.dark-mode .sidebar-nav-item-active {
  background: var(--bg-secondary);
  color: var(--primary-400);
}

.sidebar-nav-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
  width: 24px;
  text-align: center;
}

.sidebar-nav-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: var(--spacing-lg);
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.sidebar-store {
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border-radius: var(--border-radius);
  margin-bottom: var(--spacing-md);
  border: 1px solid var(--border-color);
}

.sidebar-store-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sidebar-store-value {
  display: block;
  font-size: 1rem;
  color: var(--text-primary);
}

.sidebar-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-sm);
  flex-wrap: wrap;
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user-name {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-signout-btn,
.sidebar-signin-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: var(--border-radius);
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

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

.sidebar-signout-btn:hover {
  background: var(--primary-700);
  color: white;
  text-decoration: none;
}

.sidebar-signin-btn {
  background: var(--bg-card);
  color: var(--primary-600);
  border: 1px solid var(--primary-300);
}

.sidebar-signin-btn:hover {
  background: var(--primary-50);
  color: var(--primary-700);
  text-decoration: none;
}

/* Sidebar Dark Mode Toggle */
.sidebar-dark-mode-toggle {
  width: 36px;
  height: 36px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}

.sidebar-dark-mode-toggle:hover {
  background: var(--bg-secondary);
  border-color: var(--primary-500);
}

.sidebar-dark-mode-icon {
  font-size: 1.125rem;
}

/* Sidebar Collapsed State (Desktop) */
.sidebar-collapsed {
  width: 70px;
}

.sidebar-collapsed ~ .main-content {
  margin-left: 70px;
}

.sidebar-collapsed .sidebar-brand,
.sidebar-collapsed .sidebar-nav-text,
.sidebar-collapsed .sidebar-store-label,
.sidebar-collapsed .sidebar-user-info {
  display: none;
}

.sidebar-collapsed .sidebar-store {
  padding: 0.75rem;
  text-align: center;
}

.sidebar-collapsed .sidebar-user {
  justify-content: center;
}

/* Mobile Sidebar Overlay */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition);
}

.sidebar-overlay-visible {
  opacity: 1;
  visibility: visible;
}

/* Mobile Sidebar Toggle Button */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  width: 44px;
  height: 44px;
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  cursor: pointer;
  z-index: 998;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: all var(--transition);
}

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

.sidebar-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: all var(--transition);
}

/* Flash Messages in Sidebar Layout */
.flash-notice,
.flash-alert {
  position: fixed;
  top: 1rem;
  right: 1rem;
  max-width: 400px;
  z-index: 1100;
  padding: var(--spacing-md) var(--spacing-lg);
  border-radius: var(--border-radius);
  animation: slideIn 0.3s ease-out;
}

.flash-notice {
  background: var(--accent-50);
  color: var(--accent-700);
  border: 1px solid var(--accent-200);
  box-shadow: var(--shadow-lg);
}

.flash-alert {
  background: #fef2f2;
  color: var(--error);
  border: 1px solid #fecaca;
  box-shadow: var(--shadow-lg);
}

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

/* Main Content Padding */
.main-content > main {
  padding: var(--spacing-xl);
  flex: 1;
}

/* Responsive Styles */
@media (max-width: 768px) {
  .main-content {
    margin-left: 0;
  }

  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar-mobile-open {
    transform: translateX(0);
  }

  .sidebar-toggle {
    display: flex;
  }

  .main-content > main {
    padding: var(--spacing-lg);
  }

  .flash-notice,
  .flash-alert {
    left: 1rem;
    right: 1rem;
    max-width: none;
  }

  .sidebar-nav-item {
    padding: 1rem;
  }

  .sidebar-footer {
    padding: var(--spacing-md);
  }
}

/* ===== Site Header ===== */
.site-header {
  background: linear-gradient(135deg, var(--primary-500), var(--accent-500));
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--shadow-lg);
  padding: 1.5rem 0;
  margin-bottom: 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
  transition: background var(--transition);
}

.site-logo {
  width: 40px;
  height: 40px;
  background: #ffffff;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 1.25rem;
  color: var(--primary-500);
  box-shadow: var(--shadow-md);
}

.site-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #ffffff;
  margin: 0;
  letter-spacing: -0.5px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.site-subtitle {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.95);
  margin: 0;
  font-weight: 500;
}

.header-badge {
  background: rgba(255, 255, 255, 0.25);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  color: #ffffff;
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: var(--shadow-sm);
}

.header-badge-label {
  opacity: 0.9;
}

.header-badge-value {
  color: #ffffff;
}

.header-action-btn {
  background: #ffffff;
  color: var(--primary-600);
  font-weight: 600;
}

.dark-mode-toggle {
  background: rgba(255, 255, 255, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  color: #ffffff;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition-fast);
  z-index: 1000;
}

.dark-mode-toggle:hover {
  background: rgba(255, 255, 255, 0.35);
  transform: translateY(-1px);
}

.dark-mode-text {
  display: none;
}

/* Dark mode header styles */
html.dark-mode .site-header {
  background: linear-gradient(135deg, #1e3a5f, #134e4a);
}

/* ===== Devise Forms ===== */
.devise-background {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-50) 0%, var(--accent-50) 100%);
  padding: var(--spacing-lg);
}

.devise-container {
  width: 100%;
  max-width: 450px;
}

.devise-card {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--border-radius-xl);
  box-shadow: var(--shadow-glass);
  padding: var(--spacing-2xl);
}

.devise-header {
  text-align: center;
  margin-bottom: var(--spacing-xl);
}

.devise-header h2 {
  font-size: 1.75rem;
  background: linear-gradient(135deg, var(--primary-600), var(--accent-600));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: var(--spacing-sm);
}

.devise-links {
  margin-top: var(--spacing-lg);
  padding-top: var(--spacing-lg);
  border-top: 1px solid var(--border-color);
  text-align: center;
}

.devise-links a {
  color: var(--primary-600);
  font-size: 0.875rem;
  transition: color var(--transition);
}

.devise-links a:hover {
  color: var(--primary-700);
}

/* ===== Alerts & Flash Messages ===== */
.alert {
  padding: var(--spacing-md) var(--spacing-lg);
  border-radius: var(--border-radius);
  margin-bottom: var(--spacing-lg);
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.alert-success {
  background: var(--accent-50);
  color: var(--accent-700);
  border: 1px solid var(--accent-200);
}

.alert-error,
.alert-danger {
  background: #fef2f2;
  color: var(--error);
  border: 1px solid #fecaca;
}

.alert-warning {
  background: #fffbeb;
  color: var(--warning);
  border: 1px solid #fde68a;
}

.alert-info {
  background: var(--primary-50);
  color: var(--primary-700);
  border: 1px solid var(--primary-200);
}

.notice {
  padding: var(--spacing-md) var(--spacing-lg);
  background: var(--accent-50);
  color: var(--accent-700);
  border-radius: var(--border-radius);
  margin-bottom: var(--spacing-lg);
  border: 1px solid var(--accent-200);
}

/* ===== DARK MODE OVERRIDES - Applied at END to override all styles ===== */
/* These rules override everything above for dark mode preference */

/* ===== DARK MODE - Toggle Control Only ===== */
/* ONLY responds to html.dark-mode class (user button click) */
/* Does NOT use @media queries - no forced dark mode from system */
/* These rules override everything above for dark mode preference */

/* ===== DARK MODE - Toggle Control Only ===== */
/* ONLY responds to html.dark-mode class (user button click) */
/* Does NOT use @media queries - no forced dark mode from system */

/* Variables */

/* ===== DARK MODE - Research-Based 2025-2026 Palette ===== */
/* Deep blue-grays (not pure black) with excellent contrast */

html.dark-mode {
  /* DARK MODE Backgrounds - Deep Blue-Gray */
  --bg-main: #0f172a;      /* Deep space blue-gray */
  --bg-card: #1e293b;      /* Slightly lighter */
  --bg-secondary: #334155;  /* Deep muted blue */
  --bg-accent: #475569;     /* Brighter for highlights */
  --bg-glass: rgba(30, 41, 59, 0.9);

  /* DARK MODE Text - High Contrast WCAG AA */
  --text-primary: #f1f5f9;   /* Very light gray */
  --text-secondary: #cbd5e1; /* Light gray */
  --text-tertiary: #94a3b8;  /* Medium gray */
  --text-muted: #64748b;     /* Light-medium gray */
  --text-inverse: #0f172a;

  /* DARK MODE Borders - Subtle but visible */
  --border-primary: #334155; /* Subtle edges */
  --border-secondary: #475569; /* Input fields */
  --border-accent: #60a5fa;    /* Matches primary */

  /* DARK MODE Grays */
  --gray-50: #1e293b;
  --gray-100: #334155;
  --gray-200: #475569;
  --gray-300: #64748b;
  --gray-400: #94a3b8;
  --gray-500: #cbd5e1;
  --gray-600: #e2e8f0;
  --gray-700: #f1f5f9;
  --gray-800: #f8fafc;
  --gray-900: #ffffff;

  /* Boosted visibility colors for dark mode */
  --primary-400: #60a5fa;   /* Brightened blue */
  --primary-500: #3b82f6;   /* Same as light mode */
  --primary-600: #2563eb;   /* Same as light mode */
}

/* Body in dark mode */
html.dark-mode body {
  background-color: var(--bg-main) !important;
  color: var(--text-primary) !important;
}

/* Tables - Deep backgrounds with light text */
html.dark-mode .table {
  background-color: transparent !important;
}

html.dark-mode .table thead {
  background: linear-gradient(135deg, var(--bg-card), var(--bg-secondary)) !important;
}

html.dark-mode .table th {
  color: var(--text-secondary) !important;
  border-bottom-color: var(--border-primary) !important;
}

html.dark-mode .table td {
  color: var(--text-primary) !important;
  border-bottom-color: var(--border-primary) !important;
}

html.dark-mode .table tbody tr {
  background-color: transparent !important;
}

html.dark-mode .table tbody tr:hover {
  background-color: var(--bg-secondary) !important;
}

html.dark-mode .table-striped tbody tr:nth-of-type(odd) {
  background-color: var(--bg-card) !important;
}

/* Forms - High contrast inputs */
html.dark-mode .form-control,
html.dark-mode .form-select {
  background-color: var(--bg-secondary) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-secondary) !important;
}

html.dark-mode .form-control::placeholder {
  color: var(--gray-500) !important;
}

html.dark-mode .form-control:focus,
html.dark-mode .form-select:focus {
  background-color: var(--bg-main) !important;
  border-color: var(--primary-500) !important;
  color: var(--text-primary) !important;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15) !important;
}

html.dark-mode .form-label {
  color: var(--text-secondary) !important;
}

/* Cards - Deep backgrounds */
html.dark-mode .card {
  background: var(--bg-glass) !important;
  border-color: var(--border-primary) !important;
}

html.dark-mode .card h1,
html.dark-mode .card h2,
html.dark-mode .card h3,
html.dark-mode .card h4,
html.dark-mode .card h5,
html.dark-mode .card h6 {
  color: var(--text-primary) !important;
}

html.dark-mode .card p,
html.dark-mode .card div,
html.dark-mode .card span {
  color: var(--text-secondary) !important;
}

/* Badges - White text on colored backgrounds */
html.dark-mode .badge {
  color: #FFFFFF !important;
  font-weight: 600 !important;
}

html.dark-mode .bg-primary {
  background-color: var(--primary-600) !important;
  color: #FFFFFF !important;
}

html.dark-mode .bg-info {
  background-color: var(--info) !important;
  color: #FFFFFF !important;
}

html.dark-mode .bg-success {
  background-color: var(--success) !important;
  color: #FFFFFF !important;
}

html.dark-mode .bg-warning {
  background-color: var(--warning) !important;
  color: #FFFFFF !important;
}

html.dark-mode .bg-danger {
  background-color: var(--error) !important;
  color: #FFFFFF !important;
}

html.dark-mode .bg-secondary {
  background-color: var(--bg-secondary) !important;
  color: #FFFFFF !important;
}

html.dark-mode .badge.bg-secondary {
  background-color: var(--bg-secondary) !important;
  color: var(--text-primary) !important;
  font-weight: 600 !important;
}

/* Buttons - Use consistent brand colors */
html.dark-mode .btn {
  color: #FFFFFF !important;
}

html.dark-mode .btn-primary {
  background: linear-gradient(135deg, var(--primary-500), var(--primary-600)) !important;
}

html.dark-mode .btn-secondary {
  background: var(--bg-secondary) !important;
  border: 1px solid var(--border-primary) !important;
}

html.dark-mode .btn-outline {
  background: transparent !important;
  border: 1px solid var(--gray-400) !important;
  color: var(--text-secondary) !important;
}

html.dark-mode .btn-info {
  background: var(--info) !important;
}

/* Links - Blue for visibility */
html.dark-mode a {
  color: var(--primary-400) !important;
}

html.dark-mode a:hover {
  color: var(--primary-500) !important;
}

/* Text utilities */
html.dark-mode .text-muted {
  color: var(--text-muted) !important;
}

html.dark-mode .text-primary {
  color: var(--text-primary) !important;
}

/* Alerts - Proper backgrounds */
html.dark-mode .alert-success {
  background: #064e3b !important;
  color: #34d399 !important;
  border-color: var(--success) !important;
}

html.dark-mode .alert-error,
html.dark-mode .alert-danger {
  background: #450a0a !important;
  color: #f87171 !important;
  border-color: var(--error) !important;
}

html.dark-mode .alert-warning {
  background: #451a03 !important;
  color: #fbbf24 !important;
  border-color: var(--warning) !important;
}

html.dark-mode .alert-info {
  background: #1e3a5a !important;
  color: var(--primary-400) !important;
  border-color: var(--primary-500) !important;
}

/* Bento items */
html.dark-mode .bento-item {
  background: var(--bg-glass) !important;
  border-color: var(--border-primary) !important;
}

/* Fix inline styles with CSS variables */
html.dark-mode [style*="var(--primary-50)"] {
  background: var(--bg-secondary) !important;
}

html.dark-mode [style*="var(--primary-100)"] {
  background: var(--bg-card) !important;
}

html.dark-mode [style*="var(--accent-50)"] {
  background: #134e4a !important;
}

html.dark-mode [style*="var(--accent-100)"] {
  background: #115e59 !important;
}

html.dark-mode [style*="var(--gray-50)"] {
  background: var(--bg-card) !important;
}

html.dark-mode [style*="var(--gray-100)"] {
  background: var(--bg-secondary) !important;
}

/* Fix inline gradient backgrounds */
html.dark-mode [style*="linear-gradient(135deg, var(--primary-50)"] {
  background: linear-gradient(135deg, var(--bg-card), var(--bg-secondary)) !important;
}

html.dark-mode [style*="linear-gradient(135deg, var(--accent-50)"] {
  background: linear-gradient(135deg, #134e4a, #115e59) !important;
}

/* Fix inline white backgrounds */
html.dark-mode [style*="background: white"],
html.dark-mode [style*="background: white;"] {
  background: var(--bg-card) !important;
}

html.dark-mode input[type="file"][style*="background: white"] {
  background: var(--bg-secondary) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-secondary) !important;
}

html.dark-mode input[type="file"][style*="background: white"]:hover {
  background: var(--bg-card) !important;
}

/* Fix devise form inline styles */
html.dark-mode .form-control[style*="rgba(255, 255, 255, 0.8)"] {
  background: var(--bg-secondary) !important;
  border-color: var(--border-secondary) !important;
  color: var(--text-primary) !important;
}

html.dark-mode .form-control[style*="rgba(255, 255, 255, 0.8)"]:focus {
  background: var(--bg-main) !important;
  border-color: var(--primary-500) !important;
  color: var(--text-primary) !important;
}

/* Fix inline rgba borders */
html.dark-mode [style*="rgba(0, 0, 0, 0.1)"] {
  border-color: var(--border-secondary) !important;
}

html.dark-mode [style*="rgba(255, 255, 255, 0.2)"] {
  border-color: var(--border-primary) !important;
}

html.dark-mode [style*="rgba(255, 255, 255, 0.25)"] {
  background: rgba(30, 41, 59, 0.8) !important;
  border-color: var(--border-primary) !important;
}

html.dark-mode [style*="rgba(255, 255, 255, 0.3)"] {
  border-color: var(--border-primary) !important;
}

/* Fix bento item borders in dark mode */
html.dark-mode .bento-item[style*="border-left"] {
  border-left-color: var(--primary-500) !important;
}

html.dark-mode .bento-item[style*="border-left: 4px solid var(--accent-500)"] {
  border-left-color: var(--accent-500) !important;
}

html.dark-mode .bento-item[style*="border-left: 4px solid #f59e0b"] {
  border-left-color: var(--warning) !important;
}

/* Fix badge backgrounds in dark mode */
html.dark-mode .badge[style*="background: var(--primary-50)"] {
  background: var(--bg-secondary) !important;
  color: var(--primary-400) !important;
}

html.dark-mode .badge[style*="background: var(--accent-50)"] {
  background: #134e4a !important;
  color: var(--accent-400) !important;
}

/* Fix white buttons with colored text - hard to read in both modes */
.btn[style*="background: white; color: var(--primary-600)"],
.btn[style*="background: white; color: var(--accent-600)"] {
  background: var(--primary-600) !important;
  color: white !important;
  font-weight: 600 !important;
}

.btn[style*="background: white; color: var(--primary-600)"]:hover,
.btn[style*="background: white; color: var(--accent-600)"]:hover {
  background: var(--primary-700) !important;
  color: white !important;
}

html.dark-mode .btn[style*="background: white; color: var(--primary-600)"],
html.dark-mode .btn[style*="background: white; color: var(--accent-600)"] {
  background: var(--primary-600) !important;
  color: white !important;
}

html.dark-mode .btn[style*="background: rgba(255, 255, 255, 0.2); color: white"] {
  background: var(--bg-secondary) !important;
  border-color: var(--border-primary) !important;
}

/* Fix buttons with white text on light/translucent backgrounds - poor contrast */
.btn[style*="background: rgba(255, 255, 255, 0.2); color: white"] {
  background: var(--accent-600) !important;
  color: white !important;
  border-color: transparent !important;
}

.btn[style*="background: rgba(255, 255, 255, 0.2); color: white"]:hover {
  background: var(--accent-700) !important;
  color: white !important;
}

html.dark-mode .btn[style*="background: rgba(255, 255, 255, 0.2); color: white"] {
  background: var(--bg-secondary) !important;
  border-color: var(--border-primary) !important;
}

html.dark-mode .btn[style*="background: rgba(255, 255, 255, 0.2); color: white"]:hover {
  background: var(--bg-card) !important;
}

/* General button fixes for better readability */
.btn[style*="background: white"] {
  background: var(--primary-600) !important;
  color: white !important;
}

.btn[style*="background: #ffffff"] {
  background: var(--primary-600) !important;
  color: white !important;
}

/* Notice messages */
html.dark-mode .notice {
  background: #064e3b !important;
  color: var(--accent-500) !important;
  border-color: var(--accent-600) !important;
}

/* Header dark mode */
html.dark-mode .site-logo {
  background: var(--bg-card);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

html.dark-mode .header-badge {
  background: rgba(30, 41, 59, 0.8);
  border-color: var(--border-primary);
}

html.dark-mode .header-action-btn {
  background: var(--bg-card);
  color: var(--primary-400);
}

html.dark-mode .dark-mode-toggle {
  background: rgba(30, 41, 59, 0.8);
  border-color: var(--border-primary);
}

html.dark-mode .dark-mode-toggle:hover {
  background: var(--bg-secondary);
}

/* Devise dark mode */
html.dark-mode .devise-background {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}

html.dark-mode .devise-card {
  background: var(--bg-glass);
  border-color: var(--border-primary);
}

html.dark-mode .devise-header h2 {
  background: linear-gradient(135deg, var(--primary-400), var(--accent-400));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

html.dark-mode .devise-header p {
  color: var(--text-secondary);
}

html.dark-mode .devise-links a {
  color: var(--primary-400);
}

html.dark-mode .devise-links a:hover {
  color: var(--primary-500);
}

/* Sidebar Dark Mode */
html.dark-mode .sidebar {
  background: var(--bg-glass);
  border-right-color: var(--border-primary);
}

html.dark-mode .sidebar-header {
  background: linear-gradient(135deg, #1e3a5f, #134e4a);
}

html.dark-mode .sidebar-logo {
  background: var(--bg-card);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

html.dark-mode .sidebar-footer {
  background: var(--bg-card);
  border-top-color: var(--border-primary);
}

html.dark-mode .sidebar-store {
  background: var(--bg-secondary);
  border-color: var(--border-primary);
}

html.dark-mode .sidebar-store-label {
  color: var(--text-secondary);
}

html.dark-mode .sidebar-store-value {
  color: var(--text-primary);
}

html.dark-mode .sidebar-user-name {
  color: var(--text-primary);
}

html.dark-mode .sidebar-signout-btn {
  background: var(--primary-600);
  color: white;
}

html.dark-mode .sidebar-signin-btn {
  background: var(--bg-secondary);
  color: var(--primary-400);
  border-color: var(--border-primary);
}

html.dark-mode .sidebar-dark-mode-toggle {
  background: var(--bg-secondary);
  border-color: var(--border-primary);
}

html.dark-mode .sidebar-dark-mode-toggle:hover {
  background: var(--bg-accent);
  border-color: var(--primary-500);
}

html.dark-mode .sidebar-toggle {
  background: var(--bg-glass);
  border-color: var(--border-primary);
}

html.dark-mode .sidebar-toggle:hover {
  background: var(--bg-secondary);
}

html.dark-mode .sidebar-toggle span {
  background: var(--text-primary);
}

/* Flash messages dark mode */
html.dark-mode .flash-notice {
  background: #064e3b;
  color: #34d399;
  border-color: var(--success);
}

html.dark-mode .flash-alert {
  background: #450a0a;
  color: #f87171;
  border-color: var(--error);
}
