/* ═══════════════════════════════════════════════════════════════ */
/*  AGRICONNECT DESIGN SYSTEM — v2.0                               */
/*  Production-ready, accessible, dark-mode ready                  */
/*  Last updated: 2026-05-02                                      */
/* ═══════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────────────── */
/*  SECTION 1: CSS CUSTOM PROPERTIES (Design Tokens)               */
/* ─────────────────────────────────────────────────────────────── */

:root {
  /* Primary — AgriConnect green */
  --primary-50:  #f0fdf4;
  --primary-100: #dcfce7;
  --primary-200: #bbf7d0;
  --primary-300: #86efac;
  --primary-400: #4ade80;
  --primary-500: #22c55e;
  --primary-600: #16a34a;
  --primary-700: #15803d;
  --primary-800: #166534;
  --primary-900: #14532d;

  /* Accent — warm gold */
  --accent-50:  #fffbeb;
  --accent-100: #fef3c7;
  --accent-200: #fde68a;
  --accent-300: #fcd34d;
  --accent-400: #fbbf24;
  --accent-500: #f59e0b;
  --accent-600: #d97706;

  /* Semantic shortcuts (used by JS inline styles) */
  --primary:   var(--primary-600);
  --accent:    var(--accent-500);
  --danger:    var(--danger-500);
  --warning:   var(--warning-500);
  --success:   var(--success-500);
  --info:      var(--info-500);

  /* Semantic full palette */
  --danger-50:  #fef2f2;
  --danger-100: #fee2e2;
  --danger-500: #ef4444;
  --danger-600: #dc2626;

  --warning-50:  #fffbeb;
  --warning-100: #fef3c7;
  --warning-500: #f59e0b;
  --warning-600: #d97706;

  --success-50:  #f0fdf4;
  --success-100: #dcfce7;
  --success-500: #22c55e;
  --success-600: #16a34a;

  --info-50:  #eff6ff;
  --info-100: #dbeafe;
  --info-500: #3b82f6;
  --info-600: #2563eb;

  /* Neutrals */
  --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;

  /* Surfaces */
  --bg:             var(--gray-50);
  --bg-elevated:    #ffffff;
  --surface:        #ffffff;
  --text:           var(--gray-900);
  --text-secondary: var(--gray-500);
  --text-muted:     var(--gray-400);
  --border:         var(--gray-200);

  /* Shadows */
  --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow:    0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-md: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);

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

  /* Typography */
  --font-sans:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Space Grotesk', var(--font-sans);

  /* Layout */
  --sidebar-width:     260px;
  --sidebar-collapsed: 72px;
  --header-height:     64px;
  --max-content-width: 1400px;

  /* Motion */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition:      250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Z-index */
  --z-dropdown:       100;
  --z-sticky:         200;
  --z-modal-backdrop: 300;
  --z-modal:          400;
  --z-popover:        500;
  --z-toast:          600;
  --z-tooltip:        700;
  --z-loader:         9999;
}

/* ─────────────────────────────────────────────────────────────── */
/*  SECTION 2: DARK MODE                                         */
/* ─────────────────────────────────────────────────────────────── */

[data-theme="dark"] {
  --bg:             var(--gray-900);
  --bg-elevated:    var(--gray-800);
  --surface:        var(--gray-800);
  --text:           var(--gray-50);
  --text-secondary: var(--gray-400);
  --text-muted:     var(--gray-500);
  --border:         var(--gray-700);

  --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.3);
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.4), 0 1px 2px -1px rgb(0 0 0 / 0.4);
  --shadow:    0 4px 6px -1px rgb(0 0 0 / 0.4), 0 2px 4px -2px rgb(0 0 0 / 0.4);
  --shadow-md: 0 10px 15px -3px rgb(0 0 0 / 0.5), 0 4px 6px -4px rgb(0 0 0 / 0.5);
}

/* ─────────────────────────────────────────────────────────────── */
/*  SECTION 3: BASE & RESET                                      */
/* ─────────────────────────────────────────────────────────────── */

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-sans);
  font-weight: 400;
  line-height: 1.5;
  color: var(--text);
  background-color: var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
}

:focus-visible {
  outline: 2px solid var(--primary-500);
  outline-offset: 2px;
}

::selection {
  background-color: var(--primary-200);
  color: var(--primary-900);
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ─────────────────────────────────────────────────────────────── */
/*  SECTION 4: LOADER OVERLAY                                    */
/* ─────────────────────────────────────────────────────────────── */

.loader-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-loader);
  background: linear-gradient(135deg, var(--primary-900) 0%, var(--primary-800) 50%, var(--primary-700) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity var(--transition-slow), visibility var(--transition-slow);
}

.loader-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader-content {
  text-align: center;
  color: white;
  padding: 1.5rem;
}

.loader-logo {
  width: 72px;
  height: 72px;
  margin: 0 auto 1.5rem;
  animation: loaderPulse 2s ease-in-out infinite;
}

.loader-logo svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.3));
}

@keyframes loaderPulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.08); }
}

.loader-title {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}

.loader-subtitle {
  font-size: 0.875rem;
  font-weight: 300;
  opacity: 0.85;
  margin-bottom: 2rem;
}

.loader-bar {
  width: 180px;
  height: 3px;
  background: rgba(255,255,255,0.2);
  border-radius: var(--radius-full);
  margin: 0 auto;
  overflow: hidden;
}

.loader-progress {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary-300), var(--accent-300));
  border-radius: var(--radius-full);
  animation: loaderProgress 2.5s ease-out forwards;
}

@keyframes loaderProgress {
  0%   { width: 0%; }
  50%  { width: 70%; }
  100% { width: 100%; }
}

/* ─────────────────────────────────────────────────────────────── */
/*  SECTION 5: OFFLINE BANNER                                    */
/* ─────────────────────────────────────────────────────────────── */

.offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--z-sticky);
  background: linear-gradient(90deg, var(--warning-500), var(--accent-500));
  color: white;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  transform: translateY(0);
  transition: transform var(--transition);
}

.offline-banner.hidden {
  transform: translateY(-100%);
}

.offline-banner button {
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.3);
  color: white;
  padding: 0.375rem 0.875rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.offline-banner button:hover {
  background: rgba(255,255,255,0.3);
}

/* ─────────────────────────────────────────────────────────────── */
/*  SECTION 6: SCREEN SYSTEM                                     */
/* ─────────────────────────────────────────────────────────────── */

.screen {
  display: none;
  min-height: 100vh;
}

.screen.active {
  display: flex;
}

/* ─────────────────────────────────────────────────────────────── */
/*  SECTION 7: AUTHENTICATION                                    */
/* ─────────────────────────────────────────────────────────────── */

#auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-900) 0%, var(--primary-800) 40%, var(--primary-700) 100%);
  padding: 1rem;
  position: relative;
  overflow: hidden;
}

#auth-screen::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  opacity: 0.6;
  pointer-events: none;
}

.auth-container {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-xl);
  animation: authSlideUp 0.5s ease;
  position: relative;
  z-index: 1;
}

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

.auth-brand {
  text-align: center;
  margin-bottom: 1.5rem;
}

.auth-logo {
  width: 56px;
  height: 56px;
  margin: 0 auto 1rem;
}

.auth-logo svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 2px 8px rgba(22,163,74,0.3));
}

.auth-brand h1 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-800);
  margin-bottom: 0.25rem;
}

.auth-brand p {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.auth-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  border-bottom: 2px solid var(--border);
}

.auth-tab {
  flex: 1;
  padding: 0.75rem;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: var(--transition-fast);
  position: relative;
}

.auth-tab:hover {
  color: var(--text);
}

.auth-tab.active {
  color: var(--primary-600);
  border-bottom-color: var(--primary-600);
}

.auth-form {
  display: none;
}

.auth-form.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

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

.divider {
  display: flex;
  align-items: center;
  margin: 1.25rem 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.divider span {
  padding: 0 0.75rem;
}

.oauth-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.btn-oauth {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition-fast);
  height: 42px;
}

.btn-oauth svg {
  display: block;
  flex-shrink: 0;
}

.btn-google:hover {
  background: var(--gray-50);
  border-color: var(--gray-300);
}

.btn-github {
  background: var(--gray-800);
  color: white;
  border-color: var(--gray-800);
}

.btn-github:hover {
  background: var(--gray-900);
}

.toggle-password {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  opacity: 0.5;
  transition: var(--transition-fast);
  padding: 0.25rem;
}

.toggle-password:hover {
  opacity: 1;
}

/* ─────────────────────────────────────────────────────────────── */
/*  SECTION 8: MAIN APP LAYOUT                                   */
/* ─────────────────────────────────────────────────────────────── */

.app {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: var(--z-sticky);
  transition: transform var(--transition);
}

.sidebar-header {
  height: var(--header-height);
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  text-decoration: none;
  color: inherit;
}

.logo-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.app-name {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--primary-700);
}

.sidebar-toggle {
  display: none;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  cursor: pointer;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
}

.sidebar-toggle:hover {
  background: var(--gray-100);
}

.sidebar-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--gray-600);
  border-radius: 2px;
  transition: var(--transition-fast);
}

.nav-user {
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary-400), var(--primary-600));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.user-name {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: capitalize;
}

.nav-menu {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0.625rem;
  list-style: none;
}

.nav-menu li {
  margin-bottom: 0.125rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: var(--transition-fast);
  position: relative;
}

.nav-link:hover {
  background: var(--primary-50);
  color: var(--primary-700);
}

.nav-link.active {
  background: linear-gradient(135deg, var(--primary-600), var(--primary-700));
  color: white;
  box-shadow: var(--shadow-sm);
}

.nav-link span:first-child {
  font-size: 1.125rem;
  line-height: 1;
  width: 24px;
  text-align: center;
}

.nav-badge {
  margin-left: auto;
  padding: 0.125rem 0.5rem;
  background: var(--danger-500);
  color: white;
  font-size: 0.6875rem;
  font-weight: 700;
  border-radius: var(--radius-full);
  min-width: 18px;
  text-align: center;
}

.nav-badge.hidden {
  display: none;
}

.nav-badge.alert {
  background: var(--warning-500);
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.sync-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--success-500);
  position: relative;
  flex-shrink: 0;
}

.sync-dot::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: var(--radius-full);
  background: var(--success-500);
  opacity: 0.4;
  animation: syncPulse 2s infinite;
}

@keyframes syncPulse {
  0%, 100% { transform: scale(1); opacity: 0.4; }
  50%       { transform: scale(1.5); opacity: 0; }
}

.sync-dot.offline {
  background: var(--warning-500);
}

.sync-dot.offline::after {
  background: var(--warning-500);
  animation: none;
}

.btn-logout {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem;
  background: transparent;
  color: var(--danger-500);
  border: 1.5px solid var(--danger-100);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-logout:hover {
  background: var(--danger-50);
  border-color: var(--danger-200);
}

.btn-logout svg {
  flex-shrink: 0;
}

/* Sidebar backdrop for mobile */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: calc(var(--z-sticky) - 1);
  opacity: 0;
  transition: opacity var(--transition);
}

.sidebar-backdrop.active {
  display: block;
  opacity: 1;
}

/* Main Content */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition);
}

.top-bar {
  height: var(--header-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.mobile-menu-btn {
  display: none;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.mobile-menu-btn:hover {
  background: var(--gray-100);
}

.top-bar h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.action-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
  position: relative;
}

.action-btn:hover {
  background: var(--primary-50);
  color: var(--primary-700);
  border-color: var(--primary-200);
}

.content-area {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
  background: var(--bg);
}

/* ─────────────────────────────────────────────────────────────── */
/*  SECTION 9: BUTTONS                                           */
/* ─────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  border: 1.5px solid transparent;
  line-height: 1.25;
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-600), var(--primary-700));
  color: white;
  border-color: transparent;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-700), var(--primary-800));
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

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

.btn-secondary:hover {
  background: var(--gray-50);
  border-color: var(--gray-300);
}

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

.btn-success:hover {
  background: linear-gradient(135deg, var(--success-600), var(--success-700));
}

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

.btn-danger:hover {
  background: linear-gradient(135deg, var(--danger-600), var(--danger-700));
}

.btn-block {
  width: 100%;
}

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

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-icon:hover {
  background: var(--gray-100);
  color: var(--text);
}

/* ─────────────────────────────────────────────────────────────── */
/*  SECTION 10: FORMS                                            */
/* ─────────────────────────────────────────────────────────────── */

.form-group {
  margin-bottom: 1rem;
}

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

.form-group label span.required {
  color: var(--danger-500);
  margin-left: 0.125rem;
}

.input-wrapper {
  position: relative;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9375rem;
  font-family: inherit;
  transition: var(--transition-fast);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary-400);
  box-shadow: 0 0 0 3px var(--primary-100);
}

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

.form-group select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.5rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-row .form-group {
  margin-bottom: 0;
}

/* ─────────────────────────────────────────────────────────────── */
/*  SECTION 11: CARDS & STATS                                    */
/* ─────────────────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  transition: var(--transition-fast);
  overflow: hidden;
}

.card:hover {
  box-shadow: var(--shadow-sm);
}

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

.card-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.card-body {
  padding: 1.25rem;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-xs);
  transition: var(--transition-fast);
}

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

.stat-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.stat-card-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.stat-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.stat-card-value {
  font-family: var(--font-display);
  font-size: 1.875rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: 0.25rem;
}

.stat-card-change {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.stat-card-change.positive {
  color: var(--success-600);
}

.stat-card-change.negative {
  color: var(--danger-500);
}

/* ─────────────────────────────────────────────────────────────── */
/*  SECTION 12: LISTS                                            */
/* ─────────────────────────────────────────────────────────────── */

.list-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  transition: var(--transition-fast);
}

.list-item:last-child {
  border-bottom: none;
}

.list-item:hover {
  background: var(--gray-50);
}

[data-theme="dark"] .list-item:hover {
  background: var(--gray-800);
}

.list-item-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.list-item-content {
  flex: 1;
  min-width: 0;
}

.list-item-title {
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--text);
  margin-bottom: 0.125rem;
}

.list-item-subtitle {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.list-item-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* ─────────────────────────────────────────────────────────────── */
/*  SECTION 13: BADGES                                           */
/* ─────────────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
  line-height: 1.4;
}

.badge-success {
  background: var(--success-100);
  color: var(--success-700);
}

.badge-warning {
  background: var(--warning-100);
  color: var(--warning-700);
}

.badge-danger {
  background: var(--danger-100);
  color: var(--danger-700);
}

.badge-info {
  background: var(--info-100);
  color: var(--info-700);
}

.badge-secondary {
  background: var(--gray-100);
  color: var(--gray-700);
}

/* ─────────────────────────────────────────────────────────────── */
/*  SECTION 14: TABLES                                           */
/* ─────────────────────────────────────────────────────────────── */

.table-container {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

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

.data-table thead {
  background: var(--gray-50);
  border-bottom: 1px solid var(--border);
}

[data-theme="dark"] .data-table thead {
  background: var(--gray-800);
}

.data-table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.025em;
  white-space: nowrap;
}

.data-table td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

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

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

[data-theme="dark"] .data-table tbody tr:hover {
  background: var(--gray-800);
}

/* ─────────────────────────────────────────────────────────────── */
/*  SECTION 15: PROGRESS                                         */
/* ─────────────────────────────────────────────────────────────── */

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

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-500), var(--primary-400));
  border-radius: var(--radius-full);
  transition: width 0.6s ease;
}

/* ─────────────────────────────────────────────────────────────── */
/*  SECTION 16: IMAGES                                           */
/* ─────────────────────────────────────────────────────────────── */

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 0.5rem;
}

.image-preview {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--gray-100);
}

.image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ─────────────────────────────────────────────────────────────── */
/*  SECTION 17: CREDIT SCORE                                     */
/* ─────────────────────────────────────────────────────────────── */

.credit-score {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--gray-50);
  border-radius: var(--radius);
}

[data-theme="dark"] .credit-score {
  background: var(--gray-800);
}

.credit-score-ring {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: conic-gradient(var(--primary-500) var(--score-deg, 0deg), var(--gray-200) 0);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
}

.credit-score-ring::before {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: var(--surface);
}

.credit-score-value {
  position: relative;
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--primary-700);
}

.credit-score-label {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

/* ─────────────────────────────────────────────────────────────── */
/*  SECTION 18: EMPTY STATES                                     */
/* ─────────────────────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  max-width: 400px;
  margin: 0 auto;
}

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

.empty-state h3 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.empty-state p {
  color: var(--text-secondary);
  font-size: 0.9375rem;
  margin-bottom: 1.5rem;
}

/* ─────────────────────────────────────────────────────────────── */
/*  SECTION 19: TOASTS                                           */
/* ─────────────────────────────────────────────────────────────── */

#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 380px;
  pointer-events: none;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  animation: toastSlideIn 0.3s ease;
  pointer-events: auto;
  position: relative;
  overflow: hidden;
}

.toast::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
}

.toast.info::before    { background: var(--info-500); }
.toast.success::before { background: var(--success-500); }
.toast.warning::before { background: var(--warning-500); }
.toast.error::before   { background: var(--danger-500); }

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

.toast-message {
  flex: 1;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--text);
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  padding: 0.125rem;
  margin: -0.25rem -0.25rem -0.25rem 0;
  transition: var(--transition-fast);
}

.toast-close:hover {
  color: var(--text);
}

/* ─────────────────────────────────────────────────────────────── */
/*  SECTION 20: MODALS                                           */
/* ─────────────────────────────────────────────────────────────── */

.modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition), visibility var(--transition);
}

.modal.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  transform: scale(0.95) translateY(10px);
  transition: transform var(--transition);
}

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

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}

.modal-header h3 {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.5rem;
  line-height: 1;
  padding: 0.25rem;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
}

.modal-close:hover {
  background: var(--gray-100);
  color: var(--text);
}

.modal-body {
  padding: 1.5rem;
}

/* ─────────────────────────────────────────────────────────────── */
/*  SECTION 21: LOADING SPINNER                                  */
/* ─────────────────────────────────────────────────────────────── */

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary-500);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 2rem auto;
}

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

/* ─────────────────────────────────────────────────────────────── */
/*  SECTION 22: UTILITIES                                        */
/* ─────────────────────────────────────────────────────────────── */

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

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

.text-sm { font-size: 0.875rem; }
.text-lg { font-size: 1.125rem; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }

.animate-fade-in {
  animation: fadeInUp 0.4s ease forwards;
}

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

/* ─────────────────────────────────────────────────────────────── */
/*  SECTION 23: RESPONSIVE                                       */
/* ─────────────────────────────────────────────────────────────── */

@media (min-width: 768px) {
  .auth-container { padding: 2rem; }
  .auth-brand h1 { font-size: 1.75rem; }
  .content-area { padding: 1.5rem 2rem; }
}

@media (min-width: 1024px) {
  .sidebar-toggle { display: none; }
  .content-area { padding: 2rem; }
}

@media (min-width: 1280px) {
  .content-area { padding: 2rem 2.5rem; }
}

@media (max-width: 1023px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .mobile-menu-btn {
    display: flex;
  }
  .top-bar {
    padding: 0 1rem;
  }
  .content-area {
    padding: 1rem;
  }
  .sidebar-backdrop.active {
    display: block;
  }
}

@media (max-width: 640px) {
  .form-row {
    grid-template-columns: 1fr;
  }
  .oauth-grid {
    grid-template-columns: 1fr;
  }
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  #auth-screen { padding: 0.75rem; }
  .auth-container {
    padding: 1.25rem;
    border-radius: var(--radius);
  }
  .top-bar h2 { font-size: 1.1rem; }
  .content-area { padding: 0.75rem; }
  .modal-content { max-height: 95vh; }
  .modal-body { padding: 1rem; }
}

/* ─────────────────────────────────────────────────────────────── */
/*  SECTION 24: PRINT                                            */
/* ─────────────────────────────────────────────────────────────── */

@media print {
  .sidebar, .top-bar, .action-btn, .btn-logout, .offline-banner, .loader-overlay, #toast-container {
    display: none !important;
  }
  .main-content { margin-left: 0; }
  .card {
    box-shadow: none;
    border: 1px solid var(--gray-300);
    break-inside: avoid;
  }
  body { background: white; color: black; }
}

/* ─── CSS Variables (Design Tokens) ─── */
:root {
  --primary: #16a34a;
  --primary-dark: #15803d;
  --primary-light: #dcfce7;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --success: #22c55e;

  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-elevated: #ffffff;
  --border: #e2e8f0;
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Smooth Page Transitions ─── */
.content-area {
  animation: fadeSlideUp 0.4s ease-out;
}

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

/* ─── Skeleton Loading States ─── */
.skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

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

.skeleton-card {
  height: 140px;
  margin-bottom: 1rem;
}

.skeleton-text {
  height: 16px;
  margin-bottom: 8px;
  width: 100%;
}

.skeleton-text.short { width: 60%; }

/* ─── Enhanced Cards (Glassmorphism touch) ─── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition);
  overflow: hidden;
}

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

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary);
  opacity: 0;
  transition: opacity var(--transition);
}

.stat-card:hover::before {
  opacity: 1;
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.stat-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  transition: transform var(--transition);
}

.stat-card:hover .stat-card-icon {
  transform: scale(1.1) rotate(-5deg);
}

.stat-card-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 0.75rem;
  letter-spacing: -0.02em;
}

/* ─── Enhanced Buttons ─── */
.btn {
  position: relative;
  overflow: hidden;
  transition: all var(--transition-fast);
  font-weight: 500;
  letter-spacing: 0.01em;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(255,255,255,0.15), transparent);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.btn:hover::after {
  opacity: 1;
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border: none;
  box-shadow: 0 2px 8px rgba(22, 163, 74, 0.25);
}

.btn-primary:hover {
  box-shadow: 0 4px 16px rgba(22, 163, 74, 0.35);
  transform: translateY(-1px);
}

/* ─── Enhanced Badges ─── */
.badge {
  font-weight: 600;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.35em 0.75em;
  border-radius: 999px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.05);
}

.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-secondary { background: #f1f5f9; color: #475569; }

/* ─── Enhanced List Items ─── */
.list-item {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition-fast);
  animation: slideIn 0.3s ease-out backwards;
}

.list-item:nth-child(1) { animation-delay: 0.05s; }
.list-item:nth-child(2) { animation-delay: 0.1s; }
.list-item:nth-child(3) { animation-delay: 0.15s; }
.list-item:nth-child(4) { animation-delay: 0.2s; }
.list-item:nth-child(5) { animation-delay: 0.25s; }

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

.list-item:hover {
  background: #f8fafc;
}

.list-item:last-child {
  border-bottom: none;
}

/* ─── Enhanced Modal ─── */
.modal {
  backdrop-filter: blur(8px);
  background: rgba(0, 0, 0, 0.4);
  transition: opacity var(--transition);
}

.modal-content {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border);
  transform: scale(0.95) translateY(10px);
  transition: transform var(--transition-slow), opacity var(--transition);
  opacity: 0;
}

.modal.active .modal-content {
  transform: scale(1) translateY(0);
  opacity: 1;
}

/* ─── Enhanced Toast Notifications ─── */
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 300px;
  max-width: 400px;
  animation: toastSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

.toast::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
}

.toast.success::before { background: var(--success); }
.toast.error::before { background: var(--danger); }
.toast.warning::before { background: var(--warning); }
.toast.info::before { background: var(--info); }

@keyframes toastSlideIn {
  from { transform: translateX(120%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes toastSlideOut {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(120%); opacity: 0; }
}

/* ─── Progress Bars ─── */
.progress-bar {
  height: 8px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.05);
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #4ade80);
  border-radius: 999px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.progress-bar-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
  animation: progress-shine 2s infinite;
}

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

/* ─── Empty States ─── */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  animation: fadeSlideUp 0.5s ease-out;
}

.empty-state-icon {
  font-size: 4rem;
  margin-bottom: 1.5rem;
  opacity: 0.6;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

/* ─── Form Inputs ─── */
input, select, textarea {
  transition: all var(--transition-fast);
  border: 1.5px solid var(--border);
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.1);
  outline: none;
}

/* ─── Image Grid / Previews ─── */
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 0.75rem;
}

.image-preview {
  aspect-ratio: 1;
  border-radius: var(--radius);
  overflow: hidden;
  border: 2px solid var(--border);
  transition: all var(--transition-fast);
  cursor: pointer;
}

.image-preview:hover {
  border-color: var(--primary);
  transform: scale(1.05);
  box-shadow: var(--shadow-md);
}

.image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition);
}

.image-preview:hover img {
  transform: scale(1.1);
}

/* ─── Credit Score Ring ─── */
.credit-score-ring {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: conic-gradient(var(--primary) var(--score-deg, 0deg), #e2e8f0 0deg);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: var(--shadow-sm);
}

.credit-score-ring::before {
  content: '';
  position: absolute;
  inset: 6px;
  background: var(--surface);
  border-radius: 50%;
}

.credit-score-value {
  position: relative;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
}

/* ─── Dashboard Grid ─── */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

/* ─── Table Enhancements ─── */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.875rem;
}

.data-table th {
  background: #f8fafc;
  padding: 0.875rem 1rem;
  font-weight: 600;
  text-align: left;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border);
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
}

.data-table td {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition-fast);
}

.data-table tbody tr:hover td {
  background: #f8fafc;
}

/* ─── Sidebar Enhancement ─── */
.sidebar {
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border-right: 1px solid var(--border);
  box-shadow: 4px 0 24px rgba(0,0,0,0.04);
}

.nav-link {
  position: relative;
  border-radius: var(--radius);
  margin: 0.25rem 0.75rem;
  padding: 0.75rem 1rem;
  transition: all var(--transition-fast);
}

.nav-link::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 0;
  background: var(--primary);
  border-radius: 0 4px 4px 0;
  transition: height var(--transition);
}

.nav-link.active::before {
  height: 60%;
}

.nav-link.active {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 600;
}

.nav-link:hover:not(.active) {
  background: #f1f5f9;
}

/* ─── Mobile Menu Button ─── */
.mobile-menu-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}

.mobile-menu-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}

/* ─── Top Bar ─── */
.top-bar {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

/* ─── Chart Containers ─── */
.chart-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
}

.chart-container canvas {
  max-height: 280px;
}

/* ─── Live Activity Ticker ─── */
.activity-ticker {
  background: linear-gradient(90deg, var(--primary-light), #ffffff);
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  overflow: hidden;
  white-space: nowrap;
}

.activity-ticker .ticker-dot {
  width: 8px;
  height: 8px;
  background: var(--success);
  border-radius: 50%;
  animation: pulse 2s infinite;
  flex-shrink: 0;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.2); }
}

/* ─── Responsive Tweaks ─── */
@media (max-width: 768px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .stat-card-value {
    font-size: 1.5rem;
  }

  .modal-content {
    margin: 1rem;
    max-height: calc(100vh - 2rem);
  }

  .toast {
    min-width: auto;
    max-width: calc(100vw - 2rem);
    margin: 0.5rem 1rem;
  }
}