/**
 * AppShell Styles: Sidebar, TopBar, ScopeSwitcher, and Modern Layout
 */

html, body {
  margin: 0 !important;
  padding: 0 !important;
  width: 100% !important;
  height: 100% !important;
  overflow: hidden !important;
  box-sizing: border-box;
}

#cc-app-shell {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.shell-layout {
  display: flex;
  width: 100vw;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  background: var(--surface-bg);
  color: var(--text-main);
  font-family: var(--font-sans);
}

/* Sidebar */
.shell-sidebar {
  width: var(--sidebar-width);
  background: var(--surface-panel);
  border-right: 1px solid var(--surface-border);
  display: flex;
  flex-direction: column;
  transition: width 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
  user-select: none;
}

.sidebar-brand {
  height: var(--topbar-height);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--surface-border);
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  color: var(--accent-primary);
  display: flex;
  align-items: center;
}

.brand-text {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--text-main);
}

.sidebar-toggle {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
}

.sidebar-toggle:hover {
  background: var(--surface-panel-hover);
  color: var(--text-main);
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-group-header {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-subtle);
  padding: 10px 10px 4px;
  text-transform: uppercase;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s ease;
}

.nav-link:hover {
  background: var(--surface-panel-hover);
  color: var(--text-main);
}

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

.nav-icon {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  background: var(--surface-border);
  color: var(--text-muted);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 600;
}

/* Sidebar Collapsed State */
.shell-layout.sidebar-collapsed .shell-sidebar {
  width: var(--sidebar-collapsed-width);
}

.shell-layout.sidebar-collapsed .brand-text,
.shell-layout.sidebar-collapsed .nav-label,
.shell-layout.sidebar-collapsed .nav-group-header,
.shell-layout.sidebar-collapsed .nav-badge {
  display: none;
}

.shell-layout.sidebar-collapsed .nav-link {
  justify-content: center;
  padding: 10px 0;
}

/* WO-09: Auto-collapse sidebar below 900px (icon rail) */
@media (max-width: 900px) {
  .shell-sidebar {
    width: var(--sidebar-collapsed-width, 64px) !important;
  }
  .shell-sidebar .brand-text,
  .shell-sidebar .nav-label,
  .shell-sidebar .nav-group-header,
  .shell-sidebar .nav-badge {
    display: none !important;
  }
  .shell-sidebar .nav-link {
    justify-content: center !important;
    padding: 10px 0 !important;
  }
  .sidebar-toggle {
    display: none !important;
  }
}

/* Mobile menu button (< 640px) */
.mobile-menu-btn {
  display: none;
  background: transparent;
  border: 1px solid var(--surface-border);
  color: var(--text-main);
  padding: 6px;
  border-radius: var(--radius-md);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

@media (max-width: 640px) {
  .mobile-menu-btn {
    display: flex !important;
  }
  .shell-sidebar {
    position: fixed !important;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1000;
    width: 240px !important;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
  }
  .shell-sidebar.mobile-open {
    transform: translateX(0) !important;
  }
  .shell-sidebar.mobile-open .brand-text,
  .shell-sidebar.mobile-open .nav-label,
  .shell-sidebar.mobile-open .nav-group-header,
  .shell-sidebar.mobile-open .nav-badge {
    display: inline !important;
  }
  .shell-sidebar.mobile-open .nav-link {
    justify-content: flex-start !important;
    padding: 8px 12px !important;
  }
  .mobile-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 999;
  }
  .mobile-backdrop.open {
    display: block !important;
  }
}

/* Stage & Top Bar */
.shell-stage,
.shell-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  width: 100%;
  height: 100vh;
  overflow: hidden;
  box-sizing: border-box;
}

.shell-topbar {
  height: var(--topbar-height);
  width: 100%;
  box-sizing: border-box;
  background: var(--surface-panel);
  border-bottom: 1px solid var(--surface-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
  z-index: 100;
  overflow: visible;
  white-space: nowrap;
  gap: 10px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  min-width: 0;
}

.scope-dropdown-container {
  position: relative;
}

.scope-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  box-sizing: border-box;
  white-space: nowrap;
  flex-shrink: 0;
  background: var(--surface-panel-hover);
  border: 1px solid var(--surface-border);
  padding: 0 14px;
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.scope-btn:hover {
  border-color: var(--text-subtle);
}

.scope-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  width: 320px;
  max-height: 520px;
  display: flex;
  flex-direction: column;
  background: var(--surface-card);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
  padding: 8px;
  z-index: 200;
  backdrop-filter: blur(8px);
}

.scope-menu[hidden] {
  display: none !important;
}

#scopeCountyItems {
  max-height: 280px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-border) transparent;
}

#scopeCountyItems::-webkit-scrollbar {
  width: 5px;
}

#scopeCountyItems::-webkit-scrollbar-thumb {
  background: var(--surface-border);
  border-radius: 4px;
}

.scope-search-box {
  margin: 4px 0 6px;
}

.scope-search-input {
  width: 100%;
  box-sizing: border-box;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-sm, 6px);
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.15s;
}

.scope-search-input:focus {
  border-color: var(--accent);
}

.scope-tabs-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 6px;
}

.scope-tab-btn {
  flex: 1;
  padding: 4px 6px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}

.scope-tab-btn.active {
  background: var(--surface-panel, rgba(255, 255, 255, 0.08));
  color: var(--text-main);
  border-color: var(--surface-border);
}

.scope-menu-header {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-subtle);
  padding: 4px 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.scope-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-main);
}

.scope-item:hover {
  background: var(--surface-panel-hover);
}

.scope-row-item {
  color: var(--text-main);
}

.scope-row-item:hover {
  background: var(--surface-panel-hover, rgba(255, 255, 255, 0.08)) !important;
}

.scope-row-item.active {
  background: rgba(14, 165, 233, 0.15) !important;
  color: var(--accent, #0ea5e9) !important;
}

.scope-row-item.active .scope-name {
  color: var(--accent, #0ea5e9) !important;
  font-weight: 700 !important;
}

.scope-multi-toggle:hover {
  background: var(--accent, #0ea5e9) !important;
  color: #fff !important;
  border-color: var(--accent, #0ea5e9) !important;
}

.scope-badge {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}

.scope-divider {
  height: 1px;
  background: var(--surface-border);
  margin: 6px 0;
}

/* Search Trigger */
.topbar-center {
  flex: 1 1 360px;
  min-width: 140px;
  max-width: 420px;
  margin: 0 auto;
  transition: max-width 0.2s ease;
}

.search-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  box-sizing: border-box;
  background: var(--surface-bg);
  border: 1px solid var(--surface-border);
  padding: 0 12px;
  border-radius: var(--radius-md);
  color: var(--text-subtle);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s ease;
  width: 100%;
}

.search-trigger:hover {
  border-color: var(--text-muted);
}

.search-placeholder {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-kbd {
  flex-shrink: 0;
  background: var(--surface-panel);
  border: 1px solid var(--surface-border);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Topbar Right */
.topbar-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
  min-width: 0;
}

.topbar-pill {
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.agent-pill {
  background: var(--status-success-bg);
  color: var(--status-success);
  border: 1px solid var(--status-success-border);
}

.agent-pill.running {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.35);
}

/* Responsive Topbar Compacting */
.shell-layout:not(.sidebar-collapsed) .topbar-center {
  max-width: 320px;
}

@media (max-width: 1300px) {
  .search-kbd {
    display: none;
  }
  .topbar-center {
    max-width: 260px;
  }
}

@media (max-width: 1120px) {
  .credits-pill {
    display: none;
  }
  .topbar-center {
    max-width: 200px;
  }
}

.pill-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.credits-pill {
  background: var(--surface-panel-hover);
  color: var(--text-muted);
  border: 1px solid var(--surface-border);
}

.topbar-icon-btn {
  background: transparent;
  border: 1px solid var(--surface-border);
  color: var(--text-muted);
  padding: 6px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
}

.topbar-icon-btn:hover {
  background: var(--surface-panel-hover);
  color: var(--text-main);
}

.user-menu-container {
  position: relative;
}

.user-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1px solid var(--surface-border);
  padding: 4px 10px;
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 13px;
  cursor: pointer;
}

.user-avatar {
  width: 20px;
  height: 20px;
  background: var(--accent-primary);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}

.user-role-label {
  font-weight: 500;
}

.user-menu-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  width: 220px;
  background: var(--surface-card);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  padding: 6px;
  z-index: 200;
}

.menu-section-header {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-subtle);
  padding: 6px 8px;
  letter-spacing: 0.05em;
}

.menu-item {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}

.menu-item:hover {
  background: var(--surface-panel-hover);
}

.menu-item.active {
  color: var(--accent-primary);
  font-weight: 600;
}

.classic-view-link {
  color: var(--text-muted);
  font-size: 12px;
}

/* Canvas & Screen Container */
.shell-canvas {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  height: calc(100vh - var(--topbar-height));
  max-height: calc(100vh - var(--topbar-height));
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 18px 4px;
  box-sizing: border-box;
}

#shellStageWrap,
#shellMountedContent {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  width: 100%;
}

.card {
  padding: 10px 14px !important;
}

.funnel-kpi-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-panel);
  border: 1px solid var(--surface-border);
  padding: 10px 18px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text-muted);
}

.kpi-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.kpi-num {
  font-weight: 700;
  color: var(--text-main);
}

.kpi-dot {
  color: var(--surface-border);
}

.kpi-status-badge {
  margin-left: auto;
  background: var(--accent-primary-subtle);
  color: var(--accent-primary);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}

/* Provenance Tags */
.prov-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  line-height: 1.2;
}

.prov-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.prov-tag.sourced {
  background: var(--status-success-bg);
  color: var(--status-success);
  border: 1px solid var(--status-success-border);
}

.prov-tag.estimate {
  background: var(--status-warning-bg);
  color: var(--status-warning);
  border: 1px solid var(--status-warning-border);
}

.prov-tag.open {
  background: var(--status-critical-bg);
  color: var(--status-critical);
  border: 1px solid var(--status-critical-border);
}

/* Cmd K Dialog */
.cmdk-dialog {
  border: none;
  background: transparent;
  padding: 0;
  max-width: 540px;
  width: 100%;
}

.cmdk-dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
}

.cmdk-card {
  background: var(--surface-card);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}

.cmdk-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--surface-border);
}

.cmdk-header input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 15px;
  outline: none;
}

.cmdk-esc {
  font-size: 11px;
  color: var(--text-subtle);
  background: var(--surface-panel);
  border: 1px solid var(--surface-border);
  padding: 2px 6px;
  border-radius: 4px;
}

.cmdk-list {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cmdk-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 13px;
  cursor: pointer;
}

.cmdk-item:hover {
  background: var(--surface-panel-hover);
  color: var(--accent-primary);
}

/* Coming Soon Empty State */
.coming-soon-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 480px;
}

.coming-soon-card {
  max-width: 440px;
  text-align: center;
  background: var(--surface-panel);
  border: 1px solid var(--surface-border);
  padding: 40px 32px;
  border-radius: var(--radius-lg);
}

.coming-soon-icon {
  color: var(--accent-primary);
  margin-bottom: 16px;
  display: inline-flex;
}

.coming-soon-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}

.coming-soon-text {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 24px;
}

.coming-soon-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

/* Back button in topbar */
.btn-shell-back:hover {
  background: var(--surface-panel-hover, rgba(255,255,255,0.1)) !important;
  border-color: var(--accent-primary, #38bdf8) !important;
  color: #fff !important;
}

/* Single-Line Symmetric KPI Strip */
.funnel-kpi-strip {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  background: var(--surface-panel);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  padding: 8px 16px;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow-x: auto;
  flex-wrap: nowrap;
  box-sizing: border-box;
  width: 100%;
}

.funnel-kpi-strip .kpi-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.funnel-kpi-strip .kpi-num {
  font-weight: 700;
  color: var(--text-main);
  font-size: 13px;
}

.funnel-kpi-strip .kpi-dot {
  color: var(--text-subtle);
  user-select: none;
}

.funnel-kpi-strip .kpi-status-badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* 5 Gate Qualification Pipeline Strip */
/* Gate Pipeline Cards (Delinquent Due Diligence) */
.gates.num,
.gate-pipeline-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
  width: 100%;
}

@media (max-width: 1024px) {
  .gates.num,
  .gate-pipeline-strip {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }
}

.gate,
.gate-card-base {
  background: var(--surface-card, rgba(255, 255, 255, 0.02));
  border: 1px solid var(--surface-border, var(--line));
  border-radius: var(--radius-lg, 10px);
  padding: 12px 14px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  gap: 4px;
  min-width: 0;
  box-sizing: border-box;
  position: relative;
  overflow: hidden;
}

.gate:hover,
.gate-card-base:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}

/* Big counter styling */
.gate .g-v,
.gate-card-base .g-v {
  font-size: 28px !important;
  font-weight: 800 !important;
  line-height: 1.1 !important;
  margin: 4px 0 2px !important;
  letter-spacing: -0.03em !important;
  font-feature-settings: "tnum" on, "lnum" on !important;
  display: block;
}

/* Category header / badge */
.gate .g-k,
.gate-card-base .g-k {
  font-size: 11px !important;
  font-weight: 700 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.06em !important;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* Sub-description notes */
.gate .g-n,
.gate-card-base .g-n {
  font-size: 11px !important;
  color: var(--muted, #94a3b8) !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  max-width: 100% !important;
  line-height: 1.25 !important;
}

/* Active Filtering Indicator Blip (corner indicator that does not collide with text) */
.gate .g-on,
.gate-card-base .g-on {
  position: absolute;
  top: 9px;
  right: 9px;
  width: 8px;
  height: 8px;
  padding: 0 !important;
  border-radius: 50% !important;
  font-size: 0 !important; /* Hide text completely so it never wraps or crowds card titles */
  line-height: 0 !important;
  box-shadow: 0 0 8px currentColor;
  animation: gateBlipPulse 2s infinite ease-in-out;
  display: inline-block;
}

@keyframes gateBlipPulse {
  0%, 100% {
    transform: scale(1);
    opacity: 0.9;
  }
  50% {
    transform: scale(1.35);
    opacity: 1;
    filter: drop-shadow(0 0 4px currentColor);
  }
}

/* All Pipeline / In-Scope Leads (Sky / Slate Blue) */
.gate-all,
.gate-card-all {
  border-top: 3px solid #0284c7 !important;
  border-left: 1px solid rgba(2, 132, 199, 0.25) !important;
  background: linear-gradient(180deg, rgba(2, 132, 199, 0.07) 0%, rgba(2, 132, 199, 0.02) 100%) !important;
}
.gate-all .g-k,
.gate-card-all .g-k {
  color: #38bdf8 !important;
}
.gate-all .g-v,
.gate-card-all .g-v {
  color: #7dd3fc !important;
}
.gate-all .g-on,
.gate-card-all .g-on {
  background: #0284c7 !important;
  box-shadow: 0 0 8px #0284c7 !important;
}
.gate-all:hover,
.gate-card-all:hover {
  border-color: #0284c7 !important;
  box-shadow: 0 4px 20px rgba(2, 132, 199, 0.2) !important;
}
.gate-all.on,
.gate-all.active,
.gate-card-all.active {
  background: linear-gradient(180deg, rgba(2, 132, 199, 0.22) 0%, rgba(2, 132, 199, 0.1) 100%) !important;
  border-color: #0284c7 !important;
  box-shadow: 0 0 16px rgba(2, 132, 199, 0.4), inset 0 0 0 1px #0284c7 !important;
}

/* Gate 0: Intake & Zoning Classification (Violet / Purple) */
.gate-g0,
.gate-card-g0 {
  border-top: 3px solid #8b5cf6 !important;
  border-left: 1px solid rgba(139, 92, 246, 0.25) !important;
  background: linear-gradient(180deg, rgba(139, 92, 246, 0.07) 0%, rgba(139, 92, 246, 0.02) 100%) !important;
}
.gate-g0 .g-k,
.gate-card-g0 .g-k {
  color: #c084fc !important;
}
.gate-g0 .g-v,
.gate-card-g0 .g-v {
  color: #a78bfa !important;
}
.gate-g0 .g-on,
.gate-card-g0 .g-on {
  background: #a855f7 !important;
  box-shadow: 0 0 8px #a855f7 !important;
}
.gate-g0:hover,
.gate-card-g0:hover {
  border-color: #8b5cf6 !important;
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.2) !important;
}
.gate-g0.on,
.gate-g0.active,
.gate-card-g0.active {
  background: linear-gradient(180deg, rgba(139, 92, 246, 0.22) 0%, rgba(139, 92, 246, 0.1) 100%) !important;
  border-color: #8b5cf6 !important;
  box-shadow: 0 0 16px rgba(139, 92, 246, 0.4), inset 0 0 0 1px #8b5cf6 !important;
}

/* Gate 1: Class & Tax Distress (Rose / Coral) */
.gate-g1,
.gate-card-g1 {
  border-top: 3px solid #f43f5e !important;
  border-left: 1px solid rgba(244, 63, 94, 0.25) !important;
  background: linear-gradient(180deg, rgba(244, 63, 94, 0.07) 0%, rgba(244, 63, 94, 0.02) 100%) !important;
}
.gate-g1 .g-k,
.gate-card-g1 .g-k {
  color: #fda4af !important;
}
.gate-g1 .g-v,
.gate-card-g1 .g-v {
  color: #fb7185 !important;
}
.gate-g1 .g-on,
.gate-card-g1 .g-on {
  background: #f43f5e !important;
  box-shadow: 0 0 8px #f43f5e !important;
}
.gate-g1:hover,
.gate-card-g1:hover {
  border-color: #f43f5e !important;
  box-shadow: 0 4px 20px rgba(244, 63, 94, 0.2) !important;
}
.gate-g1.on,
.gate-g1.active,
.gate-card-g1.active {
  background: linear-gradient(180deg, rgba(244, 63, 94, 0.22) 0%, rgba(244, 63, 94, 0.1) 100%) !important;
  border-color: #f43f5e !important;
  box-shadow: 0 0 16px rgba(244, 63, 94, 0.4), inset 0 0 0 1px #f43f5e !important;
}

/* Gate 2: Physical & Legal Feasibility (Amber / Gold) */
.gate-g2,
.gate-card-g2 {
  border-top: 3px solid #f59e0b !important;
  border-left: 1px solid rgba(245, 158, 11, 0.25) !important;
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.07) 0%, rgba(245, 158, 11, 0.02) 100%) !important;
}
.gate-g2 .g-k,
.gate-card-g2 .g-k {
  color: #fde68a !important;
}
.gate-g2 .g-v,
.gate-card-g2 .g-v {
  color: #fbbf24 !important;
}
.gate-g2 .g-on,
.gate-card-g2 .g-on {
  background: #f59e0b !important;
  box-shadow: 0 0 8px #f59e0b !important;
}
.gate-g2:hover,
.gate-card-g2:hover {
  border-color: #f59e0b !important;
  box-shadow: 0 4px 20px rgba(245, 158, 11, 0.2) !important;
}
.gate-g2.on,
.gate-g2.active,
.gate-card-g2.active {
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.22) 0%, rgba(245, 158, 11, 0.1) 100%) !important;
  border-color: #f59e0b !important;
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.4), inset 0 0 0 1px #f59e0b !important;
}

/* Gate 3: Valuation & Land Portal Comps (Cyan / Teal) */
.gate-g3,
.gate-card-g3 {
  border-top: 3px solid #06b6d4 !important;
  border-left: 1px solid rgba(6, 182, 212, 0.25) !important;
  background: linear-gradient(180deg, rgba(6, 182, 212, 0.07) 0%, rgba(6, 182, 212, 0.02) 100%) !important;
}
.gate-g3 .g-k,
.gate-card-g3 .g-k {
  color: #a5f3fc !important;
}
.gate-g3 .g-v,
.gate-card-g3 .g-v {
  color: #38bdf8 !important;
}
.gate-g3 .g-on,
.gate-card-g3 .g-on {
  background: #06b6d4 !important;
  box-shadow: 0 0 8px #06b6d4 !important;
}
.gate-g3:hover,
.gate-card-g3:hover {
  border-color: #06b6d4 !important;
  box-shadow: 0 4px 20px rgba(6, 182, 212, 0.2) !important;
}
.gate-g3.on,
.gate-g3.active,
.gate-card-g3.active {
  background: linear-gradient(180deg, rgba(6, 182, 212, 0.22) 0%, rgba(6, 182, 212, 0.1) 100%) !important;
  border-color: #06b6d4 !important;
  box-shadow: 0 0 16px rgba(6, 182, 212, 0.4), inset 0 0 0 1px #06b6d4 !important;
}

/* Gate 4: Financial Underwriting & MAO (Emerald / Green) */
.gate-g4,
.gate-card-g4 {
  border-top: 3px solid #10b981 !important;
  border-left: 1px solid rgba(16, 185, 129, 0.25) !important;
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.07) 0%, rgba(16, 185, 129, 0.02) 100%) !important;
}
.gate-g4 .g-k,
.gate-card-g4 .g-k {
  color: #a7f3d0 !important;
}
.gate-g4 .g-v,
.gate-card-g4 .g-v {
  color: #34d399 !important;
}
.gate-g4 .g-on,
.gate-card-g4 .g-on {
  background: #10b981 !important;
  box-shadow: 0 0 8px #10b981 !important;
}
.gate-g4:hover,
.gate-card-g4:hover {
  border-color: #10b981 !important;
  box-shadow: 0 4px 20px rgba(16, 185, 129, 0.2) !important;
}
.gate-g4.on,
.gate-g4.active,
.gate-card-g4.active {
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.22) 0%, rgba(16, 185, 129, 0.1) 100%) !important;
  border-color: #10b981 !important;
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.4), inset 0 0 0 1px #10b981 !important;
}

/* Light Theme Overrides for High Contrast & Visual Accessibility */
[data-theme="light"] .gate-all,
[data-theme="light"] .gate-card-all { border-top-color: #0284c7 !important; background: rgba(2, 132, 199, 0.04) !important; }
[data-theme="light"] .gate-all .g-v,
[data-theme="light"] .gate-card-all .g-v { color: #0369a1 !important; }
[data-theme="light"] .gate-all .g-k,
[data-theme="light"] .gate-card-all .g-k { color: #0284c7 !important; }
[data-theme="light"] .gate-all.on,
[data-theme="light"] .gate-card-all.active { background: rgba(2, 132, 199, 0.12) !important; border-color: #0284c7 !important; }

[data-theme="light"] .gate-g0,
[data-theme="light"] .gate-card-g0 { border-top-color: #7c3aed !important; background: rgba(124, 58, 237, 0.04) !important; }
[data-theme="light"] .gate-g0 .g-v,
[data-theme="light"] .gate-card-g0 .g-v { color: #6d28d9 !important; }
[data-theme="light"] .gate-g0 .g-k,
[data-theme="light"] .gate-card-g0 .g-k { color: #7c3aed !important; }
[data-theme="light"] .gate-g0.on,
[data-theme="light"] .gate-card-g0.active { background: rgba(124, 58, 237, 0.12) !important; border-color: #7c3aed !important; }

[data-theme="light"] .gate-g1,
[data-theme="light"] .gate-card-g1 { border-top-color: #e11d48 !important; background: rgba(225, 29, 72, 0.04) !important; }
[data-theme="light"] .gate-g1 .g-v,
[data-theme="light"] .gate-card-g1 .g-v { color: #be123c !important; }
[data-theme="light"] .gate-g1 .g-k,
[data-theme="light"] .gate-card-g1 .g-k { color: #e11d48 !important; }
[data-theme="light"] .gate-g1.on,
[data-theme="light"] .gate-card-g1.active { background: rgba(225, 29, 72, 0.12) !important; border-color: #e11d48 !important; }

[data-theme="light"] .gate-g2,
[data-theme="light"] .gate-card-g2 { border-top-color: #d97706 !important; background: rgba(217, 119, 6, 0.04) !important; }
[data-theme="light"] .gate-g2 .g-v,
[data-theme="light"] .gate-card-g2 .g-v { color: #b45309 !important; }
[data-theme="light"] .gate-g2 .g-k,
[data-theme="light"] .gate-card-g2 .g-k { color: #d97706 !important; }
[data-theme="light"] .gate-g2.on,
[data-theme="light"] .gate-card-g2.active { background: rgba(217, 119, 6, 0.12) !important; border-color: #d97706 !important; }

[data-theme="light"] .gate-g3,
[data-theme="light"] .gate-card-g3 { border-top-color: #0891b2 !important; background: rgba(8, 145, 178, 0.04) !important; }
[data-theme="light"] .gate-g3 .g-v,
[data-theme="light"] .gate-card-g3 .g-v { color: #0e7490 !important; }
[data-theme="light"] .gate-g3 .g-k,
[data-theme="light"] .gate-card-g3 .g-k { color: #0891b2 !important; }
[data-theme="light"] .gate-g3.on,
[data-theme="light"] .gate-card-g3.active { background: rgba(8, 145, 178, 0.12) !important; border-color: #0891b2 !important; }

[data-theme="light"] .gate-g4,
[data-theme="light"] .gate-card-g4 { border-top-color: #059669 !important; background: rgba(5, 150, 105, 0.04) !important; }
[data-theme="light"] .gate-g4 .g-v,
[data-theme="light"] .gate-card-g4 .g-v { color: #047857 !important; }
[data-theme="light"] .gate-g4 .g-k,
[data-theme="light"] .gate-card-g4 .g-k { color: #059669 !important; }
[data-theme="light"] .gate-g4.on,
[data-theme="light"] .gate-card-g4.active { background: rgba(5, 150, 105, 0.12) !important; border-color: #059669 !important; }

/* Active Gate Pill Badge - Prevents Text Bleed */
.gate-badge-pill {
  font-size: 11px !important;
  font-weight: 800 !important;
  line-height: 1 !important;
  padding: 3px 8px !important;
  border-radius: 12px !important;
  white-space: nowrap !important;
  letter-spacing: 0.5px !important;
  display: inline-block !important;
  box-sizing: border-box !important;
}

/* Spacious Full-Length Table Container with Sticky Headers */
.scroll {
  width: 100%;
  max-height: calc(100vh - 280px);
  min-height: 420px;
  overflow-y: auto;
  overflow-x: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  background: var(--surface-bg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  margin-bottom: 6px;
}

.expired-listings-pipeline .scroll {
  max-height: calc(100vh - 250px) !important;
  min-height: 460px !important;
}

.scroll table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.scroll table thead th {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface-panel);
  box-shadow: 0 1px 0 var(--surface-border);
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  white-space: nowrap;
}

.scroll table tbody td {
  padding: 6px 10px;
  font-size: 12px;
  border-bottom: 1px solid var(--surface-border);
  vertical-align: middle;
  line-height: 1.35;
}

.scroll table tbody tr {
  height: 46px;
  transition: background 0.1s ease;
}

.scroll table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.015);
}

.scroll table tbody tr:hover {
  background: rgba(56, 189, 248, 0.06);
}

/* Kanban Board & Column Scroll Constraints */
.kanban-board {
  max-height: calc(100vh - 210px);
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 8px;
}

.kanban-cards {
  max-height: calc(100vh - 290px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
}

/* Pseudo-Chatbot Console & Thread Styles */
#agentChatThread::-webkit-scrollbar {
  width: 6px;
}
#agentChatThread::-webkit-scrollbar-thumb {
  background: var(--surface-border, rgba(255, 255, 255, 0.15));
  border-radius: 4px;
}

.chat-bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
  animation: fadeIn 0.2s ease-in-out;
}

.chat-bubble.agent {
  align-self: flex-start;
  background: var(--surface-panel, #1e293b);
  border: 1px solid var(--surface-border, rgba(255, 255, 255, 0.1));
  color: var(--text-main, #f0f4fc);
  border-bottom-left-radius: 2px;
}

.chat-bubble.user {
  align-self: flex-end;
  background: #7c3aed;
  color: #ffffff;
  border-bottom-right-radius: 2px;
}

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

/* Compact Agent Mini-Cards Grid */
.agent-grid.compact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.agent-mini-card {
  transition: all 0.15s ease;
}
.agent-mini-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border-color: rgba(139, 92, 246, 0.4);
}

/* Underwriting & Profitability Visual Math Lineage */
.math-lineage-ribbon {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-panel, #1e293b);
  border: 1px solid var(--surface-border, rgba(255, 255, 255, 0.1));
  border-radius: var(--radius-md, 8px);
  padding: 10px 14px;
  margin-bottom: 14px;
  overflow-x: auto;
  font-size: 12px;
}

.lineage-step {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--surface-border, rgba(255, 255, 255, 0.08));
  border-radius: 6px;
  cursor: help;
  min-width: 110px;
  transition: all 0.15s ease;
}

.lineage-step:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--accent, #a855f7);
  transform: translateY(-1px);
}

.lineage-step .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-subtle, #94a3b8);
  font-weight: 700;
}

.lineage-step .val {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-main, #f0f4fc);
  font-family: var(--f-mono, monospace);
}

.lineage-step.highlight {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.4);
}

.lineage-step.highlight .val {
  color: #10b981;
}

.lineage-op {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-subtle, #94a3b8);
  user-select: none;
}

/* Hover Tooltip / Popover for Math Lineage and Break-Even */
.has-tooltip {
  position: relative;
}

.tooltip-box {
  visibility: hidden;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: 280px;
  background: #0f172a;
  color: #f8fafc;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 11.5px;
  line-height: 1.45;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

.has-tooltip:hover .tooltip-box,
.has-tooltip:focus-within .tooltip-box {
  visibility: visible;
  opacity: 1;
  transform: translateX(-50%) translateY(-2px);
}

[data-theme="light"] .tooltip-box,
body.theme-light .tooltip-box {
  background: #ffffff;
  color: #1e293b;
  border-color: #cbd5e1;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

/* Delinquent Tax Resolution Card */
.delinquency-resolution-card {
  background: rgba(239, 68, 68, 0.05);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 14px;
}

/* Break-Even Math Card */
.breakeven-math-card {
  background: rgba(2, 132, 199, 0.06);
  border: 1px solid rgba(2, 132, 199, 0.25);
  border-radius: 8px;
  padding: 12px 14px;
}

/* Delinquency Docket Registry Table in Rules & Codes */
.docket-table-container {
  background: var(--surface-card, #131b2b);
  border: 1px solid var(--surface-border, rgba(255, 255, 255, 0.1));
  border-radius: var(--radius-lg, 10px);
  padding: 16px;
  margin-top: 14px;
}

.docket-filter-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.docket-pill {
  padding: 4px 12px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 20px;
  background: var(--surface-panel, #1e293b);
  border: 1px solid var(--surface-border, rgba(255, 255, 255, 0.12));
  color: var(--text-main, #f0f4fc);
  cursor: pointer;
  transition: all 0.15s ease;
}

.docket-pill.active {
  background: var(--accent, #a855f7);
  color: #ffffff;
  border-color: transparent;
}

.docket-pill:hover:not(.active) {
  background: var(--surface-panel-hover, #2d3b55);
}



