/* ============================================================
   FUNDMERICA DATA PLATFORM
   Command Deck — Executive Data Operations UI
   ============================================================ */

/* --- Custom Properties --- */
:root {
  --fm-red: #C41E3A;
  --fm-red-hover: #A8182F;
  --fm-red-glow: rgba(196, 30, 58, 0.15);
  --fm-navy: #001F3F;
  --fm-navy-light: #0A2A4A;
  --fm-navy-lighter: #153556;
  --fm-cyan: #17A2B8;
  --fm-cyan-soft: rgba(23, 162, 184, 0.12);
  --fm-charcoal: #2C3E50;
  --fm-white: #FFFFFF;
  --fm-off-white: #F7F8FC;
  --fm-light-gray: #EEF1F6;
  --fm-mid-gray: #94A3B8;
  --fm-border: #DDE3ED;
  --fm-success: #0D9668;
  --fm-danger: #DC2626;
  --fm-warning: #D97706;
  --fm-sidebar-w: 264px;
  --fm-topbar-h: 0px;
  --fm-radius: 10px;
  --fm-radius-sm: 6px;
  --fm-shadow: 0 1px 3px rgba(0,31,63,0.06), 0 4px 12px rgba(0,31,63,0.04);
  --fm-shadow-hover: 0 4px 16px rgba(0,31,63,0.10);
  --fm-transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);

  /* Command Center dark theme */
  --fm-dark-bg: #0B1929;
  --fm-dark-card: #112240;
  --fm-dark-border: rgba(23, 162, 184, 0.15);
  --fm-glow-cyan: 0 0 20px rgba(23, 162, 184, 0.3);
  --fm-glow-green: 0 0 20px rgba(13, 150, 104, 0.3);
  --fm-glow-gold: 0 0 20px rgba(245, 158, 11, 0.3);
  --fm-glow-red: 0 0 20px rgba(196, 30, 58, 0.3);

  /* Bootstrap overrides */
  --bs-primary: #C41E3A;
  --bs-primary-rgb: 196, 30, 58;
  --bs-body-font-family: 'Open Sans', sans-serif;
  --bs-body-color: #2C3E50;
  --bs-body-bg: #F7F8FC;
  --bs-link-color: #C41E3A;
  --bs-link-hover-color: #A8182F;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0;
  font-family: 'Open Sans', sans-serif;
  font-size: 0.9rem;
  color: var(--fm-charcoal);
  background: var(--fm-off-white);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  color: var(--fm-navy);
  letter-spacing: -0.01em;
}

a { color: var(--fm-red); text-decoration: none; transition: color var(--fm-transition); }
a:hover { color: var(--fm-red-hover); }

::selection { background: var(--fm-red-glow); color: var(--fm-navy); }

/* --- Sidebar --- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--fm-sidebar-w);
  background: linear-gradient(195deg, var(--fm-navy) 0%, #00152E 100%);
  z-index: 1040;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 4px 0 24px rgba(0, 15, 30, 0.25);
}

.sidebar-header {
  padding: 1.75rem 1.5rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-logo {
  width: 180px;
  height: auto;
  display: block;
  margin-bottom: 0.35rem;
}

.sidebar-logo .logo-text-secondary { fill: #FFFFFF; }

.sidebar-tagline {
  display: block;
  font-family: 'Open Sans', sans-serif;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: rgba(255,255,255,0.35);
  margin-top: 0.2rem;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0;
  overflow-y: auto;
}

.sidebar-nav-label {
  display: block;
  padding: 0.5rem 1.5rem 0.35rem;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: rgba(255,255,255,0.25);
  margin-top: 0.75rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1.5rem;
  color: rgba(255,255,255,0.55);
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: all var(--fm-transition);
  position: relative;
}

.sidebar-link i {
  font-size: 1.1rem;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-link:hover {
  color: #FFFFFF;
  background: rgba(255,255,255,0.04);
  border-left-color: rgba(196, 30, 58, 0.5);
}

.sidebar-link.active {
  color: #FFFFFF;
  background: rgba(196, 30, 58, 0.12);
  border-left-color: var(--fm-red);
  font-weight: 600;
}

.sidebar-link.active::after {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--fm-red);
  border-radius: 3px 0 0 3px;
}

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.06);
  font-size: 0.7rem;
  color: rgba(255,255,255,0.2);
}

.sidebar-footer .version {
  display: block;
  margin-top: 0.2rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6rem;
  color: rgba(255,255,255,0.12);
}

/* --- Main Content Area --- */
.main-wrapper {
  margin-left: var(--fm-sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.main-content {
  flex: 1;
  padding: 2rem 2.25rem;
}

.main-footer {
  padding: 1rem 2.25rem;
  font-size: 0.75rem;
  color: var(--fm-mid-gray);
  border-top: 1px solid var(--fm-border);
  background: var(--fm-white);
}

/* --- Mobile Topbar --- */
.topbar {
  display: none;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  background: var(--fm-navy);
  color: #FFFFFF;
  position: sticky;
  top: 0;
  z-index: 1030;
}

.topbar-brand {
  font-family: 'Montserrat', sans-serif;
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: 0.02em;
}

.topbar-brand .brand-red { color: var(--fm-red); }

.sidebar-toggle {
  background: none;
  border: none;
  color: #FFFFFF;
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
  border-radius: var(--fm-radius-sm);
  transition: background var(--fm-transition);
}

.sidebar-toggle:hover { background: rgba(255,255,255,0.1); }

/* Sidebar overlay for mobile */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 15, 30, 0.6);
  z-index: 1035;
  backdrop-filter: blur(2px);
}

/* --- Page Headers --- */
.page-header {
  margin-bottom: 1.75rem;
}

.page-header h3 {
  font-size: 1.5rem;
  margin-bottom: 0.15rem;
  position: relative;
  display: inline-block;
  padding-bottom: 0.5rem;
}

.page-header h3::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 44px;
  height: 3px;
  background: var(--fm-red);
  border-radius: 2px;
}

.page-header .subtitle {
  color: var(--fm-mid-gray);
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

/* --- Stat Cards --- */
.stat-card {
  background: var(--fm-white);
  border-radius: var(--fm-radius);
  padding: 1.35rem 1.25rem;
  border-top: 3px solid var(--fm-navy);
  box-shadow: var(--fm-shadow);
  text-align: center;
  transition: all var(--fm-transition);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 80px;
  height: 80px;
  background: radial-gradient(circle at top right, rgba(0,31,63,0.03) 0%, transparent 70%);
  pointer-events: none;
}

.stat-card:hover {
  box-shadow: var(--fm-shadow-hover);
  transform: translateY(-2px);
}

.stat-card.accent-red    { border-top-color: var(--fm-red); }
.stat-card.accent-navy   { border-top-color: var(--fm-navy); }
.stat-card.accent-cyan   { border-top-color: var(--fm-cyan); }
.stat-card.accent-green  { border-top-color: var(--fm-success); }
.stat-card.accent-danger { border-top-color: var(--fm-danger); }
.stat-card.accent-gold   { border-top-color: #F59E0B; }

.stat-card .stat-icon {
  font-size: 1.3rem;
  color: var(--fm-mid-gray);
  margin-bottom: 0.5rem;
  opacity: 0.5;
}

.stat-card .stat-number {
  font-family: 'Montserrat', sans-serif;
  font-weight: 800;
  font-size: 1.85rem;
  color: var(--fm-navy);
  line-height: 1.1;
  margin-bottom: 0.25rem;
  letter-spacing: -0.02em;
}

.stat-card .stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fm-mid-gray);
}

/* --- Cards --- */
.fm-card {
  background: var(--fm-white);
  border-radius: var(--fm-radius);
  box-shadow: var(--fm-shadow);
  border: none;
  overflow: hidden;
  margin-bottom: 1.25rem;
}

.fm-card .card-header {
  background: var(--fm-navy);
  color: #FFFFFF;
  font-family: 'Montserrat', sans-serif;
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.03em;
  padding: 0.75rem 1.15rem;
  border: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.fm-card .card-header i { font-size: 0.95rem; opacity: 0.7; }

.fm-card .card-body { padding: 1.15rem; }

.fm-card .card-body.compact { padding: 0; }

/* --- Tables --- */
.fm-table {
  width: 100%;
  margin-bottom: 0;
  font-size: 0.85rem;
  border-collapse: separate;
  border-spacing: 0;
}

.fm-table thead th {
  background: var(--fm-navy);
  color: #FFFFFF;
  font-family: 'Montserrat', sans-serif;
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.65rem 0.85rem;
  border: none;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

.fm-table thead th:first-child { border-radius: var(--fm-radius-sm) 0 0 0; }
.fm-table thead th:last-child { border-radius: 0 var(--fm-radius-sm) 0 0; }

/* Remove radius when inside a card (card already has its own) */
.fm-card .fm-table thead th:first-child,
.fm-card .fm-table thead th:last-child { border-radius: 0; }

.fm-table tbody td {
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid var(--fm-light-gray);
  vertical-align: middle;
  color: var(--fm-charcoal);
}

.fm-table tbody tr:last-child td { border-bottom: none; }

.fm-table tbody tr {
  transition: background var(--fm-transition);
}

.fm-table tbody tr:nth-child(even) { background: rgba(238, 241, 246, 0.5); }

.fm-table tbody tr:hover {
  background: var(--fm-cyan-soft);
}

.fm-table tbody tr:hover td:first-child {
  box-shadow: inset 3px 0 0 var(--fm-cyan);
}

.fm-table a { font-weight: 600; }

/* Sortable headers */
.fm-table th[data-sortable] {
  cursor: pointer;
  user-select: none;
}

.fm-table th[data-sortable]:hover { background: var(--fm-navy-light); }

.fm-table th .sort-indicator {
  font-size: 0.65rem;
  margin-left: 0.3rem;
  opacity: 0.4;
}

.fm-table th.sort-asc .sort-indicator,
.fm-table th.sort-desc .sort-indicator { opacity: 1; }

/* --- Buttons --- */
.btn-fm-primary {
  background: var(--fm-red);
  color: #FFFFFF;
  border: none;
  font-family: 'Montserrat', sans-serif;
  font-weight: 600;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  padding: 0.55rem 1.35rem;
  border-radius: var(--fm-radius-sm);
  transition: all var(--fm-transition);
  box-shadow: 0 2px 8px rgba(196, 30, 58, 0.2);
}

.btn-fm-primary:hover {
  background: var(--fm-red-hover);
  color: #FFFFFF;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(196, 30, 58, 0.3);
}

.btn-fm-secondary {
  background: transparent;
  color: var(--fm-navy);
  border: 1.5px solid var(--fm-border);
  font-family: 'Montserrat', sans-serif;
  font-weight: 600;
  font-size: 0.82rem;
  padding: 0.5rem 1.2rem;
  border-radius: var(--fm-radius-sm);
  transition: all var(--fm-transition);
}

.btn-fm-secondary:hover {
  border-color: var(--fm-navy);
  background: rgba(0, 31, 63, 0.04);
  color: var(--fm-navy);
}

.btn-fm-navy {
  background: var(--fm-navy);
  color: #FFFFFF;
  border: none;
  font-family: 'Montserrat', sans-serif;
  font-weight: 600;
  font-size: 0.82rem;
  padding: 0.55rem 1.35rem;
  border-radius: var(--fm-radius-sm);
  transition: all var(--fm-transition);
}

.btn-fm-navy:hover {
  background: var(--fm-navy-light);
  color: #FFFFFF;
}

/* --- Badges --- */
.badge-fm {
  font-family: 'Montserrat', sans-serif;
  font-weight: 600;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  padding: 0.3rem 0.65rem;
  border-radius: 50px;
  text-transform: uppercase;
}

.badge-gov { background: rgba(13, 150, 104, 0.12); color: var(--fm-success); }
.badge-dnc { background: rgba(220, 38, 38, 0.12); color: var(--fm-danger); }
.badge-cyan { background: var(--fm-cyan-soft); color: #0E7C8F; }
.badge-navy { background: rgba(0, 31, 63, 0.08); color: var(--fm-navy); }
.badge-warning { background: rgba(217, 119, 6, 0.12); color: var(--fm-warning); }

/* --- Forms --- */
.fm-form .form-label {
  font-family: 'Montserrat', sans-serif;
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fm-mid-gray);
  margin-bottom: 0.35rem;
}

.fm-form .form-control {
  border: 1.5px solid var(--fm-border);
  border-radius: var(--fm-radius-sm);
  padding: 0.55rem 0.85rem;
  font-size: 0.88rem;
  color: var(--fm-charcoal);
  transition: all var(--fm-transition);
  background: var(--fm-white);
}

.fm-form .form-control:focus {
  border-color: var(--fm-cyan);
  box-shadow: 0 0 0 3px var(--fm-cyan-soft);
  outline: none;
}

.fm-form .form-control::placeholder { color: var(--fm-mid-gray); opacity: 0.6; }

.fm-form .input-group-text {
  background: var(--fm-light-gray);
  border: 1.5px solid var(--fm-border);
  border-right: none;
  color: var(--fm-mid-gray);
  border-radius: var(--fm-radius-sm) 0 0 var(--fm-radius-sm);
}

.fm-form .input-group .form-control {
  border-left: none;
  border-radius: 0 var(--fm-radius-sm) var(--fm-radius-sm) 0;
}

.fm-form .form-check-input:checked {
  background-color: var(--fm-red);
  border-color: var(--fm-red);
}

/* --- Search Form Card --- */
.search-form-card {
  background: var(--fm-white);
  border-radius: var(--fm-radius);
  padding: 1.5rem;
  box-shadow: var(--fm-shadow);
  margin-bottom: 1.5rem;
}

/* --- Pagination --- */
.fm-pagination .page-link {
  color: var(--fm-navy);
  border: 1px solid var(--fm-border);
  font-family: 'Montserrat', sans-serif;
  font-weight: 600;
  font-size: 0.78rem;
  padding: 0.4rem 0.75rem;
  border-radius: var(--fm-radius-sm);
  margin: 0 0.15rem;
  transition: all var(--fm-transition);
}

.fm-pagination .page-link:hover {
  background: rgba(0, 31, 63, 0.06);
  border-color: var(--fm-navy);
  color: var(--fm-navy);
}

.fm-pagination .page-item.active .page-link {
  background: var(--fm-red);
  border-color: var(--fm-red);
  color: #FFFFFF;
  box-shadow: 0 2px 6px rgba(196, 30, 58, 0.25);
}

/* --- Detail Page --- */
.detail-banner {
  background: linear-gradient(135deg, var(--fm-navy) 0%, #0A2A4A 100%);
  color: #FFFFFF;
  padding: 1.75rem 2rem;
  border-radius: var(--fm-radius);
  margin-bottom: 1.5rem;
  position: relative;
  overflow: hidden;
}

.detail-banner::before {
  content: '';
  position: absolute;
  top: -30%;
  right: -5%;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(196,30,58,0.08) 0%, transparent 70%);
  pointer-events: none;
}

.detail-banner h3 {
  color: #FFFFFF;
  font-size: 1.4rem;
  margin-bottom: 0.25rem;
}

.detail-banner .dba-name {
  color: rgba(255,255,255,0.5);
  font-size: 0.85rem;
}

.detail-banner .badge-fm { font-size: 0.65rem; }

/* Identifier rows with icons */
.identifier-row {
  display: flex;
  align-items: center;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--fm-light-gray);
}

.identifier-row:last-child { border-bottom: none; }

.identifier-row .id-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: var(--fm-light-gray);
  color: var(--fm-mid-gray);
  font-size: 0.8rem;
  flex-shrink: 0;
  margin-right: 0.75rem;
}

.identifier-row .id-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--fm-mid-gray);
  min-width: 100px;
}

.identifier-row .id-value {
  font-size: 0.88rem;
  color: var(--fm-charcoal);
  font-weight: 500;
}

/* Contact avatar */
.contact-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--fm-navy);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  font-size: 0.75rem;
  flex-shrink: 0;
}

/* DNC status indicators */
.dnc-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.78rem;
  font-weight: 600;
}

.dnc-indicator.dnc-clean { color: var(--fm-success); }
.dnc-indicator.dnc-flagged { color: var(--fm-danger); }

/* --- Phone Lookup --- */
.lookup-card {
  max-width: 560px;
  margin: 0 auto 2rem;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-radius: var(--fm-radius);
  margin-bottom: 1.25rem;
}

.status-indicator.status-clean {
  background: rgba(13, 150, 104, 0.08);
  border: 1.5px solid rgba(13, 150, 104, 0.2);
}

.status-indicator.status-dnc {
  background: rgba(220, 38, 38, 0.06);
  border: 1.5px solid rgba(220, 38, 38, 0.18);
}

.status-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.status-clean .status-circle {
  background: rgba(13, 150, 104, 0.15);
  color: var(--fm-success);
}

.status-dnc .status-circle {
  background: rgba(220, 38, 38, 0.12);
  color: var(--fm-danger);
}

.status-text strong {
  display: block;
  font-family: 'Montserrat', sans-serif;
  font-size: 0.9rem;
}

.status-text span {
  font-size: 0.8rem;
  color: var(--fm-mid-gray);
}

/* --- SQL Console --- */
.sql-editor-wrapper {
  border: 1.5px solid var(--fm-border);
  border-radius: var(--fm-radius);
  overflow: hidden;
  margin-bottom: 0.75rem;
}

.sql-editor-wrapper .CodeMirror {
  height: 180px;
  font-size: 0.88rem;
}

.table-pill {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--fm-navy);
  background: var(--fm-light-gray);
  border-radius: 50px;
  border: 1px solid var(--fm-border);
  cursor: pointer;
  transition: all var(--fm-transition);
  margin: 0.15rem;
}

.table-pill:hover {
  background: var(--fm-cyan-soft);
  border-color: var(--fm-cyan);
  color: #0E7C8F;
}

/* SQL plain textarea fallback */
.sql-textarea {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.88rem;
  border: 1.5px solid var(--fm-border);
  border-radius: var(--fm-radius);
  padding: 1rem;
  background: #0B1929;
  color: #E2E8F0;
  resize: vertical;
  min-height: 140px;
}

.sql-textarea:focus {
  border-color: var(--fm-cyan);
  box-shadow: 0 0 0 3px var(--fm-cyan-soft);
  outline: none;
}

/* Row count badge */
.row-count-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: 'Montserrat', sans-serif;
  font-weight: 600;
  font-size: 0.75rem;
  padding: 0.3rem 0.75rem;
  border-radius: 50px;
  background: var(--fm-cyan-soft);
  color: #0E7C8F;
}

/* --- Alerts --- */
.fm-alert {
  border-radius: var(--fm-radius);
  padding: 0.85rem 1.15rem;
  font-size: 0.85rem;
  border: none;
  border-left: 4px solid;
}

.fm-alert-danger {
  background: rgba(220, 38, 38, 0.06);
  border-left-color: var(--fm-danger);
  color: var(--fm-danger);
}

.fm-alert-success {
  background: rgba(13, 150, 104, 0.06);
  border-left-color: var(--fm-success);
  color: var(--fm-success);
}

.fm-alert-warning {
  background: rgba(217, 119, 6, 0.06);
  border-left-color: var(--fm-warning);
  color: var(--fm-warning);
}

/* --- Chart Containers --- */
.chart-container {
  position: relative;
  padding: 0.75rem;
}

/* --- Source Records Accordion --- */
.source-accordion summary {
  cursor: pointer;
  font-family: 'Montserrat', sans-serif;
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--fm-cyan);
  padding: 0.25rem 0;
}

.source-accordion pre {
  background: #0B1929;
  color: #E2E8F0;
  padding: 0.85rem;
  border-radius: var(--fm-radius-sm);
  max-height: 280px;
  overflow: auto;
  font-size: 0.78rem;
  margin-top: 0.5rem;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

/* --- Animations --- */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-in {
  animation: fadeInUp 0.4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  opacity: 0;
}

.delay-1 { animation-delay: 0.05s; }
.delay-2 { animation-delay: 0.1s; }
.delay-3 { animation-delay: 0.15s; }
.delay-4 { animation-delay: 0.2s; }
.delay-5 { animation-delay: 0.25s; }
.delay-6 { animation-delay: 0.3s; }

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--fm-mid-gray);
}

.empty-state i {
  font-size: 2.5rem;
  opacity: 0.3;
  margin-bottom: 0.75rem;
  display: block;
}

.empty-state p {
  font-size: 0.88rem;
  margin: 0;
}

/* --- Responsive --- */
@media (max-width: 992px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-backdrop.show {
    display: block;
  }

  .topbar {
    display: flex;
  }

  .main-wrapper {
    margin-left: 0;
  }

  .main-content {
    padding: 1.25rem 1rem;
  }
}

@media (max-width: 768px) {
  .stat-card .stat-number { font-size: 1.4rem; }
  .page-header h3 { font-size: 1.25rem; }
  .detail-banner { padding: 1.25rem; }
  .search-form-card { padding: 1rem; }
}

/* ============================================================
   COMMAND CENTER — Dark Theme, Animations, Pipeline, Upload
   ============================================================ */

/* --- Command Center Dark Sections --- */
.command-section {
  background: var(--fm-dark-bg, #0B1929);
  border-radius: var(--fm-radius);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

.command-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.75rem;
}

.command-header h3 {
  color: #FFFFFF;
  margin: 0;
  font-size: 1.3rem;
}

.command-header h3::after { display: none; }

.auto-refresh-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  user-select: none;
}

.auto-refresh-toggle .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--fm-mid-gray);
  transition: background 0.3s;
}

.auto-refresh-toggle.active .dot {
  background: var(--fm-success);
  box-shadow: 0 0 8px rgba(13, 150, 104, 0.6);
}

.auto-refresh-toggle.active { color: rgba(255,255,255,0.8); }

/* --- KPI Cards (Command Center) --- */
.kpi-card {
  background: var(--fm-dark-card, #112240);
  border-radius: var(--fm-radius);
  padding: 1.25rem 1rem;
  border-left: 4px solid var(--fm-cyan);
  text-align: center;
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.kpi-card.accent-green  { border-left-color: var(--fm-success); }
.kpi-card.accent-gold   { border-left-color: #F59E0B; }
.kpi-card.accent-cyan   { border-left-color: var(--fm-cyan); }
.kpi-card.accent-red    { border-left-color: var(--fm-red); }
.kpi-card.accent-purple { border-left-color: #8B5CF6; }

.kpi-card .kpi-value {
  font-family: 'Montserrat', sans-serif;
  font-weight: 800;
  font-size: 2rem;
  color: #FFFFFF;
  line-height: 1.1;
  margin-bottom: 0.25rem;
  letter-spacing: -0.02em;
  transition: all 0.4s ease;
}

.kpi-card .kpi-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.45);
}

.kpi-card .kpi-icon {
  font-size: 1.1rem;
  color: rgba(255,255,255,0.2);
  margin-bottom: 0.4rem;
}

.kpi-card.updated { animation: pulse-glow 0.6s ease; }

/* --- Tier Pipeline Flow --- */
.tier-pipeline {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 1.5rem 0;
  flex-wrap: nowrap;
  overflow-x: auto;
}

.tier-node {
  background: var(--fm-dark-card, #112240);
  border: 2px solid rgba(255,255,255,0.1);
  border-radius: var(--fm-radius);
  padding: 1rem 1.25rem;
  text-align: center;
  min-width: 120px;
  position: relative;
  transition: all 0.3s ease;
}

.tier-node:hover {
  border-color: rgba(255,255,255,0.25);
  transform: scale(1.03);
}

.tier-node .node-count {
  font-family: 'Montserrat', sans-serif;
  font-weight: 800;
  font-size: 1.5rem;
  color: #FFFFFF;
  line-height: 1.1;
}

.tier-node .node-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.45);
  margin-top: 0.3rem;
}

.tier-node.node-raw    { border-color: rgba(148, 163, 184, 0.3); }
.tier-node.node-clean  { border-color: rgba(23, 162, 184, 0.4); }
.tier-node.node-ready  { border-color: rgba(13, 150, 104, 0.5); }
.tier-node.node-dead   { border-color: rgba(220, 38, 38, 0.3); }

.tier-node.node-ready .node-count { color: var(--fm-success); }
.tier-node.node-dead   .node-count { color: var(--fm-danger); }

.tier-node .sub-counts {
  margin-top: 0.5rem;
  font-size: 0.7rem;
  color: rgba(255,255,255,0.5);
  line-height: 1.6;
}

.tier-node .sub-counts strong { color: rgba(255,255,255,0.8); }

/* Flow arrows between tier nodes */
.flow-arrow {
  display: flex;
  align-items: center;
  padding: 0 0.25rem;
  flex-shrink: 0;
}

.flow-arrow svg {
  width: 48px;
  height: 24px;
}

.flow-arrow .arrow-path {
  stroke: rgba(23, 162, 184, 0.4);
  stroke-width: 2;
  fill: none;
  stroke-dasharray: 8 4;
  animation: flowDash 1s linear infinite;
}

.flow-arrow .arrow-head {
  fill: rgba(23, 162, 184, 0.5);
}

/* --- Verification Progress Bars --- */
.verification-bar {
  margin-bottom: 0.75rem;
}

.verification-bar .vbar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.verification-bar .vbar-label .vbar-name { color: var(--fm-charcoal); }
.verification-bar .vbar-label .vbar-count { color: var(--fm-mid-gray); font-family: 'JetBrains Mono', monospace; font-size: 0.72rem; }

.verification-bar .vbar-track {
  height: 8px;
  background: var(--fm-light-gray);
  border-radius: 4px;
  overflow: hidden;
}

.verification-bar .vbar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.8s ease;
  min-width: 2px;
}

.vbar-fill.fill-green  { background: var(--fm-success); }
.vbar-fill.fill-yellow { background: var(--fm-warning); }
.vbar-fill.fill-blue   { background: var(--fm-cyan); }
.vbar-fill.fill-orange { background: #F59E0B; }
.vbar-fill.fill-red    { background: var(--fm-danger); }
.vbar-fill.fill-gray   { background: var(--fm-mid-gray); }

/* Dark mode verification bars (inside command sections) */
.command-section .verification-bar .vbar-label .vbar-name { color: rgba(255,255,255,0.7); }
.command-section .verification-bar .vbar-label .vbar-count { color: rgba(255,255,255,0.4); }
.command-section .verification-bar .vbar-track { background: rgba(255,255,255,0.08); }

/* --- Live Activity Feed --- */
.activity-feed {
  max-height: 400px;
  overflow-y: auto;
  border-radius: var(--fm-radius-sm);
}

.activity-entry {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--fm-light-gray);
  font-size: 0.82rem;
  transition: background 0.2s;
}

.activity-entry:last-child { border-bottom: none; }
.activity-entry:hover { background: var(--fm-cyan-soft); }

.activity-entry.new {
  animation: slideInDown 0.3s ease;
  background: rgba(23, 162, 184, 0.06);
}

.activity-entry .activity-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: var(--fm-mid-gray);
  flex-shrink: 0;
  min-width: 45px;
}

.activity-entry .activity-star {
  color: #F59E0B;
  font-size: 0.9rem;
  flex-shrink: 0;
  width: 16px;
}

.activity-entry .activity-name {
  font-weight: 600;
  color: var(--fm-navy);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-entry .activity-result {
  font-size: 0.72rem;
  color: var(--fm-mid-gray);
  flex-shrink: 0;
}

.activity-entry .activity-result.result-success { color: var(--fm-success); }
.activity-entry .activity-result.result-fail { color: var(--fm-danger); }
.activity-entry .activity-result.result-blocked { color: var(--fm-warning); }

/* Dark mode feed */
.command-section .activity-entry { border-bottom-color: rgba(255,255,255,0.06); }
.command-section .activity-entry:hover { background: rgba(23,162,184,0.08); }
.command-section .activity-entry .activity-name { color: #FFFFFF; }
.command-section .activity-entry .activity-time { color: rgba(255,255,255,0.35); }
.command-section .activity-entry .activity-result { color: rgba(255,255,255,0.45); }

/* --- Channel Readiness Cards --- */
.channel-card {
  background: var(--fm-white);
  border: 2px solid var(--fm-border);
  border-radius: var(--fm-radius);
  padding: 1rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.channel-card:hover {
  border-color: var(--fm-cyan);
  transform: translateY(-2px);
  box-shadow: var(--fm-shadow-hover);
}

.channel-card.active {
  border-color: var(--fm-red);
  background: rgba(196, 30, 58, 0.04);
  box-shadow: 0 0 0 3px rgba(196, 30, 58, 0.1);
}

.channel-card .channel-icon {
  font-size: 1.5rem;
  margin-bottom: 0.4rem;
}

.channel-card .channel-name {
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  font-size: 0.78rem;
  color: var(--fm-navy);
  margin-bottom: 0.3rem;
}

.channel-card .channel-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--fm-cyan);
}

.channel-card .channel-desc {
  font-size: 0.65rem;
  color: var(--fm-mid-gray);
  margin-top: 0.2rem;
}

/* Dark mode channel cards */
.command-section .channel-card {
  background: var(--fm-dark-card, #112240);
  border-color: rgba(255,255,255,0.1);
}
.command-section .channel-card:hover { border-color: var(--fm-cyan); }
.command-section .channel-card .channel-name { color: #FFFFFF; }
.command-section .channel-card .channel-count { color: var(--fm-cyan); }
.command-section .channel-card .channel-desc { color: rgba(255,255,255,0.35); }

/* --- Gap Analysis Cards --- */
.gap-card {
  background: var(--fm-white);
  border-radius: var(--fm-radius);
  padding: 1.15rem;
  box-shadow: var(--fm-shadow);
  text-align: center;
  border-top: 3px solid var(--fm-warning);
  height: 100%;
}

.gap-card .gap-count {
  font-family: 'Montserrat', sans-serif;
  font-weight: 800;
  font-size: 1.5rem;
  color: var(--fm-navy);
  line-height: 1.1;
}

.gap-card .gap-title {
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  font-size: 0.78rem;
  color: var(--fm-navy);
  margin-bottom: 0.3rem;
}

.gap-card .gap-desc {
  font-size: 0.72rem;
  color: var(--fm-mid-gray);
  margin-bottom: 0.6rem;
}

/* --- Pipeline Tab Navigation --- */
.pipeline-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.pipeline-tab {
  font-family: 'Montserrat', sans-serif;
  font-weight: 600;
  font-size: 0.78rem;
  padding: 0.5rem 1.15rem;
  border-radius: 50px;
  border: 1.5px solid var(--fm-border);
  background: var(--fm-white);
  color: var(--fm-charcoal);
  cursor: pointer;
  transition: all var(--fm-transition);
  text-decoration: none;
}

.pipeline-tab:hover {
  border-color: var(--fm-navy);
  color: var(--fm-navy);
  background: rgba(0,31,63,0.04);
}

.pipeline-tab.active {
  background: var(--fm-navy);
  border-color: var(--fm-navy);
  color: #FFFFFF;
}

/* --- Upload Zone --- */
.upload-zone {
  border: 2px dashed var(--fm-border);
  border-radius: var(--fm-radius);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--fm-white);
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--fm-cyan);
  background: var(--fm-cyan-soft);
}

.upload-zone .upload-icon {
  font-size: 3rem;
  color: var(--fm-mid-gray);
  opacity: 0.5;
  margin-bottom: 0.75rem;
}

.upload-zone p {
  color: var(--fm-mid-gray);
  font-size: 0.88rem;
  margin: 0.25rem 0;
}

.upload-zone .upload-hint {
  font-size: 0.75rem;
  color: var(--fm-mid-gray);
  opacity: 0.6;
}

/* Column mapping table */
.mapping-select {
  font-size: 0.82rem;
  padding: 0.3rem 0.5rem;
  border: 1.5px solid var(--fm-border);
  border-radius: var(--fm-radius-sm);
  background: var(--fm-white);
}

.mapping-ok { color: var(--fm-success); }
.mapping-warn { color: var(--fm-warning); }
.mapping-skip { color: var(--fm-mid-gray); opacity: 0.5; }

/* Import results */
.import-results {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.import-stat {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  font-size: 0.88rem;
}

.import-stat i { font-size: 1.1rem; }
.import-stat.stat-created { color: var(--fm-success); }
.import-stat.stat-merged  { color: var(--fm-cyan); }
.import-stat.stat-queued  { color: var(--fm-warning); }
.import-stat.stat-errors  { color: var(--fm-danger); }

/* --- System Health Cards (dark) --- */
.health-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  font-size: 0.82rem;
}

.health-item:last-child { border-bottom: none; }
.health-item .health-label { color: rgba(255,255,255,0.5); }
.health-item .health-value { color: #FFFFFF; font-weight: 600; font-family: 'JetBrains Mono', monospace; font-size: 0.78rem; }
.health-item .health-value.status-ok { color: var(--fm-success); }
.health-item .health-value.status-warn { color: var(--fm-warning); }
.health-item .health-value.status-bad { color: var(--fm-danger); }

/* --- Worker Status Cards --- */
.worker-card {
  background: var(--fm-white);
  border-radius: var(--fm-radius);
  box-shadow: var(--fm-shadow);
  padding: 1.15rem;
  border-top: 3px solid var(--fm-navy);
  height: 100%;
}

.worker-card .worker-name {
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--fm-navy);
  margin-bottom: 0.6rem;
}

.worker-card .worker-status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 0.6rem;
}

.worker-status .status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--fm-mid-gray);
}

.worker-status.running .status-dot {
  background: var(--fm-success);
  box-shadow: 0 0 6px rgba(13, 150, 104, 0.5);
  animation: pulse-dot 1.5s ease infinite;
}

.worker-status.idle .status-dot { background: var(--fm-mid-gray); }
.worker-status.running { color: var(--fm-success); }
.worker-status.idle { color: var(--fm-mid-gray); }

.worker-card .worker-stat {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  padding: 0.25rem 0;
  color: var(--fm-charcoal);
}

.worker-card .worker-stat strong {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
}

/* --- Scrape-Campaign Step Indicators --- */
.step-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--fm-navy);
}

.step-indicator .step-num {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--fm-navy);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  flex-shrink: 0;
}

/* --- Verification Badges (search results) --- */
.v-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.45rem;
  border-radius: 50px;
}

.v-badge-tps   { background: rgba(13,150,104,0.12); color: var(--fm-success); }
.v-badge-nanpa { background: rgba(217,119,6,0.12); color: var(--fm-warning); }
.v-badge-smtp  { background: rgba(23,162,184,0.12); color: #0E7C8F; }
.v-badge-pending { background: rgba(245,158,11,0.12); color: #B45309; }
.v-badge-bounced { background: rgba(220,38,38,0.12); color: var(--fm-danger); }

/* Channel readiness dots in search results */
.channel-dots {
  display: inline-flex;
  gap: 3px;
}

.channel-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--fm-light-gray);
  position: relative;
}

.channel-dot.ready { background: var(--fm-success); }
.channel-dot::before {
  content: attr(data-tip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.6rem;
  white-space: nowrap;
  background: var(--fm-navy);
  color: #fff;
  padding: 2px 6px;
  border-radius: 3px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.channel-dot:hover::before { opacity: 1; }

/* --- Keyframe Animations --- */
@keyframes pulse-glow {
  0% { transform: scale(1); box-shadow: none; }
  50% { transform: scale(1.02); box-shadow: 0 0 20px rgba(23, 162, 184, 0.3); }
  100% { transform: scale(1); box-shadow: none; }
}

@keyframes slideInDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes flowDash {
  to { stroke-dashoffset: -12; }
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

@keyframes progress-fill {
  from { width: 0; }
}

/* --- Responsive for Command Center --- */
@media (max-width: 992px) {
  .tier-pipeline { flex-wrap: wrap; gap: 0.5rem; }
  .flow-arrow { display: none; }
  .tier-node { min-width: 100px; }
  .activity-feed { max-height: 280px; }
  .pipeline-tabs { gap: 0.35rem; }
  .pipeline-tab { font-size: 0.72rem; padding: 0.4rem 0.85rem; }
}

@media (max-width: 768px) {
  .kpi-card .kpi-value { font-size: 1.5rem; }
  .command-section { padding: 1rem; }
  .upload-zone { padding: 2rem 1rem; }
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--fm-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--fm-mid-gray); }
.sidebar ::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); }

/* --- Advanced Filters Panel --- */
.advanced-filters {
    background: var(--fm-off-white);
    border: 1px solid var(--fm-border);
    border-radius: var(--fm-radius-sm);
    padding: 1rem 1.25rem;
    margin-top: 0.5rem;
}
.advanced-filters .form-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--fm-mid-gray);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.2rem;
}
.advanced-filters .form-check-label {
    font-size: 0.8rem;
}
.advanced-filters .form-control,
.advanced-filters .form-select {
    font-size: 0.8rem;
    padding: 0.3rem 0.5rem;
}
.advanced-filters .form-check {
    margin-bottom: 0.15rem;
}
.filter-group-title {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--fm-cyan);
    margin-bottom: 0.75rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--fm-border);
}
.help-text {
    font-size: 0.65rem;
    color: var(--fm-mid-gray);
    margin-top: -0.1rem;
    margin-bottom: 0.2rem;
}
.badge-verified {
    font-size: 0.55rem;
    padding: 0.15rem 0.35rem;
    margin-right: 0.15rem;
}
