/* Newguard Builder — CRM
   The pipeline page: leads as glass rows (or cards on a board of stages), a
   summary strip above, and a drawer that slides in from the right with the
   whole relationship — profile, deal, stage, and every communication logged.
   Everything here is the daylight-glass system from app.css: the same tokens,
   the same press contract (slow hover lift, instant press, spring release),
   and the same house rule that nothing may snap. Stage colour is one hue —
   periwinkle deepening as a deal gets closer — with Won in the ok green and
   Lost in slate, so red stays reserved for delete. */

.crm-main { padding: 38px 28px 90px; max-width: 1240px; width: 100%; margin: 0 auto; }
.crm-main .sub { margin-bottom: 22px; max-width: 64ch; }

/* ---- summary strip ---- */
.crm-stats {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px;
  margin-bottom: 14px;
}
.crm-stat {
  display: flex; flex-direction: column; gap: 3px; padding: 15px 18px 13px; min-width: 0;
  background: var(--glass); border: 1px solid var(--line); border-radius: 18px;
  backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4);
  box-shadow: var(--shadow-rest), inset 0 1px 0 rgba(255, 255, 255, .7);
  transition: border-color .3s var(--ease-out), box-shadow .3s var(--ease-out);
}
.crm-stat b {
  font: 800 26px/1.15 var(--display); letter-spacing: -.02em; color: #1B2650;
  font-variant-numeric: tabular-nums; margin-top: 3px;
  transition: color .3s var(--ease-out);
}
.crm-stat-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crm-stat.is-forecast {
  background: linear-gradient(180deg, rgba(76, 99, 230, .13), rgba(76, 99, 230, .04)), var(--glass);
  border-color: rgba(76, 99, 230, .32);
  box-shadow: var(--shadow-rest), 0 0 28px rgba(76, 99, 230, .1), inset 0 1px 0 rgba(255, 255, 255, .85);
}
.crm-stat.is-forecast b { color: var(--accent-deep); }
.crm-stat.is-stale.is-hot b { color: var(--warn); }
.crm-stat.is-stale.is-hot { border-color: rgba(154, 106, 18, .3); }

/* ---- the pipeline: one segment per stage, each also a filter ----
   Open stages share the row in proportion to how many leads sit in them (an
   empty stage still keeps a slot); Won and Lost hang off the end past a
   hairline. The 3px bar along the top is the stage's tint. */
.crm-pipe { display: flex; gap: 6px; margin-bottom: 18px; }
.crm-pipe:empty { display: none; }
.crm-seg {
  --stage-tint: var(--accent);
  position: relative; flex: 1 1 0; min-width: 118px; text-align: left; overflow: hidden;
  display: flex; flex-direction: column; gap: 1px; padding: 12px 13px 10px;
  background: rgba(255, 255, 255, .5); border: 1px solid var(--line-soft); border-radius: 14px;
  cursor: pointer; font: inherit; color: var(--ink);
  transition: transform .32s var(--ease-spring), box-shadow .32s var(--ease-out),
    border-color .16s var(--ease-out), background .16s var(--ease-out), flex-grow .5s var(--ease-out);
}
.crm-seg::before {
  content: ''; position: absolute; left: 13px; right: 13px; top: 0; height: 3px;
  border-radius: 0 0 3px 3px; background: var(--stage-tint);
  transition: left .3s var(--ease-out), right .3s var(--ease-out);
}
.crm-seg:hover { background: #FFFFFF; border-color: rgba(76, 99, 230, .4); transform: translateY(-1px); box-shadow: var(--shadow-lift); }
.crm-seg:hover::before { left: 0; right: 0; }
.crm-seg:active { transform: translateY(1px) scale(.98); box-shadow: var(--shadow-rest); transition-duration: .06s; }
.crm-seg.is-on {
  background: var(--accent-soft); border-color: rgba(76, 99, 230, .5);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6), 0 0 18px rgba(76, 99, 230, .14);
}
.crm-seg.is-on::before { left: 0; right: 0; }
.crm-seg-name {
  font: 700 10.5px var(--sans); letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: color .16s var(--ease-out);
}
.crm-seg.is-on .crm-seg-name { color: var(--accent-deep); }
.crm-seg-n { font: 800 20px/1.15 var(--display); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.crm-seg-v { font: 400 11px var(--mono); color: var(--muted); white-space: nowrap; }
.crm-seg.is-closed { flex: 0 0 auto; min-width: 104px; }
.crm-seg.is-closed::before { opacity: .6; }
.crm-seg.won.is-on { background: rgba(14, 138, 95, .08); border-color: rgba(14, 138, 95, .4); box-shadow: 0 0 18px rgba(14, 138, 95, .12); }
.crm-seg.won.is-on .crm-seg-name { color: var(--ok); }
.crm-seg.lost.is-on { background: rgba(24, 33, 66, .07); border-color: var(--line); box-shadow: none; }
.crm-seg.lost.is-on .crm-seg-name { color: var(--ink); }
.crm-pipe-gap { width: 1px; background: var(--line); margin: 8px 4px; flex: none; }

/* ---- toolbar: search, view, closed toggle ---- */
.crm-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.crm-search { position: relative; flex: 1 1 240px; max-width: 420px; display: flex; align-items: center; }
.crm-search svg { position: absolute; left: 13px; width: 15px; height: 15px; color: var(--muted); pointer-events: none; transition: color .16s var(--ease-out); }
.crm-search:focus-within svg { color: var(--accent-deep); }
.crm-search input { padding-left: 36px; border-radius: 999px; background: rgba(255, 255, 255, .62); }
.crm-search input::-webkit-search-cancel-button { -webkit-appearance: none; }
.crm-closed-toggle { font-size: 12.5px; margin-left: auto; }
.crm-closed-toggle input { width: auto; }

/* view swap — the old one slips out, the new one rises in */
.crm-views > * { animation: crm-view-in .3s var(--ease-out) both; }
.crm-views > .leaving { animation: crm-view-out .18s var(--ease-out) forwards; pointer-events: none; }
@keyframes crm-view-in { from { opacity: 0; transform: translateY(6px); } }
@keyframes crm-view-out { to { opacity: 0; transform: translateY(-4px); } }

/* active ↔ future — the summary strip, pipeline and future-leads list fade
   the same way as the table ↔ board swap above (the future list lives outside
   #crm-views since it has to stay visible while the active pipeline is empty) */
.crm-stats, .crm-pipe, .crm-future-wrap { animation: crm-view-in .3s var(--ease-out) both; }
.crm-stats.leaving, .crm-pipe.leaving, .crm-future-wrap.leaving { animation: crm-view-out .18s var(--ease-out) forwards; pointer-events: none; }

/* ---- the list ---- */
.crm-table-wrap {
  background: var(--glass); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; overflow-x: auto;
  backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4);
  box-shadow: var(--shadow-rest), inset 0 1px 0 rgba(255, 255, 255, .7);
}
.crm-table { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 820px; }
.crm-table th {
  text-align: left; padding: 11px 14px 10px; white-space: nowrap;
  border-bottom: 1px solid var(--line-soft); background: rgba(255, 255, 255, .45);
}
.crm-table th:first-child, .crm-table td:first-child { padding-left: 18px; }
.crm-table th:last-child, .crm-table td:last-child { padding-right: 18px; }
.crm-table th.num, .crm-table td.num { text-align: right; }
.crm-table .col-comm { width: 27%; }
.crm-table td.col-comm { max-width: 0; }
.crm-th, .crm-sort {
  font: 700 10.5px var(--sans); letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
}
.crm-sort {
  background: none; border: 0; padding: 0; cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px;
  transition: color .16s var(--ease-out);
}
.crm-sort::after {
  content: ''; width: 0; height: 0; border: 4px solid transparent; border-top-color: currentColor; border-bottom: 0;
  opacity: 0; transform: translateY(1px);
  transition: opacity .16s var(--ease-out), transform .24s var(--ease-out);
}
.crm-sort:hover { color: var(--ink); }
.crm-sort.is-on { color: var(--accent-deep); }
.crm-sort.is-on::after { opacity: 1; }
.crm-sort.is-on.asc::after { transform: translateY(-1px) rotate(180deg); }
.crm-table th.num .crm-sort { flex-direction: row-reverse; }

.crm-row { cursor: pointer; animation: crm-row-in .32s var(--ease-out) both; }
.crm-row.settled { animation: none; }
@keyframes crm-row-in { from { opacity: 0; } }
.crm-row td {
  padding: 11px 14px; vertical-align: middle; font-size: 13px;
  border-bottom: 1px solid var(--line-soft);
  transition: background .16s var(--ease-out);
}
.crm-row:last-child td { border-bottom: 0; }
.crm-row:hover td { background: rgba(255, 255, 255, .72); }
.crm-row.is-open td { background: var(--accent-soft); }
.crm-row.closed .crm-lead-name { color: var(--muted); }
/* rows can be picked up and carried to the section toggle */
.crm-row[draggable] { -webkit-user-drag: element; }
.crm-row.dragging td { opacity: .4; }
.crm-row.leaving { animation: crm-row-out .18s var(--ease-out) forwards; pointer-events: none; }
.crm-card.leaving { animation: crm-row-out .18s var(--ease-out) forwards; pointer-events: none; }
@keyframes crm-row-out { to { opacity: 0; transform: translateX(6px); } }

/* ---- the section toggle as a drop target ----
   Picking anything up wakes the other list's button: a dashed accent ring,
   then a solid fill once the pointer is over it. Pointer events on the
   children are off so dragleave doesn't flicker crossing the label. */
#crm-section .btn { transition: background .2s var(--ease-out), border-color .2s var(--ease-out), box-shadow .3s var(--ease-out), color .2s var(--ease-out), transform .32s var(--ease-spring); }
#crm-section.is-dragging .btn { pointer-events: auto; }
#crm-section.is-dragging .btn > * { pointer-events: none; }
#crm-section .btn.drop-ready {
  border-color: rgba(76, 99, 230, .55); border-style: dashed; color: var(--accent-deep);
  background: rgba(255, 255, 255, .85);
  box-shadow: 0 0 0 3px rgba(76, 99, 230, .1), 0 0 18px rgba(76, 99, 230, .18);
  animation: crm-drop-pulse 1.6s var(--ease-out) infinite;
}
@keyframes crm-drop-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(76, 99, 230, .1), 0 0 18px rgba(76, 99, 230, .18); }
  50% { box-shadow: 0 0 0 5px rgba(76, 99, 230, .16), 0 0 26px rgba(76, 99, 230, .26); }
}
#crm-section .btn.drop-ready.is-over {
  border-style: solid; border-color: var(--accent); background: var(--accent-soft); color: var(--accent-deep);
  transform: scale(1.06); animation: none;
  box-shadow: 0 0 0 4px rgba(76, 99, 230, .18), 0 0 28px rgba(76, 99, 230, .3), inset 0 1px 0 rgba(255, 255, 255, .7);
}
.crm-none { margin: 0; padding: 26px 18px; font-size: 13px; color: var(--muted); text-align: center; }
.crm-dash { color: var(--muted); opacity: .6; }

/* ---- future leads: a plainer list, no stage/value columns ---- */
.crm-future-table { min-width: 640px; }
.crm-future-table td { font-size: 13px; color: var(--ink); }

/* the lead cell: initials, company, who */
.crm-lead { display: flex; align-items: center; gap: 11px; min-width: 0; }
.crm-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font: 700 12px var(--sans); letter-spacing: .02em; color: var(--accent-deep);
  background: linear-gradient(180deg, rgba(76, 99, 230, .18), rgba(76, 99, 230, .07));
  box-shadow: inset 0 0 0 1px rgba(76, 99, 230, .22), inset 0 1px 0 rgba(255, 255, 255, .8);
}
.crm-avatar.big { width: 46px; height: 46px; font-size: 15px; }
.crm-lead-txt { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.crm-lead-name { font: 700 13.5px var(--display); color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crm-lead-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* stage pill — the dot takes the stage tint */
.pill.crm-stage { --stage-tint: var(--accent); color: var(--ink); background: rgba(255, 255, 255, .55); }
.pill.crm-stage::before { background: var(--stage-tint); box-shadow: 0 0 8px color-mix(in srgb, var(--stage-tint) 55%, transparent); }
.pill.crm-stage.won { color: var(--ok); border-color: rgba(14, 138, 95, .4); }
.pill.crm-stage.lost { color: var(--muted); }
.pill.crm-stage.lost::before { box-shadow: none; }

/* close probability — a short track and the figure */
.crm-prob { display: flex; align-items: center; gap: 9px; min-width: 130px; }
.crm-prob-track {
  flex: 1; min-width: 56px; height: 5px; border-radius: 999px; overflow: hidden;
  background: rgba(24, 33, 66, .1); box-shadow: inset 0 1px 2px rgba(24, 33, 66, .08);
}
.crm-prob-fill {
  --p: 0;
  display: block; height: 100%; width: 100%; border-radius: 999px;
  background: linear-gradient(90deg, #445CE0, #5F7BF0); box-shadow: 0 0 8px rgba(76, 99, 230, .35);
  transform: scaleX(var(--p)); transform-origin: left center;
  transition: transform .5s var(--ease-out);
}
.crm-prob.won .crm-prob-fill { background: var(--ok); box-shadow: 0 0 8px rgba(14, 138, 95, .35); }
.crm-prob-num { font: 500 11.5px var(--mono); color: var(--ink); min-width: 34px; text-align: right; font-variant-numeric: tabular-nums; }
.crm-prob.custom .crm-prob-num { color: var(--accent-deep); }

/* money — a measured value, so it sets in the mono */
.crm-money { font: 500 12.5px var(--mono); font-variant-numeric: tabular-nums; color: var(--ink); white-space: nowrap; }
.crm-money.weighted { color: var(--accent-deep); }
.crm-money.zero { color: var(--muted); }

/* last contact — how warm the relationship still is */
.crm-last-cell { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; font-size: 12.5px; color: var(--ink); }
.crm-dot { width: 7px; height: 7px; border-radius: 50%; background: rgba(24, 33, 66, .22); flex: none; transition: background .3s var(--ease-out), box-shadow .3s var(--ease-out); }
.crm-dot.fresh { background: var(--ok); box-shadow: 0 0 8px rgba(14, 138, 95, .5); }
.crm-dot.cooling { background: var(--accent); box-shadow: 0 0 8px rgba(76, 99, 230, .5); }
.crm-dot.stale { background: var(--warn); box-shadow: 0 0 8px rgba(154, 106, 18, .5); }
.crm-last-cell.stale { color: var(--warn); font-weight: 600; }
.crm-last-cell.never, .crm-last-cell.closed { color: var(--muted); }

/* last communication — type icon, the note, who and when */
.crm-comm-cell { display: flex; align-items: center; gap: 9px; min-width: 0; }
.crm-comm-ico {
  width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; flex: none;
  background: rgba(24, 33, 66, .06); color: var(--muted);
}
.crm-comm-ico svg { width: 13px; height: 13px; }
.crm-comm-txt { min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.crm-comm-note { font-size: 12.5px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crm-comm-meta { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crm-comm-cell.none { color: var(--muted); font-size: 12.5px; }

/* ---- the board ---- */
.crm-board {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(212px, 1fr); gap: 12px;
  overflow-x: auto; padding-bottom: 10px; align-items: start;
}
.crm-col {
  --stage-tint: var(--accent);
  display: flex; flex-direction: column; gap: 8px; min-width: 0; min-height: 180px; padding: 10px;
  background: rgba(255, 255, 255, .42); border: 1px solid var(--line-soft); border-radius: 18px;
  transition: background .2s var(--ease-out), border-color .2s var(--ease-out), box-shadow .3s var(--ease-out);
}
.crm-col.is-on { border-color: rgba(76, 99, 230, .35); background: rgba(255, 255, 255, .6); }
.crm-col.is-over {
  background: var(--accent-soft); border-color: rgba(76, 99, 230, .5);
  box-shadow: 0 0 22px rgba(76, 99, 230, .16), inset 0 0 0 1px rgba(76, 99, 230, .2);
}
.crm-col-head { display: flex; align-items: center; gap: 8px; padding: 4px 6px 6px; }
.crm-col-head::before {
  content: ''; width: 8px; height: 8px; border-radius: 50%; flex: none;
  background: var(--stage-tint); box-shadow: 0 0 8px color-mix(in srgb, var(--stage-tint) 55%, transparent);
}
.crm-col-name { font: 700 10.5px var(--sans); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crm-col-n { font: 500 11px var(--mono); color: var(--muted); }
.crm-col-v { font: 500 11px var(--mono); color: var(--accent-deep); }
.crm-card {
  display: flex; flex-direction: column; gap: 9px; padding: 12px 13px; cursor: grab;
  background: var(--glass-2); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow-rest), inset 0 1px 0 rgba(255, 255, 255, .8);
  transition: transform .32s var(--ease-spring), box-shadow .32s var(--ease-out),
    border-color .16s var(--ease-out), background .16s var(--ease-out), opacity .2s var(--ease-out);
  animation: crm-card-in .3s var(--ease-out) both;
}
.crm-card.settled { animation: none; }
@keyframes crm-card-in { from { opacity: 0; transform: translateY(6px); } }
.crm-card:hover { transform: translateY(-2px); background: #FFFFFF; border-color: rgba(76, 99, 230, .4); box-shadow: var(--shadow-lift), inset 0 1px 0 rgba(255, 255, 255, .9); }
.crm-card:active { cursor: grabbing; transform: scale(.985); box-shadow: var(--shadow-rest); transition-duration: .06s; }
.crm-card.dragging { opacity: .4; transform: scale(.97); }
.crm-card.is-open { border-color: rgba(76, 99, 230, .5); background: linear-gradient(180deg, rgba(76, 99, 230, .1), rgba(76, 99, 230, .03)), #FFFFFF; }
.crm-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.crm-card .crm-prob { min-width: 0; }
.crm-col-empty {
  font-size: 12px; color: var(--muted); text-align: center; padding: 20px 8px;
  border: 1px dashed var(--line); border-radius: 12px;
  transition: border-color .2s var(--ease-out), color .2s var(--ease-out);
}
.crm-col.is-over .crm-col-empty { border-color: rgba(76, 99, 230, .5); color: var(--accent-deep); }

/* ---- the drawer ----
   Slides in from the right over a soft scrim. The view carries .drawer-open;
   the aside keeps its own scroll so the page behind never moves. */
.crm-scrim {
  position: fixed; inset: 0; z-index: 40; background: rgba(24, 32, 70, .22);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  opacity: 0; pointer-events: none;
  transition: opacity .34s var(--ease-out);
}
.crm-drawer {
  position: fixed; top: 12px; right: 12px; bottom: 12px; z-index: 41;
  width: min(560px, calc(100vw - 24px));
  display: flex; flex-direction: column; min-height: 0; outline: none;
  background: rgba(255, 255, 255, .88); border: 1px solid var(--line); border-radius: 20px;
  backdrop-filter: blur(24px) saturate(1.4); -webkit-backdrop-filter: blur(24px) saturate(1.4);
  box-shadow: 0 24px 70px rgba(24, 33, 66, .28), inset 0 1px 0 rgba(255, 255, 255, .9);
  transform: translateX(calc(100% + 24px)); visibility: hidden;
  transition: transform .42s var(--ease-out), visibility 0s .42s;
}
#view-crm.drawer-open .crm-scrim { opacity: 1; pointer-events: auto; }
#view-crm.drawer-open .crm-drawer { transform: none; visibility: visible; transition: transform .42s var(--ease-out); }
.crm-dr-head { display: flex; align-items: center; gap: 12px; padding: 16px 14px 14px 18px; border-bottom: 1px solid var(--line-soft); flex: none; }
.crm-dr-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.crm-dr-title b { font: 700 17px var(--display); letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crm-dr-title span { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crm-dr-title span:empty { display: none; }
.crm-dr-body { flex: 1; min-height: 0; overflow-y: auto; padding-bottom: 6px; }
.crm-dr-sec { padding: 14px 18px 16px; border-bottom: 1px solid var(--line-soft); }
.crm-dr-sec:last-child { border-bottom: 0; }
.crm-dr-sec .insp-lab { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.crm-last { margin-left: auto; font: 500 10.5px var(--mono); letter-spacing: 0; text-transform: none; color: var(--muted); }
.crm-last.stale { color: var(--warn); }

/* the stage stepper — every stage is one press away */
.crm-stepper { display: flex; gap: 5px; flex-wrap: wrap; }
.crm-stepper > .crm-step { flex: 1 1 0; }
.crm-stepper-closed { flex-basis: 100%; display: flex; gap: 5px; margin-top: 3px; padding-top: 8px; border-top: 1px dashed var(--line-soft); }
.crm-step {
  --stage-tint: var(--accent);
  flex: 1 1 auto; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: 600 11px var(--sans); color: var(--muted); white-space: nowrap;
  background: rgba(255, 255, 255, .5); border: 1px solid var(--line-soft); border-radius: 999px;
  padding: 6px 9px; cursor: pointer; min-width: 0;
  transition: transform .32s var(--ease-spring), box-shadow .32s var(--ease-out),
    border-color .16s var(--ease-out), background .16s var(--ease-out), color .16s var(--ease-out);
}
.crm-step::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--stage-tint); opacity: .45;
  transition: opacity .16s var(--ease-out), box-shadow .16s var(--ease-out);
}
.crm-step:hover { background: #FFFFFF; color: var(--ink); border-color: rgba(76, 99, 230, .4); transform: translateY(-1px); box-shadow: var(--shadow-lift); }
.crm-step:active { transform: translateY(1px) scale(.96); box-shadow: none; transition-duration: .06s; }
.crm-step.is-done { color: var(--ink); }
.crm-step.is-done::before { opacity: 1; }
.crm-step.is-on {
  background: var(--accent-soft); color: var(--accent-deep); border-color: rgba(76, 99, 230, .5);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6), 0 0 14px rgba(76, 99, 230, .14);
}
.crm-step.is-on::before { opacity: 1; box-shadow: 0 0 8px color-mix(in srgb, var(--stage-tint) 60%, transparent); }
.crm-step.won.is-on { color: var(--ok); border-color: rgba(14, 138, 95, .4); background: rgba(14, 138, 95, .08); box-shadow: 0 0 14px rgba(14, 138, 95, .14); }
.crm-step.lost.is-on { color: var(--ink); border-color: var(--line); background: rgba(24, 33, 66, .07); box-shadow: none; }
.crm-step.lost.is-on::before { box-shadow: none; }
.crm-stepper-closed .crm-step { flex: 0 1 auto; }

/* the deal — value, expected close, probability, and what it weighs */
.crm-deal { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.crm-deal-f { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.crm-deal-f > span { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.crm-deal-f > span b { margin-left: auto; color: var(--accent-deep); font-size: 12px; }
.crm-deal-f input { font-size: 13px; padding: 8px 12px; }
.crm-money-in { position: relative; display: flex; align-items: center; }
.crm-money-in i { position: absolute; left: 12px; font: 500 13px var(--mono); color: var(--muted); font-style: normal; pointer-events: none; }
.crm-money-in input { padding-left: 24px; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.crm-deal-prob { grid-column: 1 / -1; gap: 2px; }
.crm-deal-prob input[type=range] {
  width: 100%; height: 26px; padding: 0; border: 0; background: none; box-shadow: none; accent-color: var(--accent); cursor: pointer;
}
.crm-deal-prob input[type=range]:disabled { opacity: .45; cursor: default; }
.crm-hint { margin: 0; font-size: 11.5px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; min-height: 17px; }
.crm-hint .linkish { color: var(--accent-deep); font-size: 11.5px; }
.crm-hint .linkish:hover { color: var(--accent); }
.crm-deal-weighted {
  grid-column: 1 / -1; flex-direction: row; align-items: center; justify-content: space-between;
  padding: 10px 13px; border-radius: 12px;
  background: var(--accent-soft); border: 1px solid rgba(76, 99, 230, .22);
}
.crm-deal-weighted > span { color: var(--accent-deep); font-weight: 600; }
.crm-deal-weighted b { font: 700 16px var(--display); color: var(--accent-deep); font-variant-numeric: tabular-nums; transition: color .3s var(--ease-out); }
.crm-deal-weighted.won { background: rgba(14, 138, 95, .08); border-color: rgba(14, 138, 95, .3); }
.crm-deal-weighted.won > span, .crm-deal-weighted.won b { color: var(--ok); }
.crm-deal-weighted.lost { background: rgba(24, 33, 66, .05); border-color: var(--line-soft); }
.crm-deal-weighted.lost > span, .crm-deal-weighted.lost b { color: var(--muted); }

/* profile facts */
.crm-facts { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.crm-facts > div { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.crm-facts dt { font-size: 11px; color: var(--muted); letter-spacing: .02em; }
.crm-facts dd { margin: 0; font-size: 13px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crm-facts dd a {
  color: var(--accent-deep); text-decoration: none; border-bottom: 1px solid rgba(76, 99, 230, .3);
  transition: color .16s var(--ease-out), border-color .16s var(--ease-out);
}
.crm-facts dd a:hover { color: var(--accent); border-color: currentColor; }
.crm-facts dd.empty { color: var(--muted); opacity: .65; }
.crm-notes {
  margin: 12px 0 0; padding: 10px 12px; font-size: 13px; line-height: 1.55; color: var(--ink);
  white-space: pre-wrap; word-break: break-word;
  background: rgba(255, 255, 255, .55); border: 1px solid var(--line-soft); border-radius: 12px;
}

/* logging a communication */
.crm-log { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.crm-log-types { align-self: flex-start; }
.crm-log-types .btn { padding: 5px 11px; font-size: 12px; }
.crm-log textarea { resize: vertical; min-height: 46px; font-size: 13px; }
.crm-log-row { display: flex; align-items: center; gap: 8px; }
.crm-log-row input[type=datetime-local] { width: auto; font-size: 12px; padding: 6px 10px; border-radius: 10px; color: var(--muted); }
.crm-log-row input[type=datetime-local]:focus { color: var(--ink); }

/* the timeline */
.crm-timeline { list-style: none; margin: 0; padding: 0 0 0 16px; position: relative; display: flex; flex-direction: column; gap: 9px; }
.crm-timeline:empty { display: none; }
.crm-timeline::before { content: ''; position: absolute; left: 3px; top: 12px; bottom: 12px; width: 1px; background: var(--line); }
.crm-comm {
  position: relative; padding: 9px 12px 10px;
  background: rgba(255, 255, 255, .55); border: 1px solid var(--line-soft); border-radius: 12px;
  transition: border-color .16s var(--ease-out), background .16s var(--ease-out), opacity .2s var(--ease-out), transform .2s var(--ease-out);
  animation: crm-comm-in .3s var(--ease-out) both;
}
.crm-comm.settled { animation: none; }
.crm-comm.leaving { opacity: 0; transform: translateX(8px); }
@keyframes crm-comm-in { from { opacity: 0; transform: translateY(-4px); } }
.crm-comm::before {
  content: ''; position: absolute; left: -16px; top: 14px; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 3px rgba(255, 255, 255, .95), 0 0 8px rgba(76, 99, 230, .5);
}
.crm-comm:hover { border-color: var(--line); background: rgba(255, 255, 255, .85); }
.crm-comm-head { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); margin-bottom: 5px; min-height: 20px; }
.crm-comm-head .crm-comm-ico { width: 20px; height: 20px; border-radius: 6px; background: var(--accent-soft); color: var(--accent-deep); }
.crm-comm-head .crm-comm-ico svg { width: 11px; height: 11px; }
.crm-comm-type { font: 700 10px var(--sans); letter-spacing: .09em; text-transform: uppercase; color: var(--accent-deep); }
.crm-comm-when { font-family: var(--mono); font-size: 10.5px; }
.crm-comm-by { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.crm-comm-by::before { content: '·'; margin-right: 6px; }
.crm-comm-acts { margin-left: auto; display: flex; gap: 9px; flex: none; opacity: 0; transition: opacity .16s var(--ease-out); }
.crm-comm:hover .crm-comm-acts, .crm-comm:focus-within .crm-comm-acts { opacity: 1; }
.crm-comm-acts .linkish { font-size: 11px; text-decoration: none; color: var(--muted); transition: color .16s var(--ease-out); }
.crm-comm-acts .linkish:hover { color: var(--accent-deep); }
.crm-comm-acts .linkish.del:hover, .crm-comm-acts .linkish.del.armed { color: var(--danger); }
.crm-comm-body { font-size: 13px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; color: var(--ink); }
.crm-comm-edit textarea { font-size: 13px; resize: vertical; min-height: 60px; animation: crm-comm-in .22s var(--ease-out); }
.crm-comm-edit-row { display: flex; gap: 6px; justify-content: flex-end; margin-top: 7px; }
.crm-comm-edit-row .btn { padding: 5px 12px; font-size: 12px; }

.crm-dr-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.crm-meta { font-size: 11.5px; color: var(--muted); line-height: 1.5; }

/* ---- toasts: the same glass pill as the editor's change log ---- */
.crm-toasts {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 45;
  display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none;
  max-width: calc(100vw - 32px);
}
.crm-toasts .hist-toast { pointer-events: auto; }

/* ---- the lead form ---- */
.modal.crm-modal { max-width: 580px; }
.crm-form { display: grid; grid-template-columns: 1fr 1fr; gap: 11px 12px; }
.crm-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.crm-field.wide { grid-column: 1 / -1; }
.crm-field textarea { resize: vertical; }

/* ---- narrower screens ---- */
@media (max-width: 1000px) {
  .crm-table .col-comm { display: none; }
  .crm-table { min-width: 640px; }
  .crm-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* the strip wraps into rows rather than squeezing the stage names */
  .crm-pipe { flex-wrap: wrap; }
  .crm-seg, .crm-seg.is-closed { flex-basis: calc(20% - 6px); min-width: 128px; }
  .crm-seg.is-closed { flex-grow: 1; }
  .crm-pipe-gap { display: none; }
}
@media (max-width: 760px) {
  .crm-table .col-weighted { display: none; }
  .crm-table { min-width: 560px; }
  .crm-drawer {
    top: auto; left: 0; right: 0; bottom: 0; width: 100%; max-height: 92vh; max-height: 92dvh;
    border-radius: 22px 22px 0 0; border-bottom: none;
    transform: translateY(103%);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  #view-crm.drawer-open .crm-drawer { transform: none; }
  .crm-deal, .crm-facts { grid-template-columns: 1fr; }
  .crm-closed-toggle { margin-left: 0; }
}
@media (max-width: 640px) {
  /* the header buttons drop their labels on a phone — wordmark + four pills
     do not fit 375px otherwise, and the header overflowed the screen */
  .home-head .head-actions .hl { display: none; }
  .home-head .head-actions .btn { padding: 7px 11px; }
  .crm-main { padding-left: 16px; padding-right: 16px; }
  .crm-stats { grid-template-columns: 1fr; }
  .crm-seg, .crm-seg.is-closed { flex-basis: calc(33.33% - 6px); min-width: 0; }
  .crm-form { grid-template-columns: 1fr; }
  .crm-drawer textarea, .crm-drawer input { font-size: 16px; }   /* stops iOS zooming on focus */
}

@media (prefers-reduced-motion: reduce) {
  .crm-seg:hover, .crm-seg:active, .crm-step:hover, .crm-step:active,
  .crm-card:hover, .crm-card:active, #crm-section .btn.drop-ready.is-over { transform: none; }
  #crm-section .btn.drop-ready { animation: none; }
}
