/* ============================================================
   Concierge Desk — Funnel & leak report
   ------------------------------------------------------------
   FLAGGED semantic extensions. Each leak token maps onto an
   EXISTING base token (no new raw hex):
     --ha-leak-demand  -> navy ramp  (--ha-blue-primary-soft)  A/B/C demand leaks
     --ha-leak-supply  -> danger     (--ha-danger)             fulfillment problems
     --ha-leak-neutral -> ink-muted  (--ha-ink-muted)          non-leak / neutral
   Funnel bars reuse the --ha-status-* palette from desk_tokens.css.
   Color is ALWAYS paired with a text label in the markup — never color alone.
   ============================================================ */
:root {
  --ha-leak-demand: var(--ha-blue-primary-soft);
  --ha-leak-supply: var(--ha-danger);
  --ha-leak-neutral: var(--ha-ink-muted);
}

.report {
  max-width: 880px;
  margin: 0 auto;
  padding: var(--ha-space-6) var(--ha-space-6) var(--ha-space-12);
  overflow-y: auto;
}

.report-head {
  display: flex; flex-wrap: wrap; gap: var(--ha-space-4);
  align-items: flex-end; justify-content: space-between;
  margin-bottom: var(--ha-space-6);
}
.report-sub { color: var(--ha-ink-muted); font-size: var(--ha-fs-small); margin-top: 4px; }

.report-range { display: flex; align-items: flex-end; gap: var(--ha-space-2); }
.report-field { display: flex; flex-direction: column; gap: 4px; font-size: var(--ha-fs-caption); color: var(--ha-ink-muted); }
.report-date {
  height: 34px; border: 1px solid var(--ha-border); border-radius: var(--ha-radius-md);
  padding: 0 10px; font: inherit; font-size: 13px; color: var(--ha-ink); background: var(--ha-surface);
}
.report-apply {
  height: 34px; padding: 0 16px; border: 0; border-radius: var(--ha-radius-pill);
  background: var(--ha-blue-primary); color: var(--ha-surface); font: inherit;
  font-size: 13px; font-weight: var(--ha-weight-medium); cursor: pointer;
}
.report-apply:hover { background: var(--ha-blue-primary-alt); }

.report-lowvol {
  background: var(--ha-accent-tint); border: 1px solid var(--ha-ai-border);
  border-radius: var(--ha-radius-md); padding: var(--ha-space-3) var(--ha-space-4);
  font-size: var(--ha-fs-small); color: var(--ha-ink); margin-bottom: var(--ha-space-6);
}

.report-block { margin-bottom: var(--ha-space-10); }
.report-block-h {
  font-size: var(--ha-fs-body-lg); font-weight: var(--ha-weight-bold);
  margin: 0 0 var(--ha-space-4); letter-spacing: -0.005em;
}
.report-block-note { color: var(--ha-ink-muted); font-weight: var(--ha-weight-book); font-size: var(--ha-fs-small); }
.report-empty { color: var(--ha-ink-muted); font-size: var(--ha-fs-small); padding: var(--ha-space-4) 0; }

/* tabular-nums everywhere numbers line up */
.tnum { font-variant-numeric: tabular-nums; }

/* ---- Funnel drop-off bars ---- */
.funnel { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.funnel-row {
  display: grid;
  grid-template-columns: 130px 1fr 56px 150px;
  align-items: center; gap: var(--ha-space-3);
}
.funnel-label { font-size: var(--ha-fs-small); color: var(--ha-ink); }
.funnel-track {
  height: 18px; background: var(--ha-surface-subtle);
  border-radius: var(--ha-radius-xs); overflow: hidden;
}
.funnel-bar {
  display: block; height: 100%; border-radius: var(--ha-radius-xs);
  min-width: 2px; transition: width 240ms ease;
}
.funnel-bar.s-new { background: var(--ha-status-new); }
.funnel-bar.s-contacted { background: var(--ha-status-contacted); }
.funnel-bar.s-collecting_details { background: var(--ha-status-collecting); }
.funnel-bar.s-ready_to_offer { background: var(--ha-status-ready); }
.funnel-bar.s-offered { background: var(--ha-status-offered); }
.funnel-bar.s-quoted { background: var(--ha-status-quoted); }
.funnel-bar.s-presented { background: var(--ha-status-presented); }
.funnel-bar.s-accepted { background: var(--ha-status-accepted); }
.funnel-bar.s-scheduled { background: var(--ha-status-scheduled); }
.funnel-bar.s-fulfilled { background: var(--ha-status-fulfilled); }

.funnel-count { font-size: var(--ha-fs-small); font-weight: var(--ha-weight-medium); text-align: right; }
.funnel-step { display: flex; gap: var(--ha-space-2); justify-content: flex-end; font-size: var(--ha-fs-caption); }
.funnel-kept { color: var(--ha-success); font-weight: var(--ha-weight-medium); }
.funnel-lost { color: var(--ha-ink-muted); }

.funnel-terminal { list-style: none; display: flex; gap: var(--ha-space-3); margin: var(--ha-space-4) 0 0; padding: 0; }
.term-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--ha-fs-small); color: var(--ha-ink);
  border: 1px solid var(--ha-border); border-radius: var(--ha-radius-pill);
  padding: 4px var(--ha-space-3);
}
.term-dot { width: 8px; height: 8px; border-radius: 50%; }
.term-chip.is-hold .term-dot { background: var(--ha-status-onhold); }
.term-chip.is-lost .term-dot { background: var(--ha-status-lost); }

/* ---- Leak bucket panels ---- */
.leak-panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--ha-space-4); }
.leak-panel {
  border: 1px solid var(--ha-border); border-left: 3px solid var(--leak-accent);
  border-radius: var(--ha-radius-md); padding: var(--ha-space-4); background: var(--ha-surface);
}
.leak-panel.is-dominant { box-shadow: var(--ha-shadow-card); border-color: var(--leak-accent); }
.leak-panel-head { display: flex; align-items: center; gap: var(--ha-space-2); margin-bottom: var(--ha-space-3); }
.leak-swatch { width: 10px; height: 10px; border-radius: 2px; background: var(--leak-accent); flex: none; }
.leak-panel-h { font-size: var(--ha-fs-small); font-weight: var(--ha-weight-bold); margin: 0; flex: 1; }
.leak-badge {
  display: inline-block; margin-left: 6px; font-size: 11px; font-weight: var(--ha-weight-medium);
  color: var(--ha-surface); background: var(--leak-accent); border-radius: var(--ha-radius-pill);
  padding: 1px 8px; letter-spacing: 0.01em;
}
.leak-subtotal { font-size: var(--ha-fs-body-lg); font-weight: var(--ha-weight-bold); }
.leak-share { font-size: var(--ha-fs-caption); color: var(--ha-ink-muted); margin-left: 4px; font-weight: var(--ha-weight-book); }
.leak-reasons { margin: 0; }
.leak-reason { display: flex; justify-content: space-between; gap: var(--ha-space-2); padding: 4px 0; border-top: 1px solid var(--ha-border-strong); }
.leak-reason dt { font-size: var(--ha-fs-small); color: var(--ha-ink-muted); text-transform: capitalize; }
.leak-reason dd { margin: 0; font-size: var(--ha-fs-small); font-weight: var(--ha-weight-medium); }
.leak-reason-share { color: var(--ha-ink-muted); font-weight: var(--ha-weight-book); margin-left: 4px; }

/* ---- Reliability table ---- */
.report-internal {
  display: inline-flex; align-items: center; gap: 6px; font-size: var(--ha-fs-caption);
  color: var(--ha-danger); margin: 0 0 var(--ha-space-3);
}
.report-internal-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ha-danger); }
.report-tablewrap { overflow-x: auto; }
.rel-table { width: 100%; border-collapse: collapse; font-size: var(--ha-fs-small); }
.rel-table th, .rel-table td { text-align: left; padding: 8px var(--ha-space-3); border-bottom: 1px solid var(--ha-border-strong); }
.rel-table td.tnum, .rel-table th.tnum { text-align: right; }
.rel-table thead th { color: var(--ha-ink-muted); font-weight: var(--ha-weight-medium); font-size: var(--ha-fs-caption); }
.rel-table tbody th { font-weight: var(--ha-weight-medium); }
.rel-sort { color: inherit; text-decoration: none; display: inline-flex; gap: 4px; align-items: center; }
.rel-sort:hover { color: var(--ha-blue-text); }
.rel-sort.is-active { color: var(--ha-ink); font-weight: var(--ha-weight-bold); }
.rel-caret { font-size: 9px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

:focus-visible { outline: none; box-shadow: var(--ha-focus-ring); border-radius: var(--ha-radius-xs); }

@media (prefers-reduced-motion: reduce) {
  .funnel-bar { transition: none; }
}
