/* ==========================================================================
   Insights (BI) page — sits on the same graphite/champagne theme as Leads.
   Chart colours are validated data-viz slots (see insights.js), kept apart
   from the brand champagne so data never looks like decoration.
   ========================================================================== */
.insights-page {
  --viz-1: #2a78d6;      /* single-series bars, map, "Leads" */
  --viz-2: #1baf7a;      /* "Won" */
  --viz-3: #eb6834;      /* "Lost" */
  --viz-grid: #eceef1;
  --viz-axis: #6b7480;
  --ramp-1: #86b6ef; --ramp-2: #5598e7; --ramp-3: #2a78d6; --ramp-4: #1c5cab; --ramp-5: #104281;
}

.cluster__body--insights { padding-bottom: 6px; }

/* date range control in the band */
.range { display: inline-flex; padding: 3px; gap: 2px; border-radius: 999px; background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .08); }
.range button {
  border: 0; background: transparent; color: #aeb5be; font-weight: 600; font-size: 13px;
  padding: 7px 14px; border-radius: 999px; cursor: pointer; transition: background .15s, color .15s;
}
.range button:hover { color: #fff; }
.range button.is-on { background: var(--champagne); color: var(--graphite); }
.range button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* grid */
.bi { margin-top: -44px; }
.bi-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.bi-grid[aria-busy="true"] .panel__body { opacity: .45; }
.span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; } .span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; }

.panel {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 20px 16px; min-width: 0; display: flex; flex-direction: column;
}
.panel__head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.panel__head > div { flex: 1; min-width: 0; }
.panel h2 { margin: 0; font-variation-settings: var(--wide); font-weight: 700; font-size: 15.5px; color: var(--graphite); }
.panel__lede { margin: 4px 0 0; color: var(--text-2); font-size: 13px; line-height: 1.45; }
.panel__toggle {
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-size: 12px; font-weight: 600;
  padding: 4px 10px; border-radius: 999px; cursor: pointer; flex: none;
}
.panel__toggle:hover { border-color: var(--border-strong); color: var(--graphite); }
.panel__toggle[aria-pressed="true"] { background: var(--graphite); color: #fff; border-color: var(--graphite); }
.panel__toggle:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.panel__body { flex: 1; transition: opacity .2s; }
.panel__table { overflow: auto; max-height: 360px; }
.panel__table table { width: 100%; border-collapse: collapse; font-size: 13px; }
.panel__table th { text-align: left; color: var(--muted); font-weight: 600; padding: 7px 8px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface); }
.panel__table td { padding: 7px 8px; border-bottom: 1px solid #f0f1f3; font-variant-numeric: tabular-nums; }
.panel__table td.num, .panel__table th.num { text-align: right; }

.chart { position: relative; }
.chart--md { height: 260px; }
.chart--tall { height: 300px; }   /* horizontal charts: JS sets height from row count */

/* map */
.map { height: 340px; border-radius: 10px; overflow: hidden; background: #e9edf1; z-index: 0; }
.map--muted .leaflet-tile-pane { filter: saturate(.8) brightness(1.03); }   /* OSM colours, slightly softened so the lead circles stand out */
.map__legend { margin: 10px 0 0; font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.map__dot { width: 12px; height: 12px; border-radius: 50%; background: var(--viz-1); opacity: .7; box-shadow: 0 0 0 2px #fff; }
.leaflet-tooltip.city-tip {
  font-family: var(--font); background: var(--graphite); color: #fff; border: 0; border-radius: 8px;
  padding: 8px 10px; box-shadow: var(--shadow-lg); font-size: 12.5px; line-height: 1.45;
}
.leaflet-tooltip.city-tip::before { display: none; }
.leaflet-tooltip.city-tip b { font-variation-settings: var(--wide); font-size: 13px; }
.leaflet-container { font-family: var(--font); }

/* funnel — each step is a centred bar; width = share of all leads */
.funnel { display: grid; gap: 6px; padding-top: 4px; }
.funnel__row { display: grid; grid-template-columns: 92px 1fr 128px; align-items: center; gap: 12px; }
.funnel__label { font-size: 13px; font-weight: 600; color: var(--text); }
.funnel__track { height: 34px; display: flex; justify-content: center; }
.funnel__bar {
  height: 100%; border-radius: 4px; min-width: 4px; display: flex; align-items: center; justify-content: center;
  color: #fff; font-variation-settings: var(--wide); font-weight: 700; font-size: 13px;
  transition: width .6s cubic-bezier(.2, .8, .2, 1);
}
.funnel__bar.is-light { color: var(--graphite); }
.funnel__meta { font-size: 12px; color: var(--muted); text-align: right; line-height: 1.3; }
.funnel__meta b { color: var(--text); font-weight: 600; }
.funnel__lost { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--text-2); line-height: 1.5; }
.funnel__lost b { color: var(--text); }
@media (prefers-reduced-motion: reduce) { .funnel__bar { transition: none; } }

.bi-foot { color: var(--muted); font-size: 12px; margin: 18px 2px 0; }

@media (max-width: 1100px) {
  .span-4, .span-5, .span-7, .span-8 { grid-column: span 12; }
}
@media (max-width: 720px) {
  .bi-grid { gap: 12px; }
  .panel { padding: 16px; }
  .funnel__row { grid-template-columns: 80px 1fr 70px; gap: 8px; }
  .map { height: 280px; }
}

.city-tip__hint { display: inline-block; margin-top: 3px; font-size: 11px; opacity: .75; }

/* ── Lead status donut ── */
.status { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.status__donut { position: relative; width: 210px; height: 210px; }
.status__center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; }
.status__center b { font-variation-settings: var(--wide); font-size: 34px; font-weight: 800; line-height: 1; color: var(--text); }
.status__center span { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.status__legend { width: 100%; display: grid; gap: 2px; }
.status__row {
  display: grid; grid-template-columns: 14px 1fr auto 46px; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: 10px; text-decoration: none; color: var(--text); transition: background .15s ease, opacity .2s ease;
}
.status__row:hover, .status__row.is-on { background: var(--surface-2); }
.status__row.is-dim { opacity: .4; }
.status__row:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.status__swatch { width: 12px; height: 12px; border-radius: 3px; }
.status__row b { font-size: 13.5px; font-weight: 600; }
.status__row small { display: block; font-size: 11.5px; color: var(--muted); }
.status__count { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.status__pct { font-size: 12.5px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.status__hint { margin: auto 0 0; align-self: flex-start; font-size: 11.5px; color: var(--muted); }
/* the weekly trend sits beside the status donut — match its height on wide screens */
@media (min-width: 1101px) { [data-panel="trend"] .chart { height: 400px; } }