/* Styles owned by the today-leads module group. Build on the tokens in app.css.
   Prefixes: .tl-* = Today, .ld-* = Leads. Mobile-first; nothing may scroll sideways at 375px. */

/* ================= Today ================= */
.tl-head-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.tl-head .eyebrow { font-size: 12px; }
.tl-dms { display: flex; flex-direction: column; align-items: flex-end; text-align: right; flex: none; white-space: nowrap; }
.tl-dms-num { font-size: 28px; font-weight: 600; letter-spacing: -0.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tl-dms-num .muted { font-size: 16px; font-weight: 500; letter-spacing: 0; color: var(--text-3); }
.tl-bar { display: block; width: 100%; height: 6px; margin: 12px 0 4px; border: 0; border-radius: 999px; overflow: hidden; background: var(--surface-2); appearance: none; -webkit-appearance: none; }
.tl-bar::-webkit-progress-bar { background: var(--surface-2); border-radius: 999px; }
.tl-bar::-webkit-progress-value { background: var(--text); border-radius: 999px; }
.tl-bar::-moz-progress-bar { background: var(--text); border-radius: 999px; }
.tl-counts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 10px 0 0; }
.tl-auto .tl-counts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tl-counts div { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; }
.tl-counts dt { font-size: 12px; font-weight: 500; color: var(--text-2); }
.tl-counts dd { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }

.tl-rest h2 { font-size: 18px; }
.tl-rest-actions { margin: 12px 0 4px; }
.tl-override { background: var(--warn-bg); color: var(--warn-fg); border: 1px solid var(--warn-line); }
.tl-override a { color: inherit; }

.tl-task { padding: 14px 14px 12px; }
.tl-task-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.tl-who { min-width: 0; }
.tl-step { margin: 0 0 4px; display: flex; flex-wrap: wrap; gap: 4px; }
.tl-name { font-size: 18px; margin: 0; overflow-wrap: anywhere; }
.tl-name a { text-decoration: none; }
.tl-sub { margin: 2px 0 0; color: var(--text); font-size: 14px; overflow-wrap: anywhere; }
.tl-meta { display: flex; flex-direction: column; align-items: flex-end; text-align: right; flex: none; gap: 2px; }
.tl-day { font-size: 12px; font-weight: 500; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 7px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tl-ig { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; margin: 12px 0 0; text-decoration: none; min-height: 44px; overflow-wrap: anywhere; }

.tl-dm { margin-top: 12px; }
.tl-dm-label { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.tl-len.is-over { color: var(--bad-fg); font-weight: 600; }
:where(.tl-task, .ld-actions, .ld-edit, .ld-paste) textarea { font: inherit; font-size: 16px; width: 100%; padding: 9px 11px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); resize: vertical; line-height: 1.45; }
.tl-msg { background: var(--surface); }
:where(.tl-task, .ld-actions, .ld-edit, .ld-paste) textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.tl-copy { margin-top: 8px; }
.tl-copied { margin-left: 8px; font-weight: 500; color: var(--good-fg); }
.tl-fill { margin-top: 12px; background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: var(--radius-sm); padding: 10px 12px; }
.tl-fill-lede { font-weight: 500; margin-bottom: 6px; }
.tl-fill-form label { display: block; margin-bottom: 4px; }
.tl-fill-form input[type=text] { max-width: none; }
.tl-fill-form .hint { margin: 4px 0 8px; }
.tl-fill-form + .tl-fill-form { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.tl-guide { margin-top: 12px; }
.tl-styles { margin: 6px 0 0; padding-left: 18px; font-size: 14px; }
.tl-styles li { margin: 6px 0; }
.tl-note { margin: 10px 0 0; }

.tl-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; }
.tl-actions form { margin: 0; }
.tl-done { flex: 1 1 140px; }
.tl-done .btn { width: 100%; }
.tl-actions .btn[disabled], .ld-confirm .btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.tl-more { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); }
.tl-more details { flex: 1 1 100%; }
.tl-more summary { padding: 8px 0; font-size: 14px; }
.tl-sub-form { display: grid; gap: 6px; padding: 4px 0 8px; }
.tl-sub-form label { font-size: 13px; }
.tl-sub-form select, .tl-sub-form input[type=text], .tl-sub-form input[type=date] { max-width: none; }
.tl-sub-form .btn { justify-self: start; }
.tl-collapsed summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--text); min-height: 28px; }
.tl-collapsed .hint { margin-top: 8px; }
.tl-mini { list-style: none; margin: 8px 0 0; padding: 0; font-size: 14px; }
.tl-mini li { padding: 6px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.tl-mini li:last-child { border-bottom: 0; }
.tl-mini a { font-weight: 500; text-decoration: none; }

@media (min-width: 860px) {
  .tl-queue { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; align-items: start; }
  .tl-more details { flex: 1 1 calc(50% - 8px); }
}

/* ================= Leads: list ================= */
.ld-search { padding: 12px; }
.ld-search-row { display: flex; gap: 8px; }
.ld-search-row input[type=search] { font: inherit; font-size: 16px; flex: 1; min-width: 0; min-height: 44px; padding: 8px 11px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); }
@media (min-width: 860px) { .ld-search-row input[type=search] { font-size: 14px; min-height: 38px; } }
.ld-filters { margin-top: 10px; }
.ld-filters summary { font-size: 14px; }
.ld-filter-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 10px; margin-top: 10px; }
@media (min-width: 860px) { .ld-filter-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.ld-filter label { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 2px; }
.ld-filter select, .ld-filter input { max-width: none; }
.ld-filter-actions { margin: 10px 0 0; display: flex; gap: 12px; align-items: center; }
.ld-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 2px 0 8px; flex-wrap: wrap; }
.ld-bar-links { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.ld-count { margin: 0; }
.ld-table-card { padding: 4px 12px; }
.ld-table a { text-decoration: none; }
.ld-table th a { color: inherit; }
.ld-name { font-weight: 600; display: block; overflow-wrap: anywhere; }
.ld-company, .ld-handle { display: block; color: var(--text-2); font-size: 12px; overflow-wrap: anywhere; }
.ld-tier { font-weight: 600; }
.ld-touches { display: inline-flex; gap: 10px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ld-touches > span { display: inline-flex; align-items: center; gap: 3px; color: var(--text); }
.ld-touches svg { color: var(--text-3); }
.ld-col-check { width: 34px; }
.ld-col-check input { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; }
.ld-pages { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 0 0 14px; }
.ld-bulk { border: 1px solid var(--line); }
.ld-bulk legend { font-weight: 600; padding: 0 4px; }
.ld-bulk-row { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: flex-end; }
.ld-bulk-row .ld-filter { flex: 1 1 140px; }

/* Phones: each row becomes a small card (no sideways scroll). `table.data.ld-table` outranks app.css's `table.data td`. */
@media (max-width: 639px) {
  table.data.ld-table thead tr { display: flex; align-items: center; gap: 0 10px; flex-wrap: wrap; border-bottom: 1px solid var(--line-strong); padding: 2px 0 4px; }
  table.data.ld-table thead th { border: 0; padding: 4px 0; font-size: 10px; }
  table.data.ld-table thead th.ld-col-check { width: 30px; }
  table.data.ld-table tbody tr { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; grid-template-areas: "chk lead tier" "chk status last" "chk touch touch"; gap: 4px 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  table.data.ld-table tbody tr:last-child { border-bottom: 0; }
  table.data.ld-table td { padding: 0; border: 0; }
  table.data.ld-table td.ld-col-check { grid-area: chk; padding-top: 2px; }
  table.data.ld-table td.ld-col-lead { grid-area: lead; }
  table.data.ld-table td.ld-col-tier { grid-area: tier; text-align: right; white-space: nowrap; }
  table.data.ld-table td.ld-col-status { grid-area: status; }
  table.data.ld-table td.ld-col-touch { grid-area: touch; }
  table.data.ld-table td.ld-col-last { grid-area: last; text-align: right; font-size: 12px; white-space: nowrap; }
  table.data.ld-table td.ld-col-last::before { content: "Last "; }
}

/* ================= Leads: detail ================= */
.ld-back { margin: -6px 0 10px; font-size: 14px; }
.ld-back a { text-decoration: none; color: var(--text-2); font-weight: 500; }
.ld-hero-pills { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.ld-hero-sub { color: var(--text); font-weight: 500; overflow-wrap: anywhere; }
.ld-kvs { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; margin: 8px 0 0; }
@media (min-width: 640px) { .ld-kvs { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 24px; } }
.ld-kv { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.ld-kv dt { color: var(--text-2); font-weight: 500; font-size: 13px; }
.ld-kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.ld-edit { margin-top: 12px; }
.ld-edit form { margin-top: 10px; }
.ld-edit input[type=text], .ld-edit select { max-width: none; }

.ld-action-list { display: grid; gap: 8px; }
.ld-inline { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; }
.ld-inline label { font-size: 13px; }
.ld-inline input[type=date] { width: auto; flex: 1 1 150px; max-width: 220px; }
.ld-act { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 2px 12px; }
.ld-act summary { padding: 8px 0; font-size: 14px; color: var(--text); }
.ld-sub { display: grid; gap: 6px; padding: 0 0 10px; }
.ld-sub label { font-size: 13px; }
.ld-sub .check { font-size: 14px; }
.ld-sub .btn { justify-self: start; }
.ld-danger { color: var(--bad-fg); border-color: var(--bad-line); }
.ld-danger:hover { background: var(--bad-bg); color: var(--bad-fg); border-color: var(--bad-line); }
.ld-note { display: grid; gap: 6px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.ld-note .btn { justify-self: start; }

.ld-grid { width: 100%; border-collapse: separate; border-spacing: 3px; table-layout: fixed; font-size: 12px; }
.ld-grid th { font-size: 11px; color: var(--text-3); font-weight: 500; text-align: left; padding: 2px 4px; }
.ld-grid thead th:first-child, .ld-grid tbody th { width: 34px; text-align: center; }
.ld-grid tbody th { font-variant-numeric: tabular-nums; color: var(--text); }
.ld-grid-ch { display: inline-flex; align-items: center; gap: 4px; }
.ld-grid td { vertical-align: top; padding: 0; }
.ld-cell { display: block; border-radius: 6px; padding: 4px 6px; margin-bottom: 3px; background: var(--surface-2); line-height: 1.25; border: 1px solid transparent; }
.ld-cell-label { display: block; font-weight: 600; overflow-wrap: anywhere; }
.ld-cell-date { display: block; font-size: 11px; opacity: 0.8; }
.ld-s-planned { background: var(--surface); border-color: var(--line-strong); color: var(--text); }
.ld-s-due { background: var(--info-bg); color: var(--info-fg); border-color: var(--info-line); }
.ld-s-overflow { background: var(--warn-bg); color: var(--warn-fg); border-color: var(--warn-line); }
.ld-s-done { background: var(--good-bg); color: var(--good-fg); border-color: var(--good-line); }
.ld-s-skipped { background: var(--surface-2); color: var(--text-2); }
.ld-s-cancelled { background: var(--surface-2); color: var(--text-3); text-decoration: line-through; }
.ld-today { box-shadow: inset 0 0 0 1.5px var(--text); }
.ld-legend { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0 0; }
.ld-legend-chip { display: inline-block; margin: 0; font-weight: 500; }
@media (max-width: 420px) { .ld-cell-date { display: none; } .ld-cell { padding: 3px 5px; } }

.ld-timeline { list-style: none; margin: 4px 0 0; padding: 0; }
.ld-tl { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.ld-tl:last-child { border-bottom: 0; }
.ld-tl-icon { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); }
.ld-tl-in .ld-tl-icon { background: var(--good-bg); color: var(--good-fg); }
.ld-tl-note .ld-tl-icon { background: var(--warn-bg); color: var(--warn-fg); }
.ld-tl-main { min-width: 0; }
.ld-tl-title { margin: 0; font-size: 14px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ld-tl-body { margin: 4px 0 0; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.ld-tl-message .ld-tl-body { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px; }
.ld-tl-when { margin: 2px 0 0; }

/* ================= Leads: import ================= */
.ld-paste { margin: 0 0 12px; }
.ld-paste textarea { margin-top: 8px; font-family: var(--mono); font-size: 13px; }
.ld-map td, .ld-map th { padding: 5px 8px; }
.ld-preview-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
.ld-preview { min-width: 640px; }
@media (max-width: 639px) {
  table.data.ld-preview { min-width: 0; }
  table.data.ld-preview thead { display: none; }
  table.data.ld-preview tr { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
  table.data.ld-preview td { border: 0; padding: 0; }
  table.data.ld-preview td:nth-child(n+3) { grid-column: 1 / -1; }
}
.tl-todo { margin: 8px 0 0; font-size: 14px; }
/* Today: "Check back" (not-now leads whose remind_on date has come) */
.tl-cb-list { list-style: none; margin: 8px 0 0; padding: 0; }
.tl-cb-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.tl-cb-list li:first-child { border-top: 0; }

/* Website lead sync: a "Website" badge on leads that came in through the site's booking form. */
.ld-src { font-size: 11px; padding: 0 6px; margin-right: 2px; vertical-align: 1px; }
/* Phase 5: the campaign chip on each lead row (a link that filters the list to that campaign). */
.ld-camp { display: inline-block; margin-top: 3px; font-size: 11px; padding: 0 6px; text-decoration: none; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ld-filter-wide select { max-width: 100%; }
.ld-inline select, .ld-sub select { max-width: 100%; }
.ld-camp-field { display: flex; flex-direction: column; gap: 2px; flex: 1 1 100%; min-width: 0; }
