/* ===========================================================================
   Pinoy VA CRM — components specific to the CRM (crm.pinoy-va.com)
   Loads on top of the shared design system in ../css/styles.css, reusing
   .dash-topbar, .dash-nav, .panel, .stat-card, .tbl, .badge-status, .btn,
   .toast, forms and chips. Only CRM-only pieces live here.
   ======================================================================== */

.crm-tag { font-weight: 700; color: #4f46e5; font-size: 12px; background: #eef0ff; padding: 3px 9px; border-radius: 7px; border: 1px solid #e0e3ff; }

/* ---------- Engagement pills (open / click / download tracking) ---------- */
.eng { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.eng .e { display: inline-flex; align-items: center; gap: 5px; font-family: var(--font-head); font-weight: 700; font-size: 11.5px; padding: 3px 9px; border-radius: 999px; background: var(--bg-soft); color: var(--muted); }
.eng .e svg { width: 12px; height: 12px; }
.eng .e.on.sent     { background: var(--teal-50); color: var(--teal-700); }
.eng .e.on.opened   { background: #eef0ff; color: #4f46e5; }
.eng .e.on.clicked  { background: var(--gold-50); color: var(--gold-600); }
.eng .e.on.download { background: #e9f7f1; color: #0a8f5b; }
.eng .e.on.replied  { background: #fdecf3; color: #c026a3; }

/* ---------- Activity timeline ---------- */
.timeline { position: relative; padding-left: 6px; }
.tl-item { display: flex; gap: 14px; padding: 4px 0 22px; position: relative; }
.tl-item:not(:last-child)::before { content: ""; position: absolute; left: 17px; top: 36px; bottom: -2px; width: 2px; background: var(--line); }
.tl-dot { width: 36px; height: 36px; border-radius: 11px; flex: none; display: grid; place-items: center; z-index: 1; }
.tl-dot.sent { background: var(--teal-50); color: var(--teal-700); }
.tl-dot.opened { background: #eef0ff; color: #4f46e5; }
.tl-dot.clicked { background: var(--gold-50); color: var(--gold-600); }
.tl-dot.download { background: #e9f7f1; color: #0a8f5b; }
.tl-dot.note, .tl-dot.stage { background: var(--bg-soft); color: var(--muted); }
.tl-dot.replied { background: #fdecf3; color: #c026a3; }
.tl-body { flex: 1; min-width: 0; padding-top: 4px; }
.tl-body .tl-title { font-size: 14px; color: var(--ink); }
.tl-body .tl-title b { font-family: var(--font-head); font-weight: 700; }
.tl-body .tl-time { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.tl-body .tl-snippet { font-size: 13px; color: var(--body); background: var(--bg-soft); border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 13px; margin-top: 9px; }

/* ---------- Pipeline kanban ---------- */
.kanban { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 10px; align-items: flex-start; }
.kan-col { flex: 0 0 264px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; max-height: 72vh; }
.kan-col.drag-over { border-color: var(--teal-500); box-shadow: 0 0 0 3px var(--teal-50); }
.kan-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.kan-head .kt { font-family: var(--font-head); font-weight: 700; color: var(--ink); font-size: 14px; display: flex; align-items: center; gap: 8px; }
.kan-head .kt .kdot { width: 8px; height: 8px; border-radius: 50%; }
.kan-head .kcount { font-size: 12px; font-weight: 700; color: var(--muted); background: #fff; border: 1px solid var(--line); padding: 1px 9px; border-radius: 999px; }
.kan-head .kval { font-size: 12px; color: var(--muted); }
.kan-cards { padding: 12px; display: grid; gap: 10px; overflow-y: auto; }
.deal-card { background: #fff; border: 1px solid var(--line); border-radius: 13px; padding: 14px; cursor: grab; box-shadow: var(--shadow-sm); transition: box-shadow .15s, transform .15s; }
.deal-card:hover { box-shadow: var(--shadow); }
.deal-card.dragging { opacity: .5; }
.deal-card .dc-title { font-family: var(--font-head); font-weight: 700; color: var(--ink); font-size: 14px; }
.deal-card .dc-meta { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.deal-card .dc-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; }
.deal-card .dc-val { font-family: var(--font-head); font-weight: 800; color: var(--teal-700); font-size: 15px; }
.deal-card .avatar { width: 26px; height: 26px; }
.deal-card .dc-eng { margin-top: 10px; }

/* ---------- Modal (compose, contact) ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(8,28,27,.5); backdrop-filter: blur(2px); display: none; align-items: flex-start; justify-content: center; padding: 48px 20px; z-index: 200; overflow-y: auto; }
.modal-overlay.show { display: flex; }
.modal { background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 620px; animation: stepIn .28s var(--ease); }
.modal.wide { max-width: 860px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 18px; }
.modal-head .x { width: 34px; height: 34px; border: 0; background: var(--bg-soft); border-radius: 10px; color: var(--muted); display: grid; place-items: center; }
.modal-head .x:hover { background: var(--line-2); color: var(--ink); }
.modal-body { padding: 24px; }
.modal-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 24px; border-top: 1px solid var(--line); background: var(--bg-soft); border-radius: 0 0 var(--radius-lg) var(--radius-lg); flex-wrap: wrap; }
.track-toggles { display: flex; gap: 16px; flex-wrap: wrap; }
.track-toggles label { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--body); font-weight: 600; }
.track-toggles input { accent-color: var(--teal-700); width: 16px; height: 16px; }
.attach-row { display: flex; align-items: center; gap: 11px; padding: 11px 14px; border: 1px dashed var(--line); border-radius: 11px; font-size: 13px; color: var(--muted); }
.attach-row .att-name { color: var(--ink); font-weight: 600; font-family: var(--font-head); }

/* ---------- Contact detail ---------- */
.contact-grid { display: grid; grid-template-columns: 320px 1fr; gap: 24px; align-items: start; }
.contact-card { text-align: center; }
.contact-card .avatar { width: 76px; height: 76px; margin: 0 auto 14px; }
.contact-card h2 { font-size: 20px; }
.contact-card .ccompany { color: var(--muted); font-size: 14px; margin-top: 2px; }
.contact-meta { text-align: left; margin-top: 20px; display: grid; gap: 2px; }
.contact-meta .cm { display: flex; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line-2); font-size: 14px; }
.contact-meta .cm svg { color: var(--muted); flex: none; }
.contact-meta .cm .ck { color: var(--muted); width: 86px; flex: none; }
.contact-meta .cm .cv { color: var(--ink); font-weight: 500; }

/* ---------- Sequence builder ---------- */
.seq-list { display: grid; gap: 14px; }
.seq-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 18px 22px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.seq-row .sr-name { font-family: var(--font-head); font-weight: 700; color: var(--ink); font-size: 16px; }
.seq-row .sr-meta { font-size: 13px; color: var(--muted); margin-top: 3px; }
.switch { position: relative; width: 44px; height: 25px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; background: var(--line); border-radius: 999px; transition: background .2s; cursor: pointer; }
.switch .track::before { content: ""; position: absolute; left: 3px; top: 3px; width: 19px; height: 19px; background: #fff; border-radius: 50%; transition: transform .2s; box-shadow: var(--shadow-sm); }
.switch input:checked + .track { background: var(--teal-600); }
.switch input:checked + .track::before { transform: translateX(19px); }

.seq-steps { display: grid; gap: 0; max-width: 640px; }
.seq-step { display: flex; gap: 16px; position: relative; padding-bottom: 18px; }
.seq-step:not(:last-child)::before { content: ""; position: absolute; left: 19px; top: 40px; bottom: 0; width: 2px; background: var(--line); }
.seq-step .ss-ico { width: 40px; height: 40px; border-radius: 12px; flex: none; display: grid; place-items: center; z-index: 1; }
.seq-step .ss-ico.mail { background: var(--teal-50); color: var(--teal-700); }
.seq-step .ss-ico.wait { background: var(--bg-soft); color: var(--muted); }
.seq-step .ss-ico.cond { background: var(--gold-50); color: var(--gold-600); }
.seq-step .ss-card { flex: 1; background: #fff; border: 1px solid var(--line); border-radius: 13px; padding: 14px 16px; }
.seq-step .ss-title { font-family: var(--font-head); font-weight: 700; color: var(--ink); font-size: 14px; }
.seq-step .ss-desc { font-size: 13px; color: var(--muted); margin-top: 3px; }
.seq-add { display: flex; align-items: center; gap: 10px; color: var(--teal-700); font-family: var(--font-head); font-weight: 600; font-size: 14px; padding: 12px 0; cursor: pointer; }

/* ---------- Funnel / engagement bars (dashboard) ---------- */
.funnel { display: grid; gap: 10px; }
.funnel .fn { display: grid; grid-template-columns: 130px 1fr 56px; align-items: center; gap: 12px; }
.funnel .fl { font-size: 13px; color: var(--body); font-weight: 600; font-family: var(--font-head); }
.funnel .fbar { height: 30px; background: var(--bg-soft); border-radius: 8px; overflow: hidden; }
.funnel .fbar span { display: block; height: 100%; background: linear-gradient(90deg, var(--teal-600), var(--teal-500)); border-radius: 8px; }
.funnel .fv { font-family: var(--font-head); font-weight: 700; color: var(--ink); font-size: 14px; text-align: right; }

/* tiny avatar text helper reuse from dashboards via inline svg */
.muted-link { color: var(--teal-700); font-weight: 600; cursor: pointer; }
.muted-link:hover { text-decoration: underline; }

@media (max-width: 940px) { .contact-grid { grid-template-columns: 1fr; } }
