/* ============================================================
   PROCELLA DEALER INTELLIGENCE MAP
   Design language: procella.audio website
     White/light backgrounds, navy text, Procella blue accents
   Typography:
     Headings: Bebas Neue
     Body:     Montserrat
   ============================================================ */

:root {
  --navy:         #001C64;
  --navy-light:   #1E3251;
  --procella-blue:#0070E0;
  --procella-blue-2:#4299E6;
  --procella-blue-3:#98CBF1;
  --procella-blue-4:#CBE4F8;
  --bg:           #F3F3F6;
  --panel:        #FFFFFF;
  --panel-2:      #F9F9FC;
  --border:       rgba(218, 218, 218, 0.5);
  --border-solid: #E2E2E6;
  --text:         #1E3251;
  --muted:        #7B8794;
  --shadow-sm:    0 1px 3px rgba(0, 28, 100, 0.06);
  --shadow-md:    0 4px 16px rgba(0, 28, 100, 0.08);
  --shadow-lg:    0 8px 30px rgba(0, 28, 100, 0.10);
  --radius:       10px;
  --radius-sm:    6px;
  --radius-pill:  48px;

  /* Brand pin colors */
  --c-procella:   #0070E0;
  --c-stormaudio: #F97316;
  --c-trinnov:    #10B981;
  --c-jblsynthesis: #EF4444;
  --c-wisdomaudio: #8B5CF6;
  --c-krix:       #F59E0B;
  --c-proaudiotechnology: #14B8A6;
  --c-ascendo:    #EC4899;
  --c-selected:   #0070E0;
}

* { box-sizing: border-box; }

/* -------------------- PASSWORD GATE -------------------- */
.pw-gate {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: linear-gradient(135deg, #001C64 0%, #0070E0 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}
.pw-gate.hidden { display: none; }
.pw-card {
  background: #fff;
  border-radius: 16px;
  padding: 48px 40px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 28, 100, 0.3);
  max-width: 380px;
  width: 90%;
}
.pw-logo { margin-bottom: 20px; }
.pw-logo img { width: 64px; height: 64px; }
.pw-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 24px;
  color: var(--navy);
  letter-spacing: 0.06em;
  margin: 0 0 4px;
}
.pw-sub {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin: 0 0 28px;
}
.pw-form {
  display: flex;
  gap: 8px;
}
.pw-input {
  flex: 1;
  padding: 12px 18px;
  border: 1px solid var(--border-solid);
  border-radius: var(--radius-pill);
  font-family: 'Montserrat', sans-serif;
  font-size: 14px;
  color: var(--text);
  outline: none;
  background: var(--panel-2);
}
.pw-input:focus {
  border-color: var(--procella-blue);
  box-shadow: 0 0 0 3px rgba(0, 112, 224, 0.15);
}
.pw-btn {
  padding: 12px 28px;
  background: var(--procella-blue);
  color: #fff;
  border: none;
  border-radius: var(--radius-pill);
  font-family: 'Bebas Neue', sans-serif;
  font-size: 16px;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: background .15s;
}
.pw-btn:hover { background: var(--navy); }
.pw-error {
  color: #EF4444;
  font-size: 12px;
  margin: 14px 0 0;
  font-weight: 500;
}
body.locked { overflow: hidden; }
body.locked .app-header,
body.locked .layout,
body.locked .crm-panel,
body.locked .crm-overlay,
body.locked .sidebar-overlay,
body.locked .chat-fab,
body.locked .chat-window { visibility: hidden; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Montserrat', system-ui, -apple-system, Segoe UI, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* -------------------- HEADER -------------------- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 28px;
  background: #FFFFFF;
  border-bottom: 1px solid var(--border-solid);
  position: relative;
  z-index: 1100;
  box-shadow: var(--shadow-sm);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark { display: inline-flex; flex-shrink: 0; }
.brand-logo {
  display: block;
  width: 48px;
  height: 48px;
  object-fit: contain;
}
.tagline-main {
  font-family: 'Bebas Neue', Impact, sans-serif;
  font-size: 22px;
  letter-spacing: 0.06em;
  line-height: 1;
  color: var(--navy);
}
.tagline {
  font-size: 10px;
  letter-spacing: 0.18em;
  font-weight: 600;
  color: var(--muted);
  margin-top: 3px;
}
.tagline .accent { color: var(--procella-blue); }
.header-right { display: flex; align-items: center; gap: 24px; }
.header-meta { display: flex; gap: 28px; }
.kpi {
  display: flex; flex-direction: column; align-items: center;
  padding: 0 8px;
  text-align: center;
}
.kpi-num {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 26px;
  line-height: 1;
  color: var(--procella-blue);
}
.kpi-lab {
  font-size: 9px;
  letter-spacing: 0.18em;
  color: var(--muted);
  text-transform: uppercase;
  margin-top: 2px;
  font-weight: 500;
}

/* Attack List button in header */
.attack-list-btn {
  display: flex; align-items: center; gap: 8px;
  background: var(--navy);
  color: #fff;
  border: none;
  padding: 9px 18px;
  border-radius: var(--radius-pill);
  font-family: 'Bebas Neue', sans-serif;
  font-size: 14px;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: background .15s, box-shadow .15s;
  white-space: nowrap;
}
.attack-list-btn:hover {
  background: var(--procella-blue);
  box-shadow: var(--shadow-md);
}
.attack-list-btn svg { flex-shrink: 0; }
.attack-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px;
  background: var(--procella-blue);
  color: #fff;
  border-radius: 50%;
  font-family: 'Montserrat', sans-serif;
  font-size: 11px;
  font-weight: 700;
  padding: 0 5px;
  line-height: 1;
}
.attack-list-btn:hover .attack-badge { background: #fff; color: var(--procella-blue); }
.attack-badge.pulse {
  animation: badge-pulse .4s ease;
}
@keyframes badge-pulse {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.35); }
  100% { transform: scale(1); }
}

/* Hamburger toggle for mobile */
.sidebar-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: 1px solid var(--border-solid);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  cursor: pointer;
  z-index: 1200;
}
.sidebar-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--navy);
  border-radius: 1px;
  transition: transform .2s, opacity .2s;
}
.sidebar-toggle.active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.sidebar-toggle.active span:nth-child(2) { opacity: 0; }
.sidebar-toggle.active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* -------------------- LAYOUT -------------------- */
.layout {
  display: grid;
  grid-template-columns: 310px 1fr;
  height: calc(100vh - 61px);
}

/* -------------------- SIDEBAR -------------------- */
.sidebar {
  background: #F6F8FC;
  border-right: 1px solid var(--border-solid);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #d0d0d6 transparent;
}
.sidebar::-webkit-scrollbar { width: 5px; }
.sidebar::-webkit-scrollbar-thumb { background: #d0d0d6; border-radius: 3px; }

.search-block, .filter-block, .results-block {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.results-block {
  flex: 1 1 auto;
  display: flex; flex-direction: column;
  border-bottom: 0;
  min-height: 200px;
}

.block-label {
  display: block;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 12px;
  letter-spacing: 0.16em;
  color: var(--muted);
  margin-bottom: 8px;
}

#search {
  width: 100%;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border-solid);
  padding: 10px 14px;
  border-radius: var(--radius-pill);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
#search::placeholder { color: #b0b6be; }
#search:focus {
  border-color: var(--procella-blue);
  box-shadow: 0 0 0 3px rgba(0, 112, 224, 0.1);
}

select {
  width: 100%;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border-solid);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding-right: 26px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
select:focus {
  border-color: var(--procella-blue);
  box-shadow: 0 0 0 3px rgba(0, 112, 224, 0.1);
}

/* Brand filter pills */
.brand-filters { display: flex; flex-direction: column; gap: 5px; }
.brand-pill {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-solid);
  background: var(--panel-2);
  cursor: pointer;
  user-select: none;
  transition: background .18s, border-color .18s, opacity .18s, box-shadow .18s;
}
.brand-pill input { display: none; }
.brand-pill .swatch {
  width: 10px; height: 10px; border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.06);
}
.brand-pill .name {
  flex: 1;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
}
.brand-pill .count {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}
.brand-pill:hover {
  border-color: var(--procella-blue-2);
  box-shadow: var(--shadow-sm);
}

/* Active (checked) brand pill — blue tint background + blue border + subtle glow */
.brand-pill.on {
  background: rgba(0, 112, 224, 0.07);
  border-color: var(--procella-blue);
  box-shadow: 0 0 0 2px rgba(0, 112, 224, 0.12), var(--shadow-sm);
}
.brand-pill.on .name { color: var(--navy); font-weight: 600; }
.brand-pill.on .count { color: var(--procella-blue); font-weight: 600; }
.brand-pill.on .swatch {
  box-shadow: 0 0 0 2px rgba(0,0,0,0.06), 0 0 6px currentColor;
}

/* Inactive (unchecked) brand pill */
.brand-pill.off { opacity: 1; background: var(--panel); }
.brand-pill.off .name { color: var(--muted); font-weight: 400; }
.brand-pill.off .count { color: #B8BFC6; }
.brand-pill.off .swatch { opacity: 0.3; }

/* Brand select/deselect all buttons */
.brand-actions {
  display: flex; gap: 8px;
  margin-top: 8px;
}
.btn-sm {
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--border-solid);
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  font-family: inherit;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  cursor: pointer;
  font-weight: 500;
  transition: background .12s, color .12s, border-color .12s;
}
.btn-sm:hover {
  background: var(--bg);
  color: var(--text);
  border-color: var(--procella-blue-2);
}

/* Market badge (static label) */
.market-badge {
  display: inline-block;
  padding: 6px 18px;
  background: var(--procella-blue);
  color: #fff;
  border-radius: var(--radius-pill);
  font-family: 'Bebas Neue', sans-serif;
  font-size: 14px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-top: 2px;
}

/* Reset button */
.btn-reset {
  width: 100%;
  background: transparent;
  color: var(--procella-blue);
  border: 1px solid var(--procella-blue);
  padding: 9px 12px;
  border-radius: var(--radius-pill);
  font-family: 'Bebas Neue', sans-serif;
  font-size: 13px;
  letter-spacing: 0.12em;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.btn-reset:hover {
  background: var(--procella-blue);
  color: #fff;
}

/* -------------------- RESULTS -------------------- */
.results-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 8px;
}
.results-count {
  font-family: 'Bebas Neue', sans-serif;
  color: var(--procella-blue);
  font-size: 16px;
  letter-spacing: 0.05em;
}

.results-list {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1 1 auto;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #d0d0d6 transparent;
}
.results-list::-webkit-scrollbar { width: 5px; }
.results-list::-webkit-scrollbar-thumb { background: #d0d0d6; border-radius: 3px; }
.result-item {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  transition: background .12s;
}
.result-item:hover { background: var(--panel-2); }
.result-item.selected { background: rgba(0, 112, 224, 0.05); }
.result-chips { display: inline-flex; gap: 2px; align-self: center; }
.result-chip {
  width: 7px; height: 7px; border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.08);
}
.result-item .meta {
  font-size: 11px; color: var(--muted); margin-top: 2px;
}
.result-item .name {
  font-size: 12.5px;
  color: var(--text);
  font-weight: 500;
  line-height: 1.3;
}

/* Add-to-attack-list button on result rows */
.result-add-btn {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--border-solid);
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
  font-weight: 500;
  line-height: 1;
  transition: all .15s;
}
.result-add-btn:hover {
  border-color: var(--procella-blue);
  color: var(--procella-blue);
  background: rgba(0, 112, 224, 0.06);
}
.result-add-btn.in-list {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
  font-size: 12px;
}
.result-add-btn.in-list:hover {
  background: #c0392b;
  border-color: #c0392b;
}
.result-item.in-attack-list {
  background: rgba(0, 28, 100, 0.04);
  border-left: 3px solid var(--navy);
  padding-left: 5px;
}

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.04em;
}

/* -------------------- MAP -------------------- */
.map-wrap {
  position: relative;
  background: var(--bg);
}
#map {
  width: 100%;
  height: 100%;
  background: var(--bg);
}

/* Light-mode tiles — subtle desaturation for a clean look */
.leaflet-tile-pane { filter: saturate(0.35) brightness(1.02) contrast(1.0); }

.leaflet-container { background: var(--bg); font-family: 'Montserrat', sans-serif; }
.leaflet-control-attribution {
  background: rgba(255,255,255,0.85) !important;
  color: var(--muted) !important;
  font-size: 10px !important;
}
.leaflet-control-attribution a { color: var(--procella-blue) !important; }

/* Zoom controls */
.leaflet-control-zoom a {
  background: #fff !important;
  color: var(--navy) !important;
  border-color: var(--border-solid) !important;
}
.leaflet-control-zoom a:hover {
  background: var(--panel-2) !important;
}

/* Teardrop pin markers */
.dealer-pin {
  cursor: pointer;
  transition: transform .15s, filter .15s;
}
.dealer-pin:hover { transform: scale(1.18); }
.dealer-pin.pin-selected { filter: drop-shadow(0 0 6px rgba(0, 112, 224, 0.55)); }

/* Custom branded cluster bubble */
.brand-cluster-wrap { background: transparent !important; border: none !important; }
.brand-cluster {
  width: 100%; height: 100%;
  border-radius: 50%;
  border: 2px solid;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-weight: 700;
  font-family: 'Montserrat', sans-serif;
  font-size: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}
.brand-cluster span { line-height: 1; }

/* Hide default leaflet cluster styles in case they leak */
.marker-cluster div { color: #fff !important; }

/* Popups */
.leaflet-popup-content-wrapper {
  background: #fff;
  color: var(--text);
  border-radius: var(--radius);
  border: none;
  box-shadow: var(--shadow-lg);
}
.leaflet-popup-tip { background: #fff; }
.leaflet-popup-content { margin: 14px 16px; min-width: 200px; }
.leaflet-popup-content h3 {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 18px;
  margin: 0 0 4px;
  letter-spacing: 0.04em;
  color: var(--navy);
}
.leaflet-popup-content .pop-meta {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
}
.leaflet-popup-content .pop-action {
  display: inline-block;
  margin-top: 6px;
  padding: 6px 14px;
  font-size: 11px;
  background: var(--procella-blue);
  color: #fff;
  border-radius: var(--radius-pill);
  text-decoration: none;
  font-weight: 600;
  letter-spacing: 0.04em;
}

/* -------------------- LEGEND -------------------- */
.legend {
  position: absolute;
  bottom: 16px;
  left: 16px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--border-solid);
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 11.5px;
  z-index: 500;
  backdrop-filter: blur(8px);
  min-width: 190px;
  box-shadow: var(--shadow-md);
  transition: min-width .2s ease;
}
.legend.collapsed {
  min-width: auto;
}
.legend-header {
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer;
  user-select: none;
  gap: 10px;
}
.legend-header h4 {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 12px;
  letter-spacing: 0.18em;
  margin: 0;
  color: var(--muted);
}
.legend-toggle {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  transition: transform .2s ease;
}
.legend.collapsed .legend-toggle {
  transform: rotate(-90deg);
}
.legend-body {
  margin-top: 8px;
  overflow: hidden;
  transition: max-height .25s ease, opacity .2s ease;
  max-height: 500px;
  opacity: 1;
}
.legend.collapsed .legend-body {
  max-height: 0;
  opacity: 0;
  margin-top: 0;
}
.legend-row {
  display: flex; align-items: center; gap: 9px;
  margin-bottom: 5px;
}
.legend-swatch {
  width: 18px; height: 24px;
  flex: 0 0 auto;
}
.legend-row .name { color: var(--text); font-weight: 500; }
.legend-row .role { color: var(--muted); font-size: 10.5px; margin-left: auto; }

/* -------------------- DETAIL PANEL -------------------- */
.detail-panel {
  position: absolute;
  right: 0;
  top: 61px;
  bottom: 0;
  width: 380px;
  background: var(--panel);
  border-left: 1px solid var(--border-solid);
  box-shadow: -6px 0 24px rgba(0, 28, 100, 0.08);
  padding: 24px 26px;
  overflow-y: auto;
  z-index: 1000;
  transition: transform .25s ease;
}
.close-btn {
  position: absolute; right: 14px; top: 12px;
  background: transparent; color: var(--muted);
  border: none; font-size: 24px; cursor: pointer;
  line-height: 1;
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s, color .12s;
}
.close-btn:hover { background: var(--panel-2); color: var(--procella-blue); }
.detail-panel h2 {
  font-family: 'Bebas Neue', sans-serif;
  margin: 0 0 4px;
  font-size: 26px;
  letter-spacing: 0.03em;
  color: var(--navy);
  padding-right: 30px;
  line-height: 1.05;
}
.detail-brand-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border-radius: var(--radius-pill);
  margin-top: 4px;
  margin-bottom: 14px;
  background: rgba(0, 112, 224, 0.08);
  color: var(--procella-blue);
}
.detail-brand-tag .swatch { width: 8px; height: 8px; border-radius: 50%; }

.detail-cobrand {
  margin-top: -8px;
  margin-bottom: 14px;
  font-size: 11.5px;
  color: var(--muted);
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}
.cobrand-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  border: 1px solid var(--border-solid);
  border-radius: var(--radius-pill);
  font-size: 11px;
  color: var(--text);
}
.cobrand-chip .swatch { width: 8px; height: 8px; border-radius: 50%; }

/* Popup co-brand line */
.pop-cobrand { color: var(--procella-blue) !important; font-weight: 600; }

.detail-section {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.detail-section .label {
  display: block;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--muted);
  margin-bottom: 4px;
}
.detail-section .value { font-size: 13px; color: var(--text); }
.detail-section .value a { color: var(--procella-blue); text-decoration: none; }
.detail-section .value a:hover { text-decoration: underline; }
.detail-section .value.muted { color: var(--muted); font-style: italic; font-size: 12px; }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.detail-grid .label {
  display: block;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 10.5px;
  letter-spacing: 0.15em;
  color: var(--muted);
  margin-bottom: 2px;
}

.markets-row { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.market-tag {
  font-size: 10.5px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: var(--panel-2);
  border: 1px solid var(--border-solid);
  color: var(--text);
  letter-spacing: 0.04em;
}

/* -------------------- CRM / ATTACK LIST PANEL -------------------- */
.crm-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 28, 100, 0.2);
  backdrop-filter: blur(3px);
  z-index: 1200;
}
.crm-overlay.active { display: block; }

.crm-panel {
  position: fixed;
  right: 0; top: 0; bottom: 0;
  width: 440px;
  max-width: 100vw;
  background: var(--panel);
  border-left: 1px solid var(--border-solid);
  box-shadow: -8px 0 40px rgba(0, 28, 100, 0.12);
  z-index: 1300;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .3s ease;
}
.crm-panel.open {
  transform: translateX(0);
}

.crm-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.crm-title {
  display: flex; align-items: center; gap: 10px;
}
.crm-title svg { color: var(--navy); }
.crm-title h3 {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 22px;
  letter-spacing: 0.06em;
  margin: 0;
  color: var(--navy);
}
.crm-count {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}

.crm-actions {
  padding: 10px 22px;
  border-bottom: 1px solid var(--border);
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.crm-actions-right {
  display: flex; align-items: center; gap: 10px; margin-left: auto;
}
.crm-share-toggle {
  display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 11px;
  color: var(--muted); user-select: none; white-space: nowrap;
}
.crm-share-toggle input[type="checkbox"] {
  width: 14px; height: 14px; accent-color: var(--procella); cursor: pointer;
}
.crm-share-toggle:hover { color: var(--text); }
.crm-share-label { font-family: var(--body-font); letter-spacing: 0.3px; }
.crm-clear-btn {
  color: #c0392b !important;
  border-color: #c0392b !important;
}
.crm-clear-btn:hover {
  background: #c0392b !important;
  color: #fff !important;
}

.crm-body {
  flex: 1 1 auto;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #d0d0d6 transparent;
}
.crm-body::-webkit-scrollbar { width: 5px; }
.crm-body::-webkit-scrollbar-thumb { background: #d0d0d6; border-radius: 3px; }

.crm-empty {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 60px 30px;
  text-align: center;
  gap: 10px;
}
.crm-empty p {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 16px;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0;
}
.crm-empty span {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.crm-cards { padding: 8px 0; }

/* CRM Card */
.crm-card {
  padding: 12px 22px;
  border-bottom: 1px solid var(--border);
  transition: background .12s;
}
.crm-card:hover { background: var(--panel-2); }
.crm-card-head {
  display: flex; align-items: center; gap: 10px;
  cursor: pointer;
  user-select: none;
}
.crm-card-swatch {
  width: 10px; height: 10px; border-radius: 50%;
  flex-shrink: 0;
}
.crm-card-info { flex: 1; min-width: 0; }
.crm-card-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.crm-card-meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 1px;
}
.crm-card-expand {
  background: none; border: none;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  padding: 4px;
  transition: transform .2s;
  flex-shrink: 0;
}
.crm-card.expanded .crm-card-expand { transform: rotate(180deg); }
.crm-card-remove {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 1px solid var(--border-solid);
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  transition: all .12s;
}
.crm-card-remove:hover {
  background: #c0392b;
  border-color: #c0392b;
  color: #fff;
}

.crm-card-details {
  max-height: 0;
  overflow: hidden;
  transition: max-height .25s ease, padding .25s ease;
  padding: 0 0 0 20px;
}
.crm-card.expanded .crm-card-details {
  max-height: 400px;
  padding: 10px 0 4px 20px;
}
.crm-detail-row {
  display: flex;
  margin-bottom: 6px;
  font-size: 12px;
}
.crm-detail-label {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--muted);
  width: 80px;
  flex-shrink: 0;
  padding-top: 2px;
}
.crm-detail-value {
  color: var(--text);
  flex: 1;
  word-break: break-word;
}
.crm-detail-value a { color: var(--procella-blue); text-decoration: none; }
.crm-detail-value a:hover { text-decoration: underline; }
.crm-detail-value.empty { color: var(--muted); font-style: italic; }

/* Add to Attack List button in detail panel */
.detail-attack-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  padding: 11px 16px;
  margin-top: 16px;
  border-radius: var(--radius-pill);
  font-family: 'Bebas Neue', sans-serif;
  font-size: 14px;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: all .15s;
  border: none;
}
.detail-attack-btn.add {
  background: var(--navy);
  color: #fff;
}
.detail-attack-btn.add:hover {
  background: var(--procella-blue);
}
.detail-attack-btn.remove {
  background: transparent;
  color: #c0392b;
  border: 1.5px solid #c0392b;
}
.detail-attack-btn.remove:hover {
  background: #c0392b;
  color: #fff;
}

/* Pin glow for attack-list dealers */
.dealer-pin.pin-attack { filter: drop-shadow(0 0 6px rgba(0, 28, 100, 0.5)); }

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 28, 100, 0.15);
  backdrop-filter: blur(2px);
  z-index: 999;
}
.sidebar-overlay.active {
  display: block;
}

/* -------------------- HELP CHATBOT -------------------- */
.chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--procella-blue);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 112, 224, 0.35);
  transition: transform .15s, box-shadow .15s, background .15s;
}
.chat-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(0, 112, 224, 0.45);
}
.chat-fab.open { background: var(--navy); }
.chat-fab .chat-fab-close { display: none; }
.chat-fab.open .chat-fab-icon { display: none; }
.chat-fab.open .chat-fab-close { display: block; }

.chat-window {
  position: fixed;
  bottom: 90px;
  right: 24px;
  z-index: 9998;
  width: 370px;
  max-height: 520px;
  background: var(--panel);
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(0, 28, 100, 0.18);
  display: none;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border-solid);
  animation: chatSlideUp .25s ease;
}
.chat-window.open {
  display: flex;
}
@keyframes chatSlideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.chat-head {
  background: var(--navy);
  color: #fff;
  padding: 16px 18px;
}
.chat-head-info {
  display: flex;
  align-items: center;
  gap: 12px;
}
.chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--procella-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 20px;
  color: #fff;
  flex-shrink: 0;
}
.chat-head-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 17px;
  letter-spacing: 0.04em;
}
.chat-head-sub {
  font-size: 11px;
  color: rgba(255,255,255,0.65);
  margin-top: 1px;
}
.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 320px;
  min-height: 120px;
}
.chat-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
  word-wrap: break-word;
}
.chat-msg.bot {
  align-self: flex-start;
  background: var(--panel-2);
  color: var(--text);
  border-bottom-left-radius: 4px;
}
.chat-msg.user {
  align-self: flex-end;
  background: var(--procella-blue);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-msg.bot strong { color: var(--navy); }
.chat-suggestions {
  padding: 4px 14px 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chat-suggestion {
  background: var(--procella-blue-4);
  color: var(--navy);
  border: none;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: background .12s;
}
.chat-suggestion:hover {
  background: var(--procella-blue-3);
}
.chat-input-bar {
  display: flex;
  align-items: center;
  border-top: 1px solid var(--border-solid);
  padding: 10px 12px;
  gap: 8px;
}
.chat-input-bar input {
  flex: 1;
  border: 1px solid var(--border-solid);
  border-radius: var(--radius-pill);
  padding: 9px 16px;
  font-size: 13px;
  font-family: 'Montserrat', sans-serif;
  color: var(--text);
  outline: none;
  background: var(--panel-2);
}
.chat-input-bar input:focus {
  border-color: var(--procella-blue);
  box-shadow: 0 0 0 3px rgba(0, 112, 224, 0.1);
}
.chat-send {
  background: var(--procella-blue);
  border: none;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .12s;
}
.chat-send:hover { background: var(--navy); }

/* -------------------- USER SELECTOR GATE -------------------- */
.user-gate {
  position: fixed;
  inset: 0;
  z-index: 99998;
  background: linear-gradient(135deg, #001C64 0%, #0070E0 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}
.user-gate.hidden { display: none; }
.user-select-card { max-width: 640px; width: 92vw; }
.user-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 18px;
}
.user-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: var(--panel-2);
  border: 2px solid var(--border-solid);
  border-radius: var(--radius);
  padding: 14px 8px 12px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .15s;
  text-align: center;
}
.user-card:hover {
  border-color: var(--procella-blue);
  box-shadow: 0 0 0 3px rgba(0,112,224,0.12);
  transform: translateY(-2px);
}
.user-avatar-photo {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  overflow: hidden;
  background: #1a1a2e;
  flex-shrink: 0;
}
.user-avatar-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(100%);
  transition: filter .2s;
}
.user-card:hover .user-avatar-photo img {
  filter: grayscale(0%);
}
.user-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  font-family: 'Montserrat', sans-serif;
  flex-shrink: 0;
  letter-spacing: 0.5px;
}
.user-card > .user-avatar:not(.user-avatar-photo) {
  width: 56px;
  height: 56px;
  font-size: 18px;
}
.user-avatar.sm {
  width: 24px;
  height: 24px;
  font-size: 9px;
}
.user-name {
  font-weight: 600;
  font-size: 12px;
  color: var(--text);
  display: block;
  line-height: 1.3;
}
.user-card > .user-name {
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.user-role {
  font-size: 11px;
  color: var(--muted);
  display: block;
}
.user-card > .user-role {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* -------------------- CRM TEAM TOGGLE -------------------- */
.crm-team-toggle {
  display: flex;
  gap: 0;
  border: 1px solid var(--border-solid);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.crm-toggle-btn {
  padding: 6px 14px;
  font-size: 11px;
  font-weight: 600;
  font-family: 'Montserrat', sans-serif;
  border: none;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  transition: background .12s, color .12s;
}
.crm-toggle-btn.active {
  background: var(--procella-blue);
  color: #fff;
}
.crm-toggle-btn:hover:not(.active) {
  background: var(--panel-2);
  color: var(--text);
}
.crm-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
}

/* -------------------- DETAIL: ASSIGNMENT -------------------- */
.detail-assignment {
  margin: 16px 0;
  padding: 12px 14px;
  background: var(--panel-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-solid);
}
.detail-assignment .label {
  display: block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--muted);
  margin-bottom: 8px;
  font-family: 'Montserrat', sans-serif;
}
.assignment-current {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}
.assignment-current .user-avatar { width: 28px; height: 28px; font-size: 10px; }
.assignment-date {
  font-size: 11px;
  color: var(--muted);
  margin-left: auto;
}
.unassign-btn {
  background: none;
  border: 1px solid var(--border-solid);
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  transition: color .12s, border-color .12s;
  margin-left: 4px;
}
.unassign-btn:hover { color: #EF4444; border-color: #EF4444; }
.assign-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px dashed var(--procella-blue);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--procella-blue);
  font-size: 12px;
  font-weight: 600;
  font-family: 'Montserrat', sans-serif;
  cursor: pointer;
  transition: background .12s;
}
.assign-btn:hover {
  background: rgba(0, 112, 224, 0.06);
}

/* -------------------- DETAIL: TARGETED BY -------------------- */
.detail-targeted-by {
  margin: 10px 0 0;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.detail-targeted-by .label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--muted);
  margin-right: 4px;
  font-family: 'Montserrat', sans-serif;
}
.detail-targeted-by .user-avatar {
  width: 26px;
  height: 26px;
  font-size: 9px;
}

/* -------------------- DETAIL: COMMENTS -------------------- */
.detail-comments {
  margin: 16px 0 0;
  border-top: 1px solid var(--border-solid);
  padding-top: 16px;
}
.detail-comments .label {
  display: block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--muted);
  margin-bottom: 10px;
  font-family: 'Montserrat', sans-serif;
}
.comments-thread {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
  max-height: 280px;
  overflow-y: auto;
}
.comment {
  background: var(--panel-2);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  border: 1px solid var(--border);
}
.comment-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.comment-header .user-avatar {
  width: 24px;
  height: 24px;
  font-size: 9px;
}
.comment-author {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.comment-date {
  font-size: 10px;
  color: var(--muted);
  margin-left: auto;
}
.comment-text {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
  white-space: pre-wrap;
}
.comment-form {
  display: flex;
  gap: 8px;
}
.comment-form textarea {
  flex: 1;
  border: 1px solid var(--border-solid);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 12px;
  font-family: 'Montserrat', sans-serif;
  color: var(--text);
  resize: vertical;
  min-height: 36px;
  outline: none;
  background: var(--panel);
}
.comment-form textarea:focus {
  border-color: var(--procella-blue);
  box-shadow: 0 0 0 3px rgba(0, 112, 224, 0.08);
}
.comment-form button {
  padding: 8px 16px;
  background: var(--procella-blue);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  font-family: 'Montserrat', sans-serif;
  cursor: pointer;
  align-self: flex-end;
  transition: background .12s;
}
.comment-form button:hover { background: var(--navy); }
.comments-empty {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
  padding: 8px 0;
}
.comments-loading {
  font-size: 12px;
  color: var(--muted);
  padding: 8px 0;
}

/* -------------------- CRM CARD ADDITIONS -------------------- */
.crm-card-added-by {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  color: var(--muted);
  margin-top: 4px;
}
.crm-card-added-by .user-avatar {
  width: 18px;
  height: 18px;
  font-size: 7px;
}
.crm-card-comment-preview {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  color: var(--muted);
  margin-top: 4px;
  font-style: italic;
}
.crm-card-comment-preview svg {
  flex-shrink: 0;
  opacity: 0.5;
}

/* -------------------- RESPONSIVE: TABLET -------------------- */
@media (max-width: 1100px) {
  .layout { grid-template-columns: 280px 1fr; }
  .detail-panel { width: 320px; }
}

/* -------------------- RESPONSIVE: MOBILE -------------------- */
@media (max-width: 900px) {
  .sidebar-toggle { display: flex; }
  .header-meta { display: none; }
  .crm-panel { width: 100%; }
  .attack-list-btn span:not(.attack-badge) { display: none; }
  .attack-list-btn { padding: 9px 12px; }

  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    height: calc(100vh - 56px);
  }

  .sidebar {
    position: fixed;
    top: 56px;
    left: 0;
    bottom: 0;
    width: 300px;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 10px 0 30px rgba(0, 28, 100, 0.1);
  }
  .sidebar.open {
    transform: translateX(0);
  }

  .map-wrap {
    height: calc(100vh - 56px);
  }

  .detail-panel {
    width: 100%;
    top: auto;
    bottom: 0;
    height: 55vh;
    border-left: none;
    border-top: 1px solid var(--border-solid);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 30px rgba(0, 28, 100, 0.1);
  }

  .legend {
    bottom: 10px;
    left: 10px;
    font-size: 10px;
    padding: 8px 10px;
    min-width: 140px;
  }

  .app-header {
    padding: 10px 16px;
  }
  .tagline-main { font-size: 18px; }
  .tagline { font-size: 9px; }
  .brand-logo { width: 36px; height: 36px; }
  .chat-window { width: calc(100vw - 32px); right: 16px; bottom: 80px; max-height: 60vh; }
  .chat-fab { bottom: 16px; right: 16px; width: 48px; height: 48px; }
}

/* -------------------- RESPONSIVE: SMALL PHONE -------------------- */
@media (max-width: 480px) {
  .sidebar { width: 85vw; max-width: 300px; }
  .tagline { display: none; }
  .brand { gap: 10px; }
  .detail-panel { height: 65vh; padding: 18px 16px; }
  .detail-panel h2 { font-size: 22px; }
  .detail-grid { grid-template-columns: 1fr; }
}
