/* Leads page (.ld-): follow-up desk. Tokens only, from base.css. */

/* ---------- head and tools ---------- */
.ld-head { margin-bottom: 12px; }
.ld-sum { margin: 2px 0 0; }
.ld-tools { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin-bottom: 12px; }
.ld-search { position: relative; flex: 1 1 280px; max-width: 460px; }
.ld-search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--faint); pointer-events: none; }
.ld-search .input { padding-left: 32px; min-height: 38px; width: 100%; }
.ld-sort { display: inline-flex; align-items: center; gap: 8px; margin-left: auto; }
.ld-sort-l { font-size: 13px; color: var(--muted); white-space: nowrap; }
.ld-sort .select { width: auto; min-height: 38px; }

/* ---------- queues ---------- */
.ld-queues { margin-bottom: 12px; }
.ld-queues .ld-seg { flex-wrap: wrap; } /* every queue visible, no hidden ones off the edge */
.ld-seg { display: inline-flex; }
.ld-seg button, .ld-arch-seg button { display: inline-flex; align-items: center; gap: 7px; min-height: 36px; white-space: nowrap; }
.ld-n { font-size: 12px; color: var(--muted); background: var(--surface); border: 1px solid var(--line-soft); border-radius: 999px; padding: 0 7px; line-height: 18px; }
.ld-seg button.on .ld-n, .ld-arch-seg button.on .ld-n { background: var(--surface-2); }

/* archive explanation */
.ld-explain { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: var(--r-card); }
.ld-explain p { margin: 0; font-size: 13.5px; line-height: 1.5; color: var(--muted); max-width: 820px; }
.ld-explain strong { color: var(--text); font-weight: 620; }
.ld-arch-seg { display: inline-flex; flex-wrap: wrap; align-self: flex-start; }

/* search results head */
.ld-res-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; min-height: 36px; }
.ld-res-head p { margin: 0; font-size: 13.5px; }

/* ---------- list ---------- */
.ld-list { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r-card); box-shadow: var(--shadow); }
.ld-row {
  display: grid;
  grid-template-columns: 36px minmax(180px, 1.25fr) 164px minmax(210px, 1.5fr) minmax(150px, 1fr) minmax(112px, auto) auto;
  grid-template-areas: "star who stage contact quote badge acts" "log log log log log log log" "qp qp qp qp qp qp qp";
  column-gap: 16px; row-gap: 0; padding: 14px 16px 14px 10px; align-items: center;
  border-bottom: 1px solid var(--line-soft);
}
.ld-row:last-child { border-bottom: 0; }
.ld-row.is-closed { background: var(--surface-2); }
.ld-row:first-child { border-radius: var(--r-card) var(--r-card) 0 0; }
.ld-row:last-child { border-radius: 0 0 var(--r-card) var(--r-card); }
.ld-row:only-child { border-radius: var(--r-card); }
/* urgent (set by hand): an amber band on the side, never red */
.ld-row.is-urgent { box-shadow: inset 4px 0 0 var(--warn); }
.ld-skel { display: block; padding: 18px 16px; }
.ld-skel .skeleton { display: block; height: 18px; border-radius: 6px; }

.ld-star { grid-area: star; display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: var(--r-ctl); background: none; color: var(--faint); cursor: pointer; }
.ld-star svg { width: 19px; height: 19px; }
.ld-star:hover { background: var(--surface-2); color: var(--muted); }
.ld-star.on { color: var(--text); }

.ld-who { grid-area: who; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.ld-who-top { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; min-width: 0; }
.ld-name { background: none; border: 0; padding: 0; margin: 0; font: inherit; font-weight: 650; font-size: 16px; line-height: 1.3; color: var(--text); cursor: pointer; text-align: left; min-width: 0; max-width: 100%; overflow-wrap: break-word; }
.ld-name:hover { text-decoration: underline; text-underline-offset: 2px; }
.ld-veh { font-size: 13px; line-height: 1.35; color: var(--muted); overflow-wrap: break-word; }
/* the Urgent label: filled amber, light text on light theme and dark text on dark theme */
.ld-urg { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px 1px 6px; border-radius: var(--r-chip); background: var(--warn); color: var(--surface); font-size: 12px; font-weight: 650; line-height: 18px; white-space: nowrap; }
.ld-urg svg { width: 12px; height: 12px; flex: none; }

.ld-stage { grid-area: stage; min-width: 0; }
.ld-stage-sel { width: 100%; min-height: 36px; font-size: 13.5px; }
.ld-was { font-size: 13px; }

.ld-contact { grid-area: contact; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.ld-line { font-size: 13px; line-height: 1.35; color: var(--text); min-width: 0; overflow-wrap: break-word; }
.ld-k { color: var(--muted); }
.ld-late { color: var(--bad); font-weight: 650; }

.ld-quote { grid-area: quote; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.ld-qbtn, .ld-q-static { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; min-height: 36px; justify-content: center; max-width: 100%; text-align: left; }
.ld-qbtn { margin: 0 0 0 -8px; padding: 3px 8px; background: none; border: 1px solid transparent; border-radius: var(--r-ctl); font: inherit; color: var(--text); cursor: pointer; }
.ld-qbtn:hover { background: var(--surface-2); border-color: var(--line-soft); }
.ld-qbtn[aria-expanded="true"] { background: var(--surface-2); border-color: var(--line); }
.ld-q-svc { font-size: 13px; line-height: 1.3; color: var(--muted); overflow-wrap: break-word; }
.ld-q-amt { font-size: 14.5px; font-weight: 650; line-height: 1.3; }
.ld-q-amt.faint { font-size: 13px; font-weight: 400; }
.ld-q-owe { font-size: 12.5px; }
.ld-qadd { min-height: 36px; margin-left: -8px; color: var(--muted); font-weight: 520; }
.ld-qadd svg { width: 14px; height: 14px; }
.ld-qadd:hover { color: var(--text); }

.ld-badge { grid-area: badge; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.ld-badge .chip { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.ld-chip { color: var(--text); }
.ld-chip-ic { width: 13px; height: 13px; flex: none; color: var(--muted); }
.ld-hint { font-size: 12.5px; line-height: 1.3; }

.ld-acts { grid-area: acts; display: flex; gap: 4px; align-items: center; justify-content: flex-end; }
.ld-act { width: 36px; min-height: 36px; padding: 0; display: inline-grid; place-items: center; }
.ld-act svg { width: 17px; height: 17px; }
.ld-reopen { min-height: 36px; }

/* save buttons inside a row: navy, so the brand red stays for the page's main button */
.ld-save { background: var(--plate); border-color: var(--plate); color: var(--plate-ink); font-weight: 650; }
.ld-save:hover { background: color-mix(in srgb, var(--plate) 85%, var(--text)); border-color: color-mix(in srgb, var(--plate) 85%, var(--text)); }
.ld-save:disabled { opacity: .6; }

/* drawer: the Urgent button uses the same amber as the label in the list */
.dl-urgent.ld-urg-btn.on { background: var(--warn); border-color: var(--warn); color: var(--surface); font-weight: 650; }
.dl-urgent.ld-urg-btn.on:hover { background: color-mix(in srgb, var(--warn) 88%, var(--text)); }
/* drawer: the quote, right under the next step */
.ld-dq .ld-dq-amt { font-size: 16px; font-weight: 650; }

/* search: open leads first, then the archived and customers groups */
.ld-noopen { padding: 12px 14px; margin-bottom: 4px; }
.ld-noopen p { margin: 0; font-size: 13.5px; color: var(--muted); }
.ld-noopen strong { color: var(--text); font-weight: 620; }
.ld-grp { margin-top: 12px; }
.ld-grp-btn { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 40px; padding: 6px 12px; margin-bottom: 8px; background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: var(--r-card); color: var(--text); font: inherit; font-weight: 620; font-size: 14px; text-align: left; cursor: pointer; }
.ld-grp-btn:hover { background: var(--surface); }
.ld-grp-ic { width: 16px; height: 16px; flex: none; color: var(--muted); }
.ld-grp-btn[aria-expanded="true"] .ld-grp-ic { transform: rotate(90deg); }
.ld-grp-hint { margin-left: auto; font-weight: 400; font-size: 12.5px; }
@media (prefers-reduced-motion: no-preference) { .ld-grp-ic { transition: transform 0.15s ease; } }

/* ---------- inline log box and quote panel (open under the row) ---------- */
.ld-log, .ld-qp { display: flex; gap: 8px; margin: 12px 0 2px 52px; padding: 12px; background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: var(--r-ctl); max-width: 640px; }
.ld-log { grid-area: log; flex-direction: column; }
.ld-log-seg { flex-wrap: wrap; align-self: flex-start; }
.ld-log-seg button { min-height: 36px; }
.ld-log-text { min-height: 64px; }
.ld-log-foot, .ld-qp-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ld-log-foot .btn, .ld-qp-foot .btn { min-height: 36px; }
.ld-qp { grid-area: qp; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px; }
.ld-qp .field { margin: 0; }
.ld-qp-svc { flex: 1 1 220px; min-width: 0; }
.ld-qp-amt { flex: 0 1 140px; min-width: 110px; }
.ld-qp .select, .ld-qp .input { min-height: 38px; width: 100%; }

/* ---------- empty state and next-step modal ---------- */
.ld-empty-ic { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--good-bg); color: var(--good); margin-bottom: 8px; }
.ld-empty-ic svg { width: 20px; height: 20px; }
.ld-empty .btn { margin-top: 6px; }
.ld-ns-seg { flex-wrap: wrap; align-self: flex-start; }
.ld-ns-seg button { min-height: 36px; }
.ld-ns-close { display: flex; gap: 8px; align-items: flex-start; font-size: 13.5px; cursor: pointer; }
.ld-ns-close input { margin-top: 3px; width: 16px; height: 16px; flex: none; }

/* ---------- medium screens: quote and badge drop to a second line ---------- */
@media (max-width: 1240px) and (min-width: 861px) {
  .ld-row {
    grid-template-columns: 36px minmax(0, 1.2fr) 156px minmax(0, 1.5fr);
    grid-template-areas: "star who stage contact" ". quote badge acts" "log log log log" "qp qp qp qp";
    row-gap: 6px;
  }
  .ld-badge { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
  .ld-row > .ld-acts { justify-self: end; }
}

/* ---------- phone: one clean card per lead ---------- */
@media (max-width: 860px) {
  .ld-search { flex-basis: 100%; max-width: none; }
  .ld-sort { margin-left: 0; flex: 1 1 100%; }
  .ld-sort .select { flex: 1 1 0; min-width: 0; width: 100%; }
  .ld-list { background: none; border: 0; box-shadow: none; display: flex; flex-direction: column; gap: 10px; }
  .ld-row, .ld-row:first-child, .ld-row:last-child, .ld-row:only-child {
    grid-template-columns: 36px minmax(0, 1fr) auto;
    grid-template-areas: "star who who" ". stage stage" ". contact contact" ". quote badge" "acts acts acts" "log log log" "qp qp qp";
    column-gap: 8px; row-gap: 10px; padding: 12px 12px 10px 6px; align-items: start;
    background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r-card); box-shadow: var(--shadow);
  }
  .ld-row.is-urgent { box-shadow: inset 4px 0 0 var(--warn), var(--shadow); }
  .ld-row.is-closed { background: var(--surface-2); }
  .ld-skel { display: block; }
  .ld-who { padding-top: 6px; }
  .ld-quote { align-self: center; }
  .ld-badge { align-items: flex-end; text-align: right; align-self: center; }
  .ld-acts { justify-content: flex-start; gap: 6px; border-top: 1px solid var(--line-soft); padding-top: 10px; margin-left: 6px; }
  .ld-act { width: auto; flex: 1 1 0; min-height: 40px; }
  .ld-reopen { flex: 1 1 0; min-height: 40px; }
  .ld-log, .ld-qp { margin: 0 0 0 6px; max-width: none; }
}

/* quote panel with several services (Greg, 06/11/2026) */
.ld-qp-rows { flex: 1 1 100%; display: grid; gap: 6px; }
.ld-qp-row { display: flex; align-items: flex-end; gap: 8px; }
.ld-qp-del { flex: none; margin-bottom: 2px; }
.ld-qp .ld-qp-foot { flex: 1 1 100%; }
.ld-qp-total { margin-left: auto; margin-right: 6px; font-size: 14px; }
.ld-score { margin-left: 8px; text-transform: capitalize; }
