/* Lead-gen automation v1: app-specific styles on top of the shared ui.css (don't restyle the kit here). */

.skip { position: absolute; left: -9999px; top: 0; }
.skip:focus { left: 12px; top: 8px; z-index: 20; background: var(--surface); padding: 6px 10px; border-radius: var(--radius-small); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.topbar .app-home { color: var(--text); text-decoration: none; }
.flash { margin-bottom: 16px; }
.section { margin-top: 24px; }
.section-tight { margin-top: 12px; }
.narrow { max-width: 640px; }
details > summary { color: var(--accent); }

/* Live updates */
.bumped { animation: bump 900ms ease-out; border-radius: 4px; }
@keyframes bump { from { background: var(--accent-weak); } to { background: transparent; } }
.refilled { animation: bump 900ms ease-out; }

/* ---- Overview: one row of pipeline steps plus revenue ---- */
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; grid-template-columns: repeat(5, minmax(0, 1fr)) minmax(0, 1.3fr); }
.steps .kpi { height: 100%; padding: 12px 14px; }
.steps .kpi-value { font-size: 1.7rem; }
@media (max-width: 1000px) { .steps { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) { .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } .steps .kpi-value { font-size: 1.45rem; } }

/* "Just arrived" after Simulate */
.arrivals { padding: 12px 16px; }
.arr-head h2 { font-size: 1rem; margin: 0 0 6px; }
.arrival-list { list-style: none; margin: 0 0 6px; padding: 0; display: grid; gap: 2px; }
.arrival { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; padding: 5px 8px; border-radius: var(--radius-small); font-size: 0.92rem; transition: opacity 200ms ease, translate 200ms ease; }
.arrival.arrival-pending { opacity: 0; translate: 0 6px; }
.arr-name { font-weight: 600; }
.arr-to { margin-left: auto; color: var(--muted); }

/* 14-day chart */
.bars { margin: 8px 0; }
.bars-plot { position: relative; height: 200px; padding-left: 28px; }
.bars-plot svg { width: 100%; height: 100%; display: block; overflow: visible; }
.bars-y { position: absolute; left: 0; font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; transform: translateY(-50%); }
.bars-y-top { top: 0; }
.bars-y-mid { top: 50%; }
.grid-line { stroke: var(--border); stroke-width: 1; vector-effect: non-scaling-stroke; }
.axis-line { stroke: var(--muted); stroke-width: 1; vector-effect: non-scaling-stroke; }
.hit { fill: transparent; }
g:hover > .hit { fill: var(--surface-2); }
.seg-valid { fill: var(--good); }
.seg-warnings { fill: var(--warn); }
.seg-invalid { fill: var(--bad); }
.seg-duplicate { fill: var(--bad); opacity: 0.45; }
.bars-x { display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); padding-left: 28px; margin-top: 4px; font-size: 0.72rem; color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; }
.bars-x span { white-space: nowrap; min-width: 0; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; font-size: 0.84rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.sw-valid { background: var(--good); }
.sw-warnings { background: var(--warn); }
.sw-invalid { background: var(--bad); }
.sw-duplicate { background: var(--bad); opacity: 0.45; }
details .table-wrap { margin-top: 8px; }

/* ---- Leads list ---- */
.filters { display: grid; gap: 8px; margin-bottom: 8px; }
.filter-main { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filter-main select { width: auto; flex: 0 1 220px; }
.filter-main input[type="search"] { flex: 1 1 220px; width: auto; min-width: 0; }
.more-filters > summary { font-size: 0.9rem; }
.filter-more { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); margin-top: 8px; }
.filter-more .field { display: grid; gap: 4px; }
.filter-more label { font-weight: 600; font-size: 0.86rem; }
.count-line { margin: 0 0 8px; }
.pager { display: flex; gap: 10px; align-items: center; justify-content: center; margin-top: 14px; }
.table tfoot th, .table tfoot td { border-top: 2px solid var(--border); border-bottom: 0; font-weight: 600; background: var(--surface-2); }
.table tfoot th { position: static; color: var(--text); font-size: inherit; }

/* ---- Lead page ---- */
.lead-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); align-items: start; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; }
.facts dt { color: var(--muted); font-size: 0.88rem; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 4px; }
.tl-item { position: relative; padding: 0 0 14px 20px; border-left: 2px solid var(--border); }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before { content: ""; position: absolute; left: -6px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--muted); }
.tl-assigned::before, .tl-replacement::before { border-color: var(--accent); background: var(--accent); }
.tl-pipedrive::before { border-color: var(--accent); }
.tl-feedback::before, .tl-credit::before { border-color: var(--warn); }
.tl-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 0.82rem; color: var(--muted); }
.tl-title { font-weight: 600; margin-top: 2px; }
.tl-detail { color: var(--text); font-size: 0.92rem; overflow-wrap: anywhere; }
.checks > summary, .crm > summary { color: var(--text); }
.crm > summary { font-weight: 400; color: var(--muted); }
.crm p { margin: 6px 0; }
.crm pre { max-height: 360px; font-size: 0.8rem; }
.checklist { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; }
.checklist .badge { min-width: 58px; text-align: center; }
.payload { margin-top: 6px; }
.payload pre { margin-top: 6px; max-height: 360px; font-size: 0.8rem; }
.timeline.card { padding: 16px 16px 16px 20px; }

/* ---- Submit ---- */
.submit-head { align-items: center; margin-bottom: 12px; }
.submit-head h1 { margin: 0; }
.refill { display: flex; align-items: center; gap: 10px; }
.icon-btn { font-size: 1.1rem; line-height: 1; min-width: 40px; justify-content: center; }
.lead-form { max-width: 640px; gap: 10px; }
.form.card.lead-form { align-self: start; }
.pair { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.field-error { color: var(--bad); font-size: 0.84rem; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400 !important; }
.check input { margin-top: 4px; width: 18px; height: 18px; flex: none; }
.api { max-width: 640px; }
.api > summary { font-weight: 600; }
pre.code { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.8rem; }

/* ---- Brokers and portal ---- */
.cap { width: 100%; max-width: 120px; height: 8px; display: block; margin-bottom: 4px; }
.cap-bg { fill: var(--surface-2); }
.cap-fill { fill: var(--accent); }
.cap-fill.full { fill: var(--warn); }
.cap-cell { min-width: 110px; }
.cantons { font-family: var(--mono); font-size: 0.84rem; min-width: 120px; }
.portal-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.portal-item { display: grid; gap: 6px; padding: 12px 14px; }
.portal-head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.portal-result { display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.feedback { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.feedback select { width: auto; min-width: 0; flex: 0 1 200px; }
.answered > summary h2 { display: inline; font-size: 1.2rem; }
.answered > summary { color: var(--text); margin-bottom: 10px; }

/* ---- Billing and invoice ---- */
.month-picker { display: flex; align-items: center; gap: 6px; }
.month-picker select { width: auto; }
.invoice { max-width: 820px; padding: 24px; }
.inv-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.inv-seller { font-weight: 700; font-size: 1.1rem; }
.inv-to { min-width: 200px; }
.inv-title { font-size: 1.3rem; }
.inv-facts { margin-bottom: 16px; }

/* ---- How it works ---- */
.rules { list-style: none; margin: 0; padding: 4px 16px; }
.rule { padding: 12px 0; border-bottom: 1px solid var(--border); }
.rule:last-child { border-bottom: 0; }
.rule-title { font-weight: 600; color: var(--text); }
.rule-sum { color: var(--text); }
.rule details > summary { color: var(--text); }
.rule details > summary .rule-title::after { content: " ·"; color: var(--muted); }
.rule-body { padding: 4px 0 0 18px; }
.rule-body h3 { margin-top: 12px; font-size: 0.95rem; }
.rule-body ul { padding-left: 1.25rem; margin: 0 0 0.5rem; }
.rule-body li + li { margin-top: 4px; }
.rule-body code { overflow-wrap: anywhere; }

/* ---- Phones: the columns that matter ---- */
@media (max-width: 640px) {
  .hide-sm { display: none; }
  .lead-grid { grid-template-columns: minmax(0, 1fr); }
  .facts { grid-template-columns: 1fr; gap: 0; }
  .facts dd { margin-bottom: 8px; }
  .invoice { padding: 16px; }
  .arr-to { margin-left: 0; width: 100%; }
  .page-head .row form, .page-head .row .btn { flex: 1 1 auto; }
  .page-head .row form .btn { width: 100%; justify-content: center; }
  .submit-head { flex-wrap: nowrap; }
  .bars-plot { height: 160px; }
  .bars-x span:nth-child(even) { visibility: hidden; }
}

@media print {
  .topbar, .footer, .no-print, .breadcrumb, .skip { display: none !important; }
  body { background: #fff; color: #000; }
  .card { border: 0; box-shadow: none; }
}
