/* Kandidatenliste (leads.html): Liste links, Karte rechts, Details als Seitenpanel über der Karte.
   Baut auf den Tokens aus styles.css auf. Ampel nie nur über Farbe: jede Ampel trägt ein Symbol. */

/* Etwas dunkleres Grau für kleine Schrift (4.5:1 auf Weiß), dunkel unverändert. */
.lp-body { --muted: #6c6a64; --lp-list-w: clamp(340px, 28vw, 460px); --lp-drawer-w: clamp(380px, 32vw, 520px); --lp-gutter: 20px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .lp-body { --muted: #9a988f; } }
:root[data-theme="dark"] .lp-body { --muted: #9a988f; }

.lp-gutter { padding-inline: var(--lp-gutter); }
.lp-body .topbar-inner { height: 52px; }
.lp { display: flex; flex-direction: column; min-height: 0; width: 100%; }

/* ---------- Suchleiste ---------- */
.lp-cmd { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding-block: 10px; background: var(--surface); border-bottom: 1px solid var(--line); }
.lp-title { font-size: 17px; letter-spacing: -.015em; margin: 0 4px 0 0; white-space: nowrap; }
.lp-search { display: flex; flex: 0 1 360px; min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.lp-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.lp-search input { flex: 1; min-width: 0; border: 0; background: none; color: var(--ink); font: inherit; font-size: 14.5px; padding: 7px 11px; outline: none; }
.lp-code { display: flex; border-left: 1px solid var(--line); }
.lp-code[hidden] { display: none; }
.lp-code input { width: 140px; }
.lp-search-btn { border: 0; background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 600; font-size: 14px; padding: 0 16px; cursor: pointer; }
.lp-search-btn:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.lp-search-btn:disabled { opacity: .65; cursor: progress; }
.lp-regions { display: flex; flex-wrap: wrap; gap: 4px; }
.lp-region { font: inherit; font-size: 12.5px; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; cursor: pointer; white-space: nowrap; }
.lp-region span { font-weight: 600; color: var(--ink); }
.lp-region:hover { border-color: var(--accent); }
.lp-region[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.lp-region[aria-pressed="true"] span { color: var(--accent); }
.lp-job { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-2); min-width: 0; }
.lp-job[hidden] { display: none; }
.lp-job-bar { width: 90px; height: 6px; border-radius: 3px; background: var(--track); overflow: hidden; flex: none; display: none; }
.lp-job.is-running .lp-job-bar { display: block; }
.lp-job-bar > span { display: block; height: 100%; width: 3%; background: var(--accent); transition: width .4s; }
.lp-spacer { flex: 1; }
/* Während einer Suche braucht es die Schnellwahl nicht; so bleibt die Zeile einzeilig. */
.lp-cmd:has(.lp-job.is-running) .lp-regions { display: none; }
.btn.ghost { border-color: transparent; background: none; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.ghost:disabled { opacity: .35; cursor: default; }
.btn:focus-visible, .lp-region:focus-visible, .lp-search-btn:focus-visible, .link-btn:focus-visible, .lp-view button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.small-btn { font-size: 12.5px; padding: 4px 10px; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; }

/* Aufklapper (Website hinzufügen, Mehr Filter, Hilfe) */
.lp-pop { position: relative; }
.lp-pop > summary { list-style: none; cursor: pointer; user-select: none; display: inline-flex; align-items: center; gap: 6px; }
.lp-pop > summary::-webkit-details-marker { display: none; }
.lp-pop[open] > summary { background: var(--accent-soft); color: var(--accent); }
.lp-pop-panel { position: absolute; top: calc(100% + 6px); left: 0; z-index: 1300; width: 330px; max-width: calc(100vw - 32px); background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 34px rgba(0, 0, 0, .16); padding: 14px; display: grid; gap: 10px; }
.lp-pop-right { left: auto; right: 0; }
.lp-pop-panel .field { margin-bottom: 0; }
.lp-pop-panel p { margin: 0; }
.lp-help-btn { width: 32px; justify-content: center; font-weight: 700; }
.lp-help { width: 380px; font-size: 13.5px; color: var(--ink-2); gap: 6px; max-height: min(70vh, 560px); overflow: auto; }
.lp-help h2 { font-size: 15px; margin: 0; color: var(--ink); }
.lp-help h3 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 8px 0 0; }
.lp-legend, .lp-keys { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.lp-legend li { display: flex; align-items: center; gap: 8px; }
kbd { font: 600 11.5px/1 ui-monospace, Consolas, monospace; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 2px 5px; background: var(--surface-2); color: var(--ink); }
.lp-badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 700; }
.lp-badge[hidden] { display: none; }

/* ---------- Filter ---------- */
.lp-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding-block: 8px; border-bottom: 1px solid var(--line); }
.lp-amp { display: inline-flex; flex-wrap: wrap; gap: 2px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); margin: 0; padding: 2px; }
.lp-amp-chip { position: relative; display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px 3px 4px; border-radius: 999px; font-size: 13px; font-weight: 600; cursor: pointer; }
.lp-amp-chip input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.lp-amp-chip b { font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }
.lp-amp-chip:has(input:checked) { background: color-mix(in srgb, var(--amp) 13%, var(--surface)); }
.lp-amp-chip:has(input:not(:checked)) { opacity: .5; }
.lp-amp-chip:has(input:not(:checked)) .amp-sym { background: var(--track); color: var(--muted); }
.lp-amp-chip:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }
.lp-sel { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.lp-sel select, .field select, .lp-q input {
  font: inherit; font-size: 13.5px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; min-width: 0; }
.field select { font-size: 14px; padding: 7px 9px; }
.lp-q input { width: 230px; }
.lp-sel select:focus-visible, .field select:focus-visible, .lp-q input:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.lp-more { width: 460px; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.lp-more-checks { grid-column: 1 / -1; }
.lp-more-checks { display: grid; gap: 0; }
.lp-reset { font-size: 13px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--ink-2); padding: 5px 0; cursor: pointer; }

/* ---------- Arbeitsfläche ---------- */
.lp-work { position: relative; display: grid; grid-template-columns: var(--lp-list-w) minmax(0, 1fr); min-height: 0; }
.lp-list { display: flex; flex-direction: column; min-height: 0; background: var(--surface); border-right: 1px solid var(--line); }
.lp-list-head { display: flex; align-items: center; gap: 8px; padding: 7px 12px 7px 14px; border-bottom: 1px solid var(--line); background: var(--surface); }
.lp-list-head #count { margin: 0; flex: 1; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.lp-sort select { font-size: 12.5px; padding: 3px 6px; }
.lp-view { display: none; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.lp-view button { font: inherit; font-size: 13px; font-weight: 500; border: 0; background: var(--surface); color: var(--ink-2); padding: 5px 12px; cursor: pointer; }
.lp-view button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.lp-list-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; padding: 3px 12px 3px 14px; border-bottom: 1px solid var(--line); background: var(--surface); }
.lp-follow { font-size: 12.5px; padding: 2px 0; }
.lp-hint { margin: 0 0 3px; flex: 1 1 100%; font-size: 12.5px; color: var(--ink-2); }
.lp-hint[hidden] { display: none; }
.lp-plz-warn { margin: 0; font-size: 12.5px; color: var(--bad-ink); flex: 1 1 100%; }
.lp-plz-warn[hidden] { display: none; }
.lp-harvest { font-size: 12px; line-height: 1.3; color: var(--muted); max-width: 240px; }
.lp-harvest[hidden] { display: none; }
.lp-job .link-btn { font-size: 12.5px; white-space: nowrap; }
.lp-rows { list-style: none; margin: 0; padding: 0; overflow: auto; flex: 1; min-height: 0; overscroll-behavior: contain; }

/* Listeneintrag: drei Zeilen, links die Ampel */
.lr { position: relative; display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 10px; padding: 9px 14px 9px 12px; border-bottom: 1px solid var(--line); cursor: pointer;
  /* Up to 300 rows per page: rows out of sight skip layout (about 100 ms less per reload). */
  content-visibility: auto; contain-intrinsic-size: auto 74px; }
.lr:hover, .lr.is-hover { background: var(--surface-2); }
.lr.is-hover { box-shadow: inset 3px 0 0 color-mix(in srgb, var(--accent) 45%, transparent); }
.lr[aria-current="true"] { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.lr:has(.lr-open:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; }
.lr.is-managed .lr-name { color: var(--ink-2); }
.lr-amp { display: grid; justify-items: center; align-content: start; gap: 4px; padding-top: 1px; }
.lr-dot { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; line-height: 1; color: #fff; background: var(--amp); }
.lr-dot.a-gelb { color: #3a2900; }
.lr-parts { display: flex; gap: 2px; }
.lr-parts .amp-dot { width: 11px; height: 11px; font-size: 7px; }
.lr-part { display: grid; justify-items: center; gap: 1px; cursor: help; }
.lr-part-l { font-size: 9px; font-weight: 700; line-height: 1; color: var(--muted); }
.lr-body { display: grid; gap: 1px; min-width: 0; }
.lr-l1 { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.lr-open { flex: 1; min-width: 0; border: 0; background: none; padding: 0; font: inherit; color: var(--ink); text-align: left; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; outline: none; }
.lr-name { font-size: 14.5px; font-weight: 600; letter-spacing: -.005em; }
.lr-legal { font-size: 12.5px; color: var(--muted); margin-left: 6px; }
.lr .status-pill { flex: none; font-size: 11.5px; padding: 0 7px; }
.lr-meta { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lr-domain { color: var(--ink-2); text-decoration: none; }
.lr-domain:hover, .lr-domain:focus-visible { color: var(--accent); text-decoration: underline; }
.lr-l3 { display: flex; align-items: center; gap: 6px; min-width: 0; }
.lr-why { flex: 1; min-width: 0; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lr-chip { flex: none; font-size: 11.5px; font-weight: 600; border-radius: 6px; padding: 0 6px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.lr-score { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.lr-chip.is-due { background: color-mix(in srgb, var(--warn) 24%, var(--surface)); border-color: transparent; color: var(--ink); }
.lr-fresh { background: color-mix(in srgb, var(--good) 16%, var(--surface)); border-color: transparent; color: var(--good-ink); }
.lr-quick { position: absolute; top: 6px; right: 10px; display: none; padding-left: 16px; background: linear-gradient(90deg, transparent, var(--lr-bg, var(--surface-2)) 14px); }
.lr[aria-current="true"] .lr-quick { --lr-bg: var(--accent-soft); }
.lr:hover .lr-quick, .lr:focus-within .lr-quick, .lr[aria-current="true"] .lr-quick { display: block; }
.lr-quick .btn { font-size: 12px; padding: 3px 9px; background: var(--surface); }
@media (hover: none) { .lr-quick, .lr:hover .lr-quick, .lr[aria-current="true"] .lr-quick { display: none; } }

.lp-empty { list-style: none; padding: 36px 22px; color: var(--ink-2); cursor: default; }
.lp-empty h2 { font-size: 16px; color: var(--ink); margin: 0 0 6px; }
.lp-empty p { margin: 0 0 14px; font-size: 14px; max-width: 42ch; }
.lp-empty-regions, .lp-empty-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.lp-empty-regions .btn span { font-weight: 600; }

.lp-map { position: relative; min-height: 0; min-width: 0; }
#leads-map { position: absolute; inset: 0; }
.lp-map .lm-map { border: 0; border-radius: 0; min-height: 0; }

/* ---------- Details ---------- */
.lp-drawer { position: absolute; top: 0; right: 0; bottom: 0; width: var(--lp-drawer-w); max-width: 100%; z-index: 1100; display: flex; flex-direction: column;
  background: var(--surface); border-left: 1px solid var(--line); box-shadow: -10px 0 30px rgba(0, 0, 0, .12); }
.lp-drawer[hidden] { display: none; }
.dr-loading { padding: 18px; color: var(--muted); margin: 0; }
.dr-loading.bad { color: var(--bad-ink); }
.dr-head { padding: 8px 18px 14px; border-bottom: 1px solid var(--line); display: grid; gap: 4px; }
.dr-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 -8px 0 0; }
.dr-pos { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.dr-nav-btns { display: flex; gap: 2px; }
.dr-nav-btns .btn { font-size: 18px; line-height: 1; padding: 4px 10px; }
.dr-head h2 { margin: 0; font-size: 19px; letter-spacing: -.015em; line-height: 1.25; text-wrap: balance; overflow-wrap: anywhere; outline: none; }
.dr-sub { margin: 0; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.dr-sub a { color: var(--ink-2); }
.dr-tags { margin: 4px 0 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.dr-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.dr-body { flex: 1; min-height: 0; overflow: auto; padding: 0 18px 18px; overscroll-behavior: contain; }
.dr-body section { padding: 14px 0; border-top: 1px solid var(--line); }
.dr-body section:first-child { border-top: 0; }
.dr-body h3 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px; }
.dr-body .field input, .dr-body .field textarea { font-size: 14px; }
.dr-body .field textarea { min-height: 80px; }
.dr-body input[type="text"] { font: inherit; font-size: 14px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; width: 100%; }
.dr-body p { margin: 6px 0 0; }
.lp-drawer > .mail-status { margin: 0; padding: 8px 18px; border-top: 1px solid var(--line); }
.lp-drawer > .mail-status:empty { display: none; }

/* Übernommen aus der alten Detailansicht */
.a-rot { --amp: var(--bad); }
.a-gelb { --amp: var(--warn); }
.a-gruen { --amp: var(--good); }
.a-grau { --amp: var(--muted); }
.amp { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 700; padding: 2px 9px 2px 3px; border-radius: 999px; white-space: nowrap;
  background: color-mix(in srgb, var(--amp) 14%, var(--surface)); color: var(--ink); border: 1px solid color-mix(in srgb, var(--amp) 45%, transparent); }
.amp-sym { width: 18px; height: 18px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 11px; font-weight: 800; color: #fff; line-height: 1; flex: none; background: var(--amp); }
.a-gelb .amp-sym, .amp-sym.a-gelb { color: #3a2900; }
.amp-parts { display: flex; flex-wrap: wrap; gap: 2px 8px; font-size: 11.5px; color: var(--muted); }
.amp-part { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.amp-dot { width: 13px; height: 13px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 8px; font-weight: 800; color: #fff; line-height: 1; background: var(--amp); }
.amp-dot.a-gelb { color: #3a2900; }
.amp-parts-detail { font-size: 13px; gap: 4px 12px; color: var(--ink-2); }
.amp-parts-detail .amp-dot { width: 16px; height: 16px; font-size: 10px; }
.detail-amp { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.status-pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); white-space: nowrap; }
.st-sym { font-size: 12px; line-height: 1; }
.st-top { background: color-mix(in srgb, var(--warn) 22%, var(--surface)); color: var(--ink); border-color: transparent; }
.st-angeschrieben, .st-angesprochen, .st-gespraech, .st-angebot { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.st-kunde { background: color-mix(in srgb, var(--good) 16%, var(--surface)); color: var(--good-ink); border-color: transparent; }
.st-abgesagt { color: var(--muted); }
.managed-tag { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.reason-list { margin: 8px 0 0; padding-left: 18px; font-size: 14px; }
.dl { display: grid; gap: 4px; margin: 0; }
.dl-row { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 8px; font-size: 14px; }
.dl-row dt { color: var(--muted); }
.dl-row dd { margin: 0; overflow-wrap: anywhere; }
.contact-list { list-style: none; padding: 0; margin: 8px 0 4px; display: grid; gap: 4px; font-size: 14px; }
.contact-add { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-top: 8px; }
.contact-list li { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.c-del { padding: 0 8px; min-height: 24px; line-height: 1; color: var(--muted); }
.c-del:hover { color: var(--bad); }
.sub-h { margin: 14px 0 0; font-size: 13px; font-weight: 700; }
.contact-add input, .contact-add select { font: inherit; font-size: 14px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; min-width: 0; }
.history { margin-top: 8px; font-size: 13.5px; }
.history summary { cursor: pointer; color: var(--muted); }
.warn-text { color: var(--bad-ink); }
.mail-status.bad { color: var(--bad-ink); }
.btn.danger { border-color: color-mix(in srgb, var(--bad) 55%, var(--line)); color: var(--bad-ink); }
.btn.danger:hover { background: color-mix(in srgb, var(--bad) 10%, var(--surface)); }
.btn.danger-soft { color: var(--bad-ink); }
.lp-body .error { margin: 8px 0 0; max-width: none; }

/* ---------- Fußzeile ---------- */
.lp-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 24px; padding-block: 6px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); background: var(--surface); }
.lp-foot a { color: var(--muted); }

/* ---------- Breit: alles in einem Fenster, Liste und Details scrollen für sich ---------- */
@media (min-width: 900px) {
  .lp-body { height: 100vh; height: 100dvh; min-height: 600px; }
  .lp { flex: 1; }
  .lp-work { flex: 1; }
}
@media (min-width: 1700px) {
  .lp-body { --lp-gutter: 24px; }
}

/* ---------- Schmal: Liste oder Karte, Details im Vollbild ---------- */
@media (max-width: 899.98px) {
  .lp-body { --lp-gutter: 16px; }
  .lp-title { display: none; }
  .lp-search { flex: 1 1 100%; }
  .lp-regions { flex: 1 1 auto; }
  .lp-job { flex: 1 1 100%; order: 5; }
  .lp-spacer { display: none; }
  .lp-q { flex: 1 1 140px; }
  .lp-q input { width: 100%; }
  .lp-pop-panel { position: fixed; top: auto; left: 16px; right: 16px; width: auto; margin-top: 6px; max-height: 70vh; overflow: auto; }
  .lp-more { grid-template-columns: 1fr 1fr; gap: 8px 10px; }
  .lp-work { display: block; }
  .lp-list { border-right: 0; }
  .lp-list-head { position: sticky; top: 0; z-index: 5; }
  .lp-view { display: inline-flex; flex: none; }
  .lp-sort > span { display: none; }
  .lp-sort select { max-width: 150px; }
  .lp-work[data-view="list"] .lp-map { display: none; }
  .lp-work[data-view="map"] .lp-rows { display: none; }
  .lp-map { height: calc(100dvh - 150px); min-height: 380px; }
  .lp-rows { overflow: visible; }
  .lp-drawer { position: fixed; inset: 0; width: auto; z-index: 2000; border-left: 0; box-shadow: none; }
  .lp-detail-open { overflow: hidden; }
  .lr-name { font-size: 15px; }
  .contact-add { grid-template-columns: 1fr 1fr; }
  .contact-add .btn { grid-column: 1 / -1; }
  .dl-row { grid-template-columns: 110px minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  .lp-job-bar > span { transition: none; }
}
