/**
 * Main CSS - iCare Sales Assistant
 * Modern, refined design system with glassmorphism accents
 */

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

:root {
  /* Brand Colors */
  --primary: #0095DA;
  --primary-dark: #0077b3;
  --primary-light: #33aae3;
  --primary-glow: rgba(0, 149, 218, 0.15);
  --accent: #005C99;
  --accent-dark: #004A7A;
  --accent-light: #1A6FA8;
  
  /* Semantic Colors */
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --error: #ef4444;
  --error-light: #fee2e2;
  --info: #3b82f6;
  --info-light: #dbeafe;
  
  /* Neutrals */
  --white: #ffffff;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  
  /* Typography */
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
  
  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --shadow-glow: 0 0 20px rgba(0, 149, 218, 0.25);
  --shadow-card: 0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.06);
  
  /* Border Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;
  
  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 400ms cubic-bezier(0.34, 1.56, 0.64, 1);
  
  /* Z-index scale */
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-modal: 1000;
  --z-toast: 1100;
}

/* ═══ DARK MODE ═══ */
[data-theme="dark"] {
  /* Backgrounds — inverted gray scale */
  --white: #1a1d23;
  --gray-50: #1e2128;
  --gray-100: #252830;
  --gray-200: #2e323b;
  --gray-300: #3d4250;
  --gray-400: #6b7280;
  --gray-500: #9ca3af;
  --gray-600: #c9cdd5;
  --gray-700: #d8dce4;
  --gray-800: #e8ecf1;
  --gray-900: #f1f3f6;

  /* Brand — slightly brighter for dark bg contrast */
  --primary: #1ca5e8;
  --primary-dark: #0095DA;
  --primary-light: #4db8ee;
  --primary-glow: rgba(28, 165, 232, 0.2);
  --accent: #003d66;
  --accent-dark: #002e4d;
  --accent-light: #005080;

  /* Semantic — lighter shades for readability on dark */
  --success: #34d399;
  --success-light: rgba(52, 211, 153, 0.15);
  --warning: #fbbf24;
  --warning-light: rgba(251, 191, 36, 0.15);
  --error: #f87171;
  --error-light: rgba(248, 113, 113, 0.15);
  --info: #60a5fa;
  --info-light: rgba(96, 165, 250, 0.15);

  /* Shadows — deeper for dark surfaces */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.35), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.4), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
  --shadow-glow: 0 0 20px rgba(28, 165, 232, 0.3);
  --shadow-card: 0 1px 3px rgba(0,0,0,0.2), 0 4px 12px rgba(0,0,0,0.15);
}

/* Dark mode: elements with hardcoded colors */
[data-theme="dark"] body { color-scheme: dark; }

[data-theme="dark"] .app-header {
  background: rgba(26, 29, 35, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom-color: rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .modal-overlay {
  background: rgba(0, 0, 0, 0.75);
}

[data-theme="dark"] .user-menu-divider {
  background: var(--gray-200);
}

[data-theme="dark"] .card-glass {
  background: rgba(26, 29, 35, 0.7);
}

/* Alert overrides (hardcoded colors in light mode) */
[data-theme="dark"] .alert-error { background: rgba(248, 113, 113, 0.12); color: #fca5a5; border-color: rgba(248, 113, 113, 0.2); }
[data-theme="dark"] .alert-success { background: rgba(52, 211, 153, 0.12); color: #6ee7b7; border-color: rgba(52, 211, 153, 0.2); }
[data-theme="dark"] .alert-warning { background: rgba(251, 191, 36, 0.12); color: #fcd34d; border-color: rgba(251, 191, 36, 0.2); }
[data-theme="dark"] .alert-info { background: rgba(96, 165, 250, 0.12); color: #93bbfc; border-color: rgba(96, 165, 250, 0.2); }

/* Badge overrides (hardcoded text colors in light mode need bright equivalents) */
[data-theme="dark"] .badge-success { background: rgba(52, 211, 153, 0.18); color: #6ee7b7; }
[data-theme="dark"] .badge-warning { background: rgba(251, 191, 36, 0.18); color: #fcd34d; }
[data-theme="dark"] .badge-error { background: rgba(248, 113, 113, 0.18); color: #fca5a5; }
[data-theme="dark"] .badge-info { background: rgba(96, 165, 250, 0.18); color: #93c5fd; }
[data-theme="dark"] .badge-neutral { background: rgba(156, 163, 175, 0.15); color: #d1d5db; }

/* Dark mode logo — invert black logo to white */
[data-theme="dark"] .app-logo img {
  filter: invert(1);
}

/* Dark mode sidebars */
[data-theme="dark"] .admin-sidebar,
[data-theme="dark"] .reports-sidebar {
  background: var(--accent) !important;
}

/* Scrollbar styling for dark mode */
[data-theme="dark"] ::-webkit-scrollbar { width: 8px; height: 8px; }
[data-theme="dark"] ::-webkit-scrollbar-track { background: var(--gray-100); }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 4px; }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--gray-800);
  background: linear-gradient(135deg, var(--gray-50) 0%, var(--gray-100) 100%);
  min-height: 100vh;
  margin: 0;
  padding: 0;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  margin: 0 0 1rem 0;
  font-weight: 700;
  line-height: 1.25;
  color: var(--gray-900);
  letter-spacing: -0.02em;
}
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; font-weight: 600; }

p { margin: 0 0 1rem 0; color: var(--gray-600); }

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

/* Form Elements */
.form-group { margin-bottom: 1.25rem; }

.form-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--gray-700);
  letter-spacing: -0.01em;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  font-family: inherit;
  color: var(--gray-800);
  transition: all var(--transition-fast);
  outline: none;
}

.form-input::placeholder { color: var(--gray-400); }

.form-input:hover, .form-select:hover {
  border-color: var(--gray-300);
}

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

.form-input.error {
  border-color: var(--error);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.form-error {
  color: var(--error);
  font-size: 0.8125rem;
  margin-top: 0.375rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.form-error::before { content: '⚠'; font-size: 0.75rem; }

.form-hint {
  color: var(--gray-500);
  font-size: 0.8125rem;
  margin-top: 0.375rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
  text-decoration: none;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.1) 0%, transparent 50%);
  pointer-events: none;
}

.btn-primary {
  background: linear-gradient(180deg, var(--primary-light) 0%, var(--primary) 100%);
  color: var(--white);
  box-shadow: 0 2px 4px rgba(0, 149, 218, 0.2), inset 0 1px 0 rgba(255,255,255,0.15);
}

.btn-primary:hover {
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 149, 218, 0.35), inset 0 1px 0 rgba(255,255,255,0.15);
  text-decoration: none;
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0, 149, 218, 0.2);
}

.btn-secondary {
  background: linear-gradient(180deg, var(--accent-light) 0%, var(--accent) 100%);
  color: var(--white);
  box-shadow: 0 2px 4px rgba(36, 66, 75, 0.2);
}

.btn-secondary:hover {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-dark) 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(36, 66, 75, 0.3);
}

.btn-outline {
  background: var(--white);
  color: var(--primary);
  border: 1.5px solid var(--primary);
  box-shadow: none;
}

.btn-outline::after { display: none; }

.btn-outline:hover {
  background: var(--primary-glow);
  border-color: var(--primary-dark);
}

.btn-ghost {
  background: transparent;
  color: var(--gray-600);
  box-shadow: none;
}
.btn-ghost::after { display: none; }
.btn-ghost:hover { background: var(--gray-100); color: var(--gray-800); }

.btn-danger {
  background: linear-gradient(180deg, #f87171 0%, var(--error) 100%);
  color: var(--white);
}
.btn-danger:hover {
  background: linear-gradient(180deg, var(--error) 0%, #dc2626 100%);
}

.btn:disabled {
  background: var(--gray-200);
  color: var(--gray-400);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-sm { padding: 0.5rem 1rem; font-size: 0.8125rem; }
.btn-lg { padding: 1rem 2rem; font-size: 1rem; }
.btn-icon { padding: 0.625rem; }
.btn-block { width: 100%; }

/* Cards */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--gray-100);
  transition: all var(--transition-base);
}

.card:hover {
  box-shadow: var(--shadow-lg);
  border-color: var(--gray-200);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 1rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--gray-100);
}

.card-title {
  font-size: 1.0625rem;
  font-weight: 600;
  margin: 0;
  color: var(--gray-900);
}

.card-glass {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Loading States */
.loading-spinner {
  width: 2.5rem;
  height: 2.5rem;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-spinner.small {
  width: 1.125rem;
  height: 1.125rem;
  border-width: 2px;
  display: inline-block;
  vertical-align: middle;
  margin-right: 0.5rem;
}

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

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1rem;
  z-index: var(--z-modal);
}

.loading-overlay p {
  color: var(--gray-600);
  font-weight: 500;
  margin: 0;
}

/* Pulse animation for loading text */
.loading-overlay p {
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Alerts */
.alert {
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  font-size: 0.9375rem;
  border: 1px solid transparent;
}

.alert-icon { font-size: 1.125rem; flex-shrink: 0; }

.alert-success {
  background: var(--success-light);
  color: #065f46;
  border-color: rgba(16, 185, 129, 0.2);
}

.alert-warning {
  background: var(--warning-light);
  color: #92400e;
  border-color: rgba(245, 158, 11, 0.2);
}

.alert-error {
  background: var(--error-light);
  color: #991b1b;
  border-color: rgba(239, 68, 68, 0.2);
}

.alert-info {
  background: var(--info-light);
  color: #1e40af;
  border-color: rgba(59, 130, 246, 0.2);
}

/* App Header */
.app-header {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 0.875rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
}

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

.app-logo img {
  height: 2rem;
  width: auto;
}

.app-logo h1 {
  font-size: 1.125rem;
  font-weight: 700;
  margin: 0;
  color: rgb(0, 149, 219);
  letter-spacing: -0.02em;
}

.app-logo h1 span {
  color: rgb(0, 149, 219);
}

/* User Menu */
.user-menu { position: relative; }

.user-menu-btn {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.875rem;
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-full);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-700);
  transition: all var(--transition-fast);
}

.user-menu-btn:hover {
  background: var(--gray-200);
  border-color: var(--gray-300);
}

.user-avatar {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
}

.user-menu-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--gray-100);
  min-width: 200px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px) scale(0.96);
  transition: all var(--transition-base);
  overflow: hidden;
}

.user-menu-dropdown.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.user-menu-dropdown a,
.user-menu-dropdown button {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.75rem 1rem;
  text-align: left;
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--gray-700);
  transition: all var(--transition-fast);
}

.user-menu-dropdown a:hover,
.user-menu-dropdown button:hover {
  background: var(--gray-50);
  color: var(--gray-900);
  text-decoration: none;
}

.user-menu-divider {
  height: 1px;
  background: var(--gray-100);
  margin: 0.25rem 0;
}

/* Layout */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.5rem;
}

.grid {
  display: grid;
  gap: 1.5rem;
}

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

@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .container { padding: 1rem; }
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.badge-success { background: var(--success-light); color: #065f46; }
.badge-warning { background: var(--warning-light); color: #92400e; }
.badge-error { background: var(--error-light); color: #991b1b; }
.badge-info { background: var(--info-light); color: #1e40af; }
.badge-neutral { background: var(--gray-100); color: var(--gray-600); }

/* Tables */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--gray-200);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.table th,
.table td {
  padding: 0.875rem 1rem;
  text-align: left;
}

.table th {
  font-weight: 600;
  color: var(--gray-500);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}

.table td {
  color: var(--gray-700);
  border-bottom: 1px solid var(--gray-100);
}

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

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

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

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  cursor: pointer;
}

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

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--gray-300);
  border-radius: 22px;
  transition: background var(--transition-fast);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: transform var(--transition-fast);
  box-shadow: var(--shadow-xs);
}

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

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

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: var(--z-modal);
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--white);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  max-width: 500px;
  width: 100%;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  transform: scale(0.95) translateY(10px);
  transition: transform var(--transition-spring);
  box-shadow: var(--shadow-xl);
}

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

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

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  background: var(--gray-100);
  border: none;
  border-radius: var(--radius-full);
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--gray-500);
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: var(--gray-200);
  color: var(--gray-700);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--gray-100);
}

/* Utility Classes */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gray-500); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-error { color: var(--error); }
.text-sm { font-size: 0.8125rem; }
.text-lg { font-size: 1.125rem; }

.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.p-1 { padding: 0.5rem; }
.p-2 { padding: 1rem; }
.p-3 { padding: 1.5rem; }
.p-4 { padding: 2rem; }

.hidden { display: none !important; }
.sr-only { 
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Page-specific: Login */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: linear-gradient(135deg, var(--gray-50) 0%, var(--gray-100) 50%, rgba(0, 149, 218, 0.05) 100%);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--white);
  border-radius: var(--radius-xl);
  padding: 2.5rem;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--gray-100);
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-header img {
  height: 3rem;
  margin-bottom: 1.25rem;
}

.login-header h1 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.login-header p {
  color: var(--gray-500);
  margin: 0;
}

/* Page-specific: Dashboard */
.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  border: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: all var(--transition-fast);
}

.stat-card:hover {
  border-color: var(--primary-glow);
  box-shadow: var(--shadow-md);
}

.stat-icon {
  width: 3rem;
  height: 3rem;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.stat-icon.blue { background: var(--info-light); }
.stat-icon.green { background: var(--success-light); }
.stat-icon.orange { background: var(--warning-light); }
.stat-icon.purple { background: #ede9fe; }

.stat-info h3 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
  color: var(--gray-900);
}

.stat-info p {
  font-size: 0.8125rem;
  color: var(--gray-500);
  margin: 0;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--gray-500);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-state h3 {
  color: var(--gray-700);
  margin-bottom: 0.5rem;
}

.empty-state p {
  margin-bottom: 1.5rem;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0.25rem;
  background: var(--gray-100);
  padding: 0.25rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
}

.tab-btn {
  flex: 1;
  padding: 0.625rem 1rem;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-600);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.tab-btn:hover {
  color: var(--gray-800);
}

.tab-btn.active {
  background: var(--white);
  color: var(--gray-900);
  box-shadow: var(--shadow-sm);
}

/* Smooth scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--gray-100);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--gray-400);
}

/* Focus visible for accessibility */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

button:focus:not(:focus-visible),
a:focus:not(:focus-visible) {
  outline: none;
}

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

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

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.animate-fadeIn { animation: fadeIn var(--transition-base) ease-out; }
.animate-slideUp { animation: slideUp var(--transition-slow) ease-out; }
.animate-scaleIn { animation: scaleIn var(--transition-spring) ease-out; }

/* Stagger animations for lists */
.stagger-item {
  animation: slideUp var(--transition-slow) ease-out both;
}
.stagger-item:nth-child(1) { animation-delay: 0ms; }
.stagger-item:nth-child(2) { animation-delay: 50ms; }
.stagger-item:nth-child(3) { animation-delay: 100ms; }
.stagger-item:nth-child(4) { animation-delay: 150ms; }
.stagger-item:nth-child(5) { animation-delay: 200ms; }
.stagger-item:nth-child(6) { animation-delay: 250ms; }

/* ═══════ TOAST NOTIFICATIONS ═══════ */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
  max-width: min(420px, calc(100vw - 2rem));
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 1.125rem;
  border-radius: var(--radius-md);
  background: var(--white);
  box-shadow: 0 8px 30px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.06);
  border: 1px solid var(--gray-200);
  pointer-events: auto;
  animation: toastSlideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  transition: all 0.3s ease;
  font-size: 0.9rem;
  line-height: 1.45;
  max-width: 100%;
  word-break: break-word;
}

.toast.removing {
  animation: toastSlideOut 0.25s ease forwards;
}

.toast-icon { font-size: 1.125rem; flex-shrink: 0; margin-top: 1px; }
.toast-body { flex: 1; min-width: 0; }
.toast-title { font-weight: 600; margin-bottom: 2px; color: var(--gray-900); }
.toast-message { color: var(--gray-600); font-size: 0.8375rem; }

.toast-close {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-400);
  font-size: 1.125rem;
  padding: 0;
  line-height: 1;
  transition: color var(--transition-fast);
}
.toast-close:hover { color: var(--gray-600); }

.toast-success { border-left: 3px solid var(--success); }
.toast-success .toast-icon { color: var(--success); }
.toast-error { border-left: 3px solid var(--error); }
.toast-error .toast-icon { color: var(--error); }
.toast-warning { border-left: 3px solid var(--warning); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info { border-left: 3px solid var(--info); }
.toast-info .toast-icon { color: var(--info); }

.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  background: var(--gray-300);
  border-radius: 0 0 0 var(--radius-md);
  animation: toastProgress linear forwards;
}

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(30px) scale(0.96); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toastSlideOut {
  from { opacity: 1; transform: translateX(0); max-height: 100px; margin-bottom: 0.5rem; }
  to { opacity: 0; transform: translateX(30px); max-height: 0; margin-bottom: 0; padding: 0; border: 0; }
}

@keyframes toastProgress {
  from { width: 100%; }
  to { width: 0%; }
}

/* ═══════ MOBILE RESPONSIVE ═══════ */
@media (max-width: 768px) {
  body { font-size: 14px; }
  
  .app-header {
    padding: 0.625rem 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  
  .app-logo h1 { font-size: 0.9375rem; }
  .app-logo img { height: 1.5rem; }
  
  .user-menu-btn {
    padding: 0.375rem 0.625rem;
    font-size: 0.8125rem;
  }
  
  .user-menu-btn .user-name-text { display: none; }
  
  .user-menu-dropdown {
    right: -0.5rem;
    min-width: 180px;
  }
  
  .container { padding: 0.75rem; }
  
  .dashboard-stats {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
  
  .stat-card { padding: 0.875rem; }
  .stat-icon { width: 2.5rem; height: 2.5rem; font-size: 1.25rem; }
  .stat-info h3 { font-size: 1.25rem; }
  
  .card { padding: 1rem; border-radius: var(--radius-md); }
  .card-header { flex-wrap: wrap; gap: 0.5rem; }
  
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tab-btn { white-space: nowrap; flex: 0 0 auto; font-size: 0.8125rem; padding: 0.5rem 0.75rem; }
  
  .table th, .table td { padding: 0.625rem 0.5rem; font-size: 0.8125rem; }
  .table th { font-size: 0.6875rem; }
  
  /* Stacked action buttons on mobile */
  .table td:last-child {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
  }
  
  .btn { padding: 0.625rem 1rem; font-size: 0.875rem; }
  .btn-sm { padding: 0.375rem 0.625rem; font-size: 0.75rem; }
  .btn-lg { padding: 0.75rem 1.25rem; font-size: 0.9375rem; }
  
  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.25rem; }
  h3 { font-size: 1.0625rem; }
  
  .modal { padding: 1rem; border-radius: var(--radius-md); margin: 0.5rem; }
  .modal-title { font-size: 1.0625rem; }
  
  .login-card { padding: 1.5rem; }
  .login-header h1 { font-size: 1.25rem; }
  
  .toast-container { top: 0.5rem; right: 0.5rem; left: 0.5rem; max-width: none; }
  
  /* Hide less important table columns on mobile */
  .hide-mobile { display: none !important; }
}

@media (max-width: 480px) {
  .app-header { padding: 0.5rem 0.75rem; }
  .container { padding: 0.5rem; }
  
  .dashboard-stats { gap: 0.375rem; }
  .stat-card { padding: 0.75rem; gap: 0.625rem; }
  
  .card { padding: 0.75rem; }
  .card-header { padding-bottom: 0.625rem; margin-bottom: 0.625rem; }
  .card-title { font-size: 0.9375rem; }
  
  .form-group { margin-bottom: 1rem; }
  .form-input, .form-select { padding: 0.625rem 0.75rem; font-size: 16px; } /* 16px prevents iOS zoom */
}

/* Tablet (landscape) */
@media (min-width: 769px) and (max-width: 1024px) {
  .container { padding: 1rem; }
  .dashboard-stats { grid-template-columns: repeat(3, 1fr); }
}

/* ═══════ CONFIRMATION DIALOG ═══════ */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: calc(var(--z-modal) + 10);
  padding: 1rem;
  animation: fadeIn 0.15s ease;
}

.confirm-dialog {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  max-width: 400px;
  width: 100%;
  box-shadow: var(--shadow-xl);
  animation: scaleIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.confirm-title { font-size: 1.0625rem; font-weight: 700; margin: 0 0 0.5rem; }
.confirm-message { color: var(--gray-600); font-size: 0.9rem; margin: 0 0 1.25rem; line-height: 1.5; }
.confirm-actions { display: flex; gap: 0.5rem; justify-content: flex-end; }

/* ═══════ PRINT STYLES ═══════ */
@media print {
  .app-header, .user-menu, .btn, .tabs, .toast-container { display: none !important; }
  .card { box-shadow: none; border: 1px solid #ddd; }
  body { background: white; }
}

/* ═══════ LOADING SKELETONS ═══════ */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-50) 50%, var(--gray-100) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-md);
}

.skeleton-card {
  height: 120px;
  border-radius: var(--radius-lg);
  margin-bottom: 0.75rem;
}

.skeleton-row {
  height: 1rem;
  margin-bottom: 0.5rem;
  border-radius: 4px;
}

.skeleton-row.short { width: 60%; }
.skeleton-row.medium { width: 80%; }

.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
}
