/* CRM & Pipeline: funnel, Kanban, deals table, forecast, sources, lost. All classes are prefixed crm-. */

/* ---------- filters ---------- */
.crm-fchip svg, .crm-stagechip svg { width: 14px; height: 14px; margin-right: -3px; }
.crm-fchip[aria-pressed="true"] b, .crm-fchip[aria-pressed="true"] svg { color: #fff; }
.crm-fchip b { font-weight: 700; color: var(--ink); }
.crm-filters .seg { flex: none; }

/* ---------- funnel (hero) ---------- */
.crm-funnel { padding: 24px 26px 20px; background: radial-gradient(900px 360px at 12% -20%, rgba(62, 143, 151, .28), transparent 62%), radial-gradient(700px 300px at 100% 110%, rgba(44, 122, 75, .22), transparent 60%), var(--band); box-shadow: var(--shadow-2); }
.crm-fn-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px 28px; flex-wrap: wrap; margin-bottom: 20px; }
.crm-fn-title { display: grid; gap: 4px; min-width: 0; }
.crm-fn-title .eyebrow { font: 700 11.5px var(--f-num); letter-spacing: .12em; text-transform: uppercase; }
.crm-fn-title h2 { font: 700 28px/1.05 var(--f-head); color: #fff; }
.crm-fn-title p { max-width: 520px; }
.crm-fn-kpis { display: flex; gap: 10px; }
.crm-fn-kpi { background: rgba(255, 255, 255, .06); border: 1px solid var(--band-rule); border-radius: 10px; padding: 10px 16px 9px; min-width: 134px; display: grid; gap: 1px; backdrop-filter: blur(2px); }
.crm-fn-kpi small { font: 700 10.5px var(--f-num); letter-spacing: .1em; text-transform: uppercase; color: var(--band-eyebrow); }
.crm-fn-kpi b { font: 700 32px/1.05 var(--f-head); color: #fff; font-variant-numeric: tabular-nums; }
.crm-fn-kpi u { text-decoration: none; font-size: 15px; color: var(--band-muted); margin-left: 5px; font-weight: 600; }
.crm-fn-kpi span { font-size: 12px; color: var(--band-muted); }

.crm-fn { display: grid; position: relative; }
.crm-fn-row { appearance: none; border: 0; background: transparent; color: var(--band-ink); font: inherit; text-align: left; width: 100%; display: grid; grid-template-columns: 200px minmax(0, 1fr) 300px; align-items: center; gap: 0 16px; height: 62px; padding: 0 12px; border-radius: 10px; cursor: pointer; position: relative; transition: background .15s, opacity .25s; }
.crm-fn-row:hover { background: rgba(255, 255, 255, .055); }
.crm-fn-row:focus-visible { outline: 2px solid var(--band-eyebrow); outline-offset: -2px; }
.crm-fn-row.sel { background: rgba(127, 197, 204, .13); box-shadow: inset 3px 0 0 var(--band-eyebrow); }
.crm-fn-row.dim { opacity: .5; }
.crm-fn-row.dim:hover { opacity: .85; }
.crm-fn-lab { display: grid; gap: 1px; min-width: 0; }
.crm-fn-name { display: flex; align-items: center; gap: 9px; font: 700 18px/1.15 var(--f-semi); color: #fff; }
.crm-fn-dot { width: 10px; height: 10px; border-radius: 3px; background: var(--c); flex: none; box-shadow: 0 0 0 2px rgba(255, 255, 255, .14); }
.crm-fn-sub { font-size: 12.5px; color: var(--band-muted); padding-left: 19px; }
.crm-fn-shape { position: relative; height: 100%; display: block; min-width: 0; }
.crm-fn-clip { position: absolute; inset: 1px 0; overflow: hidden; display: block; }
.crm-fn-svg { display: block; width: 100%; height: 100%; transform-origin: 50% 50%; filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .28)); transition: filter .2s; }
.crm-fn-row.sel .crm-fn-svg { filter: drop-shadow(0 0 12px rgba(127, 197, 204, .55)); }
.crm-fn-svg.anim { animation: crm-fnin .75s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(var(--i, 0) * 55ms); }
@keyframes crm-fnin { from { transform: scaleX(var(--sx, .4)); opacity: .35; } }
.crm-fn-n { position: absolute; inset: 0; display: grid; place-items: center; font: 700 24px var(--f-head); color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, .4); pointer-events: none; font-variant-numeric: tabular-nums; }
.crm-fn-row:nth-child(5) .crm-fn-n, .crm-fn-row:nth-child(6) .crm-fn-n { color: #0d2328; text-shadow: none; }
.crm-fn-conv { position: absolute; top: 0; left: 50%; transform: translate(-50%, -50%); z-index: 3; font: 600 11.5px var(--f-num); padding: 2px 9px; border-radius: 999px; background: #213e45; border: 1px solid rgba(255, 255, 255, .2); color: #cfe6e8; white-space: nowrap; box-shadow: 0 2px 8px rgba(0, 0, 0, .3); pointer-events: none; }
.crm-fn-conv.hi { color: #a8e3bd; }
.crm-fn-conv.lo { color: #f0cf86; }
.crm-fn-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; text-align: right; }
.crm-fn-stats span { display: grid; gap: 0; min-width: 0; }
.crm-fn-stats b { font: 600 16px var(--f-num); color: #fff; font-variant-numeric: tabular-nums; white-space: nowrap; }
.crm-fn-stats small { font: 600 10.5px var(--f-num); letter-spacing: .07em; text-transform: uppercase; color: var(--band-muted); }
.crm-fn-foot { display: flex; justify-content: flex-end; margin-top: 14px; }
.crm-lostchip { display: inline-flex; align-items: center; gap: 7px; padding: 6px 14px; border-radius: 999px; background: rgba(178, 59, 46, .22); border: 1px solid rgba(255, 150, 135, .35); color: #ffd6cf; font-size: 13.5px; text-decoration: none; }
.crm-lostchip:hover { background: rgba(178, 59, 46, .34); text-decoration: none; }
.crm-lostchip svg { width: 14px; height: 14px; }
.crm-lostchip.none { background: rgba(255, 255, 255, .06); border-color: var(--band-rule); color: var(--band-muted); }
.crm-lostchip b { color: #fff; font-family: var(--f-num); }
.crm-funnel .empty { color: var(--band-muted); }

/* ---------- board ---------- */
.crm-boardwrap { display: grid; gap: 10px; scroll-margin-top: calc(var(--top-h) + 12px); min-width: 0; }
.crm-board-title { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.crm-board-title h2 { font: 700 22px/1.1 var(--f-head); }
.crm-lostsw { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.crm-board { display: flex; gap: 12px; overflow-x: auto; padding: 2px 2px 12px; align-items: flex-start; scrollbar-width: thin; }
.crm-col { flex: 0 0 272px; min-width: 0; background: #e3eaeb; border: 1px solid var(--line); border-top: 3px solid var(--c); border-radius: 12px; display: flex; flex-direction: column; max-height: calc(100vh - 150px); min-height: 220px; transition: flex-basis .25s ease, background .15s, box-shadow .15s; }
.crm-col-h { padding: 11px 12px 8px; display: grid; gap: 2px; }
.crm-col-t { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.crm-col-t h3 { font: 700 15.5px/1.1 var(--f-semi); letter-spacing: .01em; }
.crm-col-n { font: 600 12px var(--f-num); background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 0 8px; color: var(--ink-2); }
.crm-col-sum { display: flex; gap: 10px; font-size: 12.5px; color: var(--ink); font-weight: 600; }
.crm-col-sum .dim { font-weight: 500; }
.crm-col-b { overflow-y: auto; padding: 4px 8px 10px; display: grid; gap: 8px; align-content: start; min-height: 110px; scrollbar-width: thin; flex: 1; }
.crm-col.drop { background: var(--brand-soft); outline: 2px dashed var(--brand); outline-offset: -3px; }
.crm-col.sel { flex-basis: 330px; background: #d8e8ea; box-shadow: 0 0 0 2px var(--brand), var(--shadow-1); }
.crm-col.collapsed { flex-basis: 66px; }
.crm-col.collapsed .crm-col-b > * { display: none; }
.crm-col.collapsed .crm-col-h { justify-items: center; }
.crm-col.collapsed .crm-col-t { flex-direction: column-reverse; gap: 10px; }
.crm-col.collapsed .crm-col-t h3 { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; font-size: 14px; }
.crm-col.collapsed .crm-col-sum { display: none; }
.crm-col-empty { display: grid; gap: 2px; text-align: center; color: var(--ink-3); font-size: 13px; padding: 22px 8px; border: 1.5px dashed var(--ctl-line); border-radius: 10px; }
.crm-col-empty small { font-size: 11.5px; }

.crm-card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 11px 9px; box-shadow: var(--shadow-1); display: grid; gap: 5px; cursor: grab; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: pan-x pan-y; position: relative; transition: box-shadow .15s, border-color .15s; min-width: 0; }
.crm-card:hover { border-color: var(--brand); box-shadow: 0 2px 6px rgba(21, 38, 43, .1), 0 8px 20px rgba(21, 38, 43, .1); }
.crm-card:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.crm-card.won { border-left: 3px solid var(--ok); }
.crm-card.lost { border-left: 3px solid var(--bad); background: #fdf8f7; }
.crm-card.dragging { opacity: .35; }
.crm-ghost { position: fixed; left: 0; top: 0; z-index: 100; pointer-events: none; margin: 0; cursor: grabbing; will-change: transform; box-shadow: 0 22px 44px rgba(21, 38, 43, .32), 0 4px 10px rgba(21, 38, 43, .2); border-color: var(--brand); }
body.crm-dragging, body.crm-dragging * { cursor: grabbing !important; user-select: none !important; }
.crm-card-h { display: flex; align-items: center; justify-content: space-between; gap: 6px; min-width: 0; }
.crm-card-co { font: 700 15.5px/1.2 var(--f-semi); color: var(--ink); min-width: 0; }
.crm-kebab { margin: -6px -7px -6px 0; width: 30px; min-height: 30px; flex: none; }
.crm-kebab svg { width: 16px; height: 16px; }
.crm-card-deal { font-size: 12.5px; color: var(--ink-3); margin-top: -3px; }
.crm-card-mid { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.crm-arr { font-size: 21px; font-weight: 700; letter-spacing: -.02em; color: var(--ink); }
.crm-prob { font-size: 12px; font-weight: 600; background: var(--brand-soft); color: var(--brand); padding: 1px 8px; border-radius: 999px; }
.crm-card-who { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--ink-2); min-width: 0; }
.crm-card-ct { display: inline-flex; align-items: center; gap: 7px; min-width: 0; }
.crm-next { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-2); min-width: 0; padding-top: 5px; border-top: 1px solid var(--line-2); }
.crm-next svg { width: 14px; height: 14px; flex: none; }
.crm-next .ellip { flex: 0 1 auto; }
.crm-next em { margin-left: auto; font-style: normal; color: var(--ink-3); white-space: nowrap; font-size: 12px; padding-left: 4px; }
.crm-next.bad { color: var(--bad); }
.crm-next.bad em { color: var(--bad); font-weight: 600; }
.crm-next.ok { color: var(--ok); font-weight: 600; }
.crm-next.dim { color: var(--ink-3); }
.crm-card-f { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.crm-age { display: inline-flex; align-items: center; gap: 5px; font: 600 11.5px var(--f-num); color: var(--ink-2); flex: none; }
.crm-age::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.crm-age.warn::before { background: #d89a1d; box-shadow: 0 0 0 3px var(--warn-soft); }
.crm-age.bad::before { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.crm-age.none { display: none; }
.crm-src { font-size: 11.5px; font-weight: 600; background: var(--surface-3); color: var(--ink-2); padding: 1px 9px; border-radius: 999px; min-width: 0; }
.crm-hint { margin: 0; }

.crm-confetti { position: fixed; inset: 0; pointer-events: none; z-index: 120; overflow: hidden; }
.crm-confetti i { position: absolute; top: -14px; left: var(--x); width: 8px; height: 14px; border-radius: 2px; animation: crm-fall var(--d) var(--w) cubic-bezier(.3, .6, .4, 1) both; }
@keyframes crm-fall { to { transform: translate(var(--dx), 105vh) rotate(var(--r)); opacity: .85; } }

/* ---------- source mini card ---------- */
.crm-sm-grid { display: grid; gap: 2px; }
.crm-sm-row { display: grid; grid-template-columns: minmax(120px, 210px) minmax(0, 1fr) 84px 72px; gap: 14px; align-items: center; border: 0; background: transparent; text-align: left; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 14px; min-height: 40px; color: var(--ink); }
.crm-sm-row:hover { background: var(--brand-tint); }
.crm-sm-row.on { background: var(--brand-soft); font-weight: 700; }
.crm-sm-bar { height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.crm-sm-bar i { display: block; height: 100%; background: var(--c2); border-radius: 999px; }
.crm-sm-l { font-size: 12.5px; color: var(--ink-2); text-align: right; }
.crm-sm-w { text-align: right; font-weight: 600; color: var(--ok); font-size: 13px; }

/* ---------- tables ---------- */
.crm-tbl { min-width: 780px; }
.crm-owner { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.crm-t-deal { max-width: 300px; }
.crm-t-next { display: inline-flex; align-items: center; gap: 6px; max-width: 230px; }
.crm-t-next svg { width: 14px; height: 14px; flex: none; color: var(--ink-3); }
.crm-od, .crm-od .xs { color: var(--bad); }
.crm-od .crm-t-next svg { color: var(--bad); }
.crm-age-t { font-weight: 600; }
.crm-age-t.ok { color: var(--ok); } .crm-age-t.warn { color: var(--warn); } .crm-age-t.bad { color: var(--bad); }
.crm-sortic { font-size: 9px; color: var(--brand); }
.crm-tot td { background: var(--surface-2); border-top: 1px solid var(--line); }
.crm-note { max-width: 260px; font-size: 13px; color: var(--ink-2); }
.crm-tbl .btn svg { width: 14px; height: 14px; }

/* ---------- forecast ---------- */
.crm-att { position: relative; padding-top: 28px; }
.crm-att-bar { display: flex; height: 24px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.crm-att-bar i { display: block; height: 100%; transition: width .4s ease; }
.crm-att-line { position: absolute; top: 6px; bottom: -4px; width: 0; border-left: 2px dashed var(--ink); }
.crm-att-line span { position: absolute; top: -8px; right: 6px; font: 600 12px var(--f-num); white-space: nowrap; color: var(--ink); }
.crm-legend { display: flex; gap: 8px 18px; flex-wrap: wrap; margin-top: 12px; font-size: 12.5px; color: var(--ink-2); }
.crm-legend span { display: inline-flex; align-items: center; gap: 6px; }
.crm-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.crm-attrow { display: flex; align-items: center; gap: 8px; }
.crm-attrow .bar { flex: 1; min-width: 70px; }
.crm-fc-deal { color: inherit; text-decoration: none; align-items: center; justify-content: space-between; }
.crm-fc-deal:hover { background: var(--brand-tint); text-decoration: none; }

/* ---------- lost modal ---------- */
.crm-reason { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; cursor: pointer; min-height: 44px; }
.crm-reason input { width: 17px; height: 17px; accent-color: var(--brand); }
.crm-reason:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); font-weight: 600; }

/* ---------- responsive ---------- */
@media (max-width: 1280px) {
  .crm-fn-row { grid-template-columns: 170px minmax(0, 1fr) 260px; }
}
@media (max-width: 1024px) {
  .crm-fn-row { grid-template-columns: 150px minmax(0, 1fr) 220px; }
  .crm-fn-name { font-size: 16px; }
  .crm-fn-stats b { font-size: 14px; }
}
@media (max-width: 640px) {
  .crm-funnel { padding: 16px 12px 14px; }
  .crm-fn-head { margin-bottom: 14px; }
  .crm-fn-title h2 { font-size: 23px; }
  .crm-fn-kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; gap: 6px; }
  .crm-fn-kpi { min-width: 0; padding: 8px 9px; }
  .crm-fn-kpi b { font-size: 24px; }
  .crm-fn-kpi u { font-size: 12px; margin-left: 3px; }
  .crm-fn-kpi span { font-size: 11px; }
  .crm-fn-row { grid-template-columns: 112px minmax(0, 1fr); grid-template-areas: "shape lab" "shape stats"; grid-template-rows: auto auto; align-content: center; height: 80px; row-gap: 4px; padding: 0 6px; gap: 0 12px; }
  .crm-fn-shape { grid-area: shape; }
  .crm-fn-lab { grid-area: lab; align-self: end; }
  .crm-fn-stats { grid-area: stats; align-self: start; text-align: left; gap: 10px; grid-template-columns: repeat(3, auto); justify-content: start; }
  .crm-fn-name { font-size: 16px; }
  .crm-fn-sub { font-size: 12px; }
  .crm-fn-stats b { font-size: 13px; }
  .crm-fn-stats small { font-size: 9.5px; }
  .crm-fn-foot { justify-content: flex-start; }
  .crm-board { scroll-snap-type: x mandatory; scroll-padding: 0 16px; margin: 0 -16px; padding: 2px 16px 12px; gap: 10px; }
  .crm-col { flex: 0 0 85vw; scroll-snap-align: center; max-height: 72vh; }
  .crm-col.sel { flex-basis: 85vw; }
  .crm-col.collapsed { display: none; }
  .crm-sm-row { grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; padding: 8px 4px; min-height: 44px; }
  .crm-sm-bar { display: none; }
  .crm-card { padding: 11px 12px 10px; }
  .crm-kebab { width: 40px; min-height: 40px; margin: -10px -10px -10px 0; }
  .crm-fchip, .crm-stagechip, .crm-lostsw { min-height: 40px; }
  .crm-filters .seg { width: 100%; }
  .crm-filters .seg button { flex: 1; min-height: 40px; }
}
