/* ─── Side Panel CRM — HubSpot-Inspired ──────────────────── */
.panel {
  position: fixed; right: 0; top: 40px; bottom: 0;
  width: 430px;
  max-width: min(430px, 100vw);
  background: var(--bg1); border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
  z-index: 30;
  transform: translateX(100%);
  transition: transform .25s cubic-bezier(.4,0,.2,1);
  box-shadow: -2px 0 16px rgba(0,0,0,.25);
}
.panel.open { transform: translateX(0); }

/* ─── Header ─────────────────────────────────────────────── */
.ptop { padding: 16px 18px 12px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.phd { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.pav {
  width: 56px; height: 56px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700; flex-shrink: 0; overflow: hidden;
  border: 2px solid var(--line2);
}
.pav img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.pnm { font-size: 15px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.3; }
.pkol { font-size: 11px; color: var(--accent); font-weight: 600; margin-bottom: 1px; }
.phd2 { font-family: var(--mono); font-size: 10px; color: var(--text3); margin-top: 1px; }
.pclose {
  background: none; border: none; color: var(--text3); cursor: pointer;
  font-size: 16px; flex-shrink: 0; padding: 4px 6px; border-radius: 6px;
  margin-left: auto; transition: all .15s;
}
.pclose:hover { background: var(--bg3); color: var(--text); }

/* ─── Action Buttons (HubSpot icon-style) ────────────────── */
.pactions { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 10px; }
.paBtn {
  font-size: 10px; padding: 5px 10px; border-radius: 20px;
  cursor: pointer; border: 1px solid var(--line2); background: transparent;
  color: var(--text2); font-family: var(--sans); font-weight: 500;
  text-decoration: none; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 4px; transition: all .15s;
}
.paBtn:hover { border-color: var(--a2); color: var(--a2); background: rgba(59,130,246,.04); text-decoration: none; }
.paBtn.gold { border-color: rgba(232,168,0,.25); color: var(--accent); background: transparent; }
.paBtn.gold:hover { background: rgba(232,168,0,.06); border-color: rgba(232,168,0,.5); }
.paBtn.grn { border-color: rgba(34,197,94,.25); color: var(--green); background: transparent; }
.paBtn.grn:hover { background: rgba(34,197,94,.06); border-color: rgba(34,197,94,.5); }

/* ─── Discard Buttons ────────────────────────────────────── */
.btn-disc {
  font-size: 9px; padding: 4px 8px; border-radius: 6px; cursor: pointer;
  border: 1px solid rgba(239,68,68,.2); background: transparent;
  color: var(--red); font-family: var(--mono); white-space: nowrap; flex-shrink: 0;
  transition: all .15s;
}
.btn-disc:hover { background: rgba(239,68,68,.08); border-color: rgba(239,68,68,.4); }
.btn-disc-del { border-color: rgba(239,68,68,.3); }
.btn-disc-del:hover { background: rgba(239,68,68,.12); }

/* ─── Pipeline Select ────────────────────────────────────── */
.pstsel {
  background: var(--bg2); border: 1px solid var(--line2); border-radius: 6px;
  color: var(--text2); font-family: var(--mono); font-size: 10px;
  padding: 5px 8px; cursor: pointer; outline: none; width: 100%;
  transition: border-color .15s;
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23666'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 22px;
}
.pstsel:focus { border-color: var(--accent); }

/* ─── Tab Bar (HubSpot underline tabs) ───────────────────── */
.ptabs { display: flex; border-bottom: 1px solid var(--line); flex-shrink: 0; padding: 0 18px; gap: 4px; }
.ptab {
  padding: 10px 12px; font-size: 11px; font-weight: 500;
  color: var(--text3); cursor: pointer; text-align: center;
  border-bottom: 2px solid transparent; transition: all .15s;
  background: none;
}
.ptab:hover { color: var(--text2); }
.ptab.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* ─── Body & Sections ────────────────────────────────────── */
.pbody { flex: 1; overflow-y: auto; padding: 16px 18px; }
.psec { margin-bottom: 20px; }
.psectit {
  font-family: var(--mono); font-size: 9px; color: var(--text3);
  letter-spacing: .08em; text-transform: uppercase; font-weight: 600;
  margin-bottom: 8px; padding-bottom: 0; border-bottom: none;
}

/* ─── Property Rows (HubSpot dotted separator) ───────────── */
.prow {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 0; border-bottom: 1px dotted var(--line);
}
.prow:last-child { border-bottom: none; }
.pkey { font-family: var(--mono); font-size: 9px; color: var(--text3); flex-shrink: 0; min-width: 90px; }
.pval { font-size: 11px; color: var(--text); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; }
.pval a { color: var(--a2); text-decoration: none; }
.pval a:hover { text-decoration: underline; }

/* ─── Editable Inputs ────────────────────────────────────── */
.peditable {
  font-size: 11px; color: var(--text); text-align: right;
  background: transparent; border: 1px solid transparent;
  border-radius: 4px; padding: 3px 6px; outline: none;
  font-family: var(--mono); width: 170px; transition: all .15s;
}
.peditable:hover { border-color: var(--line2); }
.peditable:focus { border-color: var(--accent); background: var(--bg2); }

/* ─── Stat Cards (HubSpot metrics grid) ──────────────────── */
.scard-g { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.scard {
  background: var(--bg2); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 8px; text-align: center;
  transition: border-color .15s;
}
.scard:hover { border-color: var(--line2); }
.scv { font-family: var(--mono); font-size: 16px; font-weight: 600; line-height: 1.2; }
.scl { font-family: var(--mono); font-size: 8px; color: var(--text3); text-transform: uppercase; margin-top: 4px; letter-spacing: .04em; }

/* ─── Contact Chips ──────────────────────────────────────── */
.ctgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.ctchip {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 8px; background: var(--bg2); border: 1px solid var(--line);
  border-radius: 8px; text-decoration: none; transition: all .15s;
}
.ctchip:hover { border-color: var(--line2); }
.ctchip.has { border-color: rgba(34,197,94,.2); background: rgba(34,197,94,.02); }
.ctchip.has:hover { border-color: rgba(34,197,94,.4); }
.cticon { font-size: 12px; flex-shrink: 0; }
.cttype { font-family: var(--mono); font-size: 8px; color: var(--text3); }
.ctval { font-size: 9px; color: var(--text2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); }
.ctchip.has .ctval { color: var(--green); }

/* ─── Multi-value Contact Chips ──────────────────────────── */
.ct-vals { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; width: 100%; }
.ct-val-chip {
  display: inline-flex; align-items: center; gap: 3px;
  background: var(--bg3); border: 1px solid var(--line2); border-radius: 4px;
  padding: 3px 6px; max-width: 100%;
  animation: fadeIn .15s ease;
}
.ct-val-link {
  font-family: var(--mono); font-size: 9px; color: var(--a2);
  text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 150px;
}
.ct-val-link:hover { text-decoration: underline; }
.ct-val-del {
  background: none; border: none; color: var(--red); cursor: pointer;
  font-size: 10px; padding: 0 1px; opacity: .3; transition: opacity .15s; line-height: 1;
  flex-shrink: 0;
}
.ct-val-del:hover { opacity: 1; }
.ct-add-row { display: flex; gap: 4px; margin-top: 5px; width: 100%; }
.ct-add-input {
  flex: 1; min-width: 0;
  font-family: var(--mono); font-size: 9px; color: var(--text);
  background: transparent; border: 1px solid var(--line); border-radius: 4px;
  padding: 4px 6px; outline: none; transition: all .15s;
}
.ct-add-input::placeholder { color: var(--text3); }
.ct-add-input:focus { border-color: var(--accent); background: var(--bg2); }
.ct-add-btn {
  background: transparent; border: 1px solid var(--line); border-radius: 4px;
  color: var(--green); cursor: pointer; font-size: 11px; font-weight: 600;
  padding: 3px 8px; flex-shrink: 0; transition: all .15s;
}
.ct-add-btn:hover { border-color: rgba(34,197,94,.4); background: rgba(34,197,94,.06); }

/* ─── Videos ─────────────────────────────────────────────── */
.vtitem { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.vtitem:last-child { border-bottom: none; }
.vtthumb { width: 72px; height: 40px; border-radius: 6px; background: var(--bg3); object-fit: cover; flex-shrink: 0; }
.vtph { width: 72px; height: 40px; border-radius: 6px; background: var(--bg3); flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 14px; color: var(--text3); }
.vttit { font-size: 11px; font-weight: 500; color: var(--text); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.4; margin-bottom: 3px; text-decoration: none; }
.vttit:hover { color: var(--a2); }
.vtst { font-family: var(--mono); font-size: 9px; color: var(--text3); }
.vtst.hi { color: var(--text2); }
.lbdg { font-family: var(--mono); font-size: 7px; padding: 1px 5px; border-radius: 10px; background: rgba(239,68,68,.08); color: var(--red); border: 1px solid rgba(239,68,68,.15); }

/* ─── CRM Notes ──────────────────────────────────────────── */
.notesA {
  width: 100%; background: var(--bg2); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 12px; color: var(--text);
  font-family: var(--mono); font-size: 11px; resize: none; outline: none;
  min-height: 90px; line-height: 1.7; transition: border-color .15s;
}
.notesA:focus { border-color: var(--accent); }
.notesSave {
  font-size: 10px; padding: 4px 12px; border-radius: 6px;
  border: 1px solid rgba(34,197,94,.2); background: transparent;
  color: var(--green); cursor: pointer; font-family: var(--mono);
  transition: all .15s;
}
.notesSave:hover { background: rgba(34,197,94,.08); border-color: rgba(34,197,94,.4); }
.notesSaved { color: var(--green); font-family: var(--mono); font-size: 9px; margin-left: 5px; }

/* ─── Contact Log ────────────────────────────────────────── */
.clog-item {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; background: var(--bg2); border: 1px solid var(--line);
  border-radius: 8px; margin-bottom: 4px;
  animation: fadeIn .15s ease;
}
.clog-st { font-family: var(--mono); font-size: 9px; padding: 2px 6px; border-radius: 10px; font-weight: 500; }
.clog-st.sent { background: rgba(59,130,246,.06); color: var(--a2); border: 1px solid rgba(59,130,246,.15); }
.clog-st.replied { background: rgba(34,197,94,.06); color: var(--green); border: 1px solid rgba(34,197,94,.15); }
.clog-st.no-reply { background: rgba(239,68,68,.06); color: var(--red); border: 1px solid rgba(239,68,68,.15); }
.log-form { background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-top: 8px; }
.log-sel {
  background: var(--bg2); border: 1px solid var(--line2); border-radius: 6px;
  color: var(--text2); font-family: var(--mono); font-size: 10px;
  padding: 4px 6px; cursor: pointer; outline: none; flex: 1;
  transition: border-color .15s;
}
.log-sel:focus { border-color: var(--accent); }
.log-btn {
  font-size: 10px; padding: 4px 10px; border-radius: 6px;
  border: 1px solid rgba(59,130,246,.2); background: transparent;
  color: var(--a2); cursor: pointer; font-family: var(--mono); white-space: nowrap;
  transition: all .15s;
}
.log-btn:hover { background: rgba(59,130,246,.06); border-color: rgba(59,130,246,.4); }

/* ─── AI Score Bar ───────────────────────────────────────── */
.ai-bar-wrap { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; height: 6px; margin-bottom: 8px; overflow: hidden; }
.ai-bar-fill { height: 100%; border-radius: 10px; transition: width .4s ease; }
.ai-desc { font-size: 10px; color: var(--text3); font-family: var(--mono); }

/* ─── Responsive Panel ───────────────────────────────────── */
@media (max-width: 900px) {
  .panel { width: 100%; top: 40px; }
}
@media (max-width: 600px) {
  .panel { top: 40px; }
  .ptop { padding: 12px 14px 10px; }
  .pbody { padding: 12px 14px; }
  .scard-g { grid-template-columns: 1fr 1fr; }
  .ctgrid { grid-template-columns: 1fr; }
  .ptabs { padding: 0 14px; }
}

/* ─── CRM Pipeline Timeline (stepper style) ──────────────── */
.crm-timeline { padding-left: 0; display: flex; flex-direction: column; gap: 0; }
.crm-tl-step { display: flex; align-items: center; gap: 10px; margin-bottom: 0; position: relative; padding: 7px 0; }
.crm-tl-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; z-index: 1; margin-left: 3px; transition: all .2s; }
.crm-tl-line { position: absolute; left: 7px; top: 17px; bottom: -7px; width: 2px; z-index: 0; }
.crm-tl-step:last-child .crm-tl-line { display: none; }
.crm-tl-label { font-size: 11px; flex: 1; }
.crm-tl-step.current .crm-tl-label { font-weight: 700; color: var(--text); }
.crm-tl-step.past .crm-tl-label { color: var(--green); }
.crm-tl-step.future .crm-tl-label { color: var(--text3); opacity: .6; }
.crm-tl-badge { font-family: var(--mono); font-size: 8px; padding: 2px 8px; border-radius: 10px; background: rgba(240,180,41,.1); color: var(--accent); font-weight: 600; }

/* ─── Contact Log Timeline ───────────────────────────────── */
.clog-timeline { padding-left: 6px; margin-bottom: 10px; }
.clog-timeline .clog-item { display: flex; align-items: center; gap: 8px; position: relative; padding: 6px 0 6px 18px; background: none; border: none; border-radius: 0; margin-bottom: 0; }
.clog-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; position: absolute; left: 0; z-index: 1; }
.clog-line { position: absolute; left: 3px; top: 14px; bottom: -6px; width: 2px; background: var(--line); z-index: 0; }
.clog-timeline .clog-item:last-child .clog-line { display: none; }
.clog-content { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; }

/* ─── Tags (colored dot + text style) ────────────────────── */
.crm-tags-wrap { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 6px; }
.crm-tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--mono); font-size: 10px; padding: 3px 10px;
  border-radius: 12px; border: 1px solid; font-weight: 500;
  background: transparent !important;
}
.crm-tag::before {
  content: ''; display: inline-block; width: 6px; height: 6px;
  border-radius: 50%; background: currentColor; flex-shrink: 0;
}
.crm-tag-del { background: none; border: none; color: inherit; cursor: pointer; font-size: 10px; padding: 0 2px; opacity: .4; transition: opacity .15s; }
.crm-tag-del:hover { opacity: 1; }
.crm-tag-add {
  background: transparent; border: 1px dashed var(--line2); border-radius: 12px;
  color: var(--text3); font-size: 10px; padding: 3px 10px; cursor: pointer;
  font-family: var(--mono); transition: all .15s;
}
.crm-tag-add:hover { border-color: var(--accent); color: var(--accent); }

/* ─── Tag Picker Dropdown ────────────────────────────────── */
.tag-picker-drop { background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin-top: 6px; max-height: 220px; overflow-y: auto; box-shadow: 0 4px 12px rgba(0,0,0,.15); }
.tag-picker-list { margin-bottom: 8px; }
.tag-picker-item { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 6px; font-size: 11px; cursor: pointer; transition: background .15s; color: var(--text2); }
.tag-picker-item:hover { background: var(--bg3); }
.tag-picker-item.active { background: rgba(240,180,41,.06); }
.tag-picker-check { width: 14px; font-size: 10px; color: var(--green); }
.tag-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.tag-picker-new { display: flex; align-items: center; gap: 4px; padding-top: 8px; border-top: 1px solid var(--line); }
.tag-picker-input { flex: 1; background: var(--bg2); border: 1px solid var(--line2); border-radius: 4px; padding: 4px 8px; font-size: 10px; color: var(--text); outline: none; font-family: var(--mono); }
.tag-color-row { display: flex; gap: 4px; }
.tag-color-dot { width: 14px; height: 14px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; transition: border-color .15s; }
.tag-color-dot.sel { border-color: var(--text); }
.tag-color-dot:hover { border-color: var(--text3); }

/* ─── Saved Searches ─────────────────────────────────────── */
.saved-search-item { display: flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 6px; transition: background .15s; cursor: pointer; margin-bottom: 2px; }
.saved-search-item:hover { background: var(--bg3); }
.saved-search-info { flex: 1; min-width: 0; }
.saved-search-name { font-size: 11px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.saved-search-kws { font-family: var(--mono); font-size: 9px; color: var(--text3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.saved-search-del { background: none; border: none; color: var(--red); cursor: pointer; font-size: 11px; padding: 0 2px; opacity: .4; transition: opacity .15s; flex-shrink: 0; }
.saved-search-del:hover { opacity: 1; }

/* ─── AI Factors ─────────────────────────────────────────── */
.ai-factors { padding: 8px 10px; background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; }

/* ─── Email Compose Modal ────────────────────────────────── */
.email-field-row { display: flex; align-items: flex-start; gap: 8px; padding: 8px 16px; border-bottom: 1px solid var(--line); }
.email-field-label { font-family: var(--mono); font-size: 9px; font-weight: 600; color: var(--text3); min-width: 55px; padding-top: 4px; text-transform: uppercase; letter-spacing: .5px; }
.email-field-value { flex: 1; min-width: 0; }
.email-sender-badge { font-family: var(--mono); font-size: 10px; padding: 3px 8px; border-radius: 4px; }
.email-sender-badge.connected { background: rgba(34,197,94,.08); border: 1px solid rgba(34,197,94,.2); color: var(--green); }
.email-sender-badge.disconnected { background: rgba(239,68,68,.08); border: 1px solid rgba(239,68,68,.2); color: var(--red); }
.email-recipient-card { background: var(--bg2); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; }
.email-recipient-name { font-size: 12px; font-weight: 600; color: var(--text); }
.email-recipient-detail { font-family: var(--mono); font-size: 9px; color: var(--text3); margin-top: 2px; }
.email-recipient-email { font-family: var(--mono); font-size: 10px; color: var(--green); margin-top: 3px; }
.email-recipients-list { display: flex; flex-wrap: wrap; gap: 4px; max-height: 80px; overflow-y: auto; }
.email-recipient-chip { display: flex; flex-direction: column; gap: 1px; padding: 4px 8px; background: var(--bg2); border: 1px solid var(--line); border-radius: 6px; }
.email-chip-name { font-size: 9px; font-weight: 600; color: var(--text); white-space: nowrap; }
.email-chip-email { font-family: var(--mono); font-size: 8px; color: var(--green); }
.email-tpl-btn { background: var(--bg3); border: 1px solid var(--line2); border-radius: 4px; padding: 2px 6px; font-size: 10px; cursor: pointer; transition: border-color .15s; }
.email-tpl-btn:hover { border-color: var(--accent); }
.email-compose-input { width: 100%; padding: 8px 10px; background: var(--bg2); border: 1px solid var(--line2); border-radius: 6px; color: var(--text); outline: none; box-sizing: border-box; font-family: inherit; transition: border-color .15s; }
.email-compose-input:focus { border-color: var(--accent); }
.email-compose-textarea { width: 100%; padding: 8px 10px; background: var(--bg2); border: 1px solid var(--line2); border-radius: 6px; color: var(--text); font-size: 11px; outline: none; resize: vertical; font-family: var(--mono); box-sizing: border-box; line-height: 1.6; transition: border-color .15s; }
.email-compose-textarea:focus { border-color: var(--accent); }
.email-preview-btn { background: var(--bg3); border: 1px solid var(--line2); border-radius: 4px; padding: 3px 8px; font-size: 9px; color: var(--text2); cursor: pointer; transition: all .15s; }
.email-preview-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Send button in contact card */
.ct-send-btn { background: transparent; border: 1px solid rgba(34,197,94,.2); border-radius: 4px; color: var(--green); font-size: 8px; font-family: var(--mono); padding: 1px 6px; cursor: pointer; transition: all .15s; margin-left: 4px; }
.ct-send-btn:hover { background: rgba(34,197,94,.08); border-color: rgba(34,197,94,.4); }

/* ═══════════════════════════════════════════════════════════
   CRM TAB — HubSpot-Inspired Design
   ═══════════════════════════════════════════════════════════ */

/* ─── CRM Cards (shared wrapper) ────────────────────────── */
.crm-card {
  background: var(--bg2);
  border: 1px solid var(--line2);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 16px;
  transition: border-color .2s, box-shadow .2s;
  box-shadow: 0 1px 4px rgba(0,0,0,.15);
}
.crm-card:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(0,0,0,.2); }

.crm-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.crm-card-title {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* ─── Deal Overview Card ────────────────────────────────── */
.crm-deal-card {
  background: var(--bg2);
  border: 1px solid var(--line2);
  border-top: 3px solid var(--accent);
  border-radius: 10px;
  padding: 20px 18px 16px;
  margin-bottom: 16px;
  box-shadow: 0 2px 10px rgba(0,0,0,.2), 0 0 0 1px rgba(240,180,41,.06);
}

.crm-deal-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 2px;
  margin-bottom: 16px;
  background: var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.crm-deal-metric {
  text-align: center;
  position: relative;
  background: var(--bg2);
  padding: 10px 6px;
}
.crm-deal-metric-val {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.2;
  margin-bottom: 3px;
}
.crm-deal-metric:nth-child(2) .crm-deal-metric-val { color: var(--green); }
.crm-deal-metric:nth-child(3) .crm-deal-metric-val { color: var(--a2); }
.crm-deal-metric-lbl {
  font-family: var(--sans);
  font-size: 8px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 6px;
  font-weight: 600;
}
.crm-deal-metric-input {
  width: 100%;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text);
  text-align: center;
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 6px;
  outline: none;
  transition: border-color .15s;
  box-sizing: border-box;
}
.crm-deal-metric-input:focus { border-color: var(--accent); background: var(--bg2); }

.crm-vol-btn {
  background: var(--bg3);
  border: 1px solid var(--line2);
  border-radius: 4px;
  color: var(--text2);
  font-size: 11px;
  font-weight: 700;
  width: 22px;
  height: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
  flex-shrink: 0;
}
.crm-vol-btn:hover { border-color: var(--accent); color: var(--accent); }

.crm-deal-commission {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--green);
  padding: 10px 12px;
  margin-bottom: 12px;
  background: rgba(34,197,94,.04);
  border: 1px solid rgba(34,197,94,.15);
  border-radius: 6px;
  text-align: center;
}
.crm-deal-commission strong { font-weight: 700; font-size: 13px; }

/* ─── Horizontal Stage Progress Bar ─────────────────────── */
.crm-stage-bar {
  display: flex;
  gap: 3px;
  margin-bottom: 10px;
  height: 10px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg1);
  padding: 2px;
  border: 1px solid var(--line);
}
.crm-stage-segment {
  flex: 1;
  height: 100%;
  background: rgba(255,255,255,.06);
  border-radius: 4px;
  transition: all .25s ease;
  cursor: pointer;
  position: relative;
}
.crm-stage-segment.filled {
  background: var(--seg-color);
  opacity: .8;
}
.crm-stage-segment.filled.current {
  opacity: 1;
  box-shadow: 0 0 8px color-mix(in srgb, var(--seg-color) 60%, transparent);
}
.crm-stage-segment:hover {
  transform: scaleY(1.6);
  opacity: 1;
}
/* Tooltip on hover */
.crm-stage-segment::after {
  content: attr(title);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg1);
  border: 1px solid var(--line2);
  border-radius: 4px;
  padding: 3px 8px;
  font-family: var(--mono);
  font-size: 8px;
  color: var(--text2);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s;
  z-index: 10;
}
.crm-stage-segment:hover::after { opacity: 1; }

.crm-stage-label {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  color: var(--text);
  letter-spacing: .02em;
}

/* ─── Exchange Pills ────────────────────────────────────── */
.crm-exchange-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.crm-exchange-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg1);
  border: 1px solid var(--line2);
  border-radius: 8px;
  padding: 8px 12px;
  transition: all .15s;
  box-shadow: 0 1px 3px rgba(0,0,0,.1);
}
.crm-exchange-pill:hover { border-color: var(--accent); background: rgba(240,180,41,.03); box-shadow: 0 2px 6px rgba(0,0,0,.15); }
.crm-exchange-pill.legacy { opacity: .5; border-style: dashed; }
.crm-ex-input {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text);
  background: transparent;
  border: none;
  outline: none;
  width: 80px;
  padding: 0;
  transition: color .15s;
}
.crm-ex-input:focus { color: var(--accent); }
.crm-ex-pct {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--accent);
  font-weight: 600;
  background: transparent;
  border: none;
  outline: none;
  width: 30px;
  text-align: right;
  padding: 0;
}
.crm-ex-pct-sign {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--text3);
  margin-right: 2px;
}
.crm-ex-del {
  background: none;
  border: none;
  color: var(--red);
  cursor: pointer;
  font-size: 10px;
  padding: 0 2px;
  opacity: .4;
  transition: opacity .15s;
}
.crm-ex-name-static {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text2);
}
.crm-ex-badge {
  font-family: var(--mono);
  font-size: 7px;
  color: var(--accent);
  background: rgba(240,180,41,.08);
  padding: 1px 6px;
  border-radius: 8px;
  font-weight: 600;
  text-transform: uppercase;
}

.crm-add-btn {
  font-family: var(--mono);
  font-size: 9px;
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px dashed var(--line2);
  background: transparent;
  color: var(--text3);
  cursor: pointer;
  transition: all .15s;
  width: 100%;
}
.crm-add-btn:hover { border-color: var(--accent); color: var(--accent); border-style: solid; }

/* ─── Activity Timeline ─────────────────────────────────── */
.crm-activity-group { margin-bottom: 12px; }
.crm-activity-group:last-of-type { margin-bottom: 0; }

.crm-activity-date {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 4px 0 6px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
}

.crm-activity-entry {
  background: var(--bg1);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  padding: 10px 12px;
  margin-bottom: 6px;
  transition: all .15s;
}
.crm-activity-entry:hover { border-color: var(--line2); border-left-color: var(--accent); background: var(--bg2); }
.crm-activity-entry:last-child { margin-bottom: 0; }
.crm-activity-entry[data-status="replied"] { border-left-color: var(--green); }
.crm-activity-entry[data-status="sent"] { border-left-color: var(--accent); }
.crm-activity-entry[data-status="no-reply"] { border-left-color: var(--red); }

.crm-activity-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.crm-activity-icon { font-size: 14px; flex-shrink: 0; }
.crm-activity-channel {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text2);
  font-weight: 500;
  text-transform: capitalize;
}
.crm-activity-time {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--text3);
  margin-left: auto;
}
.crm-activity-del {
  background: none;
  border: none;
  color: var(--red);
  cursor: pointer;
  font-size: 10px;
  padding: 0 2px;
  opacity: .3;
  transition: opacity .15s;
}

/* Activity message content (expandable) */
.crm-activity-message {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dotted var(--line);
  cursor: pointer;
  max-height: 40px;
  overflow: hidden;
  transition: max-height .25s ease;
  position: relative;
}
.crm-activity-message::after {
  content: 'ver m\00e1s...';
  position: absolute;
  bottom: 0;
  right: 0;
  font-family: var(--mono);
  font-size: 8px;
  color: var(--accent);
  background: linear-gradient(to left, var(--bg1) 60%, transparent);
  padding: 2px 0 2px 20px;
}
.crm-activity-message.expanded {
  max-height: 400px;
}
.crm-activity-message.expanded::after { display: none; }

.crm-activity-subject {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.crm-activity-body {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--text3);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.crm-empty-state {
  font-family: var(--sans);
  font-size: 11px;
  color: var(--text3);
  text-align: center;
  padding: 24px 12px;
  background: var(--bg1);
  border: 1px dashed var(--line2);
  border-radius: 8px;
}

/* ─── Log Form (inside activity card) ───────────────────── */
.crm-log-form {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg1);
}
.crm-log-form-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.crm-log-form-label {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 600;
}
.crm-log-form-row {
  display: flex;
  gap: 6px;
}
.crm-action-btn {
  font-size: 10px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid;
  background: transparent;
  cursor: pointer;
  font-family: var(--mono);
  white-space: nowrap;
  transition: all .15s;
  font-weight: 500;
}
.crm-action-btn.blue { border-color: rgba(59,130,246,.25); color: var(--a2); }
.crm-action-btn.blue:hover { background: rgba(59,130,246,.06); border-color: rgba(59,130,246,.5); }
.crm-action-btn.green { border-color: rgba(34,197,94,.25); color: var(--green); }
.crm-action-btn.green:hover { background: rgba(34,197,94,.06); border-color: rgba(34,197,94,.5); }

/* ─── Notes footer ──────────────────────────────────────── */
.crm-notes-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}
.crm-autosave-badge {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--green);
  background: rgba(34,197,94,.06);
  border: 1px solid rgba(34,197,94,.15);
  padding: 2px 8px;
  border-radius: 10px;
}

/* ─── Campaign section ──────────────────────────────────── */
.crm-campaign-section { padding: 0; }
.crm-campaign-row {
  display: flex;
  gap: 10px;
}
.crm-campaign-field { flex: 1; }
.crm-field-label {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 5px;
  font-weight: 500;
}
.crm-camp-input {
  width: 100%;
  text-align: left;
  background: var(--bg1);
  border-color: var(--line);
}

/* ─── Responsive overrides for CRM cards ────────────────── */
@media (max-width: 380px) {
  .crm-deal-metrics { grid-template-columns: 1fr; gap: 8px; }
  .crm-deal-metric-val { font-size: 16px; }
  .crm-exchange-grid { flex-direction: column; }
  .crm-campaign-row { flex-direction: column; gap: 8px; }
}

/* ─── Channel Audit card ────────────────────────────────── */
.aud-bar-wrap {
  background: var(--bg3); border-radius: var(--radius);
  height: 6px; overflow: hidden; margin-bottom: 4px;
}
.aud-bar-fill { height: 100%; border-radius: var(--radius); transition: width .6s ease; }
.aud-verdict {
  font-family: var(--mono); font-size: 9px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .1em; margin-bottom: 12px;
}
.aud-grid {
  display: grid; grid-template-columns: 1fr; gap: 10px;
  padding: 10px; background: var(--bg2); border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}
.aud-group-title {
  font-family: var(--mono); font-size: 8px; color: var(--text3);
  text-transform: uppercase; letter-spacing: .12em; font-weight: 600;
  margin-bottom: 6px; padding-bottom: 4px; border-bottom: 1px solid var(--line);
}
.aud-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 10px; padding: 3px 0; line-height: 1.3;
}
.aud-mark {
  font-family: var(--mono); font-weight: 700; font-size: 11px;
  width: 14px; text-align: center; flex-shrink: 0;
}
.aud-label { flex: 1; color: var(--text2); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aud-detail {
  font-family: var(--mono); font-size: 9px; color: var(--text3);
  flex-shrink: 0; max-width: 140px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.aud-vid-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 2px;
}
.aud-vid {
  display: flex; flex-direction: column; gap: 4px;
  padding: 6px; background: var(--bg2); border: 1px solid var(--line);
  border-radius: var(--radius); text-decoration: none;
  transition: var(--transition); min-width: 0;
}
.aud-vid:hover { border-color: var(--accent); background: var(--bg3); }
.aud-vid-thumb {
  width: 100%; aspect-ratio: 16 / 9; object-fit: cover;
  border-radius: 4px; background: var(--bg3);
}
.aud-vid-thumb-empty {
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: var(--text3);
}
.aud-vid-title {
  font-size: 9px; color: var(--text); line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; min-height: 2.7em;
}
.aud-vid-meta {
  display: flex; gap: 6px;
  font-family: var(--mono); font-size: 8px; color: var(--text3);
}
.aud-vid-meta span { white-space: nowrap; }

/* ─── Call Meeting collapsible section ────────────────── */
.mt-section {
  margin-top: 14px; border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--bg1); overflow: hidden;
}
.mt-toggle {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; cursor: pointer; user-select: none;
  font-size: 12px; font-weight: 600; color: var(--text);
  transition: background .15s;
}
.mt-toggle:hover { background: var(--bg2); }
.mt-subtle { font-family: var(--mono); font-size: 9px; color: var(--text3); font-weight: 400; }
.mt-arrow { font-size: 10px; color: var(--text3); }
.mt-body { padding: 12px 14px; border-top: 1px solid var(--line); background: var(--bg2); }
.mt-body.hidden { display: none; }

.mt-loading { font-family: var(--mono); font-size: 10px; color: var(--text3); padding: 20px; text-align: center; }
.mt-field { margin-bottom: 12px; }
.mt-label {
  display: block; font-family: var(--mono); font-size: 9px; font-weight: 600;
  color: var(--text2); text-transform: uppercase; letter-spacing: .1em;
  margin-bottom: 5px;
}
.mt-hint { font-size: 8px; color: var(--text3); font-weight: 400; text-transform: none; letter-spacing: 0; margin-left: 6px; }
.mt-input, .mt-textarea {
  width: 100%; box-sizing: border-box;
  background: var(--bg1); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--text); font-family: inherit; font-size: 11px; padding: 7px 10px;
  outline: none; transition: border-color .15s;
}
.mt-input:focus, .mt-textarea:focus { border-color: var(--accent); }
.mt-textarea { resize: vertical; min-height: 60px; font-family: var(--mono); font-size: 10px; line-height: 1.5; }

.mt-files-grid {
  display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px;
}
.mt-file-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 4px 4px 8px; background: var(--bg1); border: 1px solid var(--line);
  border-radius: 14px; font-family: var(--mono); font-size: 10px; max-width: 240px;
}
.mt-file-icon { font-size: 12px; flex-shrink: 0; }
.mt-file-name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 120px;
  color: var(--a2); text-decoration: none; cursor: pointer;
}
.mt-file-name:hover { color: var(--accent); text-decoration: underline; }
.mt-file-size { color: var(--text3); font-size: 9px; flex-shrink: 0; }
.mt-file-del {
  background: transparent; border: none; color: var(--text3); cursor: pointer;
  font-size: 13px; line-height: 1; padding: 2px 6px; border-radius: 50%;
  transition: var(--transition);
}
.mt-file-del:hover { background: rgba(239,68,68,.15); color: var(--red); }

.mt-btn-row { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.mt-btn-primary, .mt-btn-secondary {
  font-family: var(--mono); font-size: 10px; padding: 6px 12px; border-radius: var(--radius);
  cursor: pointer; transition: var(--transition); border: 1px solid var(--line2);
  display: inline-flex; align-items: center; gap: 4px;
}
.mt-btn-primary {
  background: rgba(168,85,247,.1); border-color: rgba(168,85,247,.4); color: var(--purple, #a855f7);
  font-weight: 600;
}
.mt-btn-primary:hover:not(:disabled) { background: rgba(168,85,247,.2); }
.mt-btn-primary:disabled { opacity: .6; cursor: not-allowed; }
.mt-btn-secondary {
  background: transparent; color: var(--text2);
}
.mt-btn-secondary:hover { background: var(--bg3); color: var(--text); border-color: var(--accent); }

/* Analysis output */
.mt-analysis {
  margin-top: 12px; padding: 12px; background: var(--bg1);
  border: 1px solid rgba(168,85,247,.25); border-radius: var(--radius-lg);
}
.mt-analysis.hidden { display: none; }
.mt-analysis-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px dashed var(--line);
}
.mt-analysis-title { font-size: 11px; font-weight: 700; color: var(--text); }
.mt-sentiment { font-family: var(--mono); font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; }
.mt-tldr {
  font-size: 11px; color: var(--text); line-height: 1.5;
  padding: 8px 10px; background: var(--bg2); border-left: 2px solid var(--purple, #a855f7);
  border-radius: 0 var(--radius) var(--radius) 0; margin-bottom: 10px;
}
.mt-nextstep {
  font-size: 10px; color: var(--text2); line-height: 1.5;
  padding: 6px 10px; background: rgba(240,180,41,.06);
  border-radius: var(--radius); margin-bottom: 12px;
  font-family: var(--mono);
}
.mt-nextstep b { color: var(--accent); }
.mt-subsect {
  font-family: var(--mono); font-size: 8px; color: var(--text3);
  text-transform: uppercase; letter-spacing: .12em; font-weight: 600;
  margin: 10px 0 4px;
}
.mt-list { list-style: none; padding: 0; margin: 0; }
.mt-list li {
  font-size: 10px; color: var(--text2); line-height: 1.6;
  padding: 3px 0 3px 14px; position: relative;
}
.mt-list li::before {
  content: '›'; position: absolute; left: 0; color: var(--text3);
}
.mt-empty { font-family: var(--mono); font-size: 9px; color: var(--text3); padding: 4px 0; }
.mt-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 6px; }
.mt-kv {
  font-size: 10px; color: var(--text); padding: 2px 0; line-height: 1.5;
}
.mt-kv span {
  color: var(--text3); font-family: var(--mono); font-size: 9px;
  margin-right: 6px;
}

/* ─── Compliance audit controls — layout vertical limpio ────────
   El side panel es estrecho (~880px max) y meter 4 cols en 1 fila
   aplastaba el campo "Exchange domain" hasta dejarlo invisible. Mejor
   2 filas: From+To arriba (50/50), Domain en su propia fila full-width,
   y el botón Analizar al final, también full-width. Garantiza que cada
   label se lea horizontalmente y que cada input tenga ancho suficiente. */
.audit-controls {
  display: grid !important;
  grid-template-columns: 1fr 1fr !important;
  gap: 8px !important;
}
.audit-controls .audit-field-from { grid-column: 1; }
.audit-controls .audit-field-to   { grid-column: 2; }
.audit-controls .audit-field-dom  { grid-column: 1 / -1; }
.audit-controls .audit-field-btn  { grid-column: 1 / -1; width: 100%; padding: 10px 14px; font-size: 13px; }
.audit-controls label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.audit-controls input {
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}
