/* Insights (attribution reporting). Mobile first; a wide two-column layout from 1000px. */
.ins-sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.ins-head h1 { margin: 0; font-size: 1.75rem; letter-spacing: -0.01em; }
.ins-span { margin: 2px 0 12px; color: var(--muted); font-weight: 600; }

/* Range chips */
.ins-ranges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.ins-chip {
  display: inline-flex; align-items: center; min-height: 40px; padding: 6px 12px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text);
  font-weight: 600; font-size: 0.875rem; text-decoration: none; white-space: nowrap;
}
.ins-chip.is-active { background: var(--brand); border-color: var(--brand); color: var(--brand-contrast); }
.ins-chip:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.ins-custom { margin-bottom: 16px; }
.ins-custom-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; align-items: end; }
.ins-custom-fields input { min-width: 0; }
.ins-custom-fields .btn { grid-column: span 2; }
.ins-error { margin: 0 0 12px; color: var(--danger); font-weight: 600; }

/* KPI tiles */
.ins-kpis { display: grid; gap: 0 16px; }
.ins-kpi-group { display: flex; flex-direction: column; }
.ins-kpi-grid { flex: 1; display: grid; gap: 10px; margin-bottom: 20px; }
.ins-kpi-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ins-kpi-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ins-kpi {
  container-type: inline-size; min-width: 0; padding: 12px; display: flex; flex-direction: column; gap: 2px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: inset 0 3px 0 var(--brand), var(--shadow);
}
.ins-kpi-label { font-size: 0.78rem; font-weight: 700; line-height: 1.25; color: var(--muted); }
.ins-kpi-3 .ins-kpi-label { min-height: 2.5em; }
.ins-kpi-value {
  font-size: 1.75rem; font-weight: 800; line-height: 1.15; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
/* Money fits its tile: "$175,000.00" is about 6.6em wide in bold tabular digits. */
.ins-kpi-money .ins-kpi-value { font-size: min(1.5rem, 14.5cqi); }
.ins-kpi-sub { font-size: 0.78rem; color: var(--muted); }
.ins-kpi-margin { box-shadow: inset 0 3px 0 var(--ok), var(--shadow); }
.ins-kpi-margin .ins-kpi-value { color: var(--ok); }
.ins-kpi-margin.is-negative { box-shadow: inset 0 3px 0 var(--danger), var(--shadow); }
.ins-kpi-margin.is-negative .ins-kpi-value { color: var(--danger); }

/* Cards */
.ins-layout { display: flex; flex-direction: column; }
.ins-side, .ins-main { display: contents; }  /* phones: one column, notes last */
.ins-notes { order: 1; }
.ins-card { overflow: hidden; margin-bottom: 16px; }
.ins-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.ins-card-title { margin: 0; font-size: 1.05rem; }
.ins-card-sub { margin: 4px 0 16px; color: var(--muted); font-size: 0.875rem; }
.ins-csv svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ins-empty { margin: 0; color: var(--muted); }

/* Funnel */
.ins-funnel { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.ins-step-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.ins-step-label { font-weight: 600; }
.ins-step-count { font-size: 1.25rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.ins-bar { height: 12px; margin: 6px 0 4px; border-radius: 999px; background: #eef1f5; overflow: hidden; }
.ins-bar span { display: block; height: 100%; border-radius: inherit; background: var(--brand); }
.ins-step-paid .ins-bar span { background: var(--ok); }
.ins-step-meta { font-size: 0.8rem; color: var(--muted); }

/* Tables: scroll sideways on phones with the name column pinned */
.ins-table-wrap {
  margin: 0 -16px -16px; overflow-x: auto; -webkit-overflow-scrolling: touch;
  border-top: 1px solid var(--border);
}
.ins-table-wrap:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.ins-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.875rem; font-variant-numeric: tabular-nums; }
.ins-table th, .ins-table td { padding: 10px; border-bottom: 1px solid var(--border); white-space: nowrap; text-align: left; vertical-align: middle; }
.ins-table .num { text-align: right; }
.ins-table thead th {
  padding-top: 8px; padding-bottom: 8px; background: #f8f9fb; color: var(--muted);
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
}
.ins-table abbr { text-decoration: none; }
.ins-table th:first-child {
  position: sticky; left: 0; z-index: 1; padding-left: 16px; background: var(--surface);
  box-shadow: 1px 0 0 var(--border);
}
.ins-table thead th:first-child, .ins-table tfoot th:first-child { background: #f8f9fb; }
.ins-table th:last-child, .ins-table td:last-child { padding-right: 16px; }
.ins-table tbody th { font-weight: 600; }
.ins-table tbody th { white-space: normal; min-width: 6.5rem; max-width: 8.5rem; overflow-wrap: break-word; line-height: 1.3; }
.ins-row-none th, .ins-row-none td { color: var(--muted); }
.ins-row-none th { font-weight: 500; font-style: italic; }
.ins-table tfoot th, .ins-table tfoot td { border-bottom: 0; background: #f8f9fb; font-weight: 800; }
.ins-table td.ins-rev { position: relative; min-width: 7.5rem; }
.ins-rev-bar {
  position: absolute; left: 10px; right: 10px; bottom: 5px; height: 4px;
  border-radius: 999px; background: #eef1f5; overflow: hidden;
}
.ins-rev-bar span { display: block; height: 100%; border-radius: inherit; background: var(--brand); }
.ins-neg { color: var(--danger); }

/* How we count */
.ins-defs { margin: 8px 0 0; }
.ins-defs dt { margin-top: 12px; font-size: 0.875rem; font-weight: 700; }
.ins-defs dt:first-child { margin-top: 0; }
.ins-defs dd { margin: 2px 0 0; color: var(--muted); font-size: 0.875rem; }

@media (min-width: 700px) {
  .ins-custom { max-width: 560px; }
  .ins-custom-fields { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
  .ins-custom-fields .btn { grid-column: auto; margin-bottom: 14px; }
  .ins-kpi-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .ins-kpi-4 .ins-kpi-label { min-height: 2.5em; }
}

@media (min-width: 1000px) {
  .insights-page .page, .insights-page .topbar-inner { max-width: 1280px; }
  .ins-kpis { grid-template-columns: minmax(0, 3fr) minmax(0, 5fr); }
  .ins-kpi { padding: 14px 16px; }
  .ins-layout { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 0 20px; align-items: start; }
  .ins-side, .ins-main { display: block; }
  .ins-table tbody th { max-width: 13rem; }
}
