/* ==========================================================================
   CRM — Automations sub-tab (the follow-up command center).
   Everything crma- prefixed. Shared components are scoped to BOTH the in-page
   root (.crma-root) AND the portalled full-screen workflow overlay (.crma-wf)
   via :is(.crma-root, .crma-wf), because CrmaFlowCard + the dot/pill/btn family
   render inside both trees.
   Page accent = ICE via the per-page --gold token swap (page-accents.css).
   The overlay is portalled OUTSIDE .app, so it re-declares the ICE tokens.
   TRUE gold is reserved for "done" states, so it gets local literals here.
   ========================================================================== */

.crma-root, .crma-wf {
  --crma-gold: #D4AF37;
  --crma-gold-hi: #E8C96A;
  --crma-gold-10: rgba(212, 175, 55, 0.12);
  --crma-gold-30: rgba(212, 175, 55, 0.32);
}
.crma-root {
  display: flex; flex-direction: column; gap: 16px; max-width: 100%;
}

/* ---- cards ----------------------------------------------------------------- */
:is(.crma-root, .crma-wf) .crma-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px 18px; box-shadow: var(--shadow-card); }
:is(.crma-root, .crma-wf) .crma-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
:is(.crma-root, .crma-wf) .crma-card-title { display: flex; align-items: center; gap: 9px; font: 600 14px var(--font-ui); color: var(--ink); }
:is(.crma-root, .crma-wf) .crma-card-title i { color: var(--gold); font-size: 13px; }
:is(.crma-root, .crma-wf) .crma-card-sub { font: 500 12px var(--font-ui); color: var(--ink-3); margin-top: 4px; max-width: 640px; }
:is(.crma-root, .crma-wf) .crma-count { font: 700 10.5px var(--font-mono); background: var(--surface-hi); color: var(--ink-2); border-radius: 999px; padding: 2px 8px; margin-left: 6px; vertical-align: 2px; }
:is(.crma-root, .crma-wf) .crma-loading { display: flex; align-items: center; gap: 9px; font: 500 12.5px var(--font-ui); color: var(--ink-3); }
:is(.crma-root, .crma-wf) .crma-loading i { color: var(--gold); }

/* ---- toggle (mirrors the Call-mode switch) ---------------------------------- */
:is(.crma-root, .crma-wf) .crma-toggle {
  appearance: none; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; flex: 0 0 auto;
  background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 999px;
  padding: 7px 13px 7px 7px; color: var(--ink-3); font: 600 12px var(--font-ui);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
:is(.crma-root, .crma-wf) .crma-toggle.on { color: var(--gold-hi); border-color: var(--gold-30); background: var(--gold-10); }
:is(.crma-root, .crma-wf) .crma-toggle-track { width: 34px; height: 20px; border-radius: 999px; background: var(--surface-hi); border: 1px solid var(--line-2); position: relative; transition: background 0.15s, border-color 0.15s; }
:is(.crma-root, .crma-wf) .crma-toggle.on .crma-toggle-track { background: var(--gold-grad); border-color: transparent; }
:is(.crma-root, .crma-wf) .crma-toggle-knob { position: absolute; top: 1px; left: 1px; width: 16px; height: 16px; border-radius: 50%; background: var(--ink-2); transition: transform 0.18s, background 0.15s; }
:is(.crma-root, .crma-wf) .crma-toggle.on .crma-toggle-knob { transform: translateX(14px); background: #06303a; }
:is(.crma-root, .crma-wf) .crma-toggle-lab { pointer-events: none; }

/* ---- warn line (templates not approved) ------------------------------------- */
:is(.crma-root, .crma-wf) .crma-warnline {
  display: flex; align-items: center; gap: 9px; margin-top: 12px;
  font: 500 12px var(--font-ui); color: var(--warn);
  background: rgba(214, 178, 90, 0.08); border: 1px solid rgba(214, 178, 90, 0.22);
  border-radius: var(--r-md); padding: 9px 13px;
}
:is(.crma-root, .crma-wf) .crma-warnline i { font-size: 11px; }

/* ---- linear flow strip (STILL used by the 90-day task card) ----------------- */
/* NOTE: no `scrollbar-width` here — setting it makes Chromium IGNORE the app's
   dark ::-webkit-scrollbar theme (dashboard.css) and paint the default white bar. */
:is(.crma-root, .crma-wf) .crma-strip { display: flex; align-items: center; gap: 10px; overflow-x: auto; padding: 14px 2px 10px; }
:is(.crma-root, .crma-wf) .crma-strip::-webkit-scrollbar { height: 6px; }
:is(.crma-root, .crma-wf) .crma-strip::-webkit-scrollbar-track { background: transparent; }
:is(.crma-root, .crma-wf) .crma-strip::-webkit-scrollbar-thumb { background: var(--gold-18); border-radius: 3px; }
:is(.crma-root, .crma-wf) .crma-strip::-webkit-scrollbar-thumb:hover { background: var(--gold-30); }
:is(.crma-root, .crma-wf) .crma-arrow { flex: 0 0 auto; color: var(--ink-5); font-size: 13px; }

/* ---- serpentine flow container (the follow-up flow, wraps + SVG connectors) -- */
:is(.crma-root, .crma-wf) .crma-strip2 {
  position: relative; display: flex; flex-wrap: wrap; align-items: center;
  justify-content: center;
  column-gap: 34px; row-gap: 42px; padding: 14px 2px 16px;
}
:is(.crma-root, .crma-wf) .crma-strip2 > * { position: relative; z-index: 1; }
:is(.crma-root, .crma-wf) .crma-flowsvg { position: absolute; inset: 0; pointer-events: none; z-index: 0; overflow: visible; }
:is(.crma-root, .crma-wf) .crma-flowlink { fill: none; stroke: var(--gold-30); stroke-width: 1.6; }
:is(.crma-root, .crma-wf) .crma-flowarr { fill: var(--gold-hi); stroke: none; }

/* ---- flow nodes (mail / wait / end) ----------------------------------------- */
:is(.crma-root, .crma-wf) .crma-node {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 10px;
  background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--r-md);
  padding: 10px 14px; white-space: nowrap; color: var(--ink);
}
:is(.crma-root, .crma-wf) .crma-node-txt { display: flex; flex-direction: column; gap: 2px; text-align: left; }
:is(.crma-root, .crma-wf) .crma-node-txt b { font: 600 12.5px var(--font-ui); color: var(--ink); }
:is(.crma-root, .crma-wf) .crma-node-txt span { font: 500 10.5px var(--font-ui); color: var(--ink-4); }
:is(.crma-root, .crma-wf) .crma-node-mail { appearance: none; cursor: pointer; border-color: var(--gold-18); transition: border-color 0.14s, background 0.14s; }
:is(.crma-root, .crma-wf) .crma-node-mail > i { color: var(--gold); font-size: 13px; }
:is(.crma-root, .crma-wf) .crma-node-mail:hover { border-color: var(--gold-30); background: var(--gold-10); }
:is(.crma-root, .crma-wf) .crma-node-lock { color: var(--warn); font-size: 10px; margin-left: 2px; }
:is(.crma-root, .crma-wf) .crma-node-wait { border-style: dashed; background: transparent; }
:is(.crma-root, .crma-wf) .crma-node-wait > i { color: var(--ink-4); font-size: 12px; }
:is(.crma-root, .crma-wf) .crma-wait-edit { display: inline-flex; align-items: baseline; gap: 6px; }
:is(.crma-root, .crma-wf) .crma-wait-edit input {
  width: 3.2ch; text-align: center; appearance: none;
  background: var(--surface-hi); border: 1px solid var(--line-2); border-radius: 7px;
  padding: 4px 5px; font: 700 14px var(--font-ui); color: var(--gold-hi);
  transition: border-color 0.15s;
}
:is(.crma-root, .crma-wf) .crma-wait-edit input:focus { outline: none; border-color: var(--gold-30); }
:is(.crma-root, .crma-wf) .crma-wait-edit b { font: 600 11px var(--font-ui); color: var(--ink-3); }
:is(.crma-root, .crma-wf) .crma-node-sub { font: 500 10px var(--font-ui); color: var(--ink-5); }
:is(.crma-root, .crma-wf) .crma-node-end > i { color: var(--crma-gold); font-size: 13px; }
:is(.crma-root, .crma-wf) .crma-node-task > i { color: var(--gold); font-size: 12px; }
:is(.crma-root, .crma-wf) .crma-node-task .crma-node-txt span { max-width: 340px; overflow: hidden; text-overflow: ellipsis; }

/* ---- filter / sort toolbar --------------------------------------------------- */
:is(.crma-root, .crma-wf) .crma-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 12px; padding-bottom: 2px; }
:is(.crma-root, .crma-wf) .crma-select {
  background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 999px;
  color: var(--ink-2); font: 600 12px var(--font-ui); padding: 7px 12px;
  cursor: pointer; outline: none; transition: border-color 0.15s;
}
:is(.crma-root, .crma-wf) .crma-select:focus { border-color: var(--gold-30); }
:is(.crma-root, .crma-wf) .crma-chips { display: flex; gap: 6px; flex-wrap: wrap; }
:is(.crma-root, .crma-wf) .crma-chip {
  appearance: none; cursor: pointer; background: transparent; border: 1px solid var(--line-2);
  color: var(--ink-3); font: 600 11.5px var(--font-ui); padding: 6px 11px; border-radius: 999px;
  transition: color 0.15s, border-color 0.15s, background 0.15s; white-space: nowrap;
}
:is(.crma-root, .crma-wf) .crma-chip em { font: 700 10px var(--font-ui); color: var(--ink-4); margin-left: 6px; font-style: normal; }
:is(.crma-root, .crma-wf) .crma-chip.on { background: var(--gold-10); border-color: var(--gold-30); color: var(--gold-hi); }
:is(.crma-root, .crma-wf) .crma-chip.on em { color: var(--gold-hi); }
:is(.crma-root, .crma-wf) .crma-sortbox { display: flex; align-items: center; gap: 7px; margin-left: auto; }
:is(.crma-root, .crma-wf) .crma-sortlab { font: 600 10px var(--font-ui); text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-5); }
:is(.crma-root, .crma-wf) .crma-dirbtn {
  appearance: none; cursor: pointer; width: 30px; height: 30px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid var(--line-2); color: var(--ink-3);
  font-size: 11px; transition: color 0.15s, border-color 0.15s, background 0.15s;
}
:is(.crma-root, .crma-wf) .crma-dirbtn:hover { color: var(--gold-hi); border-color: var(--gold-30); background: var(--gold-10); }

/* ---- who's in the automation: rows ------------------------------------------ */
:is(.crma-root, .crma-wf) .crma-head-actions { display: flex; gap: 8px; align-items: center; }
:is(.crma-root, .crma-wf) .crma-rows { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
:is(.crma-root, .crma-wf) .crma-row {
  display: grid; grid-template-columns: minmax(190px, 240px) 1fr auto;
  gap: 12px; align-items: center;
  background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--r-md);
  padding: 10px 13px; transition: border-color 0.14s, opacity 0.14s;
}
:is(.crma-root, .crma-wf) .crma-row:hover { border-color: var(--gold-18); }
:is(.crma-root, .crma-wf) .crma-row-who { display: flex; align-items: center; gap: 9px; min-width: 0; }
:is(.crma-root, .crma-wf) .crma-row-name {
  appearance: none; background: none; border: 0; padding: 0; cursor: pointer; text-align: left;
  font: 600 13.5px var(--font-ui); color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
:is(.crma-root, .crma-wf) .crma-row-name:hover { color: var(--gold-hi); text-decoration: underline dotted; text-underline-offset: 3px; }

/* step dots — a mini timeline: done = TRUE gold, next = pulsing ice, rest dim */
:is(.crma-root, .crma-wf) .crma-row-dots { display: flex; align-items: center; gap: 12px; min-width: 0; flex-wrap: wrap; }
:is(.crma-root, .crma-wf) .crma-dot { appearance: none; background: none; border: 0; padding: 0; cursor: pointer; position: relative; width: 16px; height: 16px; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
:is(.crma-root, .crma-wf) .crma-dot:not(:first-child)::before { content: ''; position: absolute; left: -12px; top: 50%; width: 12px; height: 2px; margin-top: -1px; background: var(--line-2); }
:is(.crma-root, .crma-wf) .crma-dot-core { width: 11px; height: 11px; border-radius: 50%; box-sizing: border-box; transition: transform 0.12s; }
:is(.crma-root, .crma-wf) .crma-dot:hover .crma-dot-core { transform: scale(1.25); }
:is(.crma-root, .crma-wf) .crma-dot.done .crma-dot-core { background: linear-gradient(135deg, var(--crma-gold-hi), var(--crma-gold)); box-shadow: 0 0 7px var(--crma-gold-30); }
:is(.crma-root, .crma-wf) .crma-dot.next .crma-dot-core { background: transparent; border: 2px solid var(--gold); animation: crma-pulse 1.6s ease-in-out infinite; }
:is(.crma-root, .crma-wf) .crma-dot.dim .crma-dot-core { background: var(--surface-hi); border: 1px solid var(--line-2); }
@keyframes crma-pulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--gold-30); }
  50% { box-shadow: 0 0 0 5px rgba(127, 227, 250, 0.08); }
}
:is(.crma-root, .crma-wf) .crma-next { font: 600 11.5px var(--font-ui); color: var(--gold-hi); white-space: nowrap; margin-left: 2px; }

/* status pill + controls */
:is(.crma-root, .crma-wf) .crma-row-side { display: flex; align-items: center; gap: 9px; justify-content: flex-end; }
:is(.crma-root, .crma-wf) .crma-pill { font: 600 10.5px var(--font-ui); letter-spacing: 0.02em; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
:is(.crma-root, .crma-wf) .crma-pill.err { color: var(--err); background: rgba(224, 108, 108, 0.1); border: 1px solid rgba(224, 108, 108, 0.28); }
:is(.crma-root, .crma-wf) .crma-pill.warn { color: var(--warn); background: rgba(214, 178, 90, 0.09); border: 1px solid rgba(214, 178, 90, 0.26); }
:is(.crma-root, .crma-wf) .crma-pill.done { color: var(--crma-gold-hi); background: var(--crma-gold-10); border: 1px solid var(--crma-gold-30); }
:is(.crma-root, .crma-wf) .crma-pill.stopped { color: var(--ink-3); background: var(--surface-hi); border: 1px solid var(--line-2); }
:is(.crma-root, .crma-wf) .crma-pill.auto { color: var(--cool); background: rgba(127, 227, 250, 0.06); border: 1px solid var(--line-2); }
:is(.crma-root, .crma-wf) .crma-btn {
  appearance: none; cursor: pointer; display: inline-flex; align-items: center; gap: 7px;
  background: transparent; border: 1px solid var(--line-2); border-radius: 999px;
  padding: 6px 13px; font: 600 11.5px var(--font-ui); color: var(--ink-3);
  transition: color 0.15s, border-color 0.15s, background 0.15s; white-space: nowrap;
}
:is(.crma-root, .crma-wf) .crma-btn i { font-size: 10px; }
:is(.crma-root, .crma-wf) .crma-btn.stop:hover { color: var(--err); border-color: rgba(224, 108, 108, 0.45); }
:is(.crma-root, .crma-wf) .crma-btn.resume { color: var(--gold-hi); border-color: var(--gold-30); background: var(--gold-10); }
:is(.crma-root, .crma-wf) .crma-btn.resume:hover { filter: brightness(1.12); }
:is(.crma-root, .crma-wf) .crma-btn.primary { background: var(--gold-grad); border: 0; color: #06303a; }
:is(.crma-root, .crma-wf) .crma-btn.primary:hover { filter: brightness(1.06); }

/* empty state */
:is(.crma-root, .crma-wf) .crma-nobody { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; border: 1px dashed var(--line-2); border-radius: var(--r-md); padding: 30px 20px; margin-top: 14px; }
:is(.crma-root, .crma-wf) .crma-nobody > i { font-size: 20px; color: var(--gold); opacity: 0.8; margin-bottom: 3px; }
:is(.crma-root, .crma-wf) .crma-nobody b { font: 600 14.5px var(--font-serif); color: var(--ink); }
:is(.crma-root, .crma-wf) .crma-nobody span { font: 500 12.5px var(--font-ui); color: var(--ink-3); max-width: 420px; }
:is(.crma-root, .crma-wf) .crma-nobody.slim { flex-direction: row; flex-wrap: wrap; justify-content: center; align-items: center; gap: 12px; padding: 16px; }
:is(.crma-root, .crma-wf) .crma-clearlink {
  appearance: none; background: transparent; border: 0; cursor: pointer;
  color: var(--gold-hi); font: 600 12.5px var(--font-ui);
  text-decoration: underline dotted; text-underline-offset: 3px;
}
:is(.crma-root, .crma-wf) .crma-clearlink:hover { filter: brightness(1.12); }

/* ---- activity feed ----------------------------------------------------------- */
:is(.crma-root, .crma-wf) .crma-feed { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
:is(.crma-root, .crma-wf) .crma-feed-col { padding: 14px 16px; }
:is(.crma-root, .crma-wf) .crma-feed-h { display: flex; align-items: center; gap: 8px; font: 600 11.5px var(--font-ui); color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; }
:is(.crma-root, .crma-wf) .crma-feed-h i { color: var(--gold); font-size: 11px; }
:is(.crma-root, .crma-wf) .crma-feed-hint { font: 500 10px var(--font-mono); color: var(--ink-5); text-transform: none; letter-spacing: 0; }
:is(.crma-root, .crma-wf) .crma-feed-row { display: flex; align-items: center; gap: 10px; padding: 9px 2px; }
:is(.crma-root, .crma-wf) .crma-feed-row + .crma-feed-row { border-top: 1px solid var(--line); }
:is(.crma-root, .crma-wf) .crma-feed-row > i { color: var(--ok); font-size: 12px; flex: 0 0 auto; }
:is(.crma-root, .crma-wf) .crma-feed-row.failed > i { color: var(--err); }
:is(.crma-root, .crma-wf) .crma-feed-row:not(.failed) > i.fa-envelope { color: var(--gold); }
:is(.crma-root, .crma-wf) .crma-feed-txt { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
:is(.crma-root, .crma-wf) .crma-feed-txt b { font: 600 12.5px var(--font-ui); color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
:is(.crma-root, .crma-wf) .crma-feed-txt span { font: 500 11px var(--font-ui); color: var(--ink-4); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
:is(.crma-root, .crma-wf) .crma-feed-row.failed .crma-feed-txt span { color: var(--err); opacity: 0.85; }
:is(.crma-root, .crma-wf) .crma-feed-row em { font: 500 10.5px var(--font-mono); color: var(--ink-5); font-style: normal; white-space: nowrap; }
:is(.crma-root, .crma-wf) .crma-feed-empty { font: 500 12px var(--font-ui); color: var(--ink-4); padding: 9px 2px; }

/* ---- email viewer modal (standalone selectors — Modal may render anywhere) ---- */
.crma-mailview { display: flex; flex-direction: column; gap: 12px; }
.crma-mail-locked { display: flex; align-items: center; gap: 9px; font: 500 12px var(--font-ui); color: var(--warn); background: rgba(214, 178, 90, 0.08); border: 1px solid rgba(214, 178, 90, 0.22); border-radius: var(--r-md); padding: 9px 13px; }
.crma-mail-subj { display: flex; flex-direction: column; gap: 3px; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--r-md); padding: 10px 13px; }
.crma-mail-subj span { font: 600 9.5px var(--font-mono); color: var(--ink-4); text-transform: uppercase; letter-spacing: 0.08em; }
.crma-mail-subj b { font: 600 13.5px var(--font-ui); color: var(--ink); }
.crma-mail-body { white-space: pre-wrap; font: 500 13px/1.55 var(--font-ui); color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--r-md); padding: 14px; max-height: 320px; overflow-y: auto; }
.crma-mail-missing { font: 500 12.5px var(--font-ui); color: var(--ink-3); padding: 6px 2px; }
.crma-mail-foot { display: flex; align-items: center; gap: 8px; font: 500 11px var(--font-ui); color: var(--ink-4); }
.crma-mail-foot i { font-size: 10px; }
.crma-mail-foot.dim { color: var(--ink-5); }
/* editable mode (standalone selectors + global tokens/literals — modal portals to <body>) */
.crma-mailview.editing { gap: 10px; }
.crma-mailedit { display: flex; flex-direction: column; gap: 7px; }
.crma-mail-flabel { font: 600 9.5px var(--font-mono); color: var(--ink-4); text-transform: uppercase; letter-spacing: 0.08em; margin-top: 2px; }
.crma-mail-input, .crma-mail-textarea { width: 100%; box-sizing: border-box; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--r-md); color: var(--ink); font: 500 13px/1.55 var(--font-ui); padding: 10px 12px; outline: none; transition: border-color 0.12s, box-shadow 0.12s; }
.crma-mail-input:focus, .crma-mail-textarea:focus { border-color: rgba(127, 227, 250, 0.55); box-shadow: 0 0 0 3px rgba(127, 227, 250, 0.12); }
.crma-mail-textarea { resize: vertical; min-height: 240px; white-space: pre-wrap; }
.crma-mail-hint { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; font: 500 11px var(--font-ui); color: var(--ink-4); }
.crma-mail-hint i { font-size: 10px; color: #7FE3FA; }
.crma-mail-hint code { font: 600 10.5px var(--font-mono); color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 5px; padding: 1px 5px; }
.crma-mail-saved { display: flex; align-items: center; gap: 8px; font: 600 12px var(--font-ui); color: #5fd08a; background: rgba(95, 208, 138, 0.08); border: 1px solid rgba(95, 208, 138, 0.22); border-radius: var(--r-md); padding: 9px 13px; }
.crma-mail-btn { appearance: none; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line-2); border-radius: 999px; background: var(--surface-2); color: var(--ink-2); font: 600 12.5px var(--font-ui); padding: 8px 15px; transition: color 0.12s, border-color 0.12s, background 0.12s; }
.crma-mail-btn:hover { color: #BFF3FF; border-color: rgba(127, 227, 250, 0.30); background: rgba(127, 227, 250, 0.10); }
.crma-mail-btn i { font-size: 11px; }
.crma-mail-save { appearance: none; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; border: 0; border-radius: 999px; background: linear-gradient(135deg, #BFF3FF 0%, #7FE3FA 45%, #38C7EB 100%); color: #06303a; font: 700 12.5px var(--font-ui); padding: 8px 16px; transition: filter 0.12s, opacity 0.12s; }
.crma-mail-save:hover { filter: brightness(1.06); }
.crma-mail-save:disabled { opacity: 0.45; cursor: default; filter: none; }
.crma-mail-save i { font-size: 11px; }
/* per-email arm (On/Off) control — standalone toggle since the modal portals to <body> */
.crma-mail-armrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--r-md); padding: 10px 13px; }
.crma-mail-armlab { font: 500 12px var(--font-ui); color: var(--ink-3); }
.crma-mailview .crma-toggle { appearance: none; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; background: transparent; border: 0; padding: 0; font: 700 11px var(--font-ui); color: var(--ink-4); flex: 0 0 auto; }
.crma-mailview .crma-toggle-track { position: relative; width: 34px; height: 18px; border-radius: 999px; background: var(--surface-hi, #2a2f37); border: 1px solid var(--line-2); transition: background 0.15s; }
.crma-mailview .crma-toggle-knob { position: absolute; top: 1px; left: 1px; width: 14px; height: 14px; border-radius: 50%; background: var(--ink-2); transition: transform 0.18s, background 0.15s; }
.crma-mailview .crma-toggle.on { color: #BFF3FF; }
.crma-mailview .crma-toggle.on .crma-toggle-track { background: linear-gradient(135deg, #BFF3FF, #38C7EB); border-color: transparent; }
.crma-mailview .crma-toggle.on .crma-toggle-knob { transform: translateX(16px); background: #06303a; }
/* realistic email preview — a white "inbox" card so the view matches what the lead receives */
.crma-email { background: #ffffff; color: #1a1a1a; border-radius: 10px; overflow: hidden; border: 1px solid rgba(0,0,0,0.12); font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; box-shadow: 0 6px 22px rgba(0,0,0,0.28); }
.crma-email-head { padding: 14px 20px; border-bottom: 1px solid #ececec; background: #f7f8fa; }
.crma-email-from { font: 500 12.5px/1.3 inherit; color: #444; }
.crma-email-from span { color: #8a8a8a; }
.crma-email-subj { font: 600 16px/1.35 inherit; color: #111; margin: 5px 0 3px; }
.crma-email-to { font: 500 11.5px inherit; color: #999; }
.crma-email-body { padding: 22px 20px 6px; font: 400 14px/1.6 inherit; color: #222; max-height: 300px; overflow-y: auto; }
.crma-email-body p { margin: 0 0 14px; }
.crma-email-body a { color: #1a6fd6; text-decoration: underline; word-break: break-word; }
.crma-email-logo { text-align: center; padding: 14px 0 24px; }
.crma-email-logo img { width: 140px; max-width: 55%; height: auto; display: inline-block; }
.crma-email-footer { padding: 14px 20px 20px; border-top: 1px solid #ececec; color: #8a8a8a; font: 400 12px/1.6 inherit; }
.crma-email-footer div { margin: 0 0 3px; }
.crma-email-footer a { color: #8a8a8a; text-decoration: underline; }

/* ==========================================================================
   FULL-SCREEN WORKFLOW OVERLAY (portalled to <body> — re-declares ICE tokens)
   ========================================================================== */
.crma-wf {
  --gold: #7FE3FA; --gold-hi: #BFF3FF; --gold-lo: #38C7EB;
  --gold-10: rgba(127,227,250,0.10); --gold-18: rgba(127,227,250,0.18); --gold-30: rgba(127,227,250,0.30);
  --gold-grad: linear-gradient(135deg,#BFF3FF 0%,#7FE3FA 45%,#38C7EB 100%);
  position: fixed; inset: 0; z-index: 210;
  background:
    radial-gradient(1100px 620px at 88% -12%, rgba(84,214,245,0.10), transparent 60%),
    radial-gradient(820px 560px at -8% 112%, rgba(56,199,235,0.07), transparent 55%),
    #08080b;
  display: flex; flex-direction: column; animation: crmaWfIn 0.2s ease-out;
}
@keyframes crmaWfIn { from { opacity: 0; } to { opacity: 1; } }

.crma-wf-bar { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 22px; border-bottom: 1px solid var(--line); background: rgba(0,0,0,0.25); }
.crma-wf-back { appearance: none; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 999px; color: var(--ink-2); font: 600 13px var(--font-ui); padding: 8px 15px; transition: color 0.15s, border-color 0.15s; }
.crma-wf-back:hover { color: var(--ink); border-color: var(--gold-30); }
.crma-wf-back i { font-size: 11px; }
.crma-wf-title { display: flex; align-items: center; gap: 9px; font: 600 14px var(--font-ui); color: var(--ink); }
.crma-wf-title i { color: var(--gold); font-size: 13px; }
.crma-wf-hint { font: 500 11.5px var(--font-ui); color: var(--ink-4); }

.crma-wf-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 18px 22px; display: flex; flex-direction: column; gap: 16px; position: relative; }
.crma-wf-flow { max-width: 1200px; width: 100%; }

.crma-wf-canvas {
  overflow: auto; border: 1px solid var(--line); border-radius: var(--r-lg);
  background: var(--surface); position: relative; cursor: grab;
}
.crma-wf-canvas.panning { cursor: grabbing; user-select: none; }
.crma-wf-canvas::-webkit-scrollbar { width: 6px; height: 6px; }
.crma-wf-canvas::-webkit-scrollbar-track { background: transparent; }
.crma-wf-canvas::-webkit-scrollbar-thumb { background: var(--gold-18); border-radius: 3px; }
.crma-wf-canvas::-webkit-scrollbar-thumb:hover { background: var(--gold-30); }
.crma-wf-map { position: relative; }
.crma-wf-svg { position: absolute; inset: 0; pointer-events: none; }
.crma-wf-path { fill: none; stroke: var(--line-2); stroke-width: 2; }
.crma-wf-leader { stroke: var(--line-2); stroke-width: 1; stroke-dasharray: 2 3; }
.crma-wf-leader.sel { stroke: var(--gold-30); }
.crma-wf-spot { fill: var(--gold); }
.crma-wf-spot.s-running.live { filter: drop-shadow(0 0 5px var(--gold-hi)); }
.crma-wf-spot.s-stopped { fill: var(--ink-4); }
.crma-wf-spot.s-done { fill: #D4AF37; }
.crma-wf-spot.s-unsub { fill: var(--err); }

.crma-wf-station { position: absolute; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.crma-wf-st-ico { width: 44px; height: 44px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--gold-30); color: var(--gold); display: grid; place-items: center; font-size: 15px; box-shadow: 0 0 18px var(--gold-10); }
.crma-wf-st-ico.end { color: #D4AF37; border-color: rgba(212,175,55,0.4); }
.crma-wf-st-lab { font: 600 11px var(--font-ui); color: var(--ink-3); background: rgba(0,0,0,0.35); padding: 2px 8px; border-radius: 999px; white-space: nowrap; }

.crma-wf-chip {
  position: absolute; transform: translate(-50%, -50%);
  background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 12px;
  padding: 8px 11px; cursor: pointer; display: flex; flex-direction: column; gap: 3px;
  min-width: 130px; box-shadow: var(--shadow-card); z-index: 2; transition: border-color 0.15s;
}
.crma-wf-chip:hover, .crma-wf-chip.sel { border-color: var(--gold-30); }
.crma-wf-chip.s-stopped { opacity: 0.62; filter: grayscale(0.4); }
.crma-wf-chip.s-done { border-color: rgba(212,175,55,0.35); }
.crma-wf-chip.s-unsub { border-color: rgba(224,108,108,0.35); opacity: 0.75; }
.crma-wf-chip-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.crma-wf-chip-top b { font: 600 12.5px var(--font-ui); color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crma-wf-mini {
  appearance: none; cursor: pointer; flex: 0 0 auto; width: 22px; height: 22px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line-2); background: transparent; color: var(--ink-3); font-size: 9px;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.crma-wf-mini:hover { color: var(--err); border-color: rgba(224,108,108,0.45); }
.crma-wf-mini.resume { color: var(--gold-hi); border-color: var(--gold-30); background: var(--gold-10); }
.crma-wf-mini.resume:hover { filter: brightness(1.12); color: var(--gold-hi); }
.crma-wf-chip-sub { font: 500 10.5px var(--font-ui); }
.crma-wf-count { font: 600 11px var(--font-ui); color: var(--gold-hi); font-variant-numeric: tabular-nums; }
.crma-wf-badge { font: 600 10px var(--font-ui); text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-4); }

.crma-wf-info {
  position: absolute; right: 22px; top: 18px; bottom: 18px; width: 330px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 18px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto;
  box-shadow: 0 18px 50px rgba(0,0,0,0.55); z-index: 3; animation: crmaWfInfoIn 0.18s ease-out;
}
@keyframes crmaWfInfoIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
.crma-wf-info-x { position: absolute; top: 12px; right: 12px; appearance: none; cursor: pointer; width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: transparent; border: 1px solid var(--line-2); color: var(--ink-3); font-size: 11px; transition: color 0.15s, border-color 0.15s; }
.crma-wf-info-x:hover { color: var(--ink); border-color: var(--line-strong); }
.crma-wf-info-name { font: 600 16px var(--font-serif); color: var(--ink); padding-right: 30px; }
.crma-wf-info-sub { font: 500 12px var(--font-ui); color: var(--ink-3); }
.crma-wf-info-dots { display: flex; gap: 12px; flex-wrap: wrap; }
.crma-wf-info-h { font: 600 10px var(--font-mono); color: var(--gold); text-transform: uppercase; letter-spacing: 0.12em; margin-top: 4px; }
.crma-wf-info-hist { display: flex; flex-direction: column; gap: 6px; }
.crma-wf-info-row { display: flex; gap: 8px; align-items: center; font: 500 12px var(--font-ui); color: var(--ink-2); }
.crma-wf-info-row i { color: var(--ok); font-size: 11px; flex: 0 0 auto; }
.crma-wf-info-row span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crma-wf-info-row em { font: 500 10.5px var(--font-mono); color: var(--ink-5); font-style: normal; margin-left: auto; white-space: nowrap; }
.crma-wf-info-row.dim { color: var(--ink-5); }
.crma-wf-info-next { display: flex; flex-direction: column; gap: 2px; }
.crma-wf-info-next b { font: 600 13px var(--font-ui); color: var(--ink); }
.crma-wf-info-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; }

/* ---- mobile (375px must stack cleanly) --------------------------------------- */
@media (max-width: 700px) {
  :is(.crma-root, .crma-wf) .crma-row { grid-template-columns: 1fr; gap: 8px; padding: 11px 12px; }
  :is(.crma-root, .crma-wf) .crma-row-side { justify-content: flex-start; }
  :is(.crma-root, .crma-wf) .crma-feed { grid-template-columns: 1fr; }
  :is(.crma-root, .crma-wf) .crma-card { padding: 14px; }
  :is(.crma-root, .crma-wf) .crma-card-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  :is(.crma-root, .crma-wf) .crma-node-task .crma-node-txt span { max-width: 220px; }
  :is(.crma-root, .crma-wf) .crma-tools { flex-direction: column; align-items: stretch; }
  :is(.crma-root, .crma-wf) .crma-sortbox { margin-left: 0; }
  /* Flow goes single-column on phones → each node its own row, centered so the
     JS stacked-mode down-arrows drop straight down (not zigzag between the
     varying-width pills). */
  :is(.crma-root, .crma-wf) .crma-strip2 { flex-direction: column; align-items: center; row-gap: 22px; }
  .crma-wf-body { padding: 12px; }
  .crma-wf-info { left: 10px; right: 10px; top: auto; bottom: 0; width: auto; max-height: 60%; }
}
