/* ==========================================================================
   Admin Dashboard Control Center - Balanced Emerald & Multi-Accent Theme
   Executive Modern SaaS Aesthetic (Dark / Light Balanced Design System)
   ========================================================================== */

:root {
  /* --- DARK THEME (Executive Obsidian Slate + Emerald Hero + Matching Accents) --- */
  --theme-mode: dark;

  /* Ambient Canvas & Surfaces: Deep Obsidian Slate (Clean, No Green Wash) */
  --bg-primary: #0b0f17;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.85);
  --bg-card-solid: #111827;
  --bg-card-secondary: #162032;
  --bg-hover: rgba(255, 255, 255, 0.05);
  --bg-active: rgba(16, 185, 129, 0.14);

  /* Subtle Crisp Neutral Borders */
  --border-color: rgba(255, 255, 255, 0.08);
  --border-subtle: rgba(255, 255, 255, 0.04);
  --border-hover: rgba(16, 185, 129, 0.4);
  --border-focus: #10b981;

  /* Typography & High-Contrast Readability */
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-heading: #ffffff;
  --text-accent: #34d399;
  --text-inverse: #0b0f17;

  /* Hero Accent: Emerald Green */
  --accent-primary: #10b981;
  --accent-hover: #059669;
  --accent-subtle: rgba(16, 185, 129, 0.12);
  --accent-mint: #34d399;
  --accent-success: #10b981;
  --primary-color: #10b981;

  /* Harmonious Matching Accents (Cyan, Amber, Violet, Rose, Indigo) */
  --accent-cyan: #06b6d4;
  --accent-cyan-hover: #0891b2;
  --accent-cyan-subtle: rgba(6, 182, 212, 0.14);

  --accent-warning: #f59e0b;
  --accent-amber-subtle: rgba(245, 158, 11, 0.14);

  --accent-purple: #8b5cf6;
  --accent-indigo: #6366f1;
  --accent-purple-subtle: rgba(139, 92, 246, 0.14);

  --accent-danger: #f43f5e;
  --accent-rose-subtle: rgba(244, 63, 94, 0.14);

  --accent-teal: #14b8a6;
  --accent-teal-subtle: rgba(20, 184, 166, 0.14);

  /* Curated Multi-Color Gradients */
  --gradient-emerald: linear-gradient(135deg, #10b981 0%, #059669 100%);
  --gradient-mint: linear-gradient(135deg, #34d399 0%, #10b981 100%);
  --gradient-cyan: linear-gradient(135deg, #0284c7 0%, #06b6d4 100%);
  --gradient-amber: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  --gradient-purple: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
  --gradient-rose: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);

  /* Terminal Emulation */
  --terminal-bg: #070c14;
  --terminal-text: #e2e8f0;
  --terminal-border: rgba(255, 255, 255, 0.1);
  --terminal-header-bg: #0d1522;

  /* Clean Layered Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 14px -2px rgba(0, 0, 0, 0.4), 0 2px 6px -1px rgba(16, 185, 129, 0.04);
  --shadow-lg: 0 14px 28px -4px rgba(0, 0, 0, 0.55), 0 6px 14px -2px rgba(16, 185, 129, 0.06);

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'Fira Code', 'Cascadia Code', Consolas, Monaco, monospace;

  /* Corner Radii */
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --radius-full: 9999px;
}

[data-theme="light"] {
  /* --- LIGHT THEME (Crisp Modern White / Slate Surfaces + Vivid Accents) --- */
  --theme-mode: light;

  /* Clean Slate & Pure White Canvas */
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-card-solid: #ffffff;
  --bg-card-secondary: #f1f5f9;
  --bg-hover: #f1f5f9;
  --bg-active: #e6f7ef;

  /* Crisp Neutral Borders */
  --border-color: #e2e8f0;
  --border-subtle: #f1f5f9;
  --border-hover: #10b981;
  --border-focus: #059669;

  /* Crisp Charcoal Typography */
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-heading: #0f172a;
  --text-accent: #059669;
  --text-inverse: #ffffff;

  /* Hero Emerald Accent */
  --accent-primary: #059669;
  --accent-hover: #047857;
  --accent-subtle: rgba(5, 150, 105, 0.08);
  --accent-mint: #10b981;
  --accent-success: #059669;
  --primary-color: #059669;

  /* Harmonious Matching Accents in Light Mode */
  --accent-cyan: #0284c7;
  --accent-cyan-hover: #0369a1;
  --accent-cyan-subtle: rgba(2, 132, 199, 0.1);

  --accent-warning: #d97706;
  --accent-amber-subtle: rgba(217, 119, 6, 0.1);

  --accent-purple: #7c3aed;
  --accent-indigo: #4f46e5;
  --accent-purple-subtle: rgba(124, 58, 237, 0.1);

  --accent-danger: #e11d48;
  --accent-rose-subtle: rgba(225, 29, 72, 0.1);

  --accent-teal: #0f766e;
  --accent-teal-subtle: rgba(15, 118, 110, 0.1);

  /* Terminal in Light Mode: Remains high-contrast dark console */
  --terminal-bg: #0b1120;
  --terminal-text: #f1f5f9;
  --terminal-border: #1e293b;
  --terminal-header-bg: #111827;

  /* Soft Ambient Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 14px -2px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 14px 28px -4px rgba(0, 0, 0, 0.12);
}

/* ==========================================================================
   Reset & Base Styles
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 15px;
  scroll-behavior: smooth;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(ellipse at 15% 0%, rgba(16, 185, 129, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 85% 15%, rgba(6, 182, 212, 0.04) 0%, transparent 45%);
  background-attachment: fixed;
  color: var(--text-main);
  line-height: 1.55;
  overflow-x: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
}

a {
  color: var(--text-accent);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--accent-mint);
  text-decoration: underline;
}

/* ==========================================================================
   Layout Architecture
   ========================================================================== */
.app-layout {
  display: flex;
  min-height: 100vh;
  position: relative;
}

/* ==========================================================================
   Sidebar Navigation (Balanced Slate + Emerald Brand Accent)
   ========================================================================== */
.sidebar {
  width: 268px;
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.3s ease, border-color 0.3s ease;
}

.sidebar-header {
  padding: 22px 24px;
  border-bottom: 1px solid var(--border-color);
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon-wrapper {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--gradient-emerald);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
  color: #ffffff;
  flex-shrink: 0;
}

.brand-icon {
  width: 22px;
  height: 22px;
}

.brand-text .title {
  display: block;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  color: var(--text-heading);
}

.brand-text .subtitle {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
}

/* Sidebar Navigation Items */
.sidebar-nav {
  padding: 20px 14px;
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
}

.nav-section-title {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 18px;
  margin-bottom: 8px;
  padding-left: 12px;
  opacity: 0.75;
}

.nav-section-title:first-child {
  margin-top: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 500;
  margin-bottom: 4px;
  position: relative;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.nav-item i {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  transition: transform 0.2s ease, color 0.2s ease;
}

.nav-item:hover {
  background-color: var(--bg-hover);
  color: var(--text-heading);
  transform: translateX(3px);
}

.nav-item:hover i {
  transform: scale(1.1);
}

.nav-item[data-tab="overview"]:hover i { color: var(--accent-primary); }
.nav-item[data-tab="scripts"]:hover i { color: #34d399; }
.nav-item[data-tab="terminal"]:hover i { color: #06b6d4; }
.nav-item[data-tab="business-search"]:hover i { color: #38bdf8; }
.nav-item[data-tab="database"]:hover i { color: #a78bfa; }
.nav-item[data-tab="migration"]:hover i { color: #fbbf24; }
.nav-item[data-tab="audit-logs"]:hover i { color: #f472b6; }

.nav-item.active {
  background: var(--accent-subtle);
  color: var(--accent-primary);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(16, 185, 129, 0.3);
}

.nav-item.active i {
  color: var(--accent-primary);
}

.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--gradient-emerald);
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
  box-shadow: 0 0 8px var(--accent-primary);
}

.nav-item .badge {
  margin-left: auto;
  background: var(--gradient-emerald);
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.25);
}

/* Sidebar Footer & Theme Toggle */
.sidebar-footer {
  padding: 16px 18px;
  border-top: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.system-status-mini {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
}

.status-indicator {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  position: relative;
}

.status-indicator.online {
  background-color: var(--accent-success);
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: emeraldPulse 2s infinite cubic-bezier(0.66, 0, 0, 1);
}

.status-indicator.offline {
  background-color: var(--accent-danger);
  box-shadow: 0 0 8px var(--accent-danger);
}

@keyframes emeraldPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(16, 185, 129, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

.theme-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  background-color: var(--bg-hover);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-sm);
}

.theme-toggle-btn:hover {
  background-color: var(--bg-card);
  border-color: var(--border-hover);
  color: var(--accent-primary);
  transform: translateY(-1px);
}

.theme-toggle-btn:active {
  transform: translateY(1px) scale(0.98);
}

/* ==========================================================================
   Main Content Layout & Top Sticky Bar
   ========================================================================== */
.main-wrapper {
  margin-left: 268px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}

.top-bar {
  height: 72px;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 90;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.page-title-area h1 {
  font-size: 1.28rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-heading);
}

.page-title-area p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.top-bar-controls {
  display: flex;
  align-items: center;
  gap: 14px;
}

.metric-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background-color: var(--bg-hover);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-main);
  border: 1px solid var(--border-color);
  transition: all 0.2s ease;
}

.metric-pill:hover {
  border-color: var(--border-hover);
  background-color: var(--accent-subtle);
}

.metric-pill i {
  width: 15px;
  height: 15px;
  color: var(--accent-primary);
}

/* ==========================================================================
   Content Area & Tab Animation System
   ========================================================================== */
.content-body {
  padding: 30px 32px;
  flex: 1;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
  animation: tabFadeUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes tabFadeUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==========================================================================
   KPI Cards (Harmonious Multi-Color Statistics Grid)
   ========================================================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 20px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 22px;
  display: flex;
  align-items: center;
  gap: 18px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease, border-color 0.25s ease;
}

.kpi-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-hover);
}

.kpi-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.kpi-card:hover .kpi-icon {
  transform: scale(1.06);
}

/* Distinct Matching Accent Gradients for Each KPI */
.bg-blue {
  background: var(--gradient-cyan);
  box-shadow: 0 4px 14px rgba(6, 182, 212, 0.35);
}

.bg-green {
  background: var(--gradient-emerald);
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
}

.bg-amber {
  background: var(--gradient-amber);
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.35);
}

.bg-purple {
  background: var(--gradient-purple);
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.35);
}

.kpi-info .kpi-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.kpi-info .kpi-value {
  display: block;
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-heading);
}

/* ==========================================================================
   Panels, Containers & Cards
   ========================================================================== */
.panel-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.panel-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
}

.panel-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.02);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-heading);
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-header h3 i {
  width: 20px;
  height: 20px;
  color: var(--accent-primary);
}

.panel-body {
  padding: 24px;
}

/* Grid Layout Utilities */
.grid-2-col { display: grid; grid-template-columns: 1fr 1fr; }
.grid-4-col { display: grid; grid-template-columns: repeat(4, 1fr); }
.gap-md { gap: 18px; }
.gap-lg { gap: 24px; }
.mt-md { margin-top: 18px; }
.mt-lg { margin-top: 24px; }
.mb-md { margin-bottom: 18px; }

@media (max-width: 1024px) {
  .grid-2-col, .grid-4-col { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Buttons & Interactive Elements
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  font-size: 0.86rem;
  font-weight: 600;
  font-family: inherit;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  text-decoration: none;
  line-height: 1.2;
}

.btn:active {
  transform: translateY(1px) scale(0.98);
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.35);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.78rem;
  border-radius: var(--radius-xs);
}

/* Primary Button with Emerald Radiance */
.btn-primary {
  background: var(--gradient-emerald);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.38);
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: var(--bg-hover);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--text-heading);
  transform: translateY(-1px);
}

.btn-success {
  background: var(--gradient-mint);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(52, 211, 153, 0.25);
}

.btn-success:hover {
  filter: brightness(0.94);
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--gradient-rose);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(244, 63, 94, 0.25);
}

.btn-danger:hover {
  filter: brightness(0.94);
  transform: translateY(-1px);
}

.btn-warning {
  background: var(--gradient-amber);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.25);
}

.btn-icon {
  padding: 7px;
  background-color: var(--bg-hover);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.btn-icon:hover {
  color: var(--accent-primary);
  border-color: var(--border-hover);
  background-color: var(--bg-card);
  transform: translateY(-1px);
}

/* ==========================================================================
   Data Tables & Location Statistics
   ========================================================================== */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-md);
  scrollbar-width: thin;
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.86rem;
  text-align: left;
}

.data-table th {
  background-color: rgba(255, 255, 255, 0.02);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 13px 18px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.data-table td {
  padding: 13px 18px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  background: var(--bg-card);
  transition: background-color 0.15s ease;
}

.data-table tbody tr:hover td {
  background-color: var(--bg-hover);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

/* Location and Category Specific Table Styles */
.loc-stats-table th.sortable {
  cursor: pointer;
  user-select: none;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.loc-stats-table th.sortable:hover {
  color: var(--accent-primary);
  background-color: var(--bg-hover);
}

.loc-stats-table th.sortable .sort-icon {
  margin-left: 4px;
  font-size: 0.72rem;
  opacity: 0.6;
}

.loc-cell-city {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  color: var(--text-heading);
}

.loc-id-pill {
  font-size: 0.68rem;
  font-family: var(--font-mono);
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  background: var(--bg-hover);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.loc-cat-pill {
  display: inline-block;
  font-weight: 600;
  color: var(--text-heading);
  background: var(--bg-hover);
  padding: 3px 10px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-color);
  font-size: 0.78rem;
}

/* Matching Multi-Color Stat Pills (Crystal Clear Data Hierarchy) */
.stat-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  font-weight: 700;
  font-size: 0.8rem;
  font-family: var(--font-mono);
  text-align: right;
  transition: transform 0.15s ease;
}

.stat-pill.zero {
  opacity: 0.35;
  color: var(--text-muted);
  background: transparent;
  border: 1px dashed var(--border-color);
}

/* Total Businesses: Indigo / Steel */
.stat-pill.total {
  background: rgba(99, 102, 241, 0.14);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.28);
}

/* Scraped: Emerald Green */
.stat-pill.scraped {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* With Prices: Warm Amber */
.stat-pill.prices {
  background: rgba(245, 158, 11, 0.14);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.28);
}

/* AI Normalized: Royal Violet */
.stat-pill.ai-norm {
  background: rgba(139, 92, 246, 0.15);
  color: #c084fc;
  border: 1px solid rgba(139, 92, 246, 0.3);
}

/* Main Prices: Electric Cyan */
.stat-pill.main-prices {
  background: rgba(6, 182, 212, 0.14);
  color: #22d3ee;
  border: 1px solid rgba(6, 182, 212, 0.28);
}

/* Normalized: Rose / Coral */
.stat-pill.norm {
  background: rgba(244, 63, 94, 0.14);
  color: #fb7185;
  border: 1px solid rgba(244, 63, 94, 0.28);
}

/* Grouped: Teal / Mint */
.stat-pill.grouped {
  background: rgba(20, 184, 166, 0.14);
  color: #2dd4bf;
  border: 1px solid rgba(20, 184, 166, 0.28);
}

.loc-stats-tfoot tr td {
  padding: 16px 18px;
  background: var(--bg-secondary);
  border-top: 2px solid var(--border-color);
  font-weight: 800;
  color: var(--text-heading);
}

/* ==========================================================================
   Badges, Status Indicators & Script Widgets
   ========================================================================== */
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge-status.running {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.35);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.2);
}

.badge-status.stopped {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.badge-status.failed {
  background: rgba(244, 63, 94, 0.15);
  color: #f43f5e;
  border: 1px solid rgba(244, 63, 94, 0.35);
}

.badge-status.completed {
  background: rgba(6, 182, 212, 0.15);
  color: #22d3ee;
  border: 1px solid rgba(6, 182, 212, 0.35);
}

.badge-status.never_run {
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.3);
}

/* AI Scraper Live Row Widget */
.ai-scraper-row-widget {
  background: var(--bg-hover);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  transition: all 0.25s ease;
}

.ai-scraper-row-widget.is-running {
  border-color: var(--accent-primary);
  background: rgba(16, 185, 129, 0.08);
  box-shadow: 0 0 14px rgba(16, 185, 129, 0.18);
}

.progress-bar-wrap {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: 6px;
}

.progress-bar-inner {
  height: 100%;
  background: var(--gradient-emerald);
  border-radius: var(--radius-full);
  transition: width 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.4);
}

.progress-bar-inner.complete {
  background: var(--gradient-mint);
}

/* ==========================================================================
   Script Catalog Grid & Cards
   ========================================================================== */
.scripts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 22px;
}

.script-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 22px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

.script-card:hover {
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.script-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.script-title {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: var(--text-heading);
}

.script-category-tag {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
      white-space: nowrap;
  background-color: var(--accent-purple-subtle);
  color: #c084fc;
  border: 1px solid rgba(139, 92, 246, 0.3);
  padding: 2px 8px;
  border-radius: var(--radius-xs);
}

.script-description {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
  min-height: 42px;
  line-height: 1.5;
}

.script-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  border-top: 1px dashed var(--border-color);
  padding-top: 14px;
  margin-bottom: 16px;
}

.script-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ==========================================================================
   Terminal Console & Output Viewer
   ========================================================================== */
.terminal-container {
  background-color: var(--terminal-bg);
  border: 1px solid var(--terminal-border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  height: calc(100vh - 160px);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.terminal-header {
  background-color: var(--terminal-header-bg);
  padding: 12px 20px;
  border-bottom: 1px solid var(--terminal-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #ffffff;
}

.terminal-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--accent-mint);
}

.terminal-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.terminal-body {
  padding: 18px;
  flex: 1;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 0.84rem;
  line-height: 1.65;
  color: var(--terminal-text);
  background-color: var(--terminal-bg);
  scrollbar-width: thin;
}

.terminal-line {
  white-space: pre-wrap;
  word-break: break-all;
  margin-bottom: 3px;
}

.terminal-line.error { color: #f43f5e; font-weight: 600; }
.terminal-line.warning { color: #fbbf24; }
.terminal-line.success { color: #34d399; font-weight: 600; }
.terminal-line.system { color: #38bdf8; font-style: italic; opacity: 0.9; }
.terminal-line.stdin { color: #818cf8; font-weight: 600; }

.terminal-footer {
  background-color: var(--terminal-header-bg);
  padding: 12px 18px;
  border-top: 1px solid var(--terminal-border);
}

.terminal-input-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}

.terminal-input-wrapper .input-prompt {
  color: var(--accent-mint);
  font-family: var(--font-mono);
  font-weight: bold;
  font-size: 1.1rem;
}

.terminal-input-wrapper input {
  flex: 1;
  background-color: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--terminal-border);
  color: #f8fafc;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.terminal-input-wrapper input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.25);
}

/* ==========================================================================
   Forms, Inputs & Filtering Controls
   ========================================================================== */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}

.form-input {
  width: 100%;
  padding: 9px 13px;
  background-color: var(--bg-hover);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.86rem;
  font-family: inherit;
  transition: all 0.2s ease;
}

.form-input:focus {
  outline: none;
  border-color: var(--border-focus);
  background-color: var(--bg-card);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.22);
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box i {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-box input {
  padding-left: 36px;
}

/* ==========================================================================
   Modals & Overlays
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal-overlay.active {
  display: flex;
  animation: modalBackdropFade 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-card {
  background-color: var(--bg-card-solid);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 1060px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modalScaleIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-card.modal-lg {
  max-width: 820px;
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.02);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-heading);
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-xs);
  transition: all 0.2s ease;
}

.modal-close:hover {
  color: var(--accent-danger);
  transform: rotate(90deg);
}

.modal-body {
  padding: 24px;
  max-height: 78vh;
  overflow-y: auto;
  scrollbar-width: thin;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.02);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

@keyframes modalBackdropFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalScaleIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(12px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* ==========================================================================
   Interactive Controls, Switches & Preset Buttons
   ========================================================================== */
.toggle-switch {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-muted);
  user-select: none;
}

.toggle-switch input {
  display: none;
}

.toggle-switch .slider {
  width: 36px;
  height: 20px;
  background-color: var(--bg-hover);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  position: relative;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.toggle-switch .slider::before {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  left: 2px;
  top: 2px;
  background-color: #ffffff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.toggle-switch input:checked + .slider {
  background: var(--gradient-emerald);
  border-color: var(--accent-primary);
}

.toggle-switch input:checked + .slider::before {
  transform: translateX(16px);
}

.preset-btn {
  padding: 5px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: var(--radius-xs);
  background: var(--bg-hover);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.preset-btn:hover {
  background: var(--accent-subtle);
  border-color: var(--border-hover);
  color: var(--accent-primary);
  transform: translateY(-1px);
}

.preset-btn.active {
  background: var(--gradient-emerald);
  border-color: var(--accent-primary);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

/* ==========================================================================
   Toast Notifications
   ========================================================================== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
}

.toast-message {
  pointer-events: auto;
  min-width: 290px;
  max-width: 440px;
  padding: 13px 18px;
  border-radius: var(--radius-md);
  background: var(--bg-card-solid);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  color: var(--text-main);
  font-size: 0.85rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: toastFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  backdrop-filter: blur(8px);
}

.toast-message.success {
  border-left: 4px solid var(--accent-success);
}

.toast-message.info {
  border-left: 4px solid var(--accent-cyan);
}

.toast-message.error {
  border-left: 4px solid var(--accent-danger);
}

@keyframes toastFadeIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ==========================================================================
   Custom Scrollbars
   ========================================================================== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ==========================================================================
   Accessibility & Responsive Media Queries
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
  }

  .main-wrapper {
    margin-left: 0;
  }

  .top-bar {
    padding: 0 18px;
  }

  .content-body {
    padding: 20px 18px;
  }
}
