/* pages/leads.css */
/* ---------- Leads (Plan 4 phase C) ---------- */
.leads-mini-metrics { display: grid; grid-template-columns: repeat(4, minmax(80px, 1fr)); gap: var(--space-8); }
@media (max-width: 640px) {
  .leads-mini-metrics { grid-template-columns: repeat(2, 1fr); }
}
.lmm-card {
  display: flex; flex-direction: column; gap: var(--space-4);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--text-muted);
  border-radius: var(--radius-6);
  padding: var(--space-6) var(--space-10);
}
.lmm-card--ok      { border-left-color: var(--ok); }
.lmm-card--info    { border-left-color: var(--accent); }
.lmm-card--warn    { border-left-color: var(--warn); }
.lmm-card--danger  { border-left-color: var(--danger); }
.lmm-label { font-size: var(--fs-label); color: var(--text-muted); font-weight: var(--fw-bold); text-transform: uppercase; letter-spacing: 0.5px; }
.lmm-value { font-size: var(--fs-section); color: var(--text-primary); font-family: var(--font-mono); font-weight: var(--fw-bold); }

.leads-list-container { min-height: 200px; }

.soft-refresh-bar {
  display: flex; align-items: center; justify-content: center; gap: var(--space-8);
  width: 100%;
  padding: var(--space-8) var(--space-16);
  background: var(--accent-soft-bg);
  color: var(--accent-soft-text);
  border: 0;
  border-bottom: 1px solid var(--border-subtle);
  appearance: none;
  font-family: inherit;
  font-size: var(--fs-small);
  font-weight: var(--fw-medium);
  cursor: pointer;
}
.soft-refresh-bar:hover { background: var(--accent); color: #fff; }

/* ---------- Leads C.3 + C.4 + C.5 (Plan 4) ---------- */

/* C.4 — Export split button + dropdown menu */
.split-btn { position: relative; display: inline-flex; align-items: center; }
.split-btn > .btn { border-radius: var(--radius-6) 0 0 var(--radius-6); }
.split-btn__more { min-width: var(--touch-target); padding: 0 var(--space-8); border-radius: 0 var(--radius-6) var(--radius-6) 0; border-left: 1px solid rgba(255,255,255,0.20); }
/* Container shell (position/bg/border/radius/shadow/padding/z-index) now
   comes from the shared .overlay--popover core (css/overlay.css). Only the
   content width is worth keeping bespoke — see the .overlay--popover.dd-menu
   keeper below. */
.dd-menu__item {
  display: flex; flex-direction: column; gap: var(--space-4);
  background: transparent; border: 0; cursor: pointer; text-align: left;
  padding: var(--space-8) var(--space-12); border-radius: var(--radius-6);
  color: var(--text-primary);
  font-size: var(--fs-secondary);
  width: 100%;
}
.dd-menu__item:hover { background: var(--bg-elevated); }
.dd-menu__item small { color: var(--text-muted); font-size: var(--fs-label); }
.dd-menu__sep { border: 0; border-top: 1px solid var(--border-subtle); margin: var(--space-4) 0; }
/* Width keeper: specificity 0,2,0 beats the core .overlay--popover{min-width:200px}
   (0,1,0) regardless of file/load order. dd-menu's export labels need ~220px. */
.overlay--popover.dd-menu { min-width: 220px; }

/* C.3 — Lead detail slide-in panel */
.lead-panel { display: grid; gap: var(--space-16); }
.lead-panel__meta { display: flex; flex-wrap: wrap; gap: var(--space-8); align-items: center; }
.lead-panel__section { background: var(--bg-elevated); border: 1px solid var(--border-subtle); border-radius: var(--radius-6); padding: var(--space-12); }
.lead-panel__section h4 { margin: 0 0 var(--space-8); font-size: var(--fs-secondary); font-weight: var(--fw-bold); color: var(--text-primary); }
.lead-panel__field { display: grid; grid-template-columns: 100px 1fr; gap: var(--space-8); align-items: center; padding: var(--space-4) 0; font-size: var(--fs-small); }
.lead-panel__field .caps { color: var(--text-muted); font-size: var(--fs-label); text-transform: uppercase; letter-spacing: 0.5px; font-weight: var(--fw-bold); }
.lead-panel__field strong { color: var(--text-primary); font-family: var(--font-mono); }
.lead-panel__timeline { display: grid; gap: var(--space-4); }
.lead-panel__timeline-row { display: grid; grid-template-columns: 56px 1fr; gap: var(--space-8); font-size: var(--fs-small); color: var(--text-secondary); padding: var(--space-4) 0; }
.lead-panel__timeline-row time { color: var(--text-muted); font-family: var(--font-mono); }
.lead-panel__footer { display: flex; gap: var(--space-8); }
.copy-btn { background: transparent; border: 0; color: var(--accent-soft-text); cursor: pointer; padding: var(--space-4) var(--space-6); font-size: var(--fs-label); }
.copy-btn:hover { color: var(--accent); }

/* Desktop right-click menu and manual offer routing. */
.leads-context-hint {
  display: flex; align-items: center; gap: var(--space-6);
  margin: 0; padding: var(--space-8) var(--space-12);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-muted); font-size: var(--fs-label);
}
#leads-list tr.is-context-target { background: var(--accent-soft-bg); }
.lead-context-anchor { position: fixed; width: 1px; height: 1px; pointer-events: none; }
.overlay--popover.lead-context-popover { min-width: 268px; padding: var(--space-6); }
.lead-context-menu { display: grid; gap: var(--space-4); }
.lead-context-menu__lead { display: grid; gap: var(--space-4); padding: var(--space-8) var(--space-10) var(--space-10); }
.lead-context-menu__lead strong { color: var(--text-primary); font-size: var(--fs-small); }
.lead-context-menu__lead small { color: var(--text-muted); font-family: var(--font-mono); }
.lead-context-menu__item {
  display: flex; align-items: center; gap: var(--space-8); width: 100%;
  border: 0; border-radius: var(--radius-6); background: transparent;
  padding: var(--space-8) var(--space-10); color: var(--text-secondary);
  font: inherit; font-size: var(--fs-small); text-align: left; cursor: pointer;
}
.lead-context-menu__item:hover,
.lead-context-menu__item:focus-visible { background: var(--bg-elevated); color: var(--text-primary); }
.lead-context-menu__item--primary { color: var(--accent-soft-text); font-weight: var(--fw-bold); }
.lead-context-menu__item:disabled { opacity: .45; cursor: not-allowed; }
.lead-context-menu__sep { width: 100%; border: 0; border-top: 1px solid var(--border-subtle); margin: var(--space-4) 0; }

.overlay--modal.lead-reroute-dialog .overlay__surface { width: min(760px, calc(100vw - 32px)); }
.lead-reroute { display: grid; gap: var(--space-12); }
.lead-reroute__summary { display: flex; align-items: center; gap: var(--space-10); padding: var(--space-10); border: 1px solid var(--border-subtle); border-radius: var(--radius-6); background: var(--bg-elevated); }
.lead-reroute__summary > span:last-child { display: grid; gap: var(--space-4); min-width: 0; }
.lead-reroute__summary strong { color: var(--text-primary); }
.lead-reroute__summary small { color: var(--text-muted); }
.lead-reroute__avatar { display: grid; place-items: center; width: 36px; height: 36px; flex: 0 0 36px; border-radius: 50%; background: var(--accent-soft-bg); color: var(--accent-soft-text); font-weight: var(--fw-bold); }
.lead-reroute__parameters { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 1fr); gap: var(--space-10); padding: var(--space-12); border: 1px solid var(--border-subtle); border-radius: var(--radius-6); background: var(--bg-elevated); }
.lead-reroute__field { display: grid; gap: var(--space-6); min-width: 0; color: var(--text-secondary); font-size: var(--fs-label); font-weight: var(--fw-bold); }
.lead-reroute__field em { color: var(--text-muted); font-style: normal; font-weight: var(--fw-normal); }
.lead-reroute__field--wide { grid-column: 1 / -1; }
.lead-reroute__field .textarea { min-height: 58px; resize: vertical; }
.lead-reroute__schedule { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-6); min-width: 0; border: 0; padding: 0; margin: 0; }
.lead-reroute__schedule legend { width: 100%; margin-bottom: var(--space-6); color: var(--text-secondary); font-size: var(--fs-label); font-weight: var(--fw-bold); }
.lead-reroute__schedule label { cursor: pointer; }
.lead-reroute__schedule label input { position: absolute; opacity: 0; pointer-events: none; }
.lead-reroute__schedule label span { display: block; padding: var(--space-8) var(--space-10); border: 1px solid var(--border-default); border-radius: var(--radius-6); color: var(--text-secondary); font-size: var(--fs-small); }
.lead-reroute__schedule label:has(input:checked) span { border-color: var(--accent); background: var(--accent-soft-bg); color: var(--accent-soft-text); }
.lead-reroute__datetime { flex: 1 1 190px; min-width: 190px; }
.lead-reroute__picker-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--space-10); }
.lead-reroute__search { display: flex; align-items: center; gap: var(--space-8); padding: 0 var(--space-10); border: 1px solid var(--border-default); border-radius: var(--radius-6); background: var(--bg-input); color: var(--text-muted); }
.lead-reroute__search:focus-within { border-color: var(--accent); }
.lead-reroute__search .input { flex: 1; min-width: 0; border: 0; padding-left: 0; background: transparent; box-shadow: none; }
.lead-reroute__selected-count { color: var(--text-muted); font-size: var(--fs-label); white-space: nowrap; }
.lead-reroute__offers { display: grid; gap: var(--space-6); max-height: min(38vh, 390px); overflow: auto; padding-right: var(--space-4); }
.lead-reroute-option { display: grid; gap: var(--space-8); padding: var(--space-10); border: 1px solid var(--border-subtle); border-radius: var(--radius-6); }
.lead-reroute-option:hover { border-color: var(--border-default); background: var(--bg-elevated); }
.lead-reroute-option:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent-soft-bg) 55%, transparent); }
.lead-reroute-option.is-preview-ok { border-color: var(--ok); }
.lead-reroute-option.is-preview-error { border-color: var(--danger); }
.lead-reroute-option.is-existing { opacity: .62; cursor: not-allowed; }
.lead-reroute-option__main { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; align-items: center; gap: var(--space-10); cursor: pointer; }
.lead-reroute-option__main > input { position: absolute; opacity: 0; pointer-events: none; }
.lead-reroute-option__mark { display: grid; place-items: center; width: 17px; height: 17px; border: 1px solid var(--border-default); border-radius: var(--radius-4); color: transparent; }
.lead-reroute-option:has(input:checked) .lead-reroute-option__mark { border-color: var(--accent); background: var(--accent); color: var(--text-on-accent); }
.lead-reroute-option__copy { display: grid; gap: var(--space-4); min-width: 0; }
.lead-reroute-option__copy strong { overflow: hidden; color: var(--text-primary); text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-small); }
.lead-reroute-option__copy small { color: var(--text-muted); font-size: var(--fs-label); }
.lead-reroute-option__account { display: grid; grid-template-columns: minmax(150px, .45fr) minmax(0, 1fr); align-items: center; gap: var(--space-10); padding: var(--space-8) 0 0 28px; border-top: 1px solid var(--border-subtle); color: var(--text-muted); font-size: var(--fs-label); }
.lead-reroute-option__account[hidden] { display: none; }
.lead-reroute__note { margin: 0; color: var(--text-muted); font-size: var(--fs-label); line-height: 1.45; }
.lead-reroute__error { margin: 0; color: var(--danger); font-size: var(--fs-small); }
.lead-reroute__empty { padding: var(--space-16); border: 1px dashed var(--border-default); border-radius: var(--radius-6); color: var(--text-muted); text-align: center; }

/* C.5 — Mobile cards (leads list) */
@media (max-width: 640px) {
  .lead-reroute__parameters { grid-template-columns: 1fr; }
  .lead-reroute__field--wide { grid-column: auto; }
  .lead-reroute__picker-head { grid-template-columns: 1fr; }
  .lead-reroute__selected-count { justify-self: end; }
  .lead-reroute-option__account { grid-template-columns: 1fr; padding-left: 0; }
  .leads-context-hint { display: none; }
  #leads-list .data-table thead { display: none; }
  #leads-list .data-table,
  #leads-list .data-table tbody,
  #leads-list .data-table tr,
  #leads-list .data-table td { display: block; }
  #leads-list .data-table tr {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-left: 3px solid var(--text-muted);
    border-radius: var(--radius-6);
    margin: var(--space-8) var(--space-16);
    padding: var(--space-8) var(--space-12);
  }
  #leads-list .data-table tr.is-selected { border-left-color: var(--accent); }
  /* status-based left border via row class — JS adds leads-row--* */
  #leads-list .data-table tr.leads-row--ok { border-left-color: var(--ok); }
  #leads-list .data-table tr.leads-row--warn { border-left-color: var(--warn); }
  #leads-list .data-table tr.leads-row--danger { border-left-color: var(--danger); }
  #leads-list .data-table td { border-bottom: 0; padding: var(--space-4) 0; }
  #leads-list .data-table td:first-child { display: inline-block; vertical-align: top; padding-right: var(--space-8); }
}

/* ---------- Leads custom-period date inputs ---------- */
.leads-period-custom {
  display: inline-flex;
  gap: var(--space-12);
  margin-left: var(--space-12);
  align-items: center;
}
.leads-period-custom__label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-4);
  font-size: var(--fs-small);
  color: var(--text-secondary);
}
.input--date {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-6);
  padding: var(--space-4) var(--space-8);
  font-family: var(--font-mono);
  font-size: var(--fs-small);
}
@media (max-width: 768px) {
  .leads-period-custom {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-4);
    margin-left: 0;
    width: 100%;
  }
}
