/* ============================================================
   BASILEUS CRM — command-console theme
   A calm working interface for browsing, filtering and auditing
   UK public-source records before any external action.
   ============================================================ */

body.crm-active {
  /* ---- design tokens ---- */
  --bg-0:#05070c;
  --bg-1:#080b13;
  --surface:#0b0f18;
  --surface-glass:rgba(11,15,24,.86);
  --surface-raised:#111722;
  --line:rgba(156,174,198,.16);
  --line-strong:rgba(156,174,198,.30);
  --text:#e6edf7;
  --text-dim:#94a2b8;
  --text-faint:#5c6b81;
  --cyan:#5fc7d8;
  --cyan-bright:#9ee1ea;
  --cyan-soft:rgba(95,199,216,.13);
  --amber:#f3c45a;
  --amber-deep:#1d1707;
  --green:#54e0a0;
  --blue:#7fb6ef;
  --danger:#e68a80;
  --glow-cyan:0 0 12px rgba(95,199,216,.20);
  --glow-amber:0 0 12px rgba(243,196,90,.22);
  --mono:ui-monospace,"SF Mono","JetBrains Mono","Cascadia Code",Menlo,Consolas,monospace;
  --sans:"Inter",ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;

  background:var(--bg-0);
  font-family:var(--sans);
}

@keyframes crm-sheen {
  0% { transform:translateX(-120%); }
  100% { transform:translateX(320%); }
}

@keyframes crm-pulse {
  0%,100% { box-shadow:0 0 0 0 rgba(84,224,160,.55); }
  70% { box-shadow:0 0 0 4px rgba(84,224,160,0); }
}

@keyframes crm-scan {
  0% { opacity:0; transform:translateY(0); }
  50% { opacity:1; }
  100% { opacity:0; transform:translateY(14px); }
}

body.crm-active #superDirectoryShell,
body.crm-active #left,
body.crm-active #top,
body.crm-active #right,
body.crm-active #missionKpis,
body.crm-active #regionalOpsDeck,
body.crm-active #regionalWorkspace,
body.crm-active #workspaceToggle,
body.crm-active #homeBtn,
body.crm-active #backBtn,
body.crm-active #controlsToggle,
body.crm-active #worldViewToggle,
body.crm-active #masterToggle,
body.crm-active #landingOceanControl,
body.crm-active #basilResponsePanel,
body.crm-active #loader,
body.crm-active .window-panel,
body.crm-active #cityMapLayer,
body.crm-active #landingGlobeCanvas,
body.crm-active #mapLibreBackside,
body.crm-active #farSideWorldCanvas,
body.crm-active #countryHoverCanvas,
body.crm-active #earthCoreGlow,
body.crm-active #earthAttractOverlay,
body.crm-active #earthBuildOverlay {
  display:none !important;
}

body.crm-active #mapLibreGlobe {
  opacity:1 !important;
  visibility:visible !important;
  z-index:2 !important;
  filter:saturate(.62) brightness(.66) contrast(1.06) hue-rotate(6deg);
}

body.crm-active #mapLibreGlobe::before,
body.crm-active #mapLibreGlobe::after {
  display:none !important;
}

body.crm-active .maplibregl-canvas {
  width:100vw !important;
  height:100vh !important;
  opacity:1;
}

body.crm-active #mapLibreGlobe,
body.crm-active #mapLibreGlobe .maplibregl-canvas-container {
  width:100vw !important;
  height:100vh !important;
  max-height:100vh !important;
  overflow:hidden !important;
}

#crmShell {
  position:fixed;
  inset:0;
  z-index:80;
  display:none;
  grid-template-columns:56px minmax(0, 1fr);
  grid-template-rows:minmax(0, 1fr);
  color:var(--text);
  pointer-events:none;
  font-size:13px;
  -webkit-font-smoothing:antialiased;
}

body.crm-active #crmShell {
  display:grid;
}

.crm-rail,
.crm-table-panel,
.crm-topbar,
.crm-home,
.crm-profile-drawer,
.crm-map-tools,
.crm-map-status,
.crm-empty-state,
.crm-card-list,
.crm-mobile-tabs {
  pointer-events:auto;
}

/* ---- left rail ---- */
.crm-rail {
  position:relative;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:6px;
  padding:14px 8px;
  background:linear-gradient(180deg, #070a11 0%, #05070c 100%);
  border-right:1px solid var(--line);
}

.crm-rail::after {
  content:"";
  position:absolute;
  top:0;
  right:-1px;
  width:1px;
  height:100%;
  background:linear-gradient(180deg, transparent, rgba(82,212,239,.35) 40%, rgba(82,212,239,.35) 60%, transparent);
  pointer-events:none;
}

.crm-mark {
  position:relative;
  width:30px;
  height:30px;
  display:grid;
  place-items:center;
  background:linear-gradient(140deg, #f5cf6c, #d8b36a);
  color:var(--amber-deep);
  border-radius:8px;
  font:700 13px/1 var(--sans);
  margin-bottom:12px;
  box-shadow:var(--glow-amber), inset 0 0 0 1px rgba(255,255,255,.18);
}

#crmDomainButtons {
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:4px;
}

.crm-domain-button,
.crm-settings-button,
.crm-system-button {
  position:relative;
  width:36px;
  height:36px;
  display:grid;
  place-items:center;
  border:1px solid transparent;
  border-radius:9px;
  background:transparent;
  color:var(--text-faint);
  font:600 9.5px/1 var(--mono);
  letter-spacing:.05em;
  cursor:pointer;
  transition:background .16s ease, color .16s ease, border-color .16s ease, box-shadow .16s ease;
}

.crm-domain-button:hover,
.crm-settings-button:hover,
.crm-system-button:hover {
  color:var(--cyan-bright);
  background:var(--cyan-soft);
  border-color:var(--line-strong);
}

.crm-domain-button.is-active,
.crm-system-button.is-active {
  color:var(--cyan-bright);
  background:var(--cyan-soft);
  border-color:rgba(82,212,239,.45);
  box-shadow:var(--glow-cyan), inset 0 0 0 1px rgba(82,212,239,.12);
}

.crm-domain-button.is-active::before,
.crm-system-button.is-active::before {
  content:"";
  position:absolute;
  left:-9px;
  top:50%;
  transform:translateY(-50%);
  width:3px;
  height:18px;
  border-radius:2px;
  background:var(--cyan);
  box-shadow:var(--glow-cyan);
}

.crm-settings-button {
  margin-top:auto;
}

.crm-system-button {
  margin-top:8px;
}

/* ---- main working column ---- */
.crm-main {
  min-width:0;
  min-height:0;
  display:flex;
  flex-direction:column;
  padding:16px 18px 18px;
  gap:14px;
  background:
    radial-gradient(120% 90% at 12% -10%, rgba(95,199,216,.08), transparent 55%),
    radial-gradient(90% 70% at 95% 110%, rgba(243,196,90,.07), transparent 60%),
    linear-gradient(90deg, rgba(5,7,12,.98) 0%, rgba(5,7,12,.95) 50%, rgba(5,7,12,.30) 100%);
  pointer-events:none;
}

/* ---- top bar ---- */
.crm-topbar {
  display:grid;
  grid-template-columns:minmax(260px, 520px) 1fr auto auto;
  gap:10px;
  align-items:center;
  flex:0 0 auto;
}

.crm-search {
  position:relative;
}

.crm-search input {
  width:100%;
  height:36px;
  box-sizing:border-box;
  border:1px solid var(--line);
  border-radius:9px;
  background:var(--surface-glass);
  backdrop-filter:blur(8px);
  color:var(--text);
  font:400 13px/1.2 var(--sans);
  padding:0 12px 0 34px;
  outline:none;
  transition:border-color .16s ease, box-shadow .16s ease;
}

.crm-search input:focus {
  border-color:rgba(82,212,239,.55);
  box-shadow:var(--glow-cyan);
}

.crm-search input::placeholder {
  color:var(--text-faint);
}

.crm-search::before {
  content:"";
  position:absolute;
  left:12px;
  top:50%;
  width:10px;
  height:10px;
  border:1.5px solid var(--cyan);
  border-radius:999px;
  transform:translateY(-58%);
  box-sizing:border-box;
  opacity:.8;
}

.crm-search::after {
  content:"";
  position:absolute;
  left:20px;
  top:21px;
  width:5px;
  height:1.5px;
  border-radius:999px;
  background:var(--cyan);
  transform:rotate(45deg);
  opacity:.8;
}

.crm-view-switch,
.crm-source-filter {
  display:flex;
  align-items:center;
  gap:2px;
  border:1px solid var(--line);
  background:var(--surface-glass);
  backdrop-filter:blur(8px);
  border-radius:9px;
  padding:3px;
  grid-column:3;
}

.crm-view-switch button,
.crm-source-filter select {
  height:28px;
  border:0;
  border-radius:6px;
  background:transparent;
  color:var(--text-dim);
  font:600 11px/1 var(--mono);
  letter-spacing:.03em;
  padding:0 12px;
  cursor:pointer;
  transition:background .16s ease, color .16s ease;
}

.crm-view-switch button:hover {
  color:var(--cyan-bright);
}

.crm-view-switch button.is-active {
  background:var(--cyan-soft);
  color:var(--cyan-bright);
  box-shadow:inset 0 0 0 1px rgba(82,212,239,.30);
}

.crm-source-filter select {
  min-width:120px;
  outline:none;
  appearance:none;
  padding-right:24px;
  font-family:var(--sans);
  font-weight:500;
}

.crm-data-menu {
  position:relative;
  grid-column:4;
  justify-self:end;
}

.crm-data-menu summary {
  height:36px;
  min-width:72px;
  box-sizing:border-box;
  display:grid;
  place-items:center;
  border:1px solid var(--line);
  border-radius:9px;
  background:var(--surface-glass);
  color:var(--text-dim);
  font:700 11.5px/1 var(--mono);
  letter-spacing:.04em;
  cursor:pointer;
  list-style:none;
  transition:border-color .16s ease, color .16s ease, background .16s ease;
}

.crm-data-menu summary::-webkit-details-marker {
  display:none;
}

.crm-data-menu summary:hover,
.crm-data-menu[open] summary {
  border-color:rgba(82,212,239,.36);
  color:var(--cyan-bright);
  background:rgba(82,212,239,.08);
}

.crm-data-menu-panel {
  position:absolute;
  top:calc(100% + 7px);
  right:0;
  z-index:10;
  width:190px;
  display:grid;
  gap:6px;
  padding:7px;
  border:1px solid var(--line-strong);
  border-radius:11px;
  background:rgba(7,10,16,.96);
  box-shadow:0 18px 42px rgba(0,0,0,.34);
}

.crm-source-button,
.crm-ledger-button,
.crm-add-button {
  height:36px;
  border-radius:9px;
  cursor:pointer;
  transition:filter .16s ease, box-shadow .16s ease, border-color .16s ease, color .16s ease;
}

.crm-source-button,
.crm-ledger-button,
.crm-add-button {
  width:100%;
  border:1px solid var(--line);
  background:var(--surface-glass);
  color:var(--text-dim);
  font:650 12px/1 var(--sans);
  letter-spacing:0;
  padding:0 14px;
  text-align:left;
}

.crm-source-button:hover,
.crm-ledger-button:hover,
.crm-add-button:hover {
  border-color:rgba(82,212,239,.44);
  color:var(--cyan-bright);
  background:rgba(82,212,239,.08);
}

/* ---- command home ---- */
.crm-home {
  flex:0 0 auto;
  display:grid;
  grid-template-columns:minmax(340px, 1fr) minmax(320px, .78fr);
  gap:12px;
  align-items:stretch;
  min-height:220px;
  pointer-events:auto;
}

.crm-command-panel,
.crm-reactive-panel {
  min-width:0;
  border:1px solid var(--line);
  border-radius:12px;
  background:
    linear-gradient(180deg, rgba(95,199,216,.04), transparent 160px),
    rgba(7,10,16,.78);
  box-shadow:0 18px 50px rgba(0,0,0,.28), inset 0 0 0 1px rgba(255,255,255,.025);
}

.crm-command-panel {
  display:grid;
  grid-template-rows:auto auto minmax(64px, 1fr) auto auto;
  gap:10px;
  padding:16px;
  min-height:270px;
}

.crm-command-eyebrow {
  color:var(--amber);
  font:700 10px/1 var(--mono);
  letter-spacing:.16em;
  text-transform:uppercase;
}

.crm-command-panel h2 {
  margin:0;
  color:var(--text);
  font:650 24px/1.08 var(--sans);
  letter-spacing:0;
}

.crm-command-log {
  min-height:64px;
  max-height:145px;
  display:grid;
  align-content:start;
  gap:8px;
  overflow:auto;
  padding-right:4px;
}

.crm-command-log:empty {
  display:none;
}

.crm-command-message {
  display:grid;
  grid-template-columns:72px minmax(0, 1fr);
  gap:9px;
  align-items:start;
  color:var(--text-dim);
  font:400 12.5px/1.45 var(--sans);
}

.crm-command-message b {
  color:var(--text-faint);
  font:700 10px/1.4 var(--mono);
  letter-spacing:.08em;
  text-transform:uppercase;
}

.crm-command-message p {
  margin:0;
}

.crm-command-message[data-role="user"] div {
  color:var(--text);
}

.crm-command-message[data-tone="error"] div {
  color:#f0b0a8;
}

.crm-command-form {
  display:grid;
  grid-template-columns:minmax(0, 1fr) 92px;
  gap:9px;
  align-items:end;
}

.crm-command-form textarea {
  width:100%;
  min-width:0;
  min-height:66px;
  max-height:140px;
  box-sizing:border-box;
  resize:vertical;
  border:1px solid var(--line);
  border-radius:10px;
  background:rgba(5,7,12,.76);
  color:var(--text);
  font:400 13px/1.35 var(--sans);
  padding:11px 12px;
  outline:none;
  transition:border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

.crm-command-form textarea::placeholder {
  color:var(--text-faint);
}

.crm-command-form textarea:focus {
  border-color:rgba(95,199,216,.56);
  background:rgba(7,12,18,.92);
  box-shadow:var(--glow-cyan);
}

.crm-command-form button,
.crm-command-suggestions button,
.crm-reactive-card {
  border:1px solid var(--line);
  background:var(--surface-glass);
  color:var(--text-dim);
  cursor:pointer;
  transition:border-color .16s ease, background .16s ease, color .16s ease, transform .16s ease;
}

.crm-command-form button {
  height:42px;
  border-radius:10px;
  color:var(--cyan-bright);
  font:700 12px/1 var(--mono);
  letter-spacing:.06em;
}

.crm-command-form button:disabled {
  opacity:.55;
  cursor:wait;
}

.crm-command-form button:hover,
.crm-command-suggestions button:hover,
.crm-reactive-card:hover {
  border-color:rgba(95,199,216,.42);
  background:rgba(95,199,216,.08);
  color:var(--text);
}

.crm-command-suggestions {
  display:flex;
  flex-wrap:wrap;
  gap:7px;
}

.crm-command-suggestions button {
  min-height:28px;
  border-radius:999px;
  padding:0 10px;
  font:650 11px/1 var(--sans);
}

.crm-reactive-panel {
  display:grid;
  grid-template-rows:auto auto minmax(0, 1fr);
  gap:12px;
  padding:14px;
  min-height:220px;
}

.crm-reactive-head {
  display:flex;
  align-items:start;
  justify-content:space-between;
  gap:12px;
}

.crm-reactive-head div {
  min-width:0;
  display:grid;
  gap:4px;
}

.crm-reactive-head span {
  color:var(--text-faint);
  font:700 9.5px/1 var(--mono);
  letter-spacing:.12em;
  text-transform:uppercase;
}

.crm-reactive-head b {
  color:var(--text);
  font:650 16px/1.2 var(--sans);
}

#crmReactiveMeta {
  margin:0;
  color:var(--text-dim);
  font:400 12px/1.4 var(--sans);
}

.crm-reactive-cards {
  display:grid;
  grid-template-columns:repeat(2, minmax(0, 1fr));
  gap:8px;
  align-content:start;
}

.crm-reactive-card {
  min-width:0;
  min-height:86px;
  display:grid;
  gap:6px;
  align-content:start;
  text-align:left;
  border-radius:10px;
  padding:11px;
}

.crm-reactive-card[data-kind="primary"] {
  border-color:rgba(95,199,216,.34);
  background:rgba(95,199,216,.09);
}

.crm-reactive-card[data-kind="evidence"],
.crm-reactive-card[data-kind="queue"] {
  border-color:rgba(84,224,160,.22);
}

.crm-reactive-card[data-kind="reset"] {
  opacity:.78;
}

.crm-reactive-card span {
  color:var(--text-faint);
  font:700 9.5px/1 var(--mono);
  text-transform:uppercase;
  letter-spacing:.09em;
}

.crm-reactive-card b {
  min-width:0;
  color:var(--text);
  font:650 14px/1.15 var(--sans);
  overflow-wrap:anywhere;
}

.crm-reactive-card small {
  color:var(--text-dim);
  font:400 11px/1.35 var(--sans);
}

.crm-org-hub {
  position:absolute;
  inset:66px 18px 18px;
  z-index:42;
  display:grid;
  grid-template-columns:minmax(0, 1fr) minmax(300px, 360px);
  gap:12px;
  padding:12px;
  border:1px solid var(--line);
  border-radius:14px;
  background:
    radial-gradient(90% 80% at 48% 44%, rgba(95,199,216,.12), transparent 64%),
    linear-gradient(180deg, rgba(9,14,22,.94), rgba(4,7,12,.90));
  box-shadow:0 24px 80px rgba(0,0,0,.36), inset 0 1px 0 rgba(255,255,255,.035);
  backdrop-filter:blur(18px);
  pointer-events:auto;
  overflow:hidden;
}

.crm-org-hub[hidden] {
  display:none;
}

.crm-org-map {
  position:relative;
  min-height:0;
  border:1px solid rgba(95,199,216,.14);
  border-radius:11px;
  background:
    linear-gradient(rgba(95,199,216,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(95,199,216,.04) 1px, transparent 1px),
    rgba(3,7,12,.42);
  background-size:42px 42px, 42px 42px, 100% 100%;
  overflow:hidden;
}

.crm-org-lines {
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  pointer-events:none;
}

.crm-org-lines line {
  stroke:var(--line, rgba(95,199,216,.34));
  stroke-width:.34;
  vector-effect:non-scaling-stroke;
  opacity:.54;
}

.crm-org-core {
  position:absolute;
  left:50%;
  top:50%;
  width:116px;
  height:116px;
  transform:translate(-50%, -50%);
  display:grid;
  place-items:center;
  border:1px solid rgba(95,199,216,.36);
  border-radius:50%;
  color:var(--text);
  text-align:center;
  background:radial-gradient(circle, rgba(95,199,216,.18), rgba(6,10,16,.94) 68%);
  box-shadow:0 0 48px rgba(95,199,216,.16);
}

.crm-org-core b,
.crm-org-core span,
.crm-org-core small {
  display:block;
}

.crm-org-core b {
  font:800 24px/1 var(--sans);
  letter-spacing:.12em;
}

.crm-org-core span {
  color:var(--cyan-bright);
  font:800 10px/1.2 var(--mono);
  letter-spacing:.14em;
}

.crm-org-core small {
  margin-top:5px;
  color:var(--text-faint);
  font:500 10px/1.25 var(--sans);
}

.crm-org-node {
  position:absolute;
  left:var(--x);
  top:var(--y);
  transform:translate(-50%, -50%);
  width:108px;
  min-height:58px;
  border:1px solid color-mix(in srgb, var(--accent, var(--cyan)), transparent 52%);
  border-radius:10px;
  background:linear-gradient(180deg, rgba(12,20,30,.92), rgba(5,8,13,.82));
  color:var(--text);
  text-align:left;
  padding:8px;
  cursor:pointer;
  box-shadow:0 14px 34px rgba(0,0,0,.28);
}

.crm-org-node:hover,
.crm-org-node.is-selected {
  border-color:var(--accent, var(--cyan));
  box-shadow:0 0 0 1px color-mix(in srgb, var(--accent, var(--cyan)), transparent 58%), 0 20px 46px rgba(0,0,0,.34);
}

.crm-org-node i {
  display:inline-grid;
  place-items:center;
  width:24px;
  height:24px;
  margin-right:6px;
  border:1px solid color-mix(in srgb, var(--accent, var(--cyan)), transparent 35%);
  border-radius:7px;
  color:var(--accent, var(--cyan));
  font:800 9px/1 var(--mono);
  font-style:normal;
  vertical-align:middle;
}

.crm-org-node strong {
  display:inline-block;
  max-width:58px;
  color:var(--text);
  font:700 11.5px/1 var(--sans);
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  vertical-align:middle;
}

.crm-org-node span {
  display:block;
  margin-top:5px;
  color:var(--text-faint);
  font:500 10px/1.25 var(--sans);
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.crm-org-node b {
  display:block;
  margin-top:4px;
  color:var(--accent, var(--cyan));
  font:800 9px/1 var(--mono);
  text-transform:uppercase;
}

.crm-org-detail {
  min-height:0;
  display:grid;
  grid-template-rows:auto auto minmax(0, 1fr);
  gap:10px;
  border:1px solid rgba(95,199,216,.14);
  border-radius:11px;
  background:rgba(3,7,12,.58);
  padding:12px;
  overflow:hidden;
}

.crm-org-detail-head {
  display:grid;
  grid-template-columns:44px minmax(0, 1fr);
  gap:10px;
  align-items:center;
}

.crm-org-detail-icon {
  width:44px;
  height:44px;
  display:grid;
  place-items:center;
  border:1px solid color-mix(in srgb, var(--accent, var(--cyan)), transparent 38%);
  border-radius:10px;
  color:var(--accent, var(--cyan));
  background:color-mix(in srgb, var(--accent, var(--cyan)), transparent 90%);
  font:800 12px/1 var(--mono);
}

.crm-org-detail-head b {
  display:block;
  color:var(--text);
  font:700 18px/1.08 var(--sans);
}

.crm-org-detail-head span,
.crm-org-card span,
.crm-org-body li {
  color:var(--text-dim);
  font:400 12px/1.42 var(--sans);
}

.crm-org-detail-head span {
  display:block;
  margin-top:3px;
}

.crm-org-tabs {
  display:grid;
  grid-template-columns:repeat(4, minmax(0, 1fr));
  gap:6px;
}

.crm-org-tab {
  min-height:34px;
  border:1px solid var(--line);
  border-radius:9px;
  background:var(--surface-glass);
  color:var(--text-dim);
  font:700 11px/1 var(--mono);
  cursor:pointer;
}

.crm-org-tab:hover,
.crm-org-tab.is-active {
  border-color:color-mix(in srgb, var(--accent, var(--cyan)), transparent 45%);
  color:var(--cyan-bright);
  background:color-mix(in srgb, var(--accent, var(--cyan)), transparent 90%);
}

.crm-org-body {
  min-height:0;
  overflow:auto;
}

.crm-org-body ul {
  margin:10px 0 0;
  padding-left:18px;
}

.crm-org-body li {
  margin:5px 0;
}

.crm-org-card-grid {
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:8px;
}

.crm-org-card {
  border:1px solid var(--line);
  border-radius:10px;
  padding:10px;
  background:rgba(255,255,255,.025);
}

.crm-org-card b {
  display:block;
  margin-bottom:5px;
  color:var(--text);
  font:700 12px/1.2 var(--sans);
}

#crmShell.is-org-open .crm-home,
#crmShell.is-org-open .crm-summary-row,
#crmShell.is-org-open .crm-views-bar,
#crmShell.is-org-open .crm-workspace,
#crmShell.is-org-open .crm-bulk-bar {
  opacity:.12;
  pointer-events:none;
}

/* ---- summary row ---- */
.crm-summary-row {
  flex:0 0 auto;
  display:grid;
  grid-template-columns:minmax(280px, 1fr) minmax(360px, auto);
  gap:10px 18px;
  align-items:start;
  pointer-events:auto;
}

.crm-domain-title {
  display:grid;
  grid-template-columns:auto minmax(0, auto);
  align-items:center;
  column-gap:10px;
  row-gap:5px;
  min-width:0;
}

.crm-domain-title h1 {
  margin:0;
  color:var(--text);
  font:600 17px/1.2 var(--sans);
  letter-spacing:.01em;
  white-space:nowrap;
  text-shadow:0 0 18px rgba(82,212,239,.18);
}

.crm-domain-title p {
  margin:0;
  color:var(--text-dim);
  font:400 11.5px/1.35 var(--mono);
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:normal;
  font-variant-numeric:tabular-nums;
}

#crmSourceGate {
  grid-column:1 / -1;
  max-width:100%;
  white-space:normal;
  overflow:visible;
  text-overflow:clip;
  line-height:1.35;
  overflow-wrap:anywhere;
}

.crm-source-backbone {
  grid-column:1 / -1;
  display:grid;
  grid-template-columns:repeat(4, minmax(0, 1fr));
  gap:8px;
  min-width:0;
}

.crm-source-backbone-card {
  min-width:0;
  border:1px solid var(--line);
  border-radius:8px;
  background:rgba(6,10,16,.52);
  color:inherit;
  padding:9px 10px;
  display:flex;
  flex-direction:column;
  gap:6px;
  text-align:left;
  cursor:pointer;
  font:inherit;
}

.crm-source-backbone-card:hover,
.crm-source-backbone-card:focus-visible {
  border-color:rgba(216,179,106,.42);
  background:rgba(216,179,106,.08);
}

.crm-source-backbone-card:focus-visible {
  outline:2px solid rgba(216,179,106,.42);
  outline-offset:2px;
}

.crm-source-backbone-card > b {
  color:var(--text-faint);
  font:700 9.5px/1 var(--mono);
  letter-spacing:.08em;
  text-transform:uppercase;
}

.crm-source-backbone-card small {
  color:var(--text-faint);
  font:400 10.5px/1.25 var(--sans);
}

.crm-source-backbone-pills {
  display:flex;
  flex-wrap:wrap;
  gap:5px;
  min-width:0;
}

.crm-source-backbone-pill {
  min-width:0;
  max-width:100%;
  border:1px solid var(--line);
  border-radius:999px;
  background:rgba(255,255,255,.035);
  color:var(--text-dim);
  font:500 10.5px/1.1 var(--sans);
  padding:4px 7px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  font-variant-numeric:tabular-nums;
}

.crm-source-backbone-pill b {
  color:var(--text);
  font-weight:650;
}

.crm-source-backbone-pill[data-kind="register"],
.crm-source-backbone-pill[data-kind="live"],
.crm-source-backbone-pill[data-kind="ready"],
.crm-source-backbone-pill[data-kind="gate"] {
  border-color:rgba(84,224,160,.28);
  background:rgba(84,224,160,.08);
  color:#bdeccd;
}

.crm-source-backbone-pill[data-kind="imported"] {
  border-color:rgba(127,182,239,.28);
  background:rgba(127,182,239,.08);
  color:#c3dbf6;
}

.crm-source-backbone-pill[data-kind="fixture"],
.crm-source-backbone-pill[data-kind="mapped"],
.crm-source-backbone-pill[data-kind="gap"] {
  border-color:rgba(243,196,90,.26);
  background:rgba(243,196,90,.08);
  color:#efd28a;
}

.crm-stage-bar {
  display:flex;
  flex-wrap:wrap;
  justify-content:flex-end;
  gap:6px;
  min-width:0;
}

.crm-stage-chip {
  height:29px;
  border:1px solid var(--line);
  border-radius:999px;
  background:var(--surface-glass);
  color:var(--text-dim);
  font:600 11px/1 var(--mono);
  letter-spacing:.03em;
  padding:0 12px;
  white-space:nowrap;
  cursor:pointer;
  transition:background .16s ease, color .16s ease, border-color .16s ease, box-shadow .16s ease;
  font-variant-numeric:tabular-nums;
}

.crm-stage-chip:hover {
  color:var(--cyan-bright);
  border-color:var(--line-strong);
}

.crm-stage-chip b {
  color:var(--text-faint);
  font-weight:600;
  margin-left:6px;
}

.crm-stage-chip.is-active {
  border-color:rgba(82,212,239,.50);
  background:var(--cyan-soft);
  color:var(--cyan-bright);
  box-shadow:var(--glow-cyan);
}

.crm-stage-chip.is-active b {
  color:var(--cyan-bright);
}

/* ---- saved views bar ---- */
.crm-views-bar {
  display:flex;
  align-items:center;
  gap:8px;
  flex-wrap:wrap;
  pointer-events:auto;
}

.crm-views-label {
  color:var(--cyan);
  font:600 10px/1 var(--mono);
  text-transform:uppercase;
  letter-spacing:.14em;
  white-space:nowrap;
}

.crm-views-list {
  display:flex;
  align-items:center;
  gap:6px;
  flex-wrap:wrap;
  min-width:0;
}

.crm-views-empty {
  display:none;
}

.crm-views-bar:has(.crm-views-empty) .crm-views-label {
  display:none;
}

.crm-view-chip {
  display:inline-flex;
  align-items:stretch;
  height:26px;
  border:1px solid var(--line);
  border-radius:999px;
  background:var(--surface-glass);
  overflow:hidden;
  transition:border-color .16s ease, box-shadow .16s ease;
}

.crm-view-chip:hover {
  border-color:var(--line-strong);
}

.crm-view-chip.is-active {
  border-color:rgba(82,212,239,.5);
  background:var(--cyan-soft);
  box-shadow:var(--glow-cyan);
}

.crm-view-chip > button {
  border:0;
  background:transparent;
  color:var(--text-dim);
  font:600 11.5px/1 var(--mono);
  letter-spacing:.02em;
  padding:0 4px 0 12px;
  cursor:pointer;
}

.crm-view-chip.is-active > button {
  color:var(--cyan-bright);
}

.crm-view-remove {
  padding:0 9px 0 4px !important;
  color:var(--text-faint) !important;
  font:400 14px/1 var(--sans) !important;
}

.crm-view-remove:hover {
  color:var(--danger) !important;
}

.crm-save-view {
  display:flex;
  align-items:center;
  gap:6px;
}

.crm-save-view[hidden] {
  display:none;
}

.crm-save-view input {
  height:28px;
  box-sizing:border-box;
  border:1px solid var(--line);
  border-radius:7px;
  background:var(--surface-glass);
  color:var(--text);
  font:500 12px/1 var(--sans);
  padding:0 10px;
  outline:none;
  min-width:170px;
  transition:border-color .16s ease, box-shadow .16s ease;
}

.crm-save-view input:focus {
  border-color:rgba(82,212,239,.55);
  box-shadow:var(--glow-cyan);
}

.crm-save-view-toggle {
  margin-left:auto;
}

#crmShell.is-drawer-open .crm-map-tools,
#crmShell.is-drawer-open .crm-map-zoom,
#crmShell.is-drawer-open .crm-map-legend,
#crmShell.is-drawer-open .crm-map-status {
  opacity:0;
  pointer-events:none;
}

/* ---- bulk action bar ---- */
.crm-bulk-bar {
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  gap:8px 12px;
  padding:9px 13px;
  border:1px solid rgba(82,212,239,.32);
  border-radius:10px;
  background:
    linear-gradient(180deg, rgba(82,212,239,.07), transparent),
    var(--surface-glass);
  backdrop-filter:blur(10px);
  box-shadow:var(--glow-cyan), inset 0 0 0 1px rgba(82,212,239,.05);
  pointer-events:auto;
}

.crm-bulk-bar[hidden] {
  display:none;
}

.crm-bulk-count {
  color:var(--text-dim);
  font:600 11.5px/1 var(--mono);
  letter-spacing:.04em;
  text-transform:uppercase;
  white-space:nowrap;
}

.crm-bulk-count b {
  color:var(--cyan-bright);
  font-size:13px;
  margin-right:3px;
  text-shadow:var(--glow-cyan);
}

.crm-bulk-group {
  display:flex;
  align-items:center;
  gap:6px;
}

.crm-bulk-select,
.crm-bulk-input,
.crm-bulk-date {
  height:30px;
  box-sizing:border-box;
  border:1px solid var(--line);
  border-radius:7px;
  background:var(--surface-glass);
  color:var(--text);
  font:500 12px/1 var(--sans);
  padding:0 10px;
  outline:none;
  transition:border-color .16s ease, box-shadow .16s ease;
}

.crm-bulk-select,
.crm-bulk-date {
  font-family:var(--mono);
  font-weight:600;
  cursor:pointer;
}

.crm-bulk-date {
  color-scheme:dark;
}

.crm-bulk-input {
  min-width:220px;
}

.crm-bulk-select:focus,
.crm-bulk-input:focus,
.crm-bulk-date:focus {
  border-color:rgba(82,212,239,.55);
  box-shadow:var(--glow-cyan);
}

.crm-bulk-deselect {
  margin-left:auto;
}

.crm-bulk-status {
  flex-basis:100%;
  color:var(--green);
  font:500 11.5px/1.3 var(--mono);
  min-height:0;
}

.crm-bulk-status[data-tone="error"] {
  color:#e9aaa2;
}

.crm-bulk-status:empty {
  display:none;
}

/* select-page control + row checkboxes */
.crm-select-page {
  display:inline-flex;
  align-items:center;
  gap:6px;
  color:var(--text-faint);
  font:600 10.5px/1 var(--mono);
  letter-spacing:.06em;
  text-transform:uppercase;
  cursor:pointer;
  white-space:nowrap;
}

.crm-row-check,
.crm-select-page input {
  width:14px;
  height:14px;
  flex:0 0 auto;
  accent-color:var(--cyan);
  cursor:pointer;
}

.crm-record-table tbody tr.is-checked {
  background:rgba(82,212,239,.07);
}

.crm-record-table tbody tr.is-checked.is-selected {
  background:rgba(82,212,239,.12);
}

/* ---- workspace split ---- */
.crm-workspace {
  min-height:0;
  height:auto;
  flex:1 1 auto;
  display:grid;
  grid-template-columns:minmax(520px, 58%) minmax(360px, 1fr);
  gap:13px;
  pointer-events:none;
}

.crm-workspace[data-view="list"] {
  grid-template-columns:minmax(0, 1fr);
}

.crm-workspace[data-view="list"] .crm-map-panel {
  display:none;
}

.crm-workspace[data-view="map"] {
  grid-template-columns:1fr;
}

.crm-workspace[data-view="map"] .crm-table-panel {
  display:none;
}

/* ---- table panel ---- */
.crm-table-panel {
  position:relative;
  min-width:0;
  min-height:0;
  display:grid;
  grid-template-rows:auto minmax(0, 1fr) auto;
  background:
    linear-gradient(180deg, rgba(95,199,216,.035), transparent 120px),
    var(--surface-glass);
  backdrop-filter:blur(10px);
  border:1px solid var(--line);
  border-radius:12px;
  overflow:hidden;
  box-shadow:0 18px 50px rgba(0,0,0,.45), inset 0 0 0 1px rgba(124,176,236,.04);
}

.crm-table-panel::before,
.crm-table-panel::after {
  display:none;
}

.crm-table-head {
  position:relative;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:16px;
  border-bottom:1px solid var(--line);
  overflow:hidden;
}

.crm-table-head::after {
  display:none;
}

.crm-table-head strong {
  display:block;
  color:var(--text);
  font:600 13px/1.2 var(--sans);
}

.crm-table-head span {
  display:block;
  color:var(--text-faint);
  font:400 11px/1.3 var(--mono);
  margin-top:2px;
}

.crm-table-head .crm-count-pill {
  display:inline-flex;
  align-items:center;
  height:23px;
  padding:0 10px;
  border-radius:999px;
  background:var(--cyan-soft);
  border:1px solid rgba(82,212,239,.24);
  color:var(--cyan-bright);
  font:600 11px/1 var(--mono);
  font-variant-numeric:tabular-nums;
  white-space:nowrap;
}

.crm-table-head-tools {
  display:flex;
  align-items:center;
  justify-content:flex-end;
  flex:1 1 560px;
  flex-wrap:wrap;
  gap:8px;
  min-width:0;
  position:relative;
  z-index:1;
}

.crm-due-filter {
  flex:0 1 132px;
  min-width:118px;
  height:30px;
  border:1px solid var(--line);
  border-radius:7px;
  background:var(--surface-glass);
  color:var(--text-dim);
  font:600 11px/1 var(--mono);
  letter-spacing:.02em;
  padding:0 9px;
  outline:none;
  cursor:pointer;
  transition:border-color .16s ease, color .16s ease;
}

#crmSourceFilter {
  flex-basis:190px;
  min-width:170px;
}

#crmEvidenceFilter {
  flex-basis:215px;
  min-width:200px;
}

#crmDueFilter {
  flex-basis:132px;
}

.crm-place-filter {
  flex:1 1 160px;
  min-width:145px;
  max-width:220px;
  height:30px;
  border:1px solid var(--line);
  border-radius:7px;
  background:var(--surface-glass);
  color:var(--text-dim);
  font:600 11px/1 var(--mono);
  letter-spacing:.02em;
  padding:0 9px;
  outline:none;
  transition:border-color .16s ease, color .16s ease;
}

.crm-place-filter::placeholder {
  color:var(--text-faint);
}

.crm-place-filter:hover,
.crm-place-filter:focus {
  color:var(--cyan-bright);
  border-color:rgba(82,212,239,.5);
}

.crm-due-filter:hover {
  color:var(--cyan-bright);
  border-color:var(--line-strong);
}

.crm-due-filter:focus {
  border-color:rgba(82,212,239,.5);
}

/* next-action cell in the records table */
.crm-due-cell {
  display:flex;
  flex-direction:column;
  gap:3px;
  min-width:0;
}

.crm-due-pill {
  display:inline-flex;
  align-items:center;
  align-self:flex-start;
  height:20px;
  padding:0 8px;
  border-radius:999px;
  font:600 10.5px/1 var(--mono);
  letter-spacing:.03em;
  white-space:nowrap;
  border:1px solid transparent;
}

.crm-due-pill[data-status="overdue"] {
  color:#ffb4ab;
  background:rgba(230,138,128,.14);
  border-color:rgba(230,138,128,.4);
  box-shadow:0 0 10px rgba(230,138,128,.18);
}

.crm-due-pill[data-status="today"] {
  color:var(--amber);
  background:rgba(243,196,90,.14);
  border-color:rgba(243,196,90,.42);
  box-shadow:var(--glow-amber);
}

.crm-due-pill[data-status="soon"] {
  color:var(--cyan-bright);
  background:var(--cyan-soft);
  border-color:rgba(82,212,239,.4);
}

.crm-due-pill[data-status="scheduled"] {
  color:var(--text-dim);
  background:rgba(124,176,236,.08);
  border-color:var(--line);
}

.crm-due-pill[data-status="none"] {
  color:var(--text-faint);
  background:transparent;
  border-color:var(--line);
}

.crm-due-note {
  display:block;
  max-width:100%;
  color:var(--text-faint);
  font-size:11px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

/* fit / readiness score */
.crm-fit {
  display:inline-flex;
  align-items:center;
  gap:7px;
  min-width:0;
}

.crm-fit-bar {
  position:relative;
  width:44px;
  height:5px;
  flex:0 0 auto;
  border-radius:999px;
  background:rgba(124,176,236,.14);
  overflow:hidden;
}

.crm-fit-bar > span {
  position:absolute;
  left:0;
  top:0;
  height:100%;
  border-radius:999px;
  background:var(--text-faint);
}

.crm-fit > b {
  font:700 11.5px/1 var(--mono);
  font-variant-numeric:tabular-nums;
  color:var(--text-dim);
}

.crm-fit[data-tier="strong"] .crm-fit-bar > span { background:var(--green); }
.crm-fit[data-tier="strong"] > b { color:var(--green); }
.crm-fit[data-tier="partial"] .crm-fit-bar > span { background:var(--cyan); }
.crm-fit[data-tier="partial"] > b { color:var(--cyan-bright); }
.crm-fit[data-tier="thin"] .crm-fit-bar > span { background:#e09a5a; }
.crm-fit[data-tier="thin"] > b { color:#e8b27e; }

.crm-section h3 .crm-fit {
  margin-left:6px;
}

.crm-section h3 .crm-fit > b {
  font-size:12px;
}

.crm-fit-checklist {
  display:flex;
  flex-wrap:wrap;
  gap:5px;
}

.crm-fit-check {
  display:inline-flex;
  align-items:center;
  gap:5px;
  height:24px;
  padding:0 9px;
  border-radius:999px;
  border:1px solid var(--line);
  background:var(--surface-raised);
  color:var(--text-faint);
  font:500 11px/1 var(--mono);
  letter-spacing:.01em;
}

.crm-fit-check.is-ok {
  border-color:rgba(84,224,160,.35);
  background:rgba(84,224,160,.08);
  color:#9fe6c2;
}

/* record tags */
.crm-tag-list {
  display:flex;
  flex-wrap:wrap;
  gap:6px;
  margin-bottom:8px;
}

.crm-tag,
.crm-tag-empty {
  display:inline-flex;
  align-items:center;
  min-height:24px;
  border:1px solid var(--line);
  border-radius:999px;
  background:var(--surface-raised);
  color:var(--text-dim);
  font:600 11px/1 var(--mono);
  padding:0 9px;
}

.crm-tag[data-kind="internal"] {
  border-color:rgba(216,179,106,.38);
  background:rgba(216,179,106,.10);
  color:#f0d99d;
}

.crm-tag[data-kind="source"] {
  border-color:rgba(82,212,239,.24);
  background:rgba(82,212,239,.07);
  color:#9fc9dc;
}

.crm-tag-empty {
  color:var(--text-faint);
}

.crm-tag-form {
  display:flex;
  gap:6px;
}

.crm-tag-form input {
  min-width:0;
  flex:1;
  box-sizing:border-box;
  border:1px solid var(--line);
  border-radius:8px;
  background:var(--surface-glass);
  color:var(--text);
  font:400 12.5px/1.4 var(--sans);
  padding:8px 11px;
  outline:none;
  transition:border-color .16s ease, box-shadow .16s ease;
}

.crm-tag-form input:focus {
  border-color:rgba(82,212,239,.55);
  box-shadow:var(--glow-cyan);
}

/* next-action editor in the drawer */
.crm-next-action {
  display:grid;
  gap:7px;
}

.crm-next-action input[type="text"],
.crm-next-action input[type="date"] {
  box-sizing:border-box;
  border:1px solid var(--line);
  border-radius:8px;
  background:var(--surface-glass);
  color:var(--text);
  font:400 12.5px/1.4 var(--sans);
  padding:8px 11px;
  outline:none;
  transition:border-color .16s ease, box-shadow .16s ease;
}

.crm-next-action input[type="text"]:focus,
.crm-next-action input[type="date"]:focus {
  border-color:rgba(82,212,239,.55);
  box-shadow:var(--glow-cyan);
}

.crm-next-action input[type="date"] {
  color-scheme:dark;
  font-family:var(--mono);
  font-weight:600;
  flex:1;
  min-width:0;
}

.crm-next-action-controls {
  display:flex;
  align-items:center;
  gap:6px;
}

.crm-table-scroll {
  min-height:0;
  overflow:auto;
}

.crm-table-scroll::-webkit-scrollbar,
.crm-profile-body::-webkit-scrollbar,
.crm-card-list::-webkit-scrollbar {
  width:8px;
  height:8px;
}

.crm-table-scroll::-webkit-scrollbar-thumb,
.crm-profile-body::-webkit-scrollbar-thumb,
.crm-card-list::-webkit-scrollbar-thumb {
  background:rgba(82,212,239,.22);
  border-radius:999px;
}

.crm-table-scroll::-webkit-scrollbar-thumb:hover,
.crm-profile-body::-webkit-scrollbar-thumb:hover,
.crm-card-list::-webkit-scrollbar-thumb:hover {
  background:rgba(82,212,239,.38);
}

.crm-record-table {
  width:100%;
  min-width:0;
  border-collapse:collapse;
  table-layout:fixed;
  font:400 12.5px/1.35 var(--sans);
}

/* columns: 1 Name · 2 Source · 3 Stage · 4 Next action · 5 Updated · 6 Location */
.crm-record-table th:nth-child(1),
.crm-record-table td:nth-child(1) {
  width:30%;
}

.crm-record-table th:nth-child(2),
.crm-record-table td:nth-child(2) {
  width:16%;
}

.crm-record-table th:nth-child(3),
.crm-record-table td:nth-child(3) {
  width:12%;
}

.crm-record-table th:nth-child(4),
.crm-record-table td:nth-child(4) {
  width:22%;
}

.crm-record-table th:nth-child(5),
.crm-record-table td:nth-child(5) {
  width:10%;
}

.crm-record-table th:nth-child(6),
.crm-record-table td:nth-child(6) {
  width:10%;
}

.crm-record-table th {
  position:sticky;
  top:0;
  z-index:1;
  text-align:left;
  color:var(--cyan);
  background:rgba(8,11,18,.96);
  font:600 10px/1 var(--mono);
  text-transform:uppercase;
  letter-spacing:.12em;
  padding:10px 14px;
  border-bottom:1px solid var(--line-strong);
}

.crm-record-table td {
  color:var(--text-dim);
  padding:9px 14px;
  border-bottom:1px solid rgba(124,176,236,.06);
  vertical-align:middle;
}

.crm-record-table tbody tr {
  cursor:pointer;
  transition:background .12s ease;
}

.crm-record-table tbody tr:hover {
  background:rgba(82,212,239,.05);
}

.crm-record-table tbody tr.is-map-hover {
  background:rgba(243,196,90,.07);
  box-shadow:inset 3px 0 0 var(--amber);
}

.crm-record-table tbody tr.is-selected {
  background:rgba(82,212,239,.09);
  box-shadow:inset 3px 0 0 var(--cyan), inset 0 0 22px rgba(82,212,239,.06);
}

.crm-record-name {
  display:flex;
  align-items:center;
  gap:10px;
  min-width:0;
}

.crm-record-icon {
  width:27px;
  height:27px;
  display:grid;
  place-items:center;
  flex:0 0 auto;
  border-radius:7px;
  background:linear-gradient(140deg, rgba(82,212,239,.18), rgba(82,212,239,.06));
  border:1px solid rgba(82,212,239,.22);
  color:var(--cyan-bright);
  font:700 9px/1 var(--mono);
  letter-spacing:.03em;
}

.crm-record-name strong {
  display:block;
  color:var(--text);
  font:500 13px/1.25 var(--sans);
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.crm-record-name span {
  display:block;
  color:var(--text-faint);
  font-size:11px;
  margin-top:1px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.crm-source-chip {
  display:inline-flex;
  align-items:center;
  gap:7px;
  max-width:100%;
  color:var(--text-dim);
  font:500 11.5px/1.2 var(--mono);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.crm-source-chip::before {
  content:"";
  width:7px;
  height:7px;
  flex:0 0 auto;
  border-radius:50%;
  background:var(--green);
  box-shadow:0 0 8px rgba(84,224,160,.7);
  animation:crm-pulse 2.4s ease-out infinite;
}

.crm-source-chip[data-kind="fixture"]::before,
.crm-source-chip[data-kind="mapped"]::before,
.crm-source-chip[data-kind="local"]::before {
  background:var(--text-faint);
  box-shadow:none;
  animation:none;
}

.crm-source-chip[data-kind="imported"]::before {
  background:var(--blue);
  box-shadow:0 0 8px rgba(127,182,239,.6);
  animation:none;
}

.crm-source-chip a {
  color:inherit;
  text-decoration:none;
}

.crm-stage-pill {
  display:inline-flex;
  align-items:center;
  height:23px;
  max-width:100%;
  border-radius:999px;
  padding:0 10px;
  background:rgba(243,196,90,.13);
  border:1px solid rgba(243,196,90,.30);
  color:var(--amber);
  font:600 10.5px/1 var(--mono);
  letter-spacing:.04em;
  text-transform:uppercase;
  white-space:nowrap;
}

.crm-stage-pill.is-empty {
  background:transparent;
  border-color:transparent;
  padding:0;
  color:var(--text-faint);
}

.crm-muted {
  color:var(--text-faint);
  font-size:11.5px;
  font-family:var(--mono);
}

.crm-empty-state {
  padding:40px 24px;
  color:var(--text-dim);
  font-size:12.5px;
  line-height:1.5;
}

.crm-empty-state strong {
  display:block;
  color:var(--text);
  font:600 14px/1.3 var(--sans);
  margin-bottom:6px;
}

/* ---- map panel ---- */
.crm-map-panel {
  position:relative;
  min-width:0;
  min-height:0;
  height:100%;
  max-height:100%;
  border-radius:12px;
  overflow:hidden;
  pointer-events:none;
  contain:layout paint;
  container:crm-map-panel / size;
}

.crm-map-panel::before {
  content:"";
  position:absolute;
  inset:0;
  border:1px solid var(--line-strong);
  border-radius:12px;
  box-shadow:inset 0 0 36px rgba(5,7,12,.62), inset 0 0 0 1px rgba(95,199,216,.04);
  pointer-events:none;
  z-index:2;
}

.crm-map-panel::after {
  display:none;
}

.crm-fallback-map {
  position:absolute;
  inset:0;
  overflow:hidden;
  background:
    radial-gradient(120% 100% at 50% 50%, rgba(95,199,216,.045), transparent 70%),
    #080c14;
  border-radius:12px;
  pointer-events:auto;
}

body.crm-map-live .crm-fallback-map {
  display:none;
}

.crm-fallback-map::before {
  content:"";
  position:absolute;
  inset:11%;
  border:1px solid rgba(82,212,239,.14);
  border-radius:50%;
  transform:scaleX(1.65);
  box-shadow:0 0 40px rgba(82,212,239,.08);
}

.crm-fallback-map::after {
  content:"";
  position:absolute;
  left:8%;
  right:8%;
  top:50%;
  height:1px;
  background:rgba(82,212,239,.14);
}

.crm-fallback-pin {
  position:absolute;
  width:9px;
  height:9px;
  border:1px solid rgba(5,7,12,.9);
  border-radius:50%;
  background:var(--amber);
  box-shadow:0 0 8px rgba(243,196,90,.6);
  transform:translate(-50%, -50%);
  cursor:pointer;
}

.crm-fallback-pin.is-selected {
  width:13px;
  height:13px;
  background:var(--cyan-bright);
  box-shadow:0 0 0 4px rgba(82,212,239,.25), 0 0 14px rgba(82,212,239,.7);
}

.crm-fallback-pin.is-hovered {
  width:13px;
  height:13px;
  box-shadow:0 0 0 4px rgba(243,196,90,.22), 0 0 14px rgba(243,196,90,.72);
}

.crm-fallback-label {
  position:absolute;
  left:12px;
  top:52px;
  right:12px;
  color:var(--text-faint);
  font:400 11px/1.35 var(--mono);
  pointer-events:none;
}

.crm-map-tools {
  position:absolute;
  left:12px;
  top:12px;
  z-index:3;
  display:flex;
  align-items:center;
  gap:2px;
  padding:3px;
  border-radius:9px;
  background:rgba(8,11,18,.86);
  border:1px solid var(--line-strong);
  backdrop-filter:blur(10px);
}

.crm-map-tools button {
  height:27px;
  border:0;
  border-radius:6px;
  background:transparent;
  color:var(--text-dim);
  font:600 11px/1 var(--mono);
  letter-spacing:.03em;
  padding:0 11px;
  cursor:pointer;
  transition:background .16s ease, color .16s ease;
}

.crm-map-tools button:hover {
  background:var(--cyan-soft);
  color:var(--cyan-bright);
}

.crm-map-zoom {
  position:absolute;
  top:12px;
  right:12px;
  z-index:3;
  display:flex;
  align-items:center;
  gap:4px;
  pointer-events:auto;
}

.crm-map-zoom button {
  min-width:30px;
  height:30px;
  border:1px solid var(--line-strong);
  border-radius:8px;
  background:rgba(8,11,18,.86);
  color:var(--text-dim);
  font:650 11px/1 var(--sans);
  padding:0 9px;
  cursor:pointer;
  backdrop-filter:blur(10px);
  transition:background .16s ease, color .16s ease, border-color .16s ease;
}

.crm-map-zoom button:hover {
  border-color:rgba(95,199,216,.42);
  background:rgba(95,199,216,.10);
  color:var(--cyan-bright);
}

.crm-map-legend {
  position:absolute;
  right:12px;
  bottom:64px;
  z-index:3;
  display:flex;
  align-items:center;
  justify-content:flex-end;
  flex-wrap:wrap;
  gap:7px 9px;
  max-width:min(360px, calc(100% - 24px));
  padding:8px 10px;
  border:1px solid var(--line-strong);
  border-radius:9px;
  background:rgba(8,11,18,.86);
  color:var(--text-dim);
  font:600 10.5px/1.15 var(--mono);
  letter-spacing:.03em;
  backdrop-filter:blur(10px);
  box-shadow:0 8px 24px rgba(0,0,0,.34);
  pointer-events:none;
}

.crm-legend-title {
  color:var(--text-faint);
  text-transform:uppercase;
  letter-spacing:.08em;
}

.crm-legend-item {
  display:inline-flex;
  align-items:center;
  gap:5px;
  white-space:nowrap;
}

.crm-legend-item i {
  width:8px;
  height:8px;
  border-radius:50%;
  flex:0 0 auto;
  box-shadow:0 0 8px currentColor;
}

.crm-map-status {
  position:absolute;
  left:12px;
  bottom:12px;
  right:auto;
  z-index:3;
  display:flex;
  align-items:center;
  gap:12px;
  padding:9px 13px;
  border-radius:9px;
  background:rgba(8,11,18,.86);
  border:1px solid var(--line-strong);
  backdrop-filter:blur(10px);
  box-shadow:0 8px 24px rgba(0,0,0,.4);
}

.crm-map-status strong {
  display:block;
  color:var(--text);
  font:500 12px/1.2 var(--sans);
}

.crm-map-status span {
  display:block;
  margin-top:1px;
  color:var(--text-faint);
  font:400 11px/1.3 var(--mono);
}

.crm-map-status b {
  color:var(--cyan-bright);
  font:700 16px/1 var(--mono);
  font-variant-numeric:tabular-nums;
  text-shadow:var(--glow-cyan);
}

@container crm-map-panel (max-height: 220px) {
  .crm-map-legend,
  .crm-map-status {
    display:none;
  }
}

@container crm-map-panel (max-width: 520px) {
  .crm-map-legend {
    left:12px;
    right:12px;
    justify-content:flex-start;
  }
}

/* ---- profile drawer ---- */
.crm-profile-drawer {
  position:fixed;
  top:16px;
  right:16px;
  bottom:16px;
  width:min(424px, calc(100vw - 88px));
  z-index:90;
  display:grid;
  grid-template-rows:auto minmax(0, 1fr);
  background:
    linear-gradient(180deg, rgba(82,212,239,.05), transparent 140px),
    rgba(9,13,20,.92);
  backdrop-filter:blur(16px);
  border:1px solid var(--line-strong);
  border-radius:14px;
  box-shadow:0 24px 70px rgba(0,0,0,.6), 0 0 0 1px rgba(82,212,239,.06), inset 0 0 40px rgba(82,212,239,.03);
  transform:translateX(calc(100% + 28px));
  transition:transform .24s cubic-bezier(.22,.61,.36,1);
  overflow:hidden;
}

.crm-profile-drawer.is-open {
  transform:translateX(0);
  transition:none;
}

.crm-profile-drawer::before {
  content:"";
  position:absolute;
  top:9px;
  left:9px;
  width:15px;
  height:15px;
  border:1.5px solid rgba(82,212,239,.55);
  border-right:0;
  border-bottom:0;
  border-top-left-radius:4px;
  pointer-events:none;
  z-index:3;
}

.crm-profile-head {
  position:relative;
  padding:16px 16px 14px;
  border-bottom:1px solid var(--line);
}

.crm-profile-actions {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin-bottom:13px;
}

.crm-profile-window-controls {
  display:flex;
  align-items:center;
  gap:4px;
  flex:0 0 auto;
}

.crm-profile-actions span {
  color:var(--cyan);
  font:600 10px/1 var(--mono);
  text-transform:uppercase;
  letter-spacing:.14em;
}

.crm-collapse-button,
.crm-close-button {
  width:27px;
  height:27px;
  border:1px solid transparent;
  border-radius:7px;
  background:transparent;
  color:var(--text-dim);
  font:400 15px/1 var(--sans);
  cursor:pointer;
  transition:background .16s ease, color .16s ease, border-color .16s ease;
}

.crm-collapse-button:hover,
.crm-close-button:hover {
  background:var(--cyan-soft);
  color:var(--cyan-bright);
  border-color:var(--line-strong);
}

.crm-profile-drawer.is-collapsed {
  width:64px;
  grid-template-rows:minmax(0, 1fr);
  overflow:hidden;
}

.crm-profile-drawer.is-collapsed .crm-profile-head {
  display:grid;
  align-content:start;
  padding:14px 10px;
  border-bottom:0;
}

.crm-profile-drawer.is-collapsed .crm-profile-actions {
  height:100%;
  display:grid;
  justify-items:center;
  align-content:start;
  gap:12px;
  margin:0;
}

.crm-profile-drawer.is-collapsed .crm-profile-actions span {
  max-height:calc(100vh - 132px);
  writing-mode:vertical-rl;
  transform:rotate(180deg);
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.crm-profile-drawer.is-collapsed .crm-profile-window-controls {
  flex-direction:column;
}

.crm-profile-drawer.is-collapsed .crm-profile-title,
.crm-profile-drawer.is-collapsed .crm-profile-body,
.crm-profile-drawer.is-collapsed::before {
  display:none;
}

.crm-profile-title {
  display:flex;
  align-items:flex-start;
  gap:12px;
}

.crm-profile-title .crm-record-icon {
  width:36px;
  height:36px;
  border-radius:9px;
  font-size:10px;
}

.crm-profile-title h2 {
  margin:0;
  color:var(--text);
  font:600 16px/1.25 var(--sans);
  letter-spacing:.005em;
}

.crm-profile-title p {
  margin:3px 0 0;
  color:var(--text-dim);
  font:400 12px/1.4 var(--mono);
}

.crm-profile-body {
  overflow:auto;
  padding:15px 16px 16px;
}

.crm-section {
  margin-bottom:17px;
}

.crm-section h3 {
  margin:0 0 8px;
  color:var(--cyan);
  font:600 10px/1.2 var(--mono);
  text-transform:uppercase;
  letter-spacing:.14em;
}

.crm-import-form {
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:9px;
}

.crm-import-form label {
  display:grid;
  gap:5px;
  min-width:0;
}

.crm-import-form label.is-wide {
  grid-column:1 / -1;
}

.crm-import-form label > span {
  color:var(--text-faint);
  font:600 9.5px/1 var(--mono);
  text-transform:uppercase;
  letter-spacing:.1em;
}

.crm-import-form input,
.crm-import-form select,
.crm-import-form textarea {
  width:100%;
  min-width:0;
  border:1px solid var(--line);
  border-radius:8px;
  background:var(--surface-raised);
  color:var(--text);
  font:500 12px/1.3 var(--sans);
  padding:9px 10px;
  box-sizing:border-box;
  outline:none;
  transition:border-color .16s ease, background .16s ease;
}

.crm-import-form select {
  cursor:pointer;
}

.crm-import-form textarea {
  resize:vertical;
  min-height:74px;
}

.crm-import-form input::placeholder,
.crm-import-form textarea::placeholder {
  color:var(--text-faint);
}

.crm-import-form input:focus,
.crm-import-form select:focus,
.crm-import-form textarea:focus {
  border-color:rgba(82,212,239,.5);
  background:rgba(82,212,239,.055);
}

.crm-import-form-actions {
  grid-column:1 / -1;
  display:flex;
  align-items:center;
  flex-wrap:wrap;
  gap:9px;
}

.crm-import-form-actions span {
  color:var(--text-faint);
  font:500 11px/1.35 var(--mono);
}

.crm-provenance-line {
  display:flex;
  align-items:center;
  flex-wrap:wrap;
  gap:8px;
  color:var(--text-dim);
  font:400 12px/1.4 var(--mono);
}

.crm-source-audit {
  display:grid;
  gap:8px;
}

.crm-source-audit-meta {
  display:flex;
  flex-wrap:wrap;
  gap:6px;
}

.crm-source-audit-meta span {
  min-width:0;
  border:1px solid var(--line);
  border-radius:999px;
  background:rgba(255,255,255,.035);
  color:var(--text-faint);
  font:600 10.5px/1 var(--mono);
  padding:6px 8px;
  overflow-wrap:anywhere;
}

.crm-source-gates {
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:7px;
}

.crm-source-gate {
  border:1px solid var(--line);
  border-radius:9px;
  background:var(--surface-raised);
  padding:9px 10px;
}

.crm-source-gate b {
  display:flex;
  align-items:center;
  gap:6px;
  color:var(--text-dim);
  font:600 10.5px/1.2 var(--mono);
}

.crm-source-gate b::before {
  content:"";
  width:7px;
  height:7px;
  flex:0 0 7px;
  border-radius:999px;
  background:var(--text-faint);
}

.crm-source-gate span {
  display:block;
  color:var(--text-faint);
  font:400 11.5px/1.35 var(--sans);
  margin-top:5px;
  overflow-wrap:anywhere;
}

.crm-source-gate[data-status="ready"] {
  border-color:rgba(84,224,160,.25);
}

.crm-source-gate[data-status="ready"] b::before {
  background:var(--green);
}

.crm-source-gate[data-status="partial"],
.crm-source-gate[data-status="mapped"] {
  border-color:rgba(82,212,239,.25);
}

.crm-source-gate[data-status="partial"] b::before,
.crm-source-gate[data-status="mapped"] b::before {
  background:var(--cyan);
}

.crm-source-gate[data-status="gap"] {
  border-color:rgba(224,154,90,.28);
}

.crm-source-gate[data-status="gap"] b::before {
  background:#e09a5a;
}

.crm-source-gate[data-status="locked"] {
  border-color:rgba(216,179,106,.32);
  background:rgba(216,179,106,.055);
}

.crm-source-gate[data-status="locked"] b::before {
  background:var(--gold);
}

.crm-source-links {
  display:flex;
  flex-wrap:wrap;
  gap:6px;
}

.crm-source-links a,
.crm-source-links.is-empty {
  border:1px solid var(--line);
  border-radius:999px;
  background:rgba(255,255,255,.035);
  color:var(--cyan);
  font:600 10.5px/1 var(--mono);
  padding:7px 9px;
  text-decoration:none;
}

.crm-source-links a:hover {
  border-color:rgba(82,212,239,.45);
  color:var(--cyan-bright);
}

.crm-source-links.is-empty {
  color:var(--text-faint);
}

.crm-facts-grid {
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:7px;
}

.crm-fact {
  border:1px solid var(--line);
  border-radius:9px;
  background:var(--surface-raised);
  padding:10px 11px;
  box-sizing:border-box;
}

.crm-fact span {
  display:block;
  color:var(--text-faint);
  font:600 9.5px/1 var(--mono);
  text-transform:uppercase;
  letter-spacing:.1em;
  margin-bottom:5px;
}

.crm-fact b {
  display:block;
  color:var(--text);
  font:500 12.5px/1.35 var(--sans);
  overflow-wrap:anywhere;
}

.crm-pipeline {
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(64px, 1fr));
  gap:4px;
}

.crm-pipeline-step {
  height:31px;
  display:grid;
  place-items:center;
  border-radius:8px;
  background:var(--surface-raised);
  border:1px solid var(--line);
  color:var(--text-faint);
  font:600 10.5px/1 var(--mono);
  letter-spacing:.03em;
  text-align:center;
  transition:all .16s ease;
}

.crm-pipeline-step.is-active {
  background:linear-gradient(140deg, var(--cyan), #2ba9c6);
  border-color:rgba(134,233,255,.6);
  color:#03161c;
  font-weight:700;
  box-shadow:var(--glow-cyan);
}

.crm-route-list,
.crm-related-list,
.crm-timeline {
  display:grid;
  gap:7px;
}

.crm-route,
.crm-related,
.crm-update {
  border:1px solid var(--line);
  background:var(--surface-raised);
  border-radius:9px;
  padding:10px 12px;
  color:var(--text-dim);
  font:400 12.5px/1.4 var(--sans);
  text-align:left;
}

button.crm-update {
  width:100%;
  cursor:pointer;
  transition:border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

button.crm-update:hover {
  border-color:rgba(82,212,239,.45);
  background:rgba(82,212,239,.05);
  box-shadow:var(--glow-cyan);
}

.crm-agent-candidates {
  display:grid;
  gap:8px;
}

.crm-agent-candidate {
  display:grid;
  gap:5px;
  min-height:76px;
}

.crm-agent-queue-item {
  display:grid;
  gap:5px;
  min-height:74px;
}

.crm-agent-candidate b,
.crm-agent-candidate span,
.crm-agent-queue-item b,
.crm-agent-queue-item span {
  overflow-wrap:anywhere;
}

.crm-agent-candidate.is-active,
.crm-agent-queue-item.is-active {
  border-color:rgba(84,224,160,.62);
  background:rgba(84,224,160,.08);
  box-shadow:0 0 0 1px rgba(84,224,160,.12) inset;
  cursor:default;
}

.crm-agent-candidate:disabled,
.crm-agent-queue-item:disabled {
  opacity:1;
}

.crm-ledger-task-match {
  display:flex;
  align-items:center;
  gap:8px;
  flex-wrap:wrap;
  margin-top:7px;
}

.crm-ledger-task-match .crm-action-button {
  min-height:28px;
  padding:0 10px;
}

.crm-ledger-task-match span {
  color:var(--text-faint);
  font:600 10.5px/1.35 var(--mono);
  overflow-wrap:anywhere;
}

.crm-related-card {
  border:1px solid var(--line);
  background:var(--surface-raised);
  border-radius:9px;
  overflow:hidden;
}

.crm-related-card .crm-related {
  border:0;
  border-radius:0;
  background:transparent;
}

.crm-related-card[data-source="saved"] {
  border-color:rgba(216,179,106,.38);
  background:rgba(216,179,106,.07);
}

.crm-related-meta {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  padding:0 8px 8px 12px;
}

.crm-related-meta > span {
  color:var(--text-faint);
  font:600 10.5px/1.2 var(--mono);
  letter-spacing:.02em;
}

.crm-relation-save {
  height:26px;
  padding:0 9px;
  font-size:10.5px;
}

.crm-relation-save:disabled {
  cursor:default;
  color:#f0d99d;
  border-color:rgba(216,179,106,.35);
  background:rgba(216,179,106,.10);
  box-shadow:none;
}

button.crm-related {
  cursor:pointer;
  width:100%;
  transition:border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

button.crm-related:hover {
  border-color:rgba(82,212,239,.45);
  background:rgba(82,212,239,.05);
  box-shadow:var(--glow-cyan);
}

.crm-route b {
  color:var(--text-dim);
  font-weight:600;
  margin-right:6px;
  font-family:var(--mono);
  font-size:11px;
}

.crm-route span,
.crm-related span,
.crm-update span {
  display:block;
  color:var(--text-faint);
  font-size:11px;
  margin-top:2px;
}

.crm-route a {
  color:var(--cyan);
  text-decoration:none;
  overflow-wrap:anywhere;
}

.crm-route a:hover {
  color:var(--cyan-bright);
  text-decoration:underline;
}

.crm-drawer-actions {
  display:flex;
  flex-wrap:wrap;
  gap:6px;
}

.crm-action-button {
  height:31px;
  border:1px solid var(--line-strong);
  border-radius:8px;
  background:var(--surface-glass);
  color:var(--text-dim);
  font:600 11.5px/1 var(--mono);
  letter-spacing:.02em;
  padding:0 12px;
  cursor:pointer;
  transition:background .16s ease, color .16s ease, border-color .16s ease, box-shadow .16s ease;
}

.crm-action-button:hover {
  color:var(--cyan-bright);
  border-color:rgba(82,212,239,.45);
  box-shadow:var(--glow-cyan);
}

.crm-action-button.primary {
  border-color:transparent;
  background:linear-gradient(140deg, #f5cf6c, #d8b36a);
  color:var(--amber-deep);
  font-weight:700;
  box-shadow:var(--glow-amber);
}

.crm-action-button.primary:hover {
  color:var(--amber-deep);
  filter:brightness(1.08);
  box-shadow:0 0 22px rgba(243,196,90,.45);
}

/* ---- table footer / pager ---- */
.crm-table-footer {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:9px 14px;
  border-top:1px solid var(--line);
}

.crm-table-footer span {
  color:var(--text-faint);
  font:400 11.5px/1.3 var(--mono);
  font-variant-numeric:tabular-nums;
}

.crm-pager {
  display:flex;
  gap:4px;
}

.crm-pager button {
  height:27px;
  border:1px solid var(--line-strong);
  border-radius:7px;
  background:var(--surface-glass);
  color:var(--text-dim);
  font:600 11px/1 var(--mono);
  letter-spacing:.03em;
  padding:0 12px;
  cursor:pointer;
  transition:background .16s ease, color .16s ease, border-color .16s ease, box-shadow .16s ease;
}

.crm-pager button:hover:not(:disabled) {
  color:var(--cyan-bright);
  border-color:rgba(82,212,239,.45);
  box-shadow:var(--glow-cyan);
}

.crm-pager button:disabled {
  opacity:.3;
  cursor:default;
}

.crm-sort-button {
  display:inline-flex;
  align-items:center;
  gap:5px;
  border:0;
  background:transparent;
  color:inherit;
  font:inherit;
  text-transform:inherit;
  letter-spacing:inherit;
  padding:0;
  cursor:pointer;
}

.crm-sort-button:hover {
  color:var(--cyan-bright);
}

.crm-sort-button::after {
  content:"\2191";
  font-size:10px;
  line-height:1;
  opacity:0;
  transition:opacity .16s ease;
}

.crm-sort-button.is-sorted {
  color:var(--cyan-bright);
  text-shadow:var(--glow-cyan);
}

.crm-sort-button.is-sorted::after {
  opacity:1;
}

.crm-sort-button.is-sorted.is-desc::after {
  content:"\2193";
}

.crm-drawer-status {
  margin-bottom:12px;
  border:1px solid rgba(84,224,160,.40);
  border-radius:9px;
  background:rgba(84,224,160,.10);
  color:#9fe6c2;
  font:400 12px/1.45 var(--sans);
  padding:9px 12px;
  box-shadow:0 0 16px rgba(84,224,160,.12);
}

.crm-drawer-status[data-tone="error"] {
  border-color:rgba(230,138,128,.45);
  background:rgba(230,138,128,.10);
  color:#e9aaa2;
  box-shadow:0 0 16px rgba(230,138,128,.12);
}

.crm-activity-form {
  margin-top:8px;
  display:grid;
  gap:7px;
}

.crm-activity-form textarea {
  width:100%;
  box-sizing:border-box;
  border:1px solid var(--line);
  border-radius:9px;
  background:var(--surface-glass);
  color:var(--text);
  font:400 12.5px/1.45 var(--sans);
  padding:9px 12px;
  resize:vertical;
  min-height:62px;
  outline:none;
  transition:border-color .16s ease, box-shadow .16s ease;
}

.crm-activity-form textarea:focus {
  border-color:rgba(82,212,239,.55);
  box-shadow:var(--glow-cyan);
}

.crm-activity-controls {
  display:flex;
  align-items:center;
  gap:6px;
}

.crm-activity-controls select {
  height:31px;
  flex:1;
  min-width:0;
  border:1px solid var(--line);
  border-radius:8px;
  background:var(--surface-glass);
  color:var(--text-dim);
  font:600 11.5px/1 var(--mono);
  padding:0 9px;
  outline:none;
}

.crm-update-head {
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  gap:10px;
}

.crm-update-head b {
  color:var(--text-dim);
  font:600 10px/1 var(--mono);
  text-transform:uppercase;
  letter-spacing:.08em;
}

.crm-update-head span {
  margin-top:0;
  white-space:nowrap;
}

.crm-update p {
  margin:5px 0 0;
  color:var(--text);
  overflow-wrap:anywhere;
}

.crm-update[data-kind="stage_change"] .crm-update-head b {
  color:var(--cyan-bright);
}

.crm-update-stage {
  margin-top:5px;
  color:var(--cyan-bright);
  font:600 12px/1.3 var(--mono);
}

.crm-related-pivot {
  width:100%;
  text-align:center;
}

.crm-mobile-tabs {
  display:none;
}

@media (min-width: 1101px) {
  .crm-main {
    position:relative;
    overflow:hidden;
    background:
      linear-gradient(90deg, rgba(5,7,12,.98) 0%, rgba(5,7,12,.82) 32%, rgba(5,7,12,.18) 56%, rgba(5,7,12,.06) 100%),
      radial-gradient(90% 80% at 78% 38%, rgba(95,199,216,.08), transparent 62%);
  }

  .crm-home,
  .crm-summary-row,
  .crm-views-bar {
    position:absolute;
    z-index:8;
  }

  .crm-home {
    top:66px;
    left:calc(34% + 28px);
    right:20px;
    width:auto;
    min-height:0;
    grid-template-columns:minmax(360px, 1fr) minmax(230px, .42fr);
    align-items:start;
    gap:10px;
    pointer-events:none;
  }

  .crm-command-panel,
  .crm-reactive-panel {
    background:
      linear-gradient(180deg, rgba(95,199,216,.035), transparent 130px),
      rgba(7,10,16,.62);
    backdrop-filter:blur(14px);
    pointer-events:auto;
  }

  .crm-command-panel {
    min-height:0;
    max-height:232px;
    grid-template-rows:auto auto minmax(0, auto) auto auto;
    gap:8px;
    padding:13px 14px;
  }

  .crm-command-panel h2 {
    font-size:21px;
    line-height:1.08;
  }

  .crm-command-log {
    min-height:0;
    max-height:66px;
  }

  .crm-command-form textarea {
    min-height:46px;
    max-height:76px;
    padding:9px 11px;
  }

  .crm-command-form button {
    height:38px;
  }

  .crm-command-suggestions {
    max-height:32px;
    overflow:hidden;
  }

  .crm-reactive-panel {
    min-height:0;
    max-height:232px;
    padding:12px;
    gap:9px;
    overflow:hidden;
  }

  #crmReactiveMeta {
    display:-webkit-box;
    -webkit-line-clamp:2;
    -webkit-box-orient:vertical;
    overflow:hidden;
  }

  .crm-reactive-cards {
    grid-template-columns:repeat(2, minmax(0, 1fr));
    gap:7px;
  }

  .crm-reactive-card {
    min-height:58px;
    padding:9px;
    gap:4px;
  }

  .crm-reactive-card small {
    display:none;
  }

  #crmShell.is-drawer-open .crm-home {
    right:462px;
    grid-template-columns:minmax(360px, 1fr);
  }

  #crmShell.is-drawer-open .crm-reactive-panel {
    display:none;
  }

  #crmShell.is-drawer-open.is-drawer-collapsed .crm-home {
    right:96px;
    grid-template-columns:minmax(360px, 1fr) minmax(230px, .42fr);
  }

  #crmShell.is-drawer-open.is-drawer-collapsed .crm-reactive-panel {
    display:grid;
  }

  .crm-summary-row {
    top:66px;
    left:18px;
    width:min(500px, calc(34vw - 24px));
    grid-template-columns:1fr;
    gap:9px;
  }

  .crm-domain-title {
    grid-template-columns:1fr;
  }

  .crm-stage-bar {
    justify-content:flex-start;
  }

  .crm-source-backbone {
    grid-template-columns:repeat(2, minmax(0, 1fr));
  }

  .crm-source-backbone-card {
    background:rgba(7,10,16,.70);
    backdrop-filter:blur(12px);
  }

  .crm-views-bar {
    left:18px;
    top:444px;
    width:min(500px, calc(34vw - 24px));
    z-index:9;
  }

  .crm-workspace {
    flex:1 1 auto;
    height:100%;
    min-height:0;
    grid-template-columns:minmax(390px, 34%) minmax(0, 1fr);
    gap:14px;
  }

  .crm-workspace[data-view="split"] .crm-table-panel {
    margin-top:424px;
    max-height:calc(100% - 424px);
  }

  .crm-workspace[data-view="split"] .crm-record-table th:nth-child(6),
  .crm-workspace[data-view="split"] .crm-record-table td:nth-child(6) {
    display:none;
  }

  .crm-workspace[data-view="split"] .crm-record-table th:nth-child(1),
  .crm-workspace[data-view="split"] .crm-record-table td:nth-child(1) {
    width:30%;
  }

  .crm-workspace[data-view="split"] .crm-record-table th:nth-child(2),
  .crm-workspace[data-view="split"] .crm-record-table td:nth-child(2) {
    width:28%;
  }

  .crm-workspace[data-view="split"] .crm-record-table th:nth-child(3),
  .crm-workspace[data-view="split"] .crm-record-table td:nth-child(3) {
    width:12%;
  }

  .crm-workspace[data-view="split"] .crm-record-table th:nth-child(4),
  .crm-workspace[data-view="split"] .crm-record-table td:nth-child(4) {
    width:20%;
  }

  .crm-workspace[data-view="split"] .crm-record-table th:nth-child(5),
  .crm-workspace[data-view="split"] .crm-record-table td:nth-child(5) {
    width:10%;
  }

  .crm-workspace[data-view="map"] .crm-map-panel,
  .crm-workspace[data-view="split"] .crm-map-panel {
    min-height:0;
    height:100%;
  }

  .crm-map-panel {
    box-shadow:0 18px 54px rgba(0,0,0,.24);
  }
}

/* ---- responsive ---- */
@media (max-width: 1100px) {
  .crm-main {
    background:
      radial-gradient(120% 60% at 12% -10%, rgba(82,212,239,.10), transparent 55%),
      rgba(5,7,12,.96);
  }

  .crm-workspace {
    grid-template-columns:1fr;
  }

  .crm-map-panel {
    min-height:260px;
  }

  .crm-topbar {
    grid-template-columns:1fr auto auto;
  }

  .crm-view-switch {
    grid-column:2;
  }

  .crm-data-menu {
    grid-column:3;
  }

  .crm-source-backbone {
    grid-template-columns:repeat(2, minmax(0, 1fr));
  }

  .crm-summary-row {
    grid-template-columns:1fr;
  }

  .crm-stage-bar {
    justify-content:flex-start;
  }

  .crm-source-backbone-card:last-child {
    grid-column:auto;
  }
}

@media (max-width: 1500px) {
  /* drop Location (6) first */
  .crm-record-table th:nth-child(6),
  .crm-record-table td:nth-child(6) {
    display:none;
  }

  .crm-record-table th:nth-child(1),
  .crm-record-table td:nth-child(1) {
    width:30%;
  }

  .crm-record-table th:nth-child(4),
  .crm-record-table td:nth-child(4) {
    width:24%;
  }
}

@media (max-width: 1200px) {
  /* then drop Updated (5), keeping Name / Source / Stage / Next action */
  .crm-record-table th:nth-child(5),
  .crm-record-table td:nth-child(5) {
    display:none;
  }

  .crm-record-table th:nth-child(1),
  .crm-record-table td:nth-child(1) {
    width:33%;
  }

  .crm-record-table th:nth-child(2),
  .crm-record-table td:nth-child(2) {
    width:13%;
  }

  .crm-record-table th:nth-child(3),
  .crm-record-table td:nth-child(3) {
    width:13%;
  }

  .crm-record-table th:nth-child(4),
  .crm-record-table td:nth-child(4) {
    width:28%;
  }
}

@media (max-width: 1380px) and (min-width: 901px) {
  .crm-table-head {
    align-items:flex-start;
    flex-direction:column;
    justify-content:flex-start;
    gap:10px;
  }

  .crm-table-head > div:first-child {
    max-width:100%;
  }

  .crm-table-head-tools {
    flex:none;
    width:100%;
    display:grid;
    grid-template-columns:repeat(3, minmax(0, 1fr));
    gap:8px;
  }

  .crm-table-head-tools > * {
    min-width:0;
  }

  #crmSourceFilter,
  #crmEvidenceFilter,
  #crmDueFilter,
  .crm-place-filter {
    width:100%;
    min-width:0;
    max-width:none;
    flex-basis:auto;
  }

  .crm-table-head .crm-count-pill {
    justify-self:start;
  }
}

@media (max-width: 900px) {
  .crm-main {
    overflow-x:hidden;
    overflow-y:auto;
  }

  .crm-source-backbone {
    grid-template-columns:1fr;
  }

  .crm-source-backbone-card:last-child {
    grid-column:auto;
  }

  .crm-workspace[data-view="split"] {
    grid-template-columns:1fr;
  }

  .crm-workspace[data-view="split"] .crm-map-panel {
    display:block;
    order:-1;
    height:320px;
    min-height:320px;
  }

  .crm-workspace {
    flex:0 0 auto;
    min-height:960px;
  }

  .crm-table-panel {
    min-height:620px;
  }

  .crm-table-head {
    align-items:flex-start;
    flex-direction:column;
    gap:12px;
  }

  .crm-table-head-tools {
    flex:none;
    width:100%;
    display:grid;
    grid-template-columns:minmax(0, 1fr) minmax(0, 1fr);
    align-items:center;
  }

  .crm-select-page,
  .crm-table-head .crm-count-pill {
    grid-column:auto;
  }

  #crmSourceFilter,
  #crmEvidenceFilter,
  #crmDueFilter,
  .crm-place-filter {
    width:100%;
    min-width:0;
    max-width:none;
    flex-basis:auto;
  }

  .crm-record-table thead {
    display:none;
  }

  .crm-record-table,
  .crm-record-table tbody,
  .crm-record-table tr,
  .crm-record-table td {
    display:block;
    width:auto !important;
  }

  .crm-record-table {
    table-layout:auto;
  }

  .crm-record-table tbody {
    display:grid;
    gap:10px;
    padding:10px;
  }

  .crm-record-table tbody tr {
    display:grid;
    gap:9px;
    padding:11px;
    border:1px solid rgba(124,176,236,.10);
    border-radius:10px;
    background:rgba(7,10,16,.62);
  }

  .crm-record-table tbody tr:hover,
  .crm-record-table tbody tr.is-selected,
  .crm-record-table tbody tr.is-checked {
    background:rgba(82,212,239,.07);
  }

  .crm-record-table td {
    padding:0;
    border-bottom:0;
  }

  .crm-record-table td:not(:first-child) {
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:12px;
    min-height:22px;
  }

  .crm-record-table td:nth-child(2)::before { content:"Source"; }
  .crm-record-table td:nth-child(3)::before { content:"Stage"; }
  .crm-record-table td:nth-child(4)::before { content:"Next"; }
  .crm-record-table td:nth-child(5)::before { content:"Updated"; }
  .crm-record-table td:nth-child(6)::before { content:"Place"; }

  .crm-record-table td:not(:first-child)::before {
    color:var(--text-faint);
    font:600 10px/1 var(--mono);
    letter-spacing:.10em;
    text-transform:uppercase;
  }

  .crm-record-name {
    align-items:flex-start;
  }

  .crm-record-name strong {
    white-space:normal;
  }

  .crm-source-chip {
    justify-content:flex-end;
    min-width:0;
    white-space:normal;
    text-align:right;
  }

  .crm-due-cell {
    align-items:flex-end;
  }
}

@media (max-width: 900px) {
  #crmShell {
    grid-template-columns:1fr;
    grid-template-rows:minmax(0, 1fr) 54px;
  }

  .crm-rail {
    grid-row:2;
    display:grid;
    grid-template-columns:minmax(0, 1fr) 44px;
    align-items:center;
    gap:8px;
    padding:6px 10px;
    border-right:0;
    border-top:1px solid var(--line);
  }

  .crm-rail::after {
    display:none;
  }

  .crm-mark,
  .crm-settings-button {
    display:none;
  }

  #crmDomainButtons {
    width:100%;
    min-width:0;
    display:grid;
    grid-template-columns:repeat(7, minmax(0, 1fr));
    gap:6px;
  }

  .crm-domain-button,
  .crm-system-button {
    width:100%;
    height:38px;
    min-width:0;
    overflow:hidden;
  }

  .crm-system-button {
    margin-top:0;
  }

  .crm-domain-button.is-active::before,
  .crm-system-button.is-active::before {
    display:none;
  }

  .crm-main {
    grid-row:1;
    padding:10px 10px 12px;
    gap:10px;
  }

  .crm-topbar {
    grid-template-columns:1fr;
  }

  .crm-view-switch {
    grid-column:auto;
    width:100%;
    justify-content:stretch;
  }

  .crm-data-menu {
    grid-column:auto;
    justify-self:stretch;
  }

  .crm-data-menu summary {
    width:100%;
  }

  .crm-data-menu-panel {
    left:0;
    right:0;
    width:auto;
  }

  .crm-view-switch button {
    flex:1;
  }

  .crm-command-panel h2 {
    font-size:20px;
  }

  .crm-table-head-tools {
    grid-template-columns:repeat(3, minmax(0, 1fr));
  }

  .crm-domain-title {
    grid-template-columns:1fr;
    gap:4px;
  }

  .crm-domain-title h1 {
    font-size:16px;
    white-space:normal;
  }

  .crm-domain-title p {
    font-size:11px;
  }

  .crm-source-backbone {
    grid-template-columns:repeat(2, minmax(0, 1fr));
  }

  #crmSourceGate {
    max-height:3.8em;
    overflow:hidden;
  }
}

@media (max-width: 760px) {
  #crmShell {
    grid-template-columns:1fr;
    grid-template-rows:minmax(0, 1fr) 54px;
  }

  .crm-rail {
    grid-row:2;
    display:grid;
    grid-template-columns:minmax(0, 1fr) 44px;
    align-items:center;
    gap:8px;
    padding:6px 10px;
    border-right:0;
    border-top:1px solid var(--line);
  }

  .crm-rail::after {
    display:none;
  }

  .crm-mark,
  .crm-settings-button {
    display:none;
  }

  #crmDomainButtons {
    width:100%;
    min-width:0;
    display:grid;
    grid-template-columns:repeat(7, minmax(0, 1fr));
    gap:6px;
  }

  .crm-domain-button,
  .crm-system-button {
    width:100%;
    height:38px;
    min-width:0;
    overflow:hidden;
  }

  .crm-system-button {
    margin-top:0;
  }

  .crm-domain-button.is-active::before,
  .crm-system-button.is-active::before {
    display:none;
  }

  .crm-main {
    grid-row:1;
    padding:10px 10px 12px;
    gap:10px;
    overflow-x:hidden;
    overflow-y:auto;
  }

  .crm-topbar {
    grid-template-columns:1fr;
  }

  .crm-home {
    gap:10px;
    grid-template-columns:1fr;
  }

  .crm-command-panel,
  .crm-reactive-panel {
    padding:12px;
  }

  .crm-command-log {
    max-height:120px;
  }

  .crm-command-message {
    grid-template-columns:1fr;
    gap:3px;
  }

  .crm-command-form {
    grid-template-columns:1fr;
  }

  .crm-command-form button {
    width:100%;
  }

  .crm-reactive-head {
    display:grid;
  }

  .crm-reactive-cards {
    grid-template-columns:1fr;
  }

  .crm-table-head-tools {
    grid-template-columns:1fr;
  }

  .crm-view-switch {
    grid-column:auto;
    width:100%;
    justify-content:stretch;
  }

  .crm-data-menu {
    grid-column:auto;
    justify-self:stretch;
  }

  .crm-data-menu summary {
    width:100%;
  }

  .crm-data-menu-panel {
    left:0;
    right:0;
    width:auto;
  }

  .crm-view-switch button {
    flex:1;
  }

  .crm-summary-row {
    grid-template-columns:1fr;
    gap:10px;
  }

  .crm-source-backbone {
    grid-template-columns:1fr;
  }

  .crm-workspace {
    flex:0 0 auto;
    min-height:720px;
  }

  .crm-table-panel {
    min-height:720px;
  }

  .crm-stage-bar {
    justify-content:flex-start;
    overflow:auto;
    flex-wrap:nowrap;
    padding:0 10px 4px 0;
    scroll-padding-inline:10px;
  }

  .crm-stage-chip {
    flex:0 0 auto;
    max-width:none;
  }

  .crm-domain-title {
    grid-template-columns:1fr;
    gap:4px;
  }

  .crm-domain-title h1 {
    font-size:16px;
    white-space:normal;
  }

  .crm-domain-title p {
    font-size:11px;
  }

  #crmSourceGate {
    max-height:3.8em;
    overflow:hidden;
  }

  .crm-source-backbone-card {
    padding:10px;
  }

  .crm-source-backbone-pills {
    gap:6px;
  }

  .crm-source-backbone-pill {
    font-size:10px;
    padding:4px 7px;
  }

  .crm-table-head {
    padding:14px;
  }

  .crm-table-head-tools {
    flex:none;
    grid-template-columns:1fr;
    gap:8px;
  }

  .crm-select-page {
    justify-self:start;
  }

  .crm-table-head .crm-count-pill {
    justify-self:start;
  }

  .crm-profile-drawer {
    inset:10px;
    width:auto;
    border-radius:14px;
  }

  .crm-facts-grid {
    grid-template-columns:1fr;
  }

  .crm-source-gates {
    grid-template-columns:1fr;
  }
}

@media (max-width: 1100px) {
  .crm-workspace {
    display:contents;
    min-height:0;
  }

  .crm-map-panel {
    order:1;
    flex:0 0 340px;
    width:100%;
    height:340px;
    min-height:340px;
  }

  .crm-workspace[data-view="split"] .crm-map-panel {
    order:1;
  }

  .crm-home {
    order:2;
  }

  .crm-summary-row {
    order:3;
  }

  .crm-views-bar,
  .crm-bulk-bar {
    order:4;
  }

  .crm-table-panel {
    order:5;
    flex:0 0 auto;
  }
}

@media (max-width: 760px) {
  .crm-map-panel {
    flex-basis:320px;
    height:320px;
    min-height:320px;
  }

  .crm-map-legend {
    display:none;
  }

  .crm-map-status {
    left:12px;
    right:12px;
    max-width:none;
  }
}

@media (max-width: 900px) {
  #crmShell.is-org-open .crm-main {
    overflow:hidden;
  }

  .crm-org-hub {
    inset:10px;
    grid-template-columns:1fr;
    grid-template-rows:minmax(260px, 1fr) minmax(250px, auto);
    gap:10px;
    padding:10px;
  }

  .crm-org-map {
    min-height:260px;
    overflow:auto;
  }

  .crm-org-lines {
    display:none;
  }

  .crm-org-core {
    position:sticky;
    left:50%;
    top:50%;
    width:88px;
    height:88px;
    z-index:1;
  }

  .crm-org-core b {
    font-size:16px;
  }

  .crm-org-node {
    position:relative;
    left:auto;
    top:auto;
    transform:none;
    display:inline-block;
    width:120px;
    min-height:56px;
    margin:5px;
    z-index:2;
  }

  .crm-org-detail {
    min-height:0;
    padding:10px;
  }

  .crm-org-tabs {
    grid-template-columns:1fr 1fr;
  }

  .crm-org-card-grid {
    grid-template-columns:1fr;
  }
}
