/* ============================================================
   CRM widget — SMS inbox · follow-ups · notes · favorites
   Loaded by the investor portal (/investor/) AND the React SPA (/).
   Every portal token has a fallback so the widget looks the same on
   the React app (which lacks --cyan-2 / --gold-2 / --line-gold …).
   z-index: panel 130 (above .sheet 40, .toast 60, .navwarn 120),
   toasts 140, floating icon 110.
   ============================================================ */

.crm-root, .crm-btn, .crm-toasts, .crm-fav, .crm-float {
  --crm-obsidian: var(--obsidian, #05080b);
  --crm-black: var(--black, #0a0a0c);
  --crm-panel: var(--panel, #131316);
  --crm-panel-2: var(--panel-2, #1c1c20);
  --crm-card: var(--card, rgba(18,21,30,.72));
  --crm-card-solid: var(--card-solid, #12151e);
  --crm-gold: var(--gold, #d4af52);
  --crm-gold-2: var(--gold-2, var(--gold-bright, #f6e2a0));
  --crm-gold-3: var(--gold-3, var(--gold-dark, #9a6e22));
  --crm-cyan: var(--cyan, #25b8ff);
  --crm-cyan-2: var(--cyan-2, #4fd6e6);
  --crm-text: var(--text, #f6f0e4);
  --crm-cream: var(--cream, #f5f1e8);
  --crm-muted: var(--muted, #a9b1b9);
  --crm-muted-2: var(--muted-2, #9aa3b2);
  --crm-green: var(--green, #59d687);
  --crm-red: var(--red, #ff5d58);
  --crm-good: var(--good, #34d27b);
  --crm-bad: var(--bad, #ff7a7a);
  --crm-line: var(--line, rgba(255,255,255,.09));
  --crm-line-gold: var(--line-gold, rgba(212,175,82,.28));
  --crm-radius: var(--radius, 14px);
  --crm-shadow: var(--shadow, 0 1px 3px rgba(0,0,0,.4), 0 24px 60px rgba(0,0,0,.45));
  --crm-gold-grad: var(--gold-grad, linear-gradient(135deg, #f6e2a0 0%, #d4af52 48%, #9a6e22 100%));
  --crm-display: var(--display, 'Cormorant Garamond', Georgia, 'Times New Roman', serif);
  --crm-font: var(--font, 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
  --crm-mono: var(--mono, 'Cascadia Mono', 'SF Mono', Consolas, 'Roboto Mono', monospace);
  --crm-blue: #60a5fa;      /* priority 1 */
  --crm-yellow: #f59e0b;    /* priority 2 */
  --crm-violet: #b48cff;    /* 3rd line color */
  font-family: var(--crm-font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--crm-text);
  -webkit-font-smoothing: antialiased;
}

/* ------------------------------------------------------------
   1. Icon button (slot variants + floating fallback)
   ------------------------------------------------------------ */
.crm-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
  color: var(--crm-gold-2);
  background: none;
  border: 1px solid rgba(212,175,82,.3);
  transition: .18s;
  vertical-align: middle;
  -webkit-tap-highlight-color: transparent;
}
.crm-btn:hover { color: var(--crm-gold-2); border-color: var(--crm-gold); }
.crm-btn svg { width: 17px; height: 17px; display: block; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.crm-btn-pill { font-size: 12px; color: #9a9281; padding: 7px 12px; border-radius: 20px; }
.crm-btn-pill svg { width: 15px; height: 15px; }
.crm-btn-round {
  width: 38px; height: 38px; border-radius: 50%;
  border-color: rgba(212,175,82,.35);
  background: rgba(10,10,12,.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.crm-btn-round svg { width: 18px; height: 18px; }
.crm-float { position: fixed; top: 12px; right: 14px; z-index: 110; }
.crm-float .crm-btn { box-shadow: 0 8px 24px rgba(0,0,0,.45); }
.crm-badge {
  position: absolute; top: -6px; right: -6px;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px;
  background: var(--crm-gold-grad);
  color: #0a0a0c;
  font-size: 10.5px; font-weight: 800; line-height: 18px; text-align: center;
  box-shadow: 0 4px 12px rgba(212,175,82,.35);
  font-family: var(--crm-font);
}
.crm-badge[hidden] { display: none; }
.crm-btn.pulse svg { animation: crmPulse 1.2s ease-out 1; }
.crm-btn.pulse .crm-badge { animation: crmPop .5s ease-out 1; }
@keyframes crmPulse { 0% { transform: scale(1); } 30% { transform: scale(1.35); color: #fff0ba; } 100% { transform: scale(1); } }
@keyframes crmPop { 0% { transform: scale(.4); } 60% { transform: scale(1.25); } 100% { transform: scale(1); } }
@media (max-width: 640px) {
  .crm-btn-pill { padding: 6px 9px; font-size: 11px; }
  .crm-btn-pill .crm-btn-label { display: none; }
}

/* ------------------------------------------------------------
   2. Panel shell
   ------------------------------------------------------------ */
.crm-root { position: fixed; inset: 0; z-index: 130; display: none; }
.crm-root.open { display: block; }
.crm-backdrop { position: absolute; inset: 0; background: rgba(3,5,9,.7); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.crm-dlg {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(1180px, calc(100vw - 32px));
  height: min(88vh, 900px);
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, #12161f 0%, #0c0e14 100%);
  border: 1px solid rgba(212,175,82,.32);
  border-radius: var(--crm-radius);
  box-shadow: 0 30px 90px rgba(0,0,0,.65), 0 0 0 1px rgba(0,0,0,.4);
  overflow: hidden;
  animation: crmIn .22s ease-out;
}
@keyframes crmIn { from { opacity: 0; transform: translate(-50%, -48%) scale(.985); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
.crm-root * { box-sizing: border-box; }
.crm-root button { font-family: inherit; cursor: pointer; color: inherit; }
.crm-root button:disabled { opacity: .55; cursor: default; }
.crm-root a { color: var(--crm-cyan); text-decoration: none; }
.crm-root a:hover { text-decoration: underline; }
.crm-root :focus-visible { outline: 2px solid var(--crm-gold); outline-offset: 2px; }
.crm-root input, .crm-root textarea, .crm-root select { font-family: inherit; font-size: 13.5px; color: var(--crm-text); }
.crm-root ::placeholder { color: rgba(169,177,185,.55); }
.crm-hidden { display: none !important; }
.crm-mono { font-family: var(--crm-mono); font-variant-numeric: tabular-nums; }
.crm-muted { color: var(--crm-muted-2); }
.crm-small { font-size: 12px; }

/* top bar */
.crm-top {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--crm-line-gold);
  background: rgba(10,10,12,.55);
  flex-shrink: 0;
}
.crm-brand { display: flex; align-items: center; gap: 9px; font-family: var(--crm-display); font-size: 22px; font-weight: 600; letter-spacing: .01em; color: var(--crm-cream); }
.crm-brand svg { width: 20px; height: 20px; stroke: var(--crm-gold); fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.crm-brand small { font-family: var(--crm-font); font-size: 9px; letter-spacing: 3px; color: var(--crm-gold); font-weight: 600; text-transform: uppercase; margin-left: 2px; }
.crm-tabs { display: flex; gap: 4px; margin-left: 8px; }
.crm-tab {
  background: none; border: 1px solid transparent; border-radius: 999px;
  padding: 7px 13px; font-size: 13px; color: #bcb39a; font-weight: 500; display: inline-flex; align-items: center; gap: 7px;
}
.crm-tab:hover { color: var(--crm-cream); border-color: rgba(212,175,82,.25); }
.crm-tab.on { color: #0a0a0c; background: var(--crm-gold-grad); font-weight: 700; box-shadow: 0 6px 18px rgba(212,175,82,.28); }
.crm-tab .n { font-size: 10.5px; font-weight: 800; padding: 1px 6px; border-radius: 999px; background: rgba(255,255,255,.12); }
.crm-tab.on .n { background: rgba(0,0,0,.18); }
.crm-tab .n[hidden] { display: none; }
.crm-grow { flex: 1; }
.crm-select, .crm-input, .crm-textarea {
  background: rgba(255,255,255,.04); border: 1px solid var(--crm-line); border-radius: 10px;
  padding: 7px 10px; color: var(--crm-text); outline: none;
}
.crm-select:focus, .crm-input:focus, .crm-textarea:focus { border-color: rgba(212,175,82,.55); }
.crm-select { appearance: none; -webkit-appearance: none; padding-right: 26px;
  background-image: linear-gradient(45deg, transparent 50%, #bcb39a 50%), linear-gradient(135deg, #bcb39a 50%, transparent 50%);
  background-position: calc(100% - 14px) 55%, calc(100% - 9px) 55%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
.crm-select option { background: #131316; color: #f6f0e4; }
.crm-linesel { font-size: 12.5px; max-width: 220px; }
.crm-sync { width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--crm-line); background: none; display: grid; place-items: center; padding: 0; }
.crm-sync i { width: 9px; height: 9px; border-radius: 50%; background: #6b6453; display: block; transition: .2s; }
.crm-sync[data-state="ok"] i { background: var(--crm-good); box-shadow: 0 0 8px var(--crm-good); }
.crm-sync[data-state="syncing"] i { background: var(--crm-yellow); box-shadow: 0 0 8px var(--crm-yellow); animation: crmBlink 1s infinite; }
.crm-sync[data-state="error"] i { background: var(--crm-red); box-shadow: 0 0 8px var(--crm-red); }
.crm-sync[data-state="stale"] i { background: #6b6453; }
@keyframes crmBlink { 50% { opacity: .35; } }
.crm-x {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid rgba(212,175,82,.35);
  background: rgba(10,10,12,.6); color: var(--crm-gold-2); font-size: 19px; line-height: 1; display: grid; place-items: center;
}
.crm-x:hover { border-color: var(--crm-gold); }

.crm-body { flex: 1; min-height: 0; position: relative; display: flex; }
.crm-view { flex: 1; min-height: 0; display: none; }
.crm-view.on { display: flex; }

/* generic buttons */
.crm-b {
  border: 1px solid rgba(212,175,82,.28); background: rgba(212,175,82,.05); color: #d9d0b6;
  border-radius: 999px; padding: 6px 12px; font-size: 12.5px; font-weight: 600; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px; transition: .15s;
}
.crm-b:hover { border-color: var(--crm-gold); color: var(--crm-gold-2); }
.crm-b.gold { border: 0; background: var(--crm-gold-grad); color: #10131a; font-weight: 800; box-shadow: 0 6px 18px rgba(212,175,82,.25); }
.crm-b.gold:hover { filter: brightness(1.06); color: #10131a; }
.crm-b.ghost { border-color: var(--crm-line); background: transparent; color: var(--crm-muted); }
.crm-b.danger { border-color: rgba(255,93,88,.4); color: #ffb3af; background: rgba(255,93,88,.06); }
.crm-b.sm { padding: 4px 9px; font-size: 11.5px; }
.crm-b.icon { width: 30px; height: 30px; padding: 0; justify-content: center; border-radius: 50%; font-size: 15px; }
.crm-chip {
  white-space: nowrap; padding: 5px 11px; border-radius: 999px; border: 1px solid rgba(212,175,82,.22);
  background: rgba(212,175,82,.05); color: #bcb39a; font-size: 12px; display: inline-flex; align-items: center; gap: 5px;
}
.crm-chip.on { color: #0a0a0c; background: var(--crm-gold-grad); border-color: transparent; box-shadow: 0 6px 18px rgba(212,175,82,.28); font-weight: 700; }
.crm-chip .n { font-size: 10px; opacity: .8; }
.crm-tag { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; padding: 2px 7px; border-radius: 5px; border: 1px solid var(--crm-line); color: var(--crm-muted-2); white-space: nowrap; }
.crm-tag.dnc { color: #ffb3af; border-color: rgba(255,93,88,.55); background: rgba(255,93,88,.12); font-weight: 800; }
.crm-tag.dnd { color: #ffd6a0; border-color: rgba(245,158,11,.5); background: rgba(245,158,11,.1); font-weight: 800; }
.crm-tag.ok { color: #9be3b4; border-color: rgba(89,214,135,.4); }

/* line chips: color per line index */
.crm-lchip { font-family: var(--crm-mono); font-size: 10.5px; padding: 1px 6px; border-radius: 6px; border: 1px solid; white-space: nowrap; letter-spacing: .02em; }
.crm-lchip[data-li="0"] { color: var(--crm-gold-2); border-color: rgba(212,175,82,.45); background: rgba(212,175,82,.08); }
.crm-lchip[data-li="1"] { color: var(--crm-cyan-2); border-color: rgba(79,214,230,.45); background: rgba(79,214,230,.08); }
.crm-lchip[data-li="2"] { color: var(--crm-violet); border-color: rgba(180,140,255,.45); background: rgba(180,140,255,.08); }
.crm-lchip[data-li="x"] { color: var(--crm-muted); border-color: var(--crm-line); }

/* priority star */
.crm-star { background: none; border: 0; padding: 2px 4px; font-size: 17px; line-height: 1; color: #5a5a66; border-radius: 6px; transition: .15s; }
.crm-star:hover { transform: scale(1.15); color: #8a8a99; }
.crm-star[data-p="1"] { color: var(--crm-blue); text-shadow: 0 0 10px rgba(96,165,250,.55); }
.crm-star[data-p="2"] { color: var(--crm-yellow); text-shadow: 0 0 10px rgba(245,158,11,.55); }
.crm-star[data-p="3"] { color: #ff7a3c; text-shadow: 0 0 10px rgba(255,120,60,.55); }
.crm-star.big { font-size: 22px; }

/* favorite heart (also used outside the panel by host pages) */
.crm-fav {
  background: none; border: 1px solid rgba(255,255,255,.12); color: #6b6f7a; border-radius: 999px;
  width: 26px; height: 26px; padding: 0; line-height: 1; font-size: 14px; display: inline-grid; place-items: center;
  cursor: pointer; vertical-align: middle; transition: .15s; flex-shrink: 0;
}
.crm-fav:hover { color: #ff8a9a; border-color: rgba(255,138,154,.5); transform: scale(1.08); }
.crm-fav.on { color: #ff5d7a; border-color: rgba(255,93,122,.6); background: rgba(255,93,122,.1); text-shadow: 0 0 10px rgba(255,93,122,.5); }
.crm-fav.sm { width: 22px; height: 22px; font-size: 12px; }
.crm-fav.lg { width: 34px; height: 34px; font-size: 18px; }

/* ------------------------------------------------------------
   3. Inbox — list pane
   ------------------------------------------------------------ */
.crm-inbox { flex: 1; min-height: 0; display: grid; grid-template-columns: 350px 1fr; }
.crm-list { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--crm-line); background: rgba(10,10,12,.35); }
.crm-search { padding: 10px 12px 8px; }
.crm-search .crm-input { width: 100%; padding-left: 32px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a9b1b9' stroke-width='2' stroke-linecap='round'><circle cx='11' cy='11' r='7'/><path d='M20 20l-3.5-3.5'/></svg>");
  background-repeat: no-repeat; background-position: 10px 50%; }
.crm-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 10px; }
.crm-chips::-webkit-scrollbar { display: none; }
.crm-rows { flex: 1; overflow-y: auto; min-height: 0; overscroll-behavior: contain; }
.crm-row {
  display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; align-items: center;
  padding: 10px 12px; cursor: pointer; border-bottom: 1px solid rgba(255,255,255,.05);
  transition: background .12s; position: relative;
}
.crm-row:hover { background: rgba(212,175,82,.05); }
.crm-row.on { background: rgba(212,175,82,.1); box-shadow: inset 3px 0 0 var(--crm-gold); }
.crm-row.kb { outline: 1px dashed rgba(212,175,82,.45); outline-offset: -3px; }
.crm-av { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; letter-spacing: .5px; color: #0a0a0c; background: var(--crm-gold-grad); flex-shrink: 0; }
.crm-av[data-c="1"] { background: linear-gradient(135deg, #4fd6e6, #25b8ff); }
.crm-av[data-c="2"] { background: linear-gradient(135deg, #c9b0ff, #8b5cf6); }
.crm-av[data-c="3"] { background: linear-gradient(135deg, #9be3b4, #34d27b); }
.crm-av[data-c="4"] { background: linear-gradient(135deg, #ffb3af, #ff5d58); }
.crm-av[data-c="5"] { background: linear-gradient(135deg, #e5e7eb, #9aa3b2); color: #0a0a0c; }
.crm-av.big { width: 44px; height: 44px; font-size: 14px; }
.crm-rmain { min-width: 0; }
.crm-rname { font-weight: 600; font-size: 13.5px; color: var(--crm-cream); white-space: nowrap; overflow: hidden; display: flex; align-items: center; gap: 6px; }
.crm-rname > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.crm-row.unread .crm-rname { color: #fff; }
.crm-rname .crm-tag { font-size: 8.5px; padding: 1px 5px; }
.crm-rsnip { font-size: 12.5px; color: var(--crm-muted-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.crm-row.unread .crm-rsnip { color: #d9d0b6; font-weight: 500; }
.crm-rsnip .out { color: #8a8a99; }
.crm-rside { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.crm-rtime { font-size: 11px; color: var(--crm-muted-2); white-space: nowrap; }
.crm-row.unread .crm-rtime { color: var(--crm-gold-2); font-weight: 600; }
.crm-rmeta { display: flex; align-items: center; gap: 5px; }
.crm-rec { font-size: 10px; padding: 1px 6px; border-radius: 6px; border: 1px solid rgba(79,214,230,.3); color: var(--crm-cyan-2); max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crm-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--crm-gold); box-shadow: 0 0 8px var(--crm-gold); display: inline-block; }
.crm-empty { padding: 40px 20px; text-align: center; color: var(--crm-muted-2); font-size: 13px; }
.crm-empty b { display: block; font-family: var(--crm-display); font-size: 20px; color: var(--crm-cream); margin-bottom: 6px; font-weight: 600; }
.crm-empty .crm-b { margin-top: 12px; }

/* ------------------------------------------------------------
   4. Inbox — thread pane
   ------------------------------------------------------------ */
.crm-thread { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.crm-thead { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--crm-line); flex-wrap: wrap; }
.crm-back { display: none; }
.crm-tname { min-width: 0; flex: 1; }
.crm-tname .nm { font-family: var(--crm-display); font-size: 21px; font-weight: 600; color: var(--crm-cream); line-height: 1.15; display: flex; align-items: center; gap: 8px; cursor: text; }
.crm-tname .nm .pen { font-size: 12px; opacity: .45; }
.crm-tname .nm:hover .pen { opacity: 1; }
.crm-tname .nm input { font-family: var(--crm-display); font-size: 21px; font-weight: 600; color: var(--crm-cream); background: rgba(255,255,255,.05); border: 1px solid rgba(212,175,82,.5); border-radius: 8px; padding: 1px 8px; min-width: 120px; max-width: 100%; outline: none; }
.crm-tname .ph { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--crm-muted); margin-top: 2px; flex-wrap: wrap; }
.crm-tname .ph a { color: var(--crm-cyan-2); font-family: var(--crm-mono); font-size: 12.5px; }
.crm-tacts { display: flex; align-items: center; gap: 8px; }
.crm-stage { font-size: 12px; padding: 5px 26px 5px 10px; border-radius: 999px; }
.crm-stage[data-s="blue"] { border-color: rgba(96,165,250,.6); color: #bcd6fb; }
.crm-stage[data-s="yellow"] { border-color: rgba(245,158,11,.6); color: #ffd98a; }
.crm-stage[data-s="fire"] { border-color: rgba(255,120,60,.6); color: #ffb28f; }
.crm-stage[data-s="closed"] { border-color: rgba(89,214,135,.5); color: #9be3b4; }
.crm-stage[data-s="ni"] { border-color: rgba(255,93,88,.5); color: #ffb3af; }
.crm-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--crm-muted); background: none; border: 1px solid var(--crm-line); border-radius: 999px; padding: 4px 9px 4px 5px; }
.crm-toggle i { width: 26px; height: 15px; border-radius: 999px; background: rgba(255,255,255,.12); position: relative; display: inline-block; transition: .15s; }
.crm-toggle i::after { content: ''; position: absolute; top: 2px; left: 2px; width: 11px; height: 11px; border-radius: 50%; background: #9aa3b2; transition: .15s; }
.crm-toggle.on { color: #ffd6a0; border-color: rgba(245,158,11,.5); }
.crm-toggle.on i { background: rgba(245,158,11,.5); }
.crm-toggle.on i::after { left: 13px; background: #ffd6a0; }
.crm-links { display: flex; align-items: center; gap: 6px; padding: 8px 14px; border-bottom: 1px solid var(--crm-line); flex-wrap: wrap; min-height: 40px; }
.crm-links .lbl { font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--crm-muted-2); margin-right: 4px; }
.crm-lnk { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; border: 1px solid rgba(79,214,230,.35); background: rgba(79,214,230,.06); color: var(--crm-cyan-2); font-size: 12px; max-width: 320px; text-decoration: none; }
.crm-lnk:hover { border-color: var(--crm-cyan-2); text-decoration: none; }
.crm-lnk .t { font-size: 9.5px; letter-spacing: .06em; text-transform: uppercase; opacity: .75; }
.crm-lnk .l { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crm-lnk .s { color: var(--crm-muted-2); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px; }
.crm-lnk .h { color: #ff5d7a; font-size: 11px; }
.crm-subtabs { display: flex; gap: 2px; padding: 6px 14px 0; border-bottom: 1px solid var(--crm-line); }
.crm-subtab { background: none; border: 0; border-bottom: 2px solid transparent; padding: 7px 12px; font-size: 12.5px; color: var(--crm-muted); font-weight: 500; margin-bottom: -1px; display: inline-flex; gap: 6px; align-items: center; }
.crm-subtab.on { color: var(--crm-gold-2); border-bottom-color: var(--crm-gold); }
.crm-subtab .n { font-size: 10px; padding: 0 5px; border-radius: 999px; background: rgba(255,255,255,.1); }
.crm-tbody { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; }
.crm-conv { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; overscroll-behavior: contain; scroll-behavior: smooth; }
.crm-day { text-align: center; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--crm-muted-2); margin: 10px 0 6px; display: flex; align-items: center; gap: 12px; }
.crm-day::before, .crm-day::after { content: ''; flex: 1; height: 1px; background: var(--crm-line); }
.crm-msg { display: flex; flex-direction: column; max-width: 72%; }
.crm-msg.in { align-self: flex-start; align-items: flex-start; }
.crm-msg.out { align-self: flex-end; align-items: flex-end; }
.crm-bubble { padding: 9px 13px; border-radius: 16px; font-size: 14px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; border: 1px solid transparent; }
.crm-msg.in .crm-bubble { background: var(--crm-panel-2); color: var(--crm-text); border-bottom-left-radius: 5px; border-color: rgba(255,255,255,.05); }
.crm-msg.out .crm-bubble { background: linear-gradient(135deg, rgba(212,175,82,.28), rgba(154,110,34,.22)); color: #fbf3dc; border-color: rgba(212,175,82,.3); border-bottom-right-radius: 5px; }
.crm-msg.failed .crm-bubble { border-color: rgba(255,93,88,.55); }
.crm-msg.scheduled .crm-bubble { border-style: dashed; opacity: .85; }
.crm-meta { font-size: 10.5px; color: var(--crm-muted-2); margin: 3px 6px 0; display: flex; gap: 6px; align-items: center; white-space: nowrap; }
.crm-meta .st { font-weight: 600; }
.crm-meta .st.ok { color: #9be3b4; }
.crm-meta .st.bad { color: #ffb3af; }
.crm-meta .st.sched { color: #ffd98a; }
.crm-call { align-self: center; display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--crm-muted); background: rgba(255,255,255,.03); border: 1px solid var(--crm-line); border-radius: 12px; padding: 7px 12px; max-width: 90%; flex-wrap: wrap; justify-content: center; }
.crm-call.missed { border-color: rgba(255,93,88,.35); color: #ffb3af; }
.crm-call audio { height: 30px; max-width: 260px; }
.crm-notecard { align-self: stretch; margin: 2px 6%; font-size: 12.5px; color: #e8dcb8; background: rgba(212,175,82,.06); border: 1px dashed rgba(212,175,82,.35); border-radius: 12px; padding: 8px 12px; white-space: pre-wrap; }
.crm-notecard .who { font-size: 10.5px; color: var(--crm-muted-2); margin-top: 3px; }
.crm-newpill { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 2; }

/* composer */
.crm-composer { border-top: 1px solid var(--crm-line-gold); padding: 10px 14px 12px; background: rgba(10,10,12,.45); }
.crm-composer .crm-textarea { width: 100%; min-height: 62px; max-height: 180px; resize: vertical; line-height: 1.45; font-size: 14px; }
.crm-ctools { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.crm-ctools .crm-select { font-size: 12px; padding: 5px 24px 5px 9px; max-width: 200px; }
.crm-counter { font-size: 11px; color: var(--crm-muted-2); font-family: var(--crm-mono); margin-left: auto; }
.crm-counter.warn { color: #ffd98a; }
.crm-sched { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 12px; color: #ffd98a; }
.crm-sched input { font-size: 12.5px; padding: 5px 9px; color-scheme: dark; }
.crm-dnc-warn { font-size: 11.5px; color: #ffb3af; margin-top: 6px; }

/* popover menu */
.crm-menu-wrap { position: relative; }
.crm-menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; z-index: 5; background: linear-gradient(180deg, #171b25, #0f1118); border: 1px solid rgba(212,175,82,.35); border-radius: 12px; box-shadow: 0 16px 40px rgba(0,0,0,.55); padding: 6px; display: none; }
.crm-menu.left { right: auto; left: 0; }
.crm-menu.up { top: auto; bottom: calc(100% + 6px); }
.crm-menu.open { display: block; }
.crm-menu button, .crm-menu a { display: flex; width: 100%; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 8px; background: none; border: 0; color: #d9d0b6; font-size: 13px; text-align: left; text-decoration: none; }
.crm-menu button:hover, .crm-menu a:hover { background: rgba(212,175,82,.1); color: var(--crm-cream); text-decoration: none; }
.crm-menu .sep { height: 1px; background: var(--crm-line); margin: 5px 4px; }
.crm-menu .hint { font-size: 11px; color: var(--crm-muted-2); padding: 4px 10px 6px; }
.crm-menu .on::after { content: '✓'; margin-left: auto; color: var(--crm-gold-2); }
.crm-menu .tpl-body { display: block; font-size: 11px; color: var(--crm-muted-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 300px; }

/* in-panel notes / follow-ups lists (thread sub-tabs) */
.crm-tpane { flex: 1; overflow-y: auto; padding: 14px 16px; overscroll-behavior: contain; }
.crm-note { background: rgba(212,175,82,.05); border: 1px solid rgba(212,175,82,.22); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; font-size: 13px; white-space: pre-wrap; position: relative; }
.crm-note .who { font-size: 11px; color: var(--crm-muted-2); margin-top: 4px; display: flex; gap: 8px; align-items: center; }
.crm-note .del { margin-left: auto; background: none; border: 0; color: var(--crm-muted-2); font-size: 12px; padding: 2px 6px; }
.crm-note .del:hover { color: #ffb3af; }
.crm-form { display: grid; gap: 8px; background: rgba(255,255,255,.025); border: 1px solid var(--crm-line); border-radius: 12px; padding: 12px; margin-top: 10px; }
.crm-form h5 { margin: 0 0 2px; font-family: var(--crm-display); font-size: 17px; font-weight: 600; color: var(--crm-cream); }
.crm-form-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.crm-form-row label { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--crm-muted-2); min-width: 60px; }
.crm-form .crm-input, .crm-form .crm-textarea { flex: 1; min-width: 140px; }
.crm-form .crm-textarea { min-height: 48px; resize: vertical; }
.crm-form input[type="datetime-local"] { color-scheme: dark; }
.crm-quick { display: flex; gap: 6px; flex-wrap: wrap; }

/* ------------------------------------------------------------
   5. Follow-ups tab
   ------------------------------------------------------------ */
.crm-fu, .crm-saved { flex: 1; overflow-y: auto; padding: 14px 18px 24px; overscroll-behavior: contain; }
.crm-sec { margin-bottom: 14px; }
.crm-sech { display: flex; align-items: center; gap: 10px; font-family: var(--crm-display); font-size: 19px; font-weight: 600; color: var(--crm-cream); padding: 6px 0; border-bottom: 1px solid var(--crm-line-gold); margin-bottom: 8px; cursor: default; }
.crm-sech .n { font-family: var(--crm-font); font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: rgba(212,175,82,.15); color: var(--crm-gold-2); }
.crm-sech.over { color: #ffb3af; }
.crm-sech.tog { cursor: pointer; }
.crm-sech .car { margin-left: auto; font-size: 12px; color: var(--crm-muted-2); }
.crm-furow, .crm-favrow { display: grid; grid-template-columns: 110px 1fr auto; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--crm-line); border-radius: 12px; background: rgba(255,255,255,.02); margin-bottom: 6px; }
.crm-furow.over { border-color: rgba(255,93,88,.35); }
.crm-furow.done { opacity: .6; }
.crm-furow .due { font-family: var(--crm-mono); font-size: 12px; color: var(--crm-gold-2); line-height: 1.3; }
.crm-furow.over .due { color: #ffb3af; }
.crm-furow .who { font-weight: 600; font-size: 13.5px; color: var(--crm-cream); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.crm-furow .who button { background: none; border: 0; padding: 0; color: var(--crm-cyan-2); font-weight: 600; font-size: 13.5px; }
.crm-furow .who button:hover { text-decoration: underline; }
.crm-furow .note { font-size: 12.5px; color: var(--crm-muted); margin-top: 2px; white-space: pre-wrap; }
.crm-furow .sms { font-size: 11.5px; color: #ffd98a; margin-top: 3px; }
.crm-furow .acts, .crm-favrow .acts { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.crm-favrow { grid-template-columns: 1fr auto; }
.crm-favrow .lb { font-weight: 600; font-size: 13.5px; color: var(--crm-cream); }
.crm-favrow .sb { font-size: 12.5px; color: var(--crm-muted); }
.crm-favrow .by { font-size: 11px; color: var(--crm-muted-2); margin-top: 2px; }
.crm-favrow .nt { font-size: 12.5px; color: #e8dcb8; margin-top: 4px; cursor: text; display: flex; gap: 6px; align-items: center; }
.crm-favrow .nt .pen { opacity: .4; font-size: 11px; }
.crm-favrow .nt:hover .pen { opacity: 1; }
.crm-favrow .nt input { flex: 1; font-size: 12.5px; padding: 3px 8px; }
.crm-toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }

/* ------------------------------------------------------------
   6. Confirm box + toasts
   ------------------------------------------------------------ */
.crm-confirm { position: absolute; inset: 0; z-index: 8; background: rgba(3,5,9,.66); backdrop-filter: blur(4px); display: none; place-items: center; padding: 20px; }
.crm-confirm.open { display: grid; }
.crm-confirm .bx { max-width: 440px; width: 100%; background: linear-gradient(180deg, #12161f, #0c0e14); border: 1px solid rgba(212,175,82,.4); border-radius: 16px; padding: 24px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.crm-confirm h3 { font-family: var(--crm-display); font-size: 21px; color: var(--crm-cream); margin: 0 0 8px; font-weight: 600; }
.crm-confirm p { color: var(--crm-muted); font-size: 13.5px; line-height: 1.6; margin: 0 0 18px; }
.crm-confirm .btns { display: flex; gap: 10px; justify-content: center; }
.crm-toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 140; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.crm-toast { pointer-events: auto; background: #131316; border: 1px solid rgba(212,175,82,.35); color: var(--crm-text); padding: 10px 16px; border-radius: 12px; font-size: 13px; box-shadow: 0 10px 30px rgba(0,0,0,.5); max-width: min(92vw, 420px); animation: crmToastIn .2s ease-out; cursor: default; }
.crm-toast.click { cursor: pointer; }
.crm-toast.bad { border-color: rgba(255,93,88,.55); }
.crm-toast.good { border-color: rgba(89,214,135,.5); }
@keyframes crmToastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* loading shimmer */
.crm-loading { padding: 30px; text-align: center; color: var(--crm-muted-2); font-size: 13px; }
.crm-spin { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(212,175,82,.3); border-top-color: var(--crm-gold); border-radius: 50%; animation: crmSpin .8s linear infinite; vertical-align: -2px; margin-right: 6px; }
@keyframes crmSpin { to { transform: rotate(360deg); } }

/* scrollbars */
.crm-root ::-webkit-scrollbar { width: 9px; height: 9px; }
.crm-root ::-webkit-scrollbar-thumb { background: rgba(212,175,82,.18); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
.crm-root ::-webkit-scrollbar-thumb:hover { background: rgba(212,175,82,.35); background-clip: padding-box; }

/* ------------------------------------------------------------
   7. Mobile (≤ 900px): full-screen sheet, list ↔ thread
   ------------------------------------------------------------ */
@media (max-width: 900px) {
  .crm-dlg { left: 0; top: 0; transform: none; width: 100vw; height: 100dvh; border-radius: 0; border: 0; animation: crmUp .22s ease-out; overscroll-behavior: contain; }
  @keyframes crmUp { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
  .crm-top { padding: 10px 12px; gap: 8px; flex-wrap: wrap; }
  .crm-brand { font-size: 19px; }
  .crm-brand small { display: none; }
  .crm-tabs { margin-left: 0; order: 5; width: 100%; justify-content: space-between; }
  .crm-tab { flex: 1; justify-content: center; padding: 7px 6px; font-size: 12.5px; }
  .crm-linesel { max-width: 120px; font-size: 11.5px; }
  .crm-inbox { grid-template-columns: 1fr; }
  .crm-inbox[data-mview="list"] .crm-thread { display: none; }
  .crm-inbox[data-mview="thread"] .crm-list { display: none; }
  .crm-list { border-right: 0; }
  .crm-back { display: inline-grid; }
  .crm-thead { padding: 8px 10px; gap: 8px; }
  .crm-tname .nm { font-size: 18px; }
  .crm-tacts { width: 100%; justify-content: flex-start; gap: 6px; }
  .crm-msg { max-width: 86%; }
  .crm-conv { padding: 10px 10px; }
  .crm-composer { padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); }
  .crm-ctools .crm-select { max-width: 150px; }
  .crm-fu, .crm-saved { padding: 12px 12px 30px; }
  .crm-furow { grid-template-columns: 1fr; gap: 6px; }
  .crm-furow .acts, .crm-favrow .acts { justify-content: flex-start; }
  .crm-favrow { grid-template-columns: 1fr; }
  .crm-toasts { bottom: calc(16px + env(safe-area-inset-bottom)); }
}
@media (max-width: 480px) {
  .crm-tab .n { display: none; }
  .crm-chips { padding-bottom: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .crm-dlg, .crm-toast, .crm-btn.pulse svg, .crm-btn.pulse .crm-badge { animation: none !important; }
  .crm-conv { scroll-behavior: auto; }
}
