/* =========================================================
   CRM interactive demo — scoped to #crm-demo
   All classes prefixed with crmx- to avoid collision with
   legacy .crm-* rules elsewhere.
   ========================================================= */

#crm-demo {
  width: 100%;
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  color: var(--ink);
  /* Container queries — card layout reacts to its OWN width,
     not the viewport. Prevents the nested-column crush where
     the card is inside .deepdive's 2-col split. */
  container-type: inline-size;
  container-name: crmx;
}

/* Card shell — default to single column, safe at any width. */
.crmx-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 22px);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr;
  min-height: 0;
}

/* Only split into 2 columns once the card has real room (>=720px). */
@container crmx (min-width: 720px) {
  .crmx-card {
    grid-template-columns: minmax(280px, 320px) minmax(0, 1fr);
    min-height: 560px;
  }
}

@container crmx (min-width: 860px) {
  .crmx-card {
    grid-template-columns: minmax(300px, 340px) minmax(0, 1fr);
  }
}

/* =============== LEFT COLUMN =============== */
.crmx-left {
  display: flex;
  flex-direction: column;
  /* Default (stacked): bottom border. 2-col: right border. Swapped via container query. */
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #FBFBFE 0%, #FFFFFF 60%);
  min-width: 0;
}

@container crmx (min-width: 720px) {
  .crmx-left {
    border-right: 1px solid var(--border);
    border-bottom: 0;
  }
}

.crmx-left-head {
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--border);
  background: #fff;
}

.crmx-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.crmx-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
  min-width: 0;
}
.crmx-title i {
  width: 16px; height: 16px;
  color: var(--navy);
  flex-shrink: 0;
}
.crmx-count-pill {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-2);
  background: var(--navy-50);
  padding: 4px 9px;
  border-radius: 999px;
  transition: all .25s ease;
  white-space: nowrap;
  flex-shrink: 0;
}
.crmx-count-pill.active {
  background: var(--orange-50);
  color: var(--orange);
}

/* Segment chips — desktop wraps, mobile scrolls horizontally */
.crmx-seg-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.crmx-seg {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 11px;
  cursor: pointer;
  transition: transform .18s ease, background .2s ease, color .2s ease, border-color .2s ease, box-shadow .2s ease;
  user-select: none;
  white-space: nowrap;
  line-height: 1;
  min-height: 30px;
}
.crmx-seg i {
  width: 13px; height: 13px;
  opacity: .85;
  flex-shrink: 0;
}
.crmx-seg .crmx-seg-n {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--muted);
  padding-left: 4px;
  border-left: 1px solid var(--border);
  margin-left: 2px;
}
.crmx-seg:hover {
  border-color: #CFD2E6;
  color: var(--ink);
}
.crmx-seg.active {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
  box-shadow: 0 4px 14px -6px rgba(42,40,119,.5);
}
.crmx-seg.active .crmx-seg-n {
  color: rgba(255,255,255,.7);
  border-left-color: rgba(255,255,255,.25);
}
.crmx-seg.press {
  transform: scale(.94);
}

/* Campaign button */
.crmx-camp-wrap {
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--border);
  background: #fff;
}
.crmx-camp {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.005em;
  color: #fff;
  background: var(--orange);
  border: 0;
  border-radius: var(--radius, 14px);
  padding: 11px 14px;
  cursor: pointer;
  transition: background .2s ease, transform .18s ease, box-shadow .2s ease, opacity .2s ease;
  box-shadow: 0 6px 16px -8px rgba(255,129,35,.55);
  min-height: 44px;
}
.crmx-camp i { width: 15px; height: 15px; flex-shrink: 0; }
.crmx-camp span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crmx-camp:hover:not(.crmx-disabled){ background: #F07314; }
.crmx-camp:active:not(.crmx-disabled){ transform: translateY(1px); }
.crmx-camp.crmx-disabled {
  background: #E2E3EE;
  color: var(--muted);
  cursor: not-allowed;
  box-shadow: none;
}
.crmx-camp.crmx-pulse {
  animation: crmxPulse 2.2s ease-in-out infinite;
}
@keyframes crmxPulse {
  0%, 100% { box-shadow: 0 6px 16px -8px rgba(255,129,35,.55), 0 0 0 0 rgba(255,129,35,.45); }
  50%      { box-shadow: 0 6px 16px -8px rgba(255,129,35,.55), 0 0 0 10px rgba(255,129,35,0); }
}

/* Customer list */
.crmx-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 8px 10px;
  min-height: 280px;
}
.crmx-list::-webkit-scrollbar { width: 6px; }
.crmx-list::-webkit-scrollbar-thumb { background: #E0E2F0; border-radius: 6px; }

/* On stacked layout (card < 720px), cap list height so the
   profile is still visible without a giant scroll. */
@container crmx (max-width: 719.98px) {
  .crmx-list { max-height: 280px; min-height: 180px; }
}

.crmx-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
  border-radius: var(--radius, 14px);
  cursor: pointer;
  transition: background .18s ease, transform .18s ease, opacity .25s ease;
  opacity: 1;
  transform: translateX(0);
}
.crmx-row + .crmx-row { margin-top: 2px; }
.crmx-row:hover { background: var(--navy-50); }
.crmx-row.active {
  background: var(--navy-50);
  box-shadow: inset 0 0 0 1px rgba(42,40,119,.15);
}
.crmx-row.hide {
  opacity: 0;
  transform: translateX(-10px);
  pointer-events: none;
  height: 0;
  padding: 0 10px;
  margin: 0;
  overflow: hidden;
}
.crmx-row.enter {
  opacity: 0;
  transform: translateX(-10px);
  animation: crmxRowIn .35s ease forwards;
}
@keyframes crmxRowIn {
  to { opacity: 1; transform: translateX(0); }
}

.crmx-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
  flex-shrink: 0;
  box-shadow: 0 2px 6px -2px rgba(0,0,0,.15);
}

.crmx-row-main { min-width: 0; }
.crmx-row-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.crmx-row-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.crmx-row-ago {
  font-size: 10.5px;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}

.crmx-empty {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  padding: 34px 16px;
  display: none;
}
.crmx-list.empty .crmx-empty { display: block; }

/* =============== RIGHT COLUMN =============== */
.crmx-right {
  display: flex;
  flex-direction: column;
  background: #fff;
  min-width: 0;
}

/* Profile header
   Uses flex-wrap so the LTV block wraps BELOW the name block
   when there's not enough horizontal room — rather than crushing
   the id column and forcing the phone number onto 3 lines. */
.crmx-profile-head {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  row-gap: 12px;
}
.crmx-prof-avatar {
  width: 54px; height: 54px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
  flex-shrink: 0;
  box-shadow: 0 3px 10px -3px rgba(0,0,0,.2);
  transition: transform .3s cubic-bezier(.34,1.3,.64,1);
}
.crmx-prof-avatar.swap { animation: crmxSwap .42s ease; }
@keyframes crmxSwap {
  0%   { transform: scale(.85) rotate(-4deg); opacity: .5; }
  60%  { transform: scale(1.06) rotate(2deg); }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

/* The id column — flex child with min-width:0 so its contents
   can shrink/wrap properly instead of forcing the parent to
   overflow. */
.crmx-prof-id {
  flex: 1 1 180px;
  min-width: 0;
}
.crmx-prof-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.015em;
  line-height: 1.2;
  /* Let the name wrap naturally; it will rarely need to. */
  overflow-wrap: break-word;
}
.crmx-prof-meta {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 4px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  min-width: 0;
}
.crmx-prof-meta .crmx-mono {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  color: var(--ink-2);
}
/* Phone should stay on one line in normal conditions. */
.crmx-prof-meta .crmx-phone {
  white-space: nowrap;
}
.crmx-prof-meta .crmx-sep {
  width: 3px; height: 3px;
  border-radius: 50%;
  background: #D0D3E4;
  display: inline-block;
  flex-shrink: 0;
}
.crmx-prof-meta .crmx-city {
  min-width: 0;
  overflow-wrap: anywhere;
}

.crmx-prof-ltv {
  text-align: right;
  flex-shrink: 0;
  /* When space is tight, we wrap BELOW instead of squeezing. */
  margin-left: auto;
}
.crmx-prof-ltv-label {
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.crmx-prof-ltv-amt {
  font-size: 22px;
  font-weight: 800;
  color: var(--navy);
  letter-spacing: -0.02em;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  margin-top: 2px;
  transition: color .3s ease;
  white-space: nowrap;
}

/* Tabs */
.crmx-tabs {
  display: flex;
  gap: 0;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: #fff;
  overflow-x: auto;
  scrollbar-width: none;
}
.crmx-tabs::-webkit-scrollbar { display: none; }
.crmx-tab {
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: 0;
  padding: 12px 14px;
  cursor: pointer;
  position: relative;
  transition: color .2s ease;
  white-space: nowrap;
  flex-shrink: 0;
}
.crmx-tab:hover { color: var(--ink-2); }
.crmx-tab.active {
  color: var(--navy);
}
.crmx-tab.active::after {
  content: '';
  position: absolute;
  left: 14px; right: 14px; bottom: -1px;
  height: 2px;
  background: var(--navy);
  border-radius: 2px 2px 0 0;
}

/* Tab count pill (e.g. "Orders 7") */
.crmx-tab-n {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  margin-left: 6px;
  border-radius: 999px;
  background: var(--navy-50);
  color: var(--ink-2);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1;
  transition: background .2s ease, color .2s ease;
}
.crmx-tab.active .crmx-tab-n {
  background: var(--navy);
  color: #fff;
}

/* Timeline */
.crmx-timeline {
  padding: 18px 20px 22px;
  flex: 1;
  overflow-y: auto;
}
.crmx-timeline::-webkit-scrollbar { width: 6px; }
.crmx-timeline::-webkit-scrollbar-thumb { background: #E0E2F0; border-radius: 6px; }

.crmx-ev {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 12px;
  padding-bottom: 18px;
  opacity: 0;
  transform: translateX(-14px);
  animation: crmxEvIn .38s cubic-bezier(.25,.8,.4,1) forwards;
}
@keyframes crmxEvIn {
  to { opacity: 1; transform: translateX(0); }
}

.crmx-ev:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 16px;
  top: 32px;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.crmx-ev-icon {
  width: 32px; height: 32px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  z-index: 1;
}
.crmx-ev-icon i { width: 15px; height: 15px; }
.crmx-ev-icon.orange { background: var(--orange-50); color: var(--orange); }
.crmx-ev-icon.blue   { background: #E6EEFE; color: #3366E3; }
.crmx-ev-icon.green  { background: var(--green-50); color: var(--green); }
.crmx-ev-icon.pink   { background: #FCE8F1; color: #D6408F; }
.crmx-ev-icon.navy   { background: var(--navy-50); color: var(--navy); }
.crmx-ev-icon.red    { background: var(--red-50); color: var(--red); }

.crmx-ev-body {
  min-width: 0;
  padding-top: 2px;
}
.crmx-ev-title {
  font-size: 13px;
  color: var(--ink);
  line-height: 1.4;
  letter-spacing: -0.005em;
  overflow-wrap: anywhere;
}
.crmx-ev-title b { color: var(--navy); font-weight: 700; }
.crmx-ev-title .crmx-mono {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  color: var(--ink-2);
}
.crmx-ev-time {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  font-weight: 500;
}

/* =========================================================
   Tab content — Orders / Calls / Notes lists
   Shared with Activity look-and-feel (icon + body column).
   ========================================================= */

/* Fade the whole tab panel on switch. */
.crmx-timeline.crmx-tab-in {
  animation: crmxTabIn .28s ease;
}
@keyframes crmxTabIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.crmx-rows-list,
.crmx-notes-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* "Empty tab" placeholder */
.crmx-none {
  font-size: 12.5px;
  color: var(--muted);
  padding: 30px 8px;
  text-align: center;
}

/* -------- Orders -------- */
.crmx-order-row {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 12px;
  padding: 10px 10px;
  border-radius: var(--radius, 14px);
  opacity: 0;
  transform: translateX(-10px);
  animation: crmxEvIn .38s cubic-bezier(.25,.8,.4,1) forwards;
  transition: background .18s ease;
}
.crmx-order-row + .crmx-order-row { margin-top: 2px; }
.crmx-order-row:hover { background: var(--navy-50); }

/* Timeline-style connector line between orders */
.crmx-order-row:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 26px;
  top: 42px;
  bottom: -2px;
  width: 2px;
  background: var(--border);
}

.crmx-order-icon {
  width: 32px; height: 32px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy-50);
  color: var(--navy);
  flex-shrink: 0;
  z-index: 1;
}
.crmx-order-icon i { width: 15px; height: 15px; }

.crmx-order-main { min-width: 0; padding-top: 2px; }
.crmx-order-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  row-gap: 4px;
}
.crmx-order-num {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
}
.crmx-order-product {
  font-size: 13px;
  color: var(--ink);
  letter-spacing: -0.005em;
  line-height: 1.35;
  margin-top: 3px;
  overflow-wrap: anywhere;
}
.crmx-order-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  font-weight: 500;
}
.crmx-order-meta .crmx-mono {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 600;
}
.crmx-dot {
  width: 3px; height: 3px;
  border-radius: 50%;
  background: #D0D3E4;
  display: inline-block;
  flex-shrink: 0;
}

/* Status chips */
.crmx-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  letter-spacing: .01em;
  white-space: nowrap;
  line-height: 1.3;
}
.crmx-chip i { width: 11px; height: 11px; }
.crmx-chip-green  { background: var(--green-50); color: var(--green); }
.crmx-chip-red    { background: var(--red-50);   color: var(--red); }
.crmx-chip-orange { background: var(--orange-50); color: var(--orange); }
.crmx-chip-navy   { background: var(--navy-50); color: var(--navy); }

/* -------- Calls -------- */
.crmx-call-row {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 12px;
  padding: 10px 10px;
  border-radius: var(--radius, 14px);
  opacity: 0;
  transform: translateX(-10px);
  animation: crmxEvIn .38s cubic-bezier(.25,.8,.4,1) forwards;
  transition: background .18s ease;
}
.crmx-call-row + .crmx-call-row { margin-top: 2px; }
.crmx-call-row:hover { background: var(--navy-50); }

.crmx-call-row:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 26px;
  top: 42px;
  bottom: -2px;
  width: 2px;
  background: var(--border);
}

.crmx-call-icon {
  width: 32px; height: 32px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  z-index: 1;
}
.crmx-call-icon i { width: 15px; height: 15px; }
.crmx-call-icon.blue { background: #E6EEFE; color: #3366E3; }
.crmx-call-icon.navy { background: var(--navy-50); color: var(--navy); }

.crmx-call-main { min-width: 0; padding-top: 2px; }
.crmx-call-top {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  row-gap: 2px;
}
.crmx-call-who {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.005em;
}
.crmx-call-dir {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.crmx-call-outcome {
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.4;
  margin-top: 3px;
  overflow-wrap: anywhere;
}
.crmx-call-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  font-weight: 500;
}
.crmx-call-meta .crmx-mono {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 600;
}

/* -------- Notes -------- */
.crmx-notes-list {
  gap: 10px;
}
.crmx-note-card {
  position: relative;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 12px;
  padding: 12px 12px;
  background: #FFFBEF;
  border: 1px solid #F4E7C4;
  border-radius: var(--radius, 14px);
  opacity: 0;
  transform: translateY(6px);
  animation: crmxNoteIn .38s cubic-bezier(.25,.8,.4,1) forwards;
}
@keyframes crmxNoteIn {
  to { opacity: 1; transform: translateY(0); }
}
.crmx-note-icon {
  width: 28px; height: 28px;
  border-radius: 9px;
  background: #FBEFD0;
  color: #B78100;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.crmx-note-icon i { width: 14px; height: 14px; }
.crmx-note-body { min-width: 0; }
.crmx-note-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.crmx-note-author {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.005em;
}
.crmx-note-author i {
  width: 12px; height: 12px;
  color: var(--muted);
}
.crmx-note-time {
  font-size: 10.5px;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
}
.crmx-note-text {
  font-size: 12.5px;
  color: var(--ink);
  line-height: 1.5;
  margin-top: 5px;
  overflow-wrap: anywhere;
}

/* Replay button */
.crmx-replay {
  position: absolute;
  right: 14px;
  top: 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-2);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 11px;
  cursor: pointer;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease, background .2s ease, color .2s ease;
  z-index: 5;
  box-shadow: var(--shadow-sm);
}
.crmx-replay i { width: 13px; height: 13px; }
.crmx-replay.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
.crmx-replay:hover { background: var(--navy); color: #fff; border-color: var(--navy); }

/* Toast */
.crmx-toast {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translate(-50%, 14px);
  background: var(--ink);
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 999px;
  box-shadow: 0 10px 24px -8px rgba(0,0,0,.3);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .28s ease, transform .28s ease;
  z-index: 6;
  max-width: calc(100% - 32px);
  text-align: center;
}
.crmx-toast i { width: 14px; height: 14px; color: var(--green); flex-shrink: 0; }
.crmx-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Wrap positioning so toast + replay can absolutely-position */
.crmx-stage { position: relative; }

/* =========================================================
   TABLET NARROW (600–899px)
   Columns stacked. Segment chips still wrap (there's room).
   Left column gets its list capped in height above.
   ========================================================= */
@media (max-width: 899px){
  .crmx-left-head { padding: 16px 16px 12px; }
  .crmx-camp-wrap { padding: 12px 16px 10px; }
  .crmx-profile-head { padding: 18px 18px 14px; gap: 12px; }
  .crmx-tabs { padding: 0 14px; }
  .crmx-timeline { padding: 16px 18px 20px; }
}

/* =========================================================
   MOBILE (<600px)
   Single column, top-down: chips → list → campaign →
   profile → timeline. Chips become a single-row horizontal
   scroll with edge fades. Campaign is full-width (it already
   is, but we ensure tap target height). Timeline events stay
   full-width and legible.
   ========================================================= */
@media (max-width: 599px){
  .crmx-card {
    border-radius: var(--radius, 16px);
  }

  .crmx-left-head { padding: 14px 14px 10px; }

  /* Chip row: horizontal scroll strip with soft edge fades */
  .crmx-seg-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    margin: 0 -14px;
    padding: 2px 14px 4px;
    /* Soft edge fade using mask */
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 14px, #000 calc(100% - 14px), transparent 100%);
            mask-image: linear-gradient(90deg, transparent 0, #000 14px, #000 calc(100% - 14px), transparent 100%);
  }
  .crmx-seg-row::-webkit-scrollbar { display: none; }
  .crmx-seg {
    scroll-snap-align: start;
    min-height: 36px;
    padding: 8px 12px;
    font-size: 12.5px;
    flex-shrink: 0;
  }

  /* Count pill: keep it compact, don't let it push title off */
  .crmx-head-row { margin-bottom: 10px; }

  .crmx-camp-wrap { padding: 12px 14px 10px; }
  .crmx-camp { padding: 12px 14px; min-height: 46px; font-size: 13.5px; }

  /* Customer list: a touch more room, clearer tap targets */
  .crmx-list {
    padding: 6px 6px 8px;
    max-height: 260px;
    min-height: 160px;
  }
  .crmx-row {
    grid-template-columns: 36px minmax(0, 1fr) auto;
    padding: 10px 10px;
    min-height: 52px;
  }
  .crmx-avatar { width: 36px; height: 36px; font-size: 12.5px; }

  /* Profile header: keep avatar + id on row 1; LTV wraps BELOW.
     This is the fix for phone-number-breaking-on-3-lines. */
  .crmx-profile-head {
    padding: 16px 14px 14px;
    gap: 12px;
    align-items: flex-start;
  }
  .crmx-prof-avatar {
    width: 48px; height: 48px;
    font-size: 16px;
  }
  .crmx-prof-id {
    flex: 1 1 0;
    min-width: 0;
  }
  .crmx-prof-name { font-size: 16px; }
  .crmx-prof-meta {
    gap: 8px;
    font-size: 11.5px;
  }
  .crmx-prof-ltv {
    /* Wrap the LTV block beneath the avatar+id row on mobile,
       aligned left so it reads naturally. */
    flex: 1 0 100%;
    text-align: left;
    margin-left: 0;
    padding-top: 4px;
    border-top: 1px dashed var(--border);
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
  }
  .crmx-prof-ltv-label {
    margin-top: 2px;
  }
  .crmx-prof-ltv-amt {
    font-size: 20px;
    margin-top: 0;
  }

  /* Tabs: horizontal scroll if too many */
  .crmx-tabs { padding: 0 10px; }
  .crmx-tab { padding: 11px 12px; font-size: 12.5px; min-height: 42px; }

  /* Timeline: full width, breathing room */
  .crmx-timeline { padding: 14px 14px 18px; }
  .crmx-ev {
    grid-template-columns: 30px minmax(0, 1fr);
    gap: 10px;
    padding-bottom: 16px;
  }
  .crmx-ev:not(:last-child)::before {
    left: 14px;
    top: 30px;
  }
  .crmx-ev-icon { width: 28px; height: 28px; border-radius: 9px; }
  .crmx-ev-icon i { width: 13px; height: 13px; }
  .crmx-ev-title { font-size: 12.5px; line-height: 1.45; }
  .crmx-ev-title .crmx-mono { font-size: 11.5px; }
  .crmx-ev-time { font-size: 10.5px; }

  /* Tab content lists: match activity padding adjustments */
  .crmx-order-row,
  .crmx-call-row {
    grid-template-columns: 30px minmax(0, 1fr);
    gap: 10px;
    padding: 9px 8px;
  }
  .crmx-order-row:not(:last-child)::before,
  .crmx-call-row:not(:last-child)::before {
    left: 22px;
    top: 40px;
  }
  .crmx-order-icon,
  .crmx-call-icon {
    width: 28px; height: 28px;
    border-radius: 9px;
  }
  .crmx-order-icon i,
  .crmx-call-icon i { width: 13px; height: 13px; }
  .crmx-order-product,
  .crmx-call-outcome { font-size: 12px; }
  .crmx-order-meta,
  .crmx-call-meta { font-size: 10.5px; }
  .crmx-note-card { padding: 10px 11px; }
  .crmx-note-text { font-size: 12px; }
  .crmx-tab-n {
    min-width: 16px;
    height: 16px;
    font-size: 10px;
    padding: 0 5px;
    margin-left: 5px;
  }

  /* Replay button: don't overlap content */
  .crmx-replay {
    right: 10px; top: 10px;
    font-size: 11px;
    padding: 5px 10px;
  }

  .crmx-toast {
    bottom: 14px;
    font-size: 12px;
    padding: 8px 14px;
  }
}

/* =========================================================
   EXTRA NARROW (<380px) — safety net for old phones
   ========================================================= */
@media (max-width: 379px){
  .crmx-prof-meta .crmx-sep { display: none; }
  .crmx-prof-meta {
    gap: 2px 8px;
    flex-direction: column;
    align-items: flex-start;
  }
  .crmx-prof-name { font-size: 15.5px; }
  .crmx-prof-ltv-amt { font-size: 18px; }
}
