/* crm.css — CRM (Leads) view. All selectors are scoped under .crm-* so this
   file CANNOT affect any other Flowboard surface. Built on Flowboard design
   tokens (see styles/tokens.css) — keep parity with .project-header, .btn,
   .tab-badge, etc. */

.crm-root {
  display: flex; flex-direction: column;
  height: 100%; min-height: 0;
  background: var(--bg-app);
}

/* ── Header — mirrors .project-header ─────────────────────────────── */
.crm-header {
  flex-shrink: 0;
  padding: 20px 24px 14px;
  background: var(--bg-surface);
}
.crm-title-row {
  display: flex; align-items: center; gap: 10px;
}
.crm-title {
  font-size: 22px; font-weight: 700; color: var(--ink-strong);
  letter-spacing: -0.02em;
}
.crm-title-sub {
  font-size: 13px; font-weight: 500; color: var(--ink-muted);
  margin-left: 6px;
}

/* Stat chips on the title row (counts: today, overdue, hot) */
.crm-stat-chips {
  display: flex; gap: 6px; margin-left: auto;
}
.crm-stat-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  background: var(--bg-subtle); color: var(--ink-muted);
  font-size: 12px; font-weight: 600;
  border: 1px solid var(--border);
}
.crm-stat-chip b { color: var(--ink-strong); font-weight: 700; }
.crm-stat-chip.is-warn  { background: rgba(253,171,61,.10); color: #b66f00; border-color: rgba(253,171,61,.32); }
.crm-stat-chip.is-warn b { color: #8a5300; }
.crm-stat-chip.is-danger { background: rgba(226,68,92,.08); color: #b41f37; border-color: rgba(226,68,92,.30); }
.crm-stat-chip.is-danger b { color: #8a1024; }

/* Tabs row — mirrors .project-tabs (only one tab today, but the slot is here) */
.crm-tabs {
  display: flex; align-items: center; gap: 2px;
}
.crm-tab {
  padding: 10px 14px; font-size: 13.5px; font-weight: 500;
  color: var(--ink-muted); cursor: pointer; border: none; background: none;
  border-bottom: 2px solid transparent;
  display: flex; align-items: center; gap: 6px;
  transition: color 0.1s;
}
.crm-tab:hover { color: var(--ink-strong); }
.crm-tab.is-active {
  color: var(--brand); border-bottom-color: var(--brand); font-weight: 600;
}
.crm-tab .tab-badge {
  background: var(--bg-subtle); color: var(--ink-muted);
  border-radius: 999px; padding: 1px 7px; font-size: 11px; font-weight: 600;
}
.crm-tab.is-active .tab-badge { background: var(--brand-soft); color: var(--brand); }

/* ── Toolbar — mirrors .board-toolbar ─────────────────────────────── */
.crm-toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 24px; background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: nowrap;
}
.crm-search {
  flex: 0 1 320px;
  padding: 6px 12px;
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--bg-surface);
  font: inherit; font-size: 13px; color: var(--ink-strong);
  outline: none; transition: border-color .12s, box-shadow .12s;
  min-height: 32px;
}
.crm-search:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.crm-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border: 1px solid transparent; background: transparent;
  border-radius: var(--r-md);
  font-size: 13px; font-weight: 500; color: var(--ink-body);
  cursor: pointer; transition: background .1s, border-color .1s;
  min-height: 32px;
}
.crm-toggle:hover { background: var(--bg-subtle); }
.crm-toggle input { display: none; }
.crm-toggle.is-on {
  background: #eef3ff; color: var(--brand-dark);
  border-color: #d5e3fb;
}
.crm-toolbar-right {
  margin-left: auto; display: flex; align-items: center; gap: 6px;
}

/* Buttons — alias the project's .btn / .btn-primary. We don't redefine .btn
   itself; we reuse it. These crm-* button classes are kept only as aliases
   for things the project's .btn doesn't cover (danger). */
.crm-btn-danger {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border: 1px solid #f4c1cb; border-radius: var(--r-md);
  background: var(--bg-surface); color: #c0223a;
  font-size: 13px; font-weight: 500;
  cursor: pointer; min-height: 32px;
}
.crm-btn-danger:hover { background: #fdf2f4; }

/* ── Board ────────────────────────────────────────────────────────── */
.crm-board {
  flex: 1; min-height: 0;
  display: flex; gap: 12px;
  padding: 16px 20px 20px;
  overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x proximity;
  background: var(--bg-app);
}
.crm-col {
  flex: 0 0 280px;
  display: flex; flex-direction: column;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  scroll-snap-align: start;
  min-height: 0;
  transition: background .12s, border-color .12s;
}
.crm-col.is-drop {
  background: #eef3ff;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.crm-col-head {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-row);
  font-size: 13px; font-weight: 700; color: var(--ink-strong);
}
.crm-col-dot {
  width: 8px; height: 8px; border-radius: 999px;
  background: var(--stage-color, var(--ink-faint));
}
.crm-col-name { flex: 1; letter-spacing: .01em; }
.crm-col-count {
  font-size: 11px; color: var(--ink-muted); background: var(--bg-subtle);
  padding: 1px 8px; border-radius: 999px; font-weight: 600;
}

.crm-col-body {
  flex: 1; min-height: 0;
  padding: 8px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px;
}
.crm-empty {
  text-align: center; color: var(--ink-faint); font-size: 12px;
  padding: 20px 8px;
}

/* ── Card ─────────────────────────────────────────────────────────── */
.crm-card {
  position: relative;
  padding: 10px 12px 10px 14px;
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--bg-surface);
  cursor: pointer;
  transition: transform .1s, box-shadow .1s, border-color .1s;
}
.crm-card::before {
  content: "";
  position: absolute; left: 0; top: 8px; bottom: 8px;
  width: 3px; border-radius: 2px;
  background: var(--stage-color, var(--ink-faint));
}
.crm-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}
.crm-card.is-dragging { opacity: .4; }
.crm-card.is-overdue { border-color: rgba(226,68,92,.35); }
.crm-card.is-overdue::before { background: var(--prio-high); }

.crm-card-head {
  display: flex; align-items: baseline; justify-content: flex-start; gap: 6px;
  margin-bottom: 4px;
}
.crm-card-flag {
  font-size: 14px; line-height: 1; flex: none;
  /* Lift slightly so the flag's baseline lines up visually with the
     name's lowercase-x height — flag emojis sit deeper than text. */
  position: relative; top: 1px;
  /* Fall back gracefully on platforms without Apple/Google flag glyphs
     (old Windows). The text inside the emoji is hidden behind the
     character itself when supported. */
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji",
               "Twemoji Mozilla", sans-serif;
}
.crm-card-name {
  font-size: 13px; font-weight: 600; color: var(--ink-strong);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1 1 auto; min-width: 0;
}
.crm-card-head .crm-card-value { margin-left: auto; }
.crm-card-value {
  font-size: 11px; color: #00853d; font-weight: 700;
  background: rgba(0,200,117,.1); padding: 2px 6px; border-radius: var(--r-sm);
  flex-shrink: 0;
}

.crm-card-meta { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 6px; }
.crm-pill {
  font-size: 10px; font-weight: 600; color: var(--ink-muted);
  background: var(--bg-subtle); padding: 2px 7px; border-radius: 999px;
}
.crm-pill-meta { background: rgba(24,119,242,.12); color: #1877f2; }

.crm-card-contact {
  font-size: 11px; color: var(--ink-muted); line-height: 1.5;
  display: flex; flex-direction: column; gap: 2px;
}
.crm-card-contact a { color: var(--brand); text-decoration: none; }
.crm-card-contact a:hover { text-decoration: underline; }
.crm-card-email {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Lead-creation timestamp. Sits between contact info and the "next
   action" reminder so the sales rep can answer "how fresh is this?"
   at a glance without opening the drawer. */
.crm-card-created {
  margin-top: 6px; font-size: 10.5px; color: var(--ink-faint, #a3a8b6);
  font-weight: 500; letter-spacing: .01em;
  display: inline-flex; align-items: center; gap: 4px;
}
.crm-card-due {
  margin-top: 6px; padding: 3px 8px; border-radius: var(--r-sm);
  font-size: 11px; font-weight: 600;
  background: var(--brand-soft); color: var(--brand-dark);
}
.crm-card-due.today    { background: rgba(253,171,61,.16); color: #b66f00; }
.crm-card-due.overdue  { background: rgba(226,68,92,.12); color: #c0223a; }

/* ── Drawer ───────────────────────────────────────────────────────── */
.crm-drawer-shade {
  position: fixed; inset: 0; background: rgba(15,23,41,.36);
  z-index: 9000; display: flex; justify-content: flex-end;
  animation: crmFadeIn .15s ease-out;
}
@keyframes crmFadeIn { from { opacity: 0 } to { opacity: 1 } }
.crm-drawer {
  width: min(540px, 100vw);
  background: var(--bg-surface); height: 100vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-drawer);
  animation: crmSlideIn .2s cubic-bezier(.2,.7,.3,1);
}
@keyframes crmSlideIn { from { transform: translateX(40px); opacity: 0 } to { transform: translateX(0); opacity: 1 } }
.crm-drawer-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border-row);
}
.crm-drawer-name { font-size: 17px; font-weight: 700; color: var(--ink-strong); }
.crm-drawer-sub  { font-size: 11px; color: var(--ink-muted); margin-top: 4px; font-family: ui-monospace, monospace; }
.crm-icon-btn {
  width: 30px; height: 30px; border: 0; border-radius: var(--r-md);
  background: transparent; color: var(--ink-muted); cursor: pointer; font-size: 16px;
}
.crm-icon-btn:hover { background: var(--bg-subtle); color: var(--ink-strong); }

/* Drawer tabs — mirror .project-tabs */
.crm-drawer-tabs {
  display: flex; gap: 2px; padding: 0 14px;
  border-bottom: 1px solid var(--border-row);
}
.crm-drawer-tabs button {
  padding: 10px 14px; border: 0; background: transparent;
  font-size: 13px; font-weight: 500; color: var(--ink-muted);
  cursor: pointer; border-bottom: 2px solid transparent;
  transition: color .1s, border-color .1s;
}
.crm-drawer-tabs button:hover { color: var(--ink-strong); }
.crm-drawer-tabs button.is-active {
  color: var(--brand); border-bottom-color: var(--brand); font-weight: 600;
}

.crm-drawer-body {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 16px 20px 20px;
}

/* ── Forms ────────────────────────────────────────────────────────── */
.crm-form {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px;
}
.crm-row {
  display: flex; flex-direction: column; gap: 4px;
}
.crm-row-full { grid-column: 1 / -1; }
.crm-row span {
  color: var(--ink-muted); font-size: 11px;
  text-transform: uppercase; letter-spacing: .04em; font-weight: 700;
}
.crm-row input, .crm-row select, .crm-row textarea {
  width: 100%; padding: 7px 10px;
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--bg-surface);
  font: inherit; font-size: 13px; color: var(--ink-strong); font-weight: 500;
  outline: none; transition: border-color .1s, box-shadow .1s;
  min-height: 32px;
}
.crm-row textarea { font-family: inherit; resize: vertical; min-height: 64px; }
.crm-row input:focus, .crm-row select:focus, .crm-row textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

/* ── Campaign details panel (Meta-sourced leads) ───────────────────── */
.crm-camp-wrap {
  margin-top: 4px;
  padding: 0;
  background: linear-gradient(180deg, rgba(108,43,217,.04), rgba(108,43,217,.02));
  border: 1px solid rgba(108,43,217,.18);
  border-radius: var(--r-md);
  overflow: hidden;
}
.crm-camp-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px;
  cursor: pointer; user-select: none;
}
.crm-camp-head:hover { background: rgba(108,43,217,.06); }
.crm-camp-title {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em;
  color: var(--brand);
}
.crm-camp-platform-tag {
  font-size: 10px; font-weight: 800;
  padding: 2px 7px; border-radius: 999px;
  letter-spacing: .04em;
}
.crm-camp-platform-tag.is-fb,
.crm-camp-platform-tag.is-facebook   { background: rgba(24,119,242,.12); color: #1877f2; border: 1px solid rgba(24,119,242,.26); }
.crm-camp-platform-tag.is-ig,
.crm-camp-platform-tag.is-instagram  { background: rgba(228,64,95,.10);  color: #c13584;  border: 1px solid rgba(228,64,95,.28); }
.crm-camp-caret {
  transition: transform .15s ease;
  color: var(--ink-muted); font-size: 12px;
}
.crm-camp-caret.is-open { transform: rotate(180deg); }

.crm-camp-body {
  padding: 6px 12px 12px;
  border-top: 1px solid rgba(108,43,217,.14);
  background: var(--bg-surface);
}
.crm-camp-hint {
  font-size: 11.5px; line-height: 1.4;
  color: var(--ink-muted);
  background: rgba(253,171,61,.08);
  border: 1px solid rgba(253,171,61,.30);
  padding: 6px 10px;
  border-radius: var(--r-sm);
  margin: 8px 0;
}
.crm-camp-hint code {
  font-family: ui-monospace, monospace; font-size: 11px;
  background: rgba(0,0,0,.05); padding: 1px 4px; border-radius: 3px;
}

.crm-camp-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
  margin: 10px 0 12px;
}
@media (max-width: 540px) { .crm-camp-grid { grid-template-columns: 1fr; } }
.crm-camp-field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.crm-camp-label {
  font-size: 10px; font-weight: 800; letter-spacing: .04em;
  text-transform: uppercase; color: var(--ink-muted);
}
.crm-camp-value {
  font-size: 13px; font-weight: 600; color: var(--ink-strong);
  display: flex; flex-direction: column; gap: 2px;
  word-break: break-word;
}
.crm-camp-id {
  font-family: ui-monospace, monospace; font-size: 10.5px;
  font-weight: 500; color: var(--ink-muted);
  background: var(--bg-subtle);
  padding: 1px 6px; border-radius: 3px;
  align-self: flex-start;
}

.crm-camp-actions {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding-top: 8px;
  border-top: 1px dashed rgba(108,43,217,.18);
}
.crm-camp-flash {
  font-size: 12px; font-weight: 700; color: #00853d;
  animation: crmCampFlash .3s ease-out;
}
.crm-camp-error {
  font-size: 11.5px; color: #c0223a;
  background: #fff0f3; padding: 3px 8px; border-radius: 4px;
  border: 1px solid #f5c0cc;
}
.crm-camp-link {
  font-size: 12px; font-weight: 600;
  color: var(--brand); text-decoration: none;
  margin-left: auto;
}
.crm-camp-link:hover { text-decoration: underline; }

@keyframes crmCampFlash {
  from { opacity: 0; transform: translateX(-4px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Course picker — inline "add new course" UI ───────────────────── */
.crm-course-add {
  display: flex; flex-direction: column; gap: 6px;
  padding: 8px; border: 1px dashed var(--brand);
  border-radius: var(--r-md); background: var(--brand-soft);
}
.crm-course-add input {
  width: 100%; padding: 7px 10px;
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--bg-surface);
  font: inherit; font-size: 13px; color: var(--ink-strong); font-weight: 500;
  outline: none; min-height: 32px;
}
.crm-course-add input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.crm-course-add-actions {
  display: flex; justify-content: flex-end; gap: 6px;
}

/* ── Activity timeline ────────────────────────────────────────────── */
.crm-activity-actions {
  display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px;
}
.crm-act-trigger {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-surface); font-size: 13px; font-weight: 500;
  color: var(--ink-body); cursor: pointer; transition: all .1s;
  min-height: 32px;
}
.crm-act-trigger:hover {
  background: var(--bg-subtle); color: var(--ink-strong);
}
.crm-act-trigger.is-open {
  background: #eef3ff; color: var(--brand-dark); border-color: #d5e3fb;
}
.crm-act-trigger-emoji { font-size: 13px; line-height: 1; }

.crm-act-composer {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px;
  padding: 14px; margin-bottom: 16px;
  background: var(--bg-subtle);
  border: 1px solid var(--border); border-radius: var(--r-lg);
  animation: crmComposerIn .18s ease-out;
}
.crm-act-composer .crm-row              { margin: 0; }
.crm-act-composer .crm-row-full         { grid-column: 1 / -1; }
.crm-act-composer-actions {
  grid-column: 1 / -1;
  display: flex; gap: 8px; justify-content: flex-end; margin-top: 2px;
}
@keyframes crmComposerIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.crm-timeline { display: flex; flex-direction: column; gap: 10px; }
.crm-act {
  padding: 10px 12px; border: 1px solid var(--border-row);
  border-radius: var(--r-md);
  background: var(--bg-surface);
}
.crm-act-head { display: flex; justify-content: space-between; align-items: center; }
.crm-act-kind {
  font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 2px 8px; border-radius: var(--r-sm);
  background: var(--bg-subtle); color: var(--ink-body);
}
.crm-act-call           { background: var(--brand-soft);            color: var(--brand-dark); }
.crm-act-demo_scheduled { background: rgba(253,171,61,.16);         color: #b66f00; }
.crm-act-demo_done      { background: rgba(162,93,220,.16);         color: #6c2bd9; }
.crm-act-stage_change   { background: rgba(0,200,117,.16);          color: #00853d; }
.crm-act-reminder_set   { background: rgba(253,113,61,.16);         color: #b54300; }
.crm-act-meta_intake    { background: rgba(24,119,242,.14);         color: #1877f2; }
.crm-act-note           { background: var(--bg-subtle);             color: var(--ink-body); }
.crm-act-time { font-size: 11px; color: var(--ink-faint); }
.crm-act-body {
  margin-top: 6px; font-size: 12px; color: var(--ink-body); line-height: 1.5;
}
.crm-act-body b { color: var(--ink-strong); font-weight: 700; }

/* ── Reminders tab ────────────────────────────────────────────────── */
.crm-reminder { display: flex; flex-direction: column; gap: 14px; }
.crm-reminder-current {
  padding: 12px 14px; background: var(--brand-soft);
  border: 1px solid #b8d6fc; border-radius: var(--r-md);
  font-size: 13px; color: var(--ink-strong);
}
.crm-reminder-current.overdue {
  background: rgba(226,68,92,.06); border-color: rgba(226,68,92,.18);
  color: #c0223a;
}
.crm-quick { display: flex; gap: 6px; flex-wrap: wrap; }
.crm-quick button {
  padding: 6px 12px; border: 1px solid var(--border);
  border-radius: 999px; background: var(--bg-surface);
  font-size: 12px; font-weight: 500; color: var(--ink-body);
  cursor: pointer;
}
.crm-quick button:hover { background: var(--bg-subtle); border-color: var(--border-strong); }

/* ── Modal — mirrors the project's modal-backdrop / modal-card pattern ── */
.crm-modal-shade {
  position: fixed; inset: 0; background: rgba(15,23,41,.36);
  z-index: 9100; display: flex; align-items: center; justify-content: center;
  animation: crmFadeIn .15s ease-out;
}
.crm-modal {
  width: min(560px, 92vw); max-height: 90vh; overflow-y: auto;
  background: var(--bg-surface); border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
}
.crm-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border-row);
}
.crm-modal-head h2 { margin: 0; font-size: 17px; font-weight: 700; color: var(--ink-strong); }
.crm-modal .crm-form { padding: 16px 20px; }
.crm-modal-actions {
  grid-column: 1 / -1;
  display: flex; justify-content: flex-end; gap: 8px;
  padding-top: 8px; border-top: 1px solid var(--border-row); margin-top: 8px;
}

/* Meta Ads integration modal */
.crm-meta-modal {
  width: min(720px, 94vw);
  /* Size to content up to 94vh — when there's only a couple of
     intake rows the modal stays compact instead of stretching to
     fill the screen with empty space. Once content exceeds the
     cap, the body's overflow-y kicks in. */
  max-height: 94vh;
  background: var(--bg-surface); border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
}
.crm-meta-body {
  padding: 16px 20px;
  /* Outer scroll only — long content overflows here, but inner
     panels (recent-intake rows, JSON dumps) flow naturally so
     users don't have to fight with nested scroll regions. */
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 12px;
  flex: 1 1 auto; min-height: 0;
}
/* Recent-intake rows + JSON payloads — no inner scroll, no
   inner cap. Wraps long single-line JSON so it can't push the
   modal sideways. Vertical growth is handled by the body's
   outer overflow-y. */
.crm-meta-modal pre,
.crm-meta-modal .crm-meta-evt-raw,
.crm-meta-modal code.crm-meta-json,
.crm-meta-modal .crm-meta-evt-summary {
  max-height: none;
  overflow: visible;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.crm-meta-status {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--r-md);
  font-size: 13px; font-weight: 600;
}
.crm-meta-status.is-ok   { background: rgba(0,200,117,.10); color: #00853d; border: 1px solid rgba(0,200,117,.30); }
.crm-meta-status.is-warn { background: rgba(253,171,61,.10); color: #b66f00; border: 1px solid rgba(253,171,61,.32); }
.crm-meta-status-dot {
  width: 8px; height: 8px; border-radius: 999px;
  background: currentColor; flex-shrink: 0;
}
.crm-meta-status-text { flex: 1; }

.crm-meta-h {
  margin: 4px 0 2px; font-size: 12px; font-weight: 700;
  color: var(--ink-muted); text-transform: uppercase; letter-spacing: .04em;
}
.crm-meta-p {
  margin: 0; font-size: 13px; color: var(--ink-body); line-height: 1.5;
}
.crm-meta-p code,
.crm-meta-vars code {
  font-family: ui-monospace, monospace; font-size: 12px;
  background: var(--bg-subtle); padding: 1px 6px; border-radius: var(--r-sm);
  color: var(--ink-strong);
}
.crm-meta-p-faint { color: var(--ink-muted); font-size: 12px; }

.crm-meta-copy-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border: 1px solid var(--border);
  border-radius: var(--r-md); background: var(--bg-subtle);
}
.crm-meta-copy-row code {
  flex: 1; font-family: ui-monospace, monospace; font-size: 12px;
  color: var(--ink-strong); white-space: nowrap; overflow-x: auto;
  background: transparent; padding: 0;
}

.crm-meta-vars {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 6px;
}
.crm-meta-vars li {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--r-md);
  border: 1px solid var(--border); background: var(--bg-surface);
  font-size: 12.5px;
}
.crm-meta-vars li.is-ok      { border-color: rgba(0,200,117,.30); background: rgba(0,200,117,.06); }
.crm-meta-vars li.is-missing { border-color: rgba(253,171,61,.32); background: rgba(253,171,61,.06); }
.crm-meta-vars li code { flex-shrink: 0; }
.crm-meta-vars li span { color: var(--ink-body); }
.crm-meta-vars li.is-ok span      { color: #00853d; font-weight: 600; }
.crm-meta-vars li.is-missing span { color: #b66f00; font-weight: 500; }

/* ── Editable Meta credentials form ──────────────────────────────────── */
.crm-meta-fields {
  display: flex; flex-direction: column; gap: 14px;
  margin: 4px 0 10px;
}
.crm-meta-field { display: flex; flex-direction: column; gap: 6px; }
.crm-meta-field-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
@media (max-width: 540px) { .crm-meta-field-grid { grid-template-columns: 1fr; } }

.crm-meta-field-head label {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--ink-strong);
}
.crm-meta-field-head code {
  font-family: ui-monospace, monospace; font-size: 11.5px;
  background: var(--bg-subtle); padding: 2px 6px; border-radius: 4px;
  color: var(--ink-strong);
}
.crm-meta-pill {
  font-size: 10px; font-weight: 800; letter-spacing: .04em;
  text-transform: uppercase;
  padding: 2px 7px; border-radius: 999px;
  border: 1px solid transparent;
}
.crm-meta-pill.is-ok      { color: #00853d; background: rgba(0,200,117,.10);  border-color: rgba(0,200,117,.30); }
.crm-meta-pill.is-missing { color: #b66f00; background: rgba(253,171,61,.10); border-color: rgba(253,171,61,.32); }
.crm-meta-pill.is-optional { opacity: .85; }
.crm-meta-source {
  font-size: 10px; font-weight: 600; color: var(--ink-faint);
  font-style: italic;
}

.crm-meta-input {
  width: 100%; box-sizing: border-box;
  font: inherit; font-size: 13px;
  padding: 8px 10px;
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  background: white;
  color: var(--ink-strong);
  transition: border-color .12s ease, box-shadow .12s ease;
}
.crm-meta-input::placeholder { color: var(--ink-faint); font-style: italic; }
.crm-meta-input:hover:not(:disabled) { border-color: var(--border-strong); }
.crm-meta-input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(108,43,217,.12); }
.crm-meta-input:disabled { background: var(--bg-subtle); color: var(--ink-faint); cursor: not-allowed; }

.crm-meta-input-row { display: flex; gap: 6px; align-items: stretch; }
.crm-meta-input-row .crm-meta-input { flex: 1; }
.crm-meta-input-row .btn { white-space: nowrap; }
.crm-meta-eye:disabled,
.crm-meta-clear:disabled { opacity: .5; cursor: not-allowed; }
.crm-meta-clear { color: #c0223a; border-color: #f5c0cc; }
.crm-meta-clear:hover { background: #fff0f3; }

.crm-meta-field-help {
  font-size: 11.5px; color: var(--ink-muted); line-height: 1.45;
}
.crm-meta-field-help code {
  font-family: ui-monospace, monospace; font-size: 11px;
  background: var(--bg-subtle); padding: 1px 4px; border-radius: 3px;
}

.crm-meta-save-row {
  display: flex; align-items: center; gap: 12px;
  margin-top: 4px;
}
.crm-meta-saved-flash {
  font-size: 12px; font-weight: 700; color: #00853d;
  animation: crmMetaFlash .3s ease-out;
}
@keyframes crmMetaFlash {
  from { opacity: 0; transform: translateX(-4px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Auto-sync block ─────────────────────────────────────────────────── */
.crm-meta-sync {
  display: flex; flex-direction: column; gap: 8px;
  padding: 12px;
  background: linear-gradient(180deg, rgba(0,200,117,.04), rgba(0,200,117,.02));
  border: 1px solid rgba(0,200,117,.22);
  border-radius: var(--r-md);
  margin: 4px 0 12px;
}
.crm-meta-sync-row {
  display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap;
}
.crm-meta-sync-interval {
  display: flex; flex-direction: column; gap: 4px;
}
.crm-meta-sync-interval span {
  font-size: 10.5px; font-weight: 800; letter-spacing: .04em;
  text-transform: uppercase; color: var(--ink-muted);
}
.crm-meta-sync-interval select {
  font: inherit; font-size: 13px;
  padding: 7px 10px; min-width: 150px;
  border: 1px solid var(--border-soft); border-radius: var(--r-md);
  background: white; color: var(--ink-strong); font-weight: 600;
}
.crm-meta-sync-interval select:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(108,43,217,.12);
}

.crm-meta-sync-status {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  font-size: 12px;
}
.crm-meta-sync-pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 800; letter-spacing: .04em;
  text-transform: uppercase;
  padding: 3px 8px; border-radius: 999px;
}
.crm-meta-sync-pill.is-on  { color: #00853d; background: rgba(0,200,117,.10); border: 1px solid rgba(0,200,117,.30); }
.crm-meta-sync-pill.is-off { color: var(--ink-muted); background: var(--bg-subtle); border: 1px solid var(--border-soft); }

.crm-meta-sync-meta {
  font-size: 11.5px; color: var(--ink-muted); line-height: 1.45;
}
.crm-meta-sync-meta b { color: var(--ink-strong); font-weight: 700; }

.crm-meta-sync-msg {
  font-size: 12px; padding: 6px 10px; border-radius: var(--r-sm);
}
.crm-meta-sync-msg.is-ok  { background: rgba(0,200,117,.10);  color: #00853d; border: 1px solid rgba(0,200,117,.30); }
.crm-meta-sync-msg.is-err { background: rgba(228,68,92,.08);  color: #c0223a; border: 1px solid rgba(228,68,92,.28); }

.crm-meta-recent-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 4px;
}
.crm-meta-recent {
  display: flex; flex-direction: column; gap: 6px;
  /* Taller default so users can read several events without scrolling
     inside a tiny inner viewport. The whole list is still allowed to
     overflow into its own scroller for very long histories. */
  max-height: min(60vh, 520px); overflow-y: auto;
  border: 1px solid var(--border-row); border-radius: var(--r-md);
  padding: 8px;
}
.crm-meta-evt {
  padding: 8px 10px; background: var(--bg-surface);
  border: 1px solid var(--border-row); border-radius: var(--r-sm);
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease;
}
.crm-meta-evt:hover { border-color: var(--border-strong); }
.crm-meta-evt.is-open { border-color: var(--brand); background: linear-gradient(180deg, rgba(108,43,217,.04), var(--bg-surface)); }
.crm-meta-evt.is-error { border-color: rgba(226,68,92,.32); background: rgba(226,68,92,.04); }
.crm-meta-evt.is-sync  { border-color: rgba(0,200,117,.30); background: rgba(0,200,117,.04); }
.crm-meta-evt-row {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  margin-bottom: 4px;
}
.crm-meta-evt-tag {
  font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em;
  padding: 2px 7px; border-radius: var(--r-sm);
  background: var(--bg-subtle); color: var(--ink-body);
}
.crm-meta-evt-tag.tag-meta_webhook        { background: rgba(24,119,242,.14); color: #1877f2; }
.crm-meta-evt-tag.tag-meta_webhook_dup    { background: var(--bg-subtle);     color: var(--ink-muted); }
.crm-meta-evt-tag.tag-meta_webhook_error  { background: rgba(226,68,92,.10); color: #b41f37; }
.crm-meta-evt-tag.tag-meta_ad             { background: rgba(24,119,242,.14); color: #1877f2; }
.crm-meta-evt-tag.tag-meta_sync_run       { background: rgba(0,200,117,.12);  color: #00853d; }
.crm-meta-evt-tag.tag-meta_sync_error     { background: rgba(226,68,92,.10);  color: #b41f37; }
.crm-meta-evt-tag.tag-unknown             { background: var(--bg-subtle);     color: var(--ink-muted); }
.crm-meta-evt-time {
  font-size: 11px; color: var(--ink-faint);
  display: inline-flex; align-items: center; gap: 6px;
}
.crm-meta-evt-caret { color: var(--ink-muted); font-size: 10px; }
.crm-meta-evt-summary {
  font-size: 12.5px; color: var(--ink-strong); font-weight: 500;
  word-break: break-word;
}
.crm-meta-evt-summary:empty::before { content: "—"; color: var(--ink-faint); }
.crm-meta-evt-lead {
  font-size: 11px; color: var(--ink-muted); font-family: ui-monospace, monospace;
  margin-top: 2px;
}

/* Expanded raw-payload pane */
.crm-meta-evt-detail {
  margin-top: 8px;
  border-top: 1px dashed var(--border-row);
  padding-top: 8px;
}
.crm-meta-evt-detail-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 10.5px; font-weight: 800; letter-spacing: .04em;
  text-transform: uppercase; color: var(--ink-muted);
  margin-bottom: 4px;
}
.crm-meta-evt-detail-head .btn { padding: 3px 8px; font-size: 11px; }
.crm-meta-evt-json {
  font-family: ui-monospace, monospace; font-size: 11px;
  line-height: 1.45;
  background: #0f1729; color: #d6dde9;
  padding: 8px 10px; border-radius: 4px;
  /* No inner scroll — the modal body handles overflow. Long lead
     payloads now flow at their natural height inside the row. */
  max-height: none; overflow: visible;
  white-space: pre-wrap; word-break: break-word;
  margin: 0;
}

.crm-meta-actions {
  padding: 12px 20px; border-top: 1px solid var(--border-row);
  display: flex; justify-content: flex-end; gap: 8px;
}
.crm-meta-error {
  padding: 8px 12px; border-radius: var(--r-md);
  background: rgba(226,68,92,.08); color: #b41f37;
  border: 1px solid rgba(226,68,92,.22);
  font-size: 13px;
}

/* Lost-reason modal — narrower, danger accent, used by stage transitions */
.crm-lost-modal {
  width: min(420px, 92vw);
  background: var(--bg-surface); border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.crm-lost-head {
  padding: 16px 20px;
  background: rgba(226,68,92,.06);
  border-bottom: 1px solid rgba(226,68,92,.18);
  display: flex; align-items: center; gap: 10px;
}
.crm-lost-head h2 { margin: 0; font-size: 15px; font-weight: 700; color: #b41f37; }
.crm-lost-head-emoji { font-size: 18px; }
.crm-lost-body { padding: 16px 20px; }
.crm-lost-body p {
  margin: 0 0 12px; font-size: 13px; color: var(--ink-body); line-height: 1.5;
}
.crm-lost-body p b { color: var(--ink-strong); font-weight: 700; }
.crm-lost-presets {
  display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px;
}
.crm-lost-preset {
  padding: 5px 10px; border: 1px solid var(--border);
  border-radius: 999px; background: var(--bg-surface);
  font-size: 12px; font-weight: 500; color: var(--ink-body);
  cursor: pointer; transition: all .1s;
}
.crm-lost-preset:hover { background: var(--bg-subtle); border-color: var(--border-strong); }
.crm-lost-preset.is-on {
  background: rgba(226,68,92,.08); border-color: rgba(226,68,92,.35); color: #b41f37;
}
.crm-lost-actions {
  padding: 0 20px 16px;
  display: flex; justify-content: flex-end; gap: 8px;
}
.crm-btn-lost {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border: 0; border-radius: var(--r-md);
  background: var(--prio-high); color: white;
  font-size: 13px; font-weight: 600; cursor: pointer;
  min-height: 32px;
}
.crm-btn-lost:hover { background: var(--prio-critical); }
.crm-btn-lost:disabled { opacity: .5; cursor: not-allowed; }

/* ── Board / Queue mode toggle ─────────────────────────────────── */
.crm-mode-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-surface, #fff);
  overflow: hidden;
  margin-left: 4px;
}
.crm-mode-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 12px;
  cursor: pointer;
  transition: background .12s ease, color .12s ease;
}
.crm-mode-btn:hover { background: var(--bg-subtle); color: var(--ink-strong); }
.crm-mode-btn.is-on {
  background: var(--brand);
  color: #fff;
}
.crm-mode-btn.is-on:hover { background: var(--brand-dark, #0060b9); }

/* ── Action Queue ──────────────────────────────────────────────── */
.crm-aq {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px 18px 28px;
  overflow-y: auto;
  min-height: 0;
  flex: 1;
}
.aq-bucket {
  background: var(--bg-surface, #fff);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.aq-bucket-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
  font-size: 12.5px;
  color: var(--ink-strong);
}
.aq-bucket-head.is-danger { background: rgba(226,68,92,.08); color: #8a1024; border-bottom-color: rgba(226,68,92,.20); }
.aq-bucket-head.is-warn   { background: rgba(253,171,61,.10); color: #8a5300; border-bottom-color: rgba(253,171,61,.22); }
.aq-bucket-head.is-info   { background: rgba(0,115,234,.07);  color: #0050a8; border-bottom-color: rgba(0,115,234,.18); }
.aq-bucket-title {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-size: 11.5px;
}
.aq-bucket-count {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  background: rgba(0,0,0,.06);
  color: var(--ink-strong);
  padding: 2px 7px;
  border-radius: 999px;
  min-width: 22px;
  text-align: center;
}
.aq-bucket-body { display: flex; flex-direction: column; }

.aq-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px;
  border-top: 1px solid var(--border-row, #eaecf1);
  cursor: pointer;
  transition: background .1s ease;
}
.aq-row:first-child { border-top: 0; }
.aq-row:hover { background: var(--bg-hover, #f0f3f7); }
.aq-stage-dot {
  width: 8px; height: 8px; border-radius: 50%;
  flex-shrink: 0;
}
.aq-row-main { flex: 1; min-width: 0; }
.aq-row-name {
  font-size: 13px; font-weight: 600; color: var(--ink-strong);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.aq-row-sub {
  font-size: 11.5px; color: var(--ink-muted);
  margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.aq-hint {
  font-size: 11px; font-weight: 600;
  color: var(--ink-muted);
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(0,0,0,.05);
  flex-shrink: 0;
}
.aq-hint.is-danger { color: #8a1024; background: rgba(226,68,92,.10); }
.aq-hint.is-warn   { color: #8a5300; background: rgba(253,171,61,.14); }
.aq-hint.is-info   { color: #0050a8; background: rgba(0,115,234,.10); }

.crm-aq-empty {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  padding: 60px 20px;
  color: var(--ink-muted);
}
.crm-aq-empty-emoji { font-size: 36px; margin-bottom: 10px; }
.crm-aq-empty-title { font-size: 16px; font-weight: 700; color: var(--ink-strong); margin-bottom: 4px; }
.crm-aq-empty-sub   { font-size: 13px; max-width: 360px; line-height: 1.5; }

/* ── Dashboard view ───────────────────────────────────────────────── */
.crm-dashboard {
  flex: 1; overflow: auto;
  padding: 18px 24px 32px;
  display: flex; flex-direction: column; gap: 16px;
}

/* Range tabs */
.crm-dash-range {
  display: inline-flex; gap: 4px; align-self: flex-start;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 4px;
}
.crm-dash-range-btn {
  font: inherit; font-size: 12px; font-weight: 600;
  border: none; background: transparent; cursor: pointer;
  padding: 5px 12px; border-radius: 999px;
  color: var(--ink-muted);
  transition: background .15s, color .15s;
}
.crm-dash-range-btn:hover { color: var(--ink-strong); background: var(--bg-subtle); }
.crm-dash-range-btn.is-on {
  background: var(--brand, #a25ddc); color: white;
}

/* KPI strip */
.crm-dash-kpis {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}
.crm-dash-kpi {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--kpi-accent, var(--brand));
  border-radius: var(--r-md);
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 4px;
}
.crm-dash-kpi-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--ink-muted);
}
.crm-dash-kpi-value {
  font-size: 28px; font-weight: 800; color: var(--ink-strong);
  line-height: 1.1; letter-spacing: -.02em;
}
.crm-dash-kpi-hint {
  font-size: 11px; color: var(--ink-muted); font-weight: 500;
}

/* Section card */
.crm-dash-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px 16px 16px;
}
.crm-dash-card-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 12px;
}
.crm-dash-card-head h3 {
  margin: 0; font-size: 14px; font-weight: 700; color: var(--ink-strong);
  letter-spacing: -.01em;
}
.crm-dash-card-sub {
  font-size: 11px; font-weight: 500; color: var(--ink-muted);
}

/* Two-up grid for funnel + sources / countries + leaderboard */
.crm-dash-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}
@media (max-width: 980px) {
  .crm-dash-grid { grid-template-columns: 1fr; }
}

/* Daily count bars */
.crm-dash-daily {
  display: flex; align-items: flex-end; gap: 2px;
  height: 180px; padding: 8px 0 0;
}
.crm-dash-daily-col {
  flex: 1; min-width: 6px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  height: 100%;
}
.crm-dash-daily-bar-wrap {
  position: relative; flex: 1;
  width: 100%; display: flex; align-items: flex-end; justify-content: center;
}
.crm-dash-daily-bar {
  width: 100%; max-width: 32px;
  background: linear-gradient(180deg, var(--brand, #a25ddc), #c89cef);
  border-radius: 4px 4px 0 0;
  transition: filter .15s;
}
.crm-dash-daily-col:hover .crm-dash-daily-bar { filter: brightness(1.08); }
.crm-dash-daily-bar.is-weekend {
  background: linear-gradient(180deg, #c89cef, #e2d2f4);
  opacity: .8;
}
.crm-dash-daily-bar.is-today {
  background: linear-gradient(180deg, #00c875, #4dd99a);
  box-shadow: 0 0 0 2px rgba(0,200,117,.18);
}
.crm-dash-daily-count {
  position: absolute; top: -16px; left: 50%; transform: translateX(-50%);
  font-size: 10px; font-weight: 700; color: var(--ink-muted);
  pointer-events: none;
}
.crm-dash-daily-tick {
  font-size: 9.5px; color: var(--ink-faint, #a3a8b6);
  white-space: nowrap; font-weight: 500;
  margin-top: 2px;
}

/* Funnel */
.crm-dash-funnel {
  display: flex; flex-direction: column; gap: 8px;
}
.crm-dash-funnel-row {
  display: grid; grid-template-columns: 140px 1fr; gap: 10px;
  align-items: center;
}
.crm-dash-funnel-label {
  font-size: 12px; font-weight: 600; color: var(--ink-body);
  display: inline-flex; align-items: center; gap: 6px;
}
.crm-dash-funnel-emoji { font-size: 14px; }
.crm-dash-funnel-bar-wrap {
  position: relative;
  height: 22px;
  background: var(--bg-subtle);
  border-radius: var(--r-sm);
  overflow: hidden;
}
.crm-dash-funnel-bar {
  height: 100%;
  border-radius: var(--r-sm);
  transition: width .25s ease;
  min-width: 4px;
}
.crm-dash-funnel-count {
  position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
  font-size: 11px; font-weight: 700; color: white;
  text-shadow: 0 1px 2px rgba(0,0,0,.25);
  pointer-events: none;
}
.crm-dash-funnel-pct {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-size: 11px; font-weight: 600; color: var(--ink-muted);
  pointer-events: none;
}

/* Generic list (source, country) */
.crm-dash-list {
  display: flex; flex-direction: column; gap: 8px;
}
.crm-dash-empty {
  font-size: 12px; color: var(--ink-muted); padding: 16px;
  text-align: center; font-style: italic;
}

/* Source row */
.crm-dash-source-row {
  display: grid; grid-template-columns: 130px 1fr auto; gap: 10px;
  align-items: center;
}
.crm-dash-source-label {
  font-size: 12px; font-weight: 600; color: var(--ink-body);
}
.crm-dash-source-bar-wrap {
  height: 8px; background: var(--bg-subtle); border-radius: 999px; overflow: hidden;
}
.crm-dash-source-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--brand, #a25ddc), #c89cef);
  border-radius: 999px;
}
.crm-dash-source-count {
  font-size: 11px; font-weight: 600; color: var(--ink-muted);
  white-space: nowrap;
}

/* Country row */
.crm-dash-country-row {
  display: grid; grid-template-columns: 24px 32px 1fr auto; gap: 8px;
  align-items: center;
}
.crm-dash-country-flag {
  font-size: 18px; line-height: 1;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}
.crm-dash-country-iso {
  font-size: 11px; font-weight: 700; color: var(--ink-muted); letter-spacing: .04em;
}
.crm-dash-country-bar-wrap {
  height: 8px; background: var(--bg-subtle); border-radius: 999px; overflow: hidden;
}
.crm-dash-country-bar {
  height: 100%;
  background: linear-gradient(90deg, #fdab3d, #fd713d);
  border-radius: 999px;
}
.crm-dash-country-count {
  font-size: 11px; font-weight: 700; color: var(--ink-body);
}

/* ── Country-wise lead count (full-width table) ─────────────────────
   The compact `.crm-dash-country-row` list above is the legacy mini
   version; this richer table is what the dashboard renders today —
   name + ISO + total + share-bar + outcome split + win-rate. */
.crm-dash-country-table-wrap {
  /* Capped height so a workspace with many countries scrolls inside
     the card rather than pushing the rest of the dashboard down. */
  max-height: 420px; overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}
.crm-dash-country-table {
  width: 100%; border-collapse: collapse;
  font-size: 12.5px;
}
.crm-dash-country-table th {
  position: sticky; top: 0; z-index: 1;
  background: var(--bg-surface);
  text-align: left; font-weight: 700;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--ink-muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.crm-dash-country-table th.num { text-align: right; }
.crm-dash-country-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border-soft, #f1f3f7);
  color: var(--ink-body);
  vertical-align: middle;
}
.crm-dash-country-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.crm-dash-country-table tbody tr:hover { background: var(--bg-subtle); }
.crm-dash-country-table tbody tr:last-child td { border-bottom: none; }

.crm-dash-country-flag-cell {
  font-size: 20px; line-height: 1;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  text-align: center;
}
.crm-dash-country-name {
  font-size: 12.5px; font-weight: 600; color: var(--ink-strong);
  line-height: 1.2;
}
.crm-dash-country-iso-sub {
  font-size: 10px; font-weight: 600; color: var(--ink-faint, #a3a8b6);
  letter-spacing: .06em; line-height: 1.2; margin-top: 1px;
}
.crm-dash-country-total {
  font-size: 14px; font-weight: 700; color: var(--ink-strong);
}
.crm-dash-country-share {
  display: flex; align-items: center; gap: 8px;
  min-width: 140px;
}
.crm-dash-country-share-bar-wrap {
  flex: 1; height: 8px; background: var(--bg-subtle);
  border-radius: 999px; overflow: hidden;
}
.crm-dash-country-share-bar {
  height: 100%;
  background: linear-gradient(90deg, #fdab3d, #fd713d);
  border-radius: 999px;
  transition: width .25s ease;
}
.crm-dash-country-share-pct {
  font-size: 11px; font-weight: 600; color: var(--ink-muted);
  white-space: nowrap; font-variant-numeric: tabular-nums;
  min-width: 30px; text-align: right;
}

/* Leaderboard */
.crm-dash-leaderboard {
  width: 100%; border-collapse: collapse;
  font-size: 12px;
}
.crm-dash-leaderboard th {
  text-align: left; font-weight: 700; color: var(--ink-muted);
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em;
  padding: 6px 8px; border-bottom: 1px solid var(--border);
}
.crm-dash-leaderboard td {
  padding: 8px; border-bottom: 1px solid var(--border-soft, #f1f3f7);
  color: var(--ink-body);
}
.crm-dash-leaderboard td:first-child {
  display: flex; align-items: center;
}
.crm-dash-leaderboard tr:last-child td { border-bottom: none; }
.crm-dash-leaderboard tr.is-me { background: rgba(162,93,220,.06); }
.crm-dash-leaderboard tr.is-me td:first-child { font-weight: 700; }

/* Recent activity */
.crm-dash-recent {
  display: flex; flex-direction: column; gap: 6px;
}
.crm-dash-recent-row {
  display: grid; grid-template-columns: auto 1fr auto auto; gap: 10px;
  align-items: center;
  padding: 8px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font: inherit; cursor: pointer;
  text-align: left;
  transition: background .12s, border-color .12s;
}
.crm-dash-recent-row:hover {
  background: var(--bg-subtle);
  border-color: var(--border);
}
.crm-dash-recent-flag {
  font-size: 16px; line-height: 1;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}
.crm-dash-recent-name {
  font-size: 12.5px; font-weight: 600; color: var(--ink-strong);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.crm-dash-recent-when {
  font-size: 11px; color: var(--ink-faint, #a3a8b6);
  white-space: nowrap;
}
