/* Stats Dashboard — dc.js layout, overrides, dark mode */

/* ── Tab navigation ──────────────────────────────────── */

/* Sticky container for the top-level tab bar.
   The bar itself stays as a normal flex row; .analytics-shell-nav is the
   pin point so the heading + subtitle scroll away while the tab strip
   stays anchored. Backdrop blur keeps charts behind it readable. */
.analytics-shell-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  margin-bottom: 1.5rem;
  background: rgb(var(--color-bg-primary) / 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.analytics-shell-nav > .stats-tab-bar {
  margin-bottom: 0;
}

.stats-tab-bar {
  display: flex;
  gap: 0;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid rgb(var(--color-border));
}

/* Mobile: dropdown replaces tab buttons */
.stats-tab-select {
  display: none;
  width: 100%;
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
  font-size: 0.9375rem;
  font-weight: 600;
  color: rgb(var(--color-text-primary));
  background-color: rgb(var(--color-bg-secondary));
  border: 2px solid rgb(var(--color-border));
  border-radius: 0.5rem;
  cursor: pointer;
  appearance: auto;
}

@media (max-width: 768px) {
  .stats-tab-bar { display: none; }
  .stats-tab-select { display: block; }
}

.stats-tab {
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: rgb(var(--color-text-muted));
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.stats-tab:hover {
  color: rgb(var(--color-text-primary));
}

.stats-tab--active {
  color: rgb(var(--color-primary));
  border-bottom-color: rgb(var(--color-primary));
}

.stats-tab-content {
  display: none;
}

.stats-tab-content--active {
  display: block;
}

#overview-tab.stats-tab-content--active {
  display: flex !important;
  flex-direction: column;
  gap: 1.5rem;
}

/* ── Dashboard grid ───────────────────────────────────── */

.stats-dashboard {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.stats-kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.stats-kpi-card {
  background: rgb(var(--color-bg-secondary));
  border: 1px solid rgb(var(--color-border));
  border-radius: 0.5rem;
  padding: 1rem 1.25rem;
  text-align: center;
}

.stats-kpi-card .kpi-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgb(var(--color-text-muted));
  margin-bottom: 0.25rem;
}

.stats-kpi-card .kpi-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: rgb(var(--color-text-primary));
  line-height: 1.2;
}

.stats-kpi-card .kpi-sub {
  font-size: 0.75rem;
  color: rgb(var(--color-text-muted));
  margin-top: 0.25rem;
}

/* ── Filter bar ───────────────────────────────────────── */

.stats-filter-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: rgb(var(--color-bg-secondary));
  border: 1px solid rgb(var(--color-border));
  border-radius: 0.5rem;
  min-height: 2.75rem;
}

.stats-filter-bar.empty {
  display: none;
}

.stats-filter-bar .filter-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgb(var(--color-text-muted));
  margin-right: 0.25rem;
}

.stats-filter-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.5rem;
  background: rgb(var(--color-primary) / 0.12);
  color: rgb(var(--color-primary));
  border-radius: 0.25rem;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: default;
}

.stats-filter-tag .filter-remove {
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  opacity: 0.6;
  transition: opacity 0.15s;
}

.stats-filter-tag .filter-remove:hover {
  opacity: 1;
}

.stats-reset-all {
  margin-left: auto;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: rgb(var(--color-error));
  background: rgb(var(--color-error) / 0.1);
  border: none;
  border-radius: 0.25rem;
  cursor: pointer;
  transition: background 0.15s;
}

.stats-reset-all:hover {
  background: rgb(var(--color-error) / 0.2);
}

/* ── Page-level controls row (above the chart grid) ──
   Two reserved zones: left for future page slicers (date-window etc.),
   right for display options (Show numbers, future density/theme). */

.stats-page-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: -0.5rem;
}

.stats-page-controls-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1 1 auto;
  min-width: 0;
}

.stats-page-controls-left:empty {
  display: none;
}

.stats-page-controls-right {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 0 0 auto;
}

.stats-controls-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: rgb(var(--color-text-secondary));
  cursor: pointer;
  user-select: none;
}

.stats-controls-toggle input[type="checkbox"] {
  width: 0.875rem;
  height: 0.875rem;
  margin: 0;
  accent-color: rgb(var(--color-primary));
  cursor: pointer;
}

/* ── Chart grid ───────────────────────────────────────── */

.stats-chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.stats-chart-grid .chart-span-full {
  grid-column: 1 / -1;
}

.stats-chart-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1.5rem;
}

.stats-chart-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

/* ── Chart container ──────────────────────────────────── */

.stats-chart-box {
  background: rgb(var(--color-bg-secondary));
  border: 1px solid rgb(var(--color-border));
  border-radius: 0.5rem;
  padding: 1rem 1.25rem;
  overflow: hidden;
}

.stats-chart-box .chart-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.stats-chart-box .chart-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: rgb(var(--color-text-primary));
}

.stats-chart-box .chart-reset {
  font-size: 0.6875rem;
  color: rgb(var(--color-primary));
  cursor: pointer;
  text-decoration: none;
  visibility: hidden;
}

.stats-chart-box .chart-reset:hover {
  text-decoration: underline;
}

.stats-chart-box .chart-drill-back {
  font-size: 0.6875rem;
  color: rgb(var(--color-primary));
  cursor: pointer;
  text-decoration: none;
  margin-left: 0.5rem;
  margin-right: auto;
  font-weight: 600;
}

.stats-chart-box .chart-drill-back:hover {
  text-decoration: underline;
}

.stats-chart-box .chart-mode-toggle {
  display: inline-flex;
  align-items: center;
  margin-left: auto;
}

.stats-chart-box .chart-mode-toggle + .chart-reset,
.stats-chart-box .chart-gear-btn + .chart-reset,
.stats-chart-box .chart-gear-btn + .chart-drill-back {
  margin-left: 0.5rem;
}

.stats-chart-box .chart-mode-btn {
  font-size: 0.6875rem;
  line-height: 1.25;
  padding: 0.125rem 0.5rem;
  border: 1px solid rgb(var(--color-border));
  background: transparent;
  color: rgb(var(--color-text-secondary));
  cursor: pointer;
  font-family: inherit;
}

.stats-chart-box .chart-mode-btn:first-child {
  border-top-left-radius: 0.25rem;
  border-bottom-left-radius: 0.25rem;
}

.stats-chart-box .chart-mode-btn:last-child {
  border-top-right-radius: 0.25rem;
  border-bottom-right-radius: 0.25rem;
}

.stats-chart-box .chart-mode-btn + .chart-mode-btn {
  border-left: none;
}

.stats-chart-box .chart-mode-btn:hover {
  background: rgb(var(--color-text-muted) / 0.08);
  color: rgb(var(--color-text-primary));
}

.stats-chart-box .chart-mode-btn--active {
  background: rgb(var(--color-primary) / 0.12);
  color: rgb(var(--color-primary));
  border-color: rgb(var(--color-primary) / 0.4);
  font-weight: 600;
}

/* ── Per-visual options gear + popover ──
   Inline click-mode toggle handles the high-frequency switch; the gear
   opens a popover for less-frequent options (granularity, future
   sort/cap/chart-type). Mounted on every chart-box; hidden when the
   chart has no options to expose (no drill, no future sort, …). */

.stats-chart-box .chart-gear-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  margin-left: 0.5rem;
  padding: 0;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 0.25rem;
  color: rgb(var(--color-text-secondary));
  cursor: pointer;
  font-family: inherit;
}

.stats-chart-box .chart-gear-btn:hover,
.stats-chart-box .chart-gear-btn[aria-expanded="true"] {
  background: rgb(var(--color-text-muted) / 0.08);
  color: rgb(var(--color-text-primary));
  border-color: rgb(var(--color-border));
}

.stats-chart-box .chart-gear-btn svg {
  width: 0.95rem;
  height: 0.95rem;
  display: block;
}

.stats-chart-box .chart-gear-btn[hidden] {
  display: none;
}

/* Popover anchors to the chart-box (not the body) so it scrolls with the
   chart and inherits the dashboard's stacking context. Arrow points up at
   the gear. */
.stats-chart-box {
  position: relative;
}

.chart-options-popover {
  position: absolute;
  top: 2.5rem;
  right: 0.75rem;
  z-index: 30;
  min-width: 13rem;
  max-width: 18rem;
  background: rgb(var(--color-bg-secondary));
  border: 1px solid rgb(var(--color-border));
  border-radius: 0.5rem;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.15);
  padding: 0.75rem 0.875rem;
  font-size: 0.75rem;
}

.chart-options-popover[hidden] {
  display: none;
}

.chart-options-section + .chart-options-section {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgb(var(--color-border));
}

.chart-options-section-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: rgb(var(--color-text-secondary));
  margin: 0 0 0.4rem;
}

.chart-options-radio {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0;
  cursor: pointer;
  color: rgb(var(--color-text-primary));
}

.chart-options-radio input[type="radio"] {
  width: 0.875rem;
  height: 0.875rem;
  margin: 0;
  accent-color: rgb(var(--color-primary));
  cursor: pointer;
}

.chart-options-radio span {
  flex: 1 1 auto;
}

.stats-chart-box .chart-toggle {
  font-size: 0.6875rem;
  color: rgb(var(--color-text-secondary));
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  user-select: none;
}

.stats-chart-box .chart-toggle input[type="checkbox"] {
  width: 0.75rem;
  height: 0.75rem;
  margin: 0;
  accent-color: rgb(var(--color-primary));
}

/* ── dc.js overrides ──────────────────────────────────── */

.dc-chart .bar {
  shape-rendering: crispEdges;
}

/* Selectors below match (or exceed) dc.min.css's specificity so they win even
   when dc.min.css is loaded later (judge-detail / rep-detail include it
   inline). Without these, dc defaults (e.g. fill:#fff on row labels) make
   the text invisible on the light-mode page background where row labels
   extend beyond their bar. */

.dc-chart g.axis text {
  font-size: 0.6875rem;
  fill: rgb(var(--color-text-secondary));
}

.dc-chart g.axis line,
.dc-chart g.axis path {
  stroke: rgb(var(--color-text-muted) / 0.4);
  stroke-opacity: 1;
}

.dc-chart g.row text {
  font-size: 0.75rem;
  fill: rgb(var(--color-text-primary));
}

.dc-chart g.pie-slice text,
.dc-chart .pie-label {
  font-size: 0.6875rem;
  font-weight: 500;
  fill: rgb(var(--color-text-primary));
}

/* Bar chart value labels rendered on/above bars */
.dc-chart g.bar text,
.dc-chart .bar text,
.dc-chart .barLabel {
  fill: rgb(var(--color-text-primary));
  font-size: 0.625rem;
  font-variant-numeric: tabular-nums;
}

/* Row chart value labels (custom, rendered at right edge by stats-framework.js) */
.dc-chart .row-value-label {
  fill: rgb(var(--color-text-primary));
  font-size: 0.6875rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.dc-chart .pie-slice {
  cursor: pointer;
}

.dc-chart g.row {
  cursor: pointer;
}

/* Number display */
.dc-chart .number-display {
  font-size: 1.75rem;
  font-weight: 700;
}

/* ── Case cards section ──────────────────────────────── */

.stats-cards-section {
  margin-top: 2rem;
}

.stats-cards-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.stats-cards-summary {
  font-size: 0.875rem;
  font-weight: 600;
  color: rgb(var(--color-text-secondary));
}

.stats-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1rem;
}

/* Card overrides for stats view — compact variant */
.stats-case-card {
  padding: 1rem 1.25rem;
  margin-bottom: 0;
  background: rgb(var(--color-bg-secondary));
  border: 1px solid rgb(var(--color-border));
  border-radius: 0.5rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.stats-case-card:hover {
  border-color: rgb(var(--color-primary) / 0.3);
  box-shadow: var(--shadow-md);
}

.stats-card-header {
  margin-bottom: 0.5rem;
}

.stats-card-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.stats-card-case-number {
  font-size: 1rem;
  font-weight: 700;
  color: rgb(var(--color-text-primary));
  text-decoration: none;
  transition: color 0.15s;
}

.stats-card-case-number:hover {
  color: rgb(var(--color-primary));
}

.stats-card-action-type {
  font-size: 0.8125rem;
  color: rgb(var(--color-text-secondary));
  margin-top: 0.125rem;
}

.stats-card-info {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-bottom: 0.5rem;
}

.stats-card-info-item {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.8125rem;
  color: rgb(var(--color-text-secondary));
}

.stats-card-info-icon {
  font-size: 0.875rem;
  flex-shrink: 0;
}

.stats-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid rgb(var(--color-border-light, var(--color-border)));
  font-size: 0.75rem;
  color: rgb(var(--color-text-muted));
}

.stats-card-footer-left,
.stats-card-footer-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.stats-card-judges {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-card-court-type {
  font-weight: 600;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

.stats-card-language {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-weight: 500;
}

.stats-cards-load-more {
  text-align: center;
  margin-top: 1rem;
}

/* ── Duration stats table ────────────────────────────── */

.duration-stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.duration-stats-table th {
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: rgb(var(--color-text-muted));
  padding: 0.5rem 0.625rem;
  border-bottom: 2px solid rgb(var(--color-border));
}

.duration-stats-table th.num,
.duration-stats-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.duration-stats-table td {
  padding: 0.5rem 0.625rem;
  border-bottom: 1px solid rgb(var(--color-border));
  color: rgb(var(--color-text-primary));
}

.duration-stats-table tr:last-child td {
  border-bottom: none;
}

.duration-stats-table tbody tr:hover {
  background: rgb(var(--color-bg-tertiary, var(--color-bg-secondary)));
}

.duration-stats-warning td {
  color: rgb(var(--color-text-muted));
}

.duration-stats-warning .warn-n {
  color: rgb(var(--color-warning));
  font-weight: 600;
}

/* ── Duration toggle row ─────────────────────────────── */

.duration-toggle-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.duration-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
  color: rgb(var(--color-text-secondary));
  cursor: pointer;
  user-select: none;
}

.duration-toggle-label input[type="checkbox"] {
  accent-color: rgb(var(--color-primary));
}

/* ── Box plot grouping dropdown ──────────────────────── */

.boxplot-grouping-select {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border: 1px solid rgb(var(--color-border));
  border-radius: 0.25rem;
  background: rgb(var(--color-bg-secondary));
  color: rgb(var(--color-text-primary));
  cursor: pointer;
}

.boxplot-grouping-select:focus {
  outline: none;
  border-color: rgb(var(--color-primary));
  box-shadow: 0 0 0 2px rgb(var(--color-primary) / 0.15);
}

/* ── Box plot SVG ────────────────────────────────────── */

.box-plot-box {
  fill: rgb(var(--color-primary) / 0.3);
  stroke: rgb(var(--color-primary));
}

.box-plot-median {
  stroke: rgb(var(--color-primary));
  stroke-width: 2;
}

.box-plot-whisker {
  stroke: rgb(var(--color-text-muted));
}

.box-plot-outlier {
  fill: rgb(var(--color-text-muted));
}

/* ── Trend line SVG ──────────────────────────────────── */

.trend-line {
  fill: none;
  stroke-width: 2;
}

.trend-iqr-area {
  stroke: none;
}

.trend-dot {
  cursor: default;
}

/* ── Gantt Chart ──────────────────────────────────────── */

.gantt-chart-box {
  position: relative;
}

.gantt-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.gantt-count {
  font-size: 0.75rem;
  color: rgb(var(--color-text-muted));
  font-variant-numeric: tabular-nums;
}

.gantt-sort-label {
  font-size: 0.75rem;
  color: rgb(var(--color-text-secondary));
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}

.gantt-sort-select {
  font-size: 0.75rem;
  padding: 0.2rem 0.4rem;
  border: 1px solid rgb(var(--color-border));
  border-radius: 0.25rem;
  background: rgb(var(--color-bg-secondary));
  color: rgb(var(--color-text-primary));
  cursor: pointer;
}

.gantt-sort-select:focus {
  outline: none;
  border-color: rgb(var(--color-primary));
  box-shadow: 0 0 0 2px rgb(var(--color-primary) / 0.15);
}

.gantt-wrapper {
  position: relative;
}

.gantt-axis-svg {
  display: block;
  border-bottom: 1px solid rgb(var(--color-border));
}

.gantt-scroll {
  max-height: 600px;
  overflow-y: auto;
  overflow-x: hidden;
}

.gantt-bars-svg {
  display: block;
}

.gantt-row:hover rect {
  filter: brightness(1.1);
}

.gantt-row:hover text {
  font-weight: 600;
}

.gantt-tooltip {
  display: none;
  position: absolute;
  z-index: 20;
  background: rgb(var(--color-bg-primary));
  border: 1px solid rgb(var(--color-border));
  border-radius: 0.375rem;
  padding: 0.625rem 0.75rem;
  font-size: 0.75rem;
  line-height: 1.5;
  color: rgb(var(--color-text-primary));
  box-shadow: var(--shadow-lg, 0 4px 12px rgba(0,0,0,0.15));
  pointer-events: none;
  max-width: 280px;
  white-space: nowrap;
}

.gantt-tooltip strong {
  color: rgb(var(--color-text-primary));
  font-size: 0.8125rem;
}

.gantt-tooltip em {
  color: rgb(var(--color-warning));
}

/* ── Responsive ───────────────────────────────────────── */

@media (max-width: 1023px) {
  .stats-chart-grid {
    grid-template-columns: 1fr 1fr;
  }

  .stats-chart-row-3 {
    grid-template-columns: 1fr 1fr;
  }

  .stats-chart-row-3 > :last-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 639px) {
  .stats-kpi-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .stats-chart-grid,
  .stats-chart-row-3,
  .stats-chart-row-2 {
    grid-template-columns: 1fr;
  }

  .stats-chart-row-3 > :last-child {
    grid-column: auto;
  }

  .stats-filter-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  .stats-reset-all {
    margin-left: 0;
    margin-top: 0.25rem;
  }

  .stats-cards-grid {
    grid-template-columns: 1fr;
  }

  .gantt-scroll {
    max-height: 400px;
    overflow-x: auto;
  }

  .gantt-controls {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
}

/* ── Print ────────────────────────────────────────────── */

@media print {
  .stats-filter-bar,
  .stats-reset-all,
  .chart-reset,
  .chart-drill-back,
  .chart-gear-btn,
  .chart-options-popover,
  button {
    display: none !important;
  }

  .stats-dashboard {
    gap: 0.75rem;
  }

  .stats-chart-grid {
    grid-template-columns: 1fr 1fr;
  }

  .stats-chart-box {
    break-inside: avoid;
    border-color: #ddd;
  }

  .dc-chart svg {
    max-width: 100%;
  }
}

/* ── Case Stage Funnel ─────────────────────────────── */

.funnel-chart {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  padding: 0.25rem 0;
}

.funnel-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
}

.funnel-label {
  width: 5.5rem;
  flex-shrink: 0;
  text-align: right;
  color: rgb(var(--color-text-secondary));
  font-weight: 500;
}

.funnel-bar-track {
  flex: 1;
  height: 1.125rem;
  background: rgb(var(--color-text-muted) / 0.1);
  border-radius: 0.25rem;
  overflow: hidden;
}

.funnel-bar-fill {
  height: 100%;
  border-radius: 0.25rem;
  transition: width 0.3s ease;
}

.funnel-value {
  width: 5rem;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  color: rgb(var(--color-text-secondary));
}

.funnel-pct {
  color: rgb(var(--color-text-muted));
  font-size: 0.6875rem;
}

.funnel-exit-divider {
  border-top: 1px solid rgb(var(--color-border));
  margin: 0.25rem 0;
}

.funnel-bar--exit .funnel-label {
  color: rgb(var(--color-text-muted));
}

/* ── Duration Section Toggles ──────────────────────── */

.dur-section {
  margin-bottom: 0.75rem;
}

.dur-section-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: rgb(var(--color-bg-secondary));
  border: 1px solid rgb(var(--color-border));
  border-radius: 0.375rem;
  color: rgb(var(--color-text-primary));
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}

.dur-section-toggle:hover {
  background: rgb(var(--color-bg-tertiary, var(--color-bg-secondary)));
}

.dur-section-arrow {
  font-size: 0.625rem;
  color: rgb(var(--color-text-muted));
  width: 0.75rem;
}

.dur-section-body {
  padding-top: 0.75rem;
}

/* ── Server-rendered charts (patents stats etc) ────── */

.stats-charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

@media (max-width: 639px) {
  .stats-charts-row {
    grid-template-columns: 1fr;
  }
}

.stats-chart-panel {
  background: rgb(var(--color-bg-secondary));
  border: 1px solid rgb(var(--color-border));
  border-radius: 0.5rem;
  padding: 1rem 1.25rem;
}

.stats-chart-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: rgb(var(--color-text-primary));
  margin-bottom: 0.75rem;
}

/* Horizontal bar chart */
.stats-bar-chart {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.stats-bar-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
}

.stats-bar-label {
  width: 4rem;
  flex-shrink: 0;
  text-align: right;
  color: rgb(var(--color-text-secondary));
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-bar-track {
  flex: 1;
  height: 1.25rem;
  background: rgb(var(--color-text-muted) / 0.08);
  border-radius: 0.25rem;
  overflow: hidden;
}

.stats-bar-fill {
  height: 100%;
  border-radius: 0.25rem;
  background: rgb(var(--color-primary));
  transition: width 0.4s ease;
  min-width: 2px;
}

.stats-bar-fill--alt {
  background: rgb(var(--color-accent, var(--color-primary)));
}

.stats-bar-fill--status-granted { background: rgb(var(--color-success, 34 197 94)); }
.stats-bar-fill--status-expired { background: rgb(var(--color-text-muted)); }
.stats-bar-fill--status-revoked { background: rgb(var(--color-error, 239 68 68)); }
.stats-bar-fill--status-pending { background: rgb(var(--color-warning, 234 179 8)); }
.stats-bar-fill--status-opposed { background: rgb(var(--color-info, 59 130 246)); }
.stats-bar-fill--status-surrendered { background: rgb(var(--color-text-secondary)); }
.stats-bar-fill--status-unknown { background: rgb(var(--color-text-muted)); }

.stats-bar-value {
  width: 3rem;
  flex-shrink: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: rgb(var(--color-text-secondary));
  font-weight: 600;
  font-size: 0.75rem;
}

/* Vertical year chart */
.stats-year-chart {
  padding-top: 0.5rem;
}

.stats-year-bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 8rem;
}

.stats-year-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
  min-width: 0;
}

.stats-year-bar {
  width: 100%;
  background: rgb(var(--color-primary));
  border-radius: 2px 2px 0 0;
  transition: height 0.4s ease;
  min-height: 2px;
}

.stats-year-col:hover .stats-year-bar {
  background: rgb(var(--color-primary) / 0.8);
}

.stats-year-label {
  font-size: 0.5625rem;
  color: rgb(var(--color-text-muted));
  margin-top: 0.25rem;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
  height: 1.5rem;
  overflow: hidden;
}

/* Stats table */
.stats-table-container {
  overflow-x: auto;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.stats-table th {
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: rgb(var(--color-text-muted));
  padding: 0.5rem 0.625rem;
  border-bottom: 2px solid rgb(var(--color-border));
}

.stats-table th.text-right {
  text-align: right;
}

.stats-table td {
  padding: 0.5rem 0.625rem;
  border-bottom: 1px solid rgb(var(--color-border));
  color: rgb(var(--color-text-primary));
}

.stats-table td.text-right {
  text-align: right;
}

.stats-table tr:last-child td {
  border-bottom: none;
}

.stats-table tbody tr:hover {
  background: rgb(var(--color-bg-tertiary, var(--color-bg-secondary)));
}

/* IPC grid */
.stats-ipc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
}

.stats-ipc-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: rgb(var(--color-text-muted) / 0.04);
  border-radius: 0.375rem;
}

.stats-ipc-badge {
  font-size: 1rem;
  font-weight: 700;
  min-width: 1.5rem;
  text-align: center;
}

.stats-ipc-name {
  flex: 1;
  font-size: 0.8125rem;
  color: rgb(var(--color-text-secondary));
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-ipc-count {
  font-size: 0.875rem;
  font-weight: 700;
  color: rgb(var(--color-text-primary));
  font-variant-numeric: tabular-nums;
}

/* ── Enhanced tooltip ────────────────────────────────── */

.stats-tooltip {
  display: none;
  position: absolute;
  z-index: 30;
  background: rgb(var(--color-bg-primary));
  border: 1px solid rgb(var(--color-border));
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: rgb(var(--color-text-primary));
  box-shadow: var(--shadow-lg, 0 4px 12px rgba(0,0,0,0.15));
  pointer-events: none;
  max-width: 320px;
}

.stats-tooltip .tooltip-title {
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.stats-tooltip .tooltip-value {
  font-size: 1rem;
  font-weight: 600;
  color: rgb(var(--color-primary));
}

.stats-tooltip .tooltip-pct {
  color: rgb(var(--color-text-muted));
  font-size: 0.75rem;
}

.stats-tooltip .tooltip-detail {
  margin-top: 0.375rem;
  font-size: 0.75rem;
  color: rgb(var(--color-text-secondary));
}

/* ── Cross-link panel ───────────────────────────────── */

.stats-cross-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: rgb(var(--color-bg-secondary));
  border: 1px solid rgb(var(--color-border));
  border-radius: 0.5rem;
}

.stats-cross-links-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgb(var(--color-text-muted));
}

.stats-cross-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.625rem;
  background: rgb(var(--color-primary) / 0.08);
  color: rgb(var(--color-primary));
  border-radius: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.stats-cross-link:hover {
  background: rgb(var(--color-primary) / 0.16);
  color: rgb(var(--color-primary-dark, var(--color-primary)));
}

/* ── Analytics Hub ───────────────────────────────────── */

.stats-kpi-card--link {
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.stats-kpi-card--link:hover {
  border-color: rgb(var(--color-primary) / 0.3);
  box-shadow: var(--shadow-md);
}

.stats-kpi-card--link .kpi-sub {
  color: rgb(var(--color-primary));
}

/* ── Top Parties ────────────────────────────────────── */

.top-parties-list {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.top-party-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
}

.top-party-rank {
  width: 1.5rem;
  flex-shrink: 0;
  text-align: right;
  font-size: 0.75rem;
  font-weight: 600;
  color: rgb(var(--color-text-muted));
  font-variant-numeric: tabular-nums;
}

.top-party-name {
  width: 10rem;
  flex-shrink: 0;
  color: rgb(var(--color-text-secondary));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-party-bar {
  flex: 1;
  height: 1rem;
  background: rgb(var(--color-text-muted) / 0.08);
  border-radius: 0.25rem;
  overflow: hidden;
}

.top-party-bar-fill {
  height: 100%;
  border-radius: 0.25rem;
  transition: width 0.3s ease;
  min-width: 2px;
}

.top-party-count {
  width: 2.5rem;
  flex-shrink: 0;
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: rgb(var(--color-text-primary));
  font-size: 0.75rem;
}

@media (max-width: 639px) {
  .top-party-name {
    width: 6rem;
  }
}

/* ── IPC Treemap ─────────────────────────────────────── */

.ipc-treemap-box {
  overflow: visible;
}

.ipc-treemap-wrap {
  position: relative;
  min-height: 350px;
}

.ipc-treemap-svg {
  display: block;
  width: 100%;
}

/* Breadcrumb navigation */
.ipc-breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
  font-size: 0.8125rem;
  min-height: 1.5rem;
}

.ipc-crumb-link {
  color: rgb(var(--color-primary));
  cursor: pointer;
  font-weight: 500;
  transition: color 0.15s;
}

.ipc-crumb-link:hover {
  color: rgb(var(--color-primary-dark, var(--color-primary)));
  text-decoration: underline;
}

.ipc-crumb-sep {
  color: rgb(var(--color-text-muted));
  user-select: none;
}

.ipc-crumb-current {
  font-weight: 700;
  color: rgb(var(--color-text-primary));
}

.ipc-crumb-level {
  color: rgb(var(--color-text-muted));
  font-size: 0.75rem;
  font-style: italic;
}

/* Tile text — ensure crisp rendering */
.ipc-tile text {
  pointer-events: none;
  user-select: none;
}

.ipc-tile rect {
  transition: fill 0.15s;
}

/* Accessible focus outline for keyboard nav */
.ipc-tile:focus-visible rect {
  outline: 2px solid rgb(var(--color-primary));
  outline-offset: 1px;
}

/* ── Sankey Diagram ─────────────────────────────────── */

#sankey-container svg {
  display: block;
}

#sankey-container path {
  transition: stroke 0.15s;
}

/* ── Loading Skeletons ──────────────────────────────── */

.stats-skeleton {
  background: linear-gradient(
    90deg,
    rgb(var(--color-bg-secondary)) 25%,
    rgb(var(--color-border)) 37%,
    rgb(var(--color-bg-secondary)) 63%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: 0.375rem;
}

.stats-skeleton--chart {
  width: 100%;
  height: 200px;
}

.stats-skeleton--list {
  width: 100%;
  height: 160px;
}

.stats-skeleton--kpi {
  width: 60%;
  height: 2rem;
  margin: 0 auto;
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Consistent chart heights ───────────────────────── */

.stats-chart-box {
  min-height: 0;
}

.stats-chart-box svg {
  transition: opacity 0.2s ease;
}

/* ── Smooth tab transitions ─────────────────────────── */

.stats-tab-content {
  animation: stats-fade-in 0.2s ease;
}

@keyframes stats-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Heat map horizontal scroll on mobile ───────────── */

.heatmap-scroll-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  min-width: 0;
}

.heatmap-scroll-wrap svg {
  min-width: 740px;
}

/* ── Mobile Responsive Enhancements (Phase 6) ───────── */

@media (max-width: 767px) {
  /* Stack all chart grids */
  .stats-chart-grid,
  .stats-chart-row-3,
  .stats-chart-row-2,
  .stats-charts-row {
    grid-template-columns: 1fr;
  }

  .stats-chart-row-3 > :last-child {
    grid-column: auto;
  }

  /* KPI cards: 2-column grid */
  .stats-kpi-row {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .stats-kpi-card {
    padding: 0.75rem;
  }

  .stats-kpi-card .kpi-value {
    font-size: 1.375rem;
  }

  .stats-kpi-card .kpi-label {
    font-size: 0.6875rem;
  }

  /* Filter bar collapses */
  .stats-filter-bar {
    flex-direction: column;
    align-items: stretch;
    padding: 0.5rem 0.75rem;
    gap: 0.375rem;
  }

  .stats-filter-bar .filter-label {
    margin-right: 0;
  }

  .stats-reset-all {
    margin-left: 0;
    align-self: flex-end;
  }

  /* Cards single column */
  .stats-cards-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  /* Chart boxes compact */
  .stats-chart-box {
    padding: 0.75rem;
  }

  .stats-chart-box .chart-title {
    font-size: 0.8125rem;
  }

  /* Page-level controls row stacks on mobile so the future left-zone
     slicers don't crowd the Show numbers toggle. */
  .stats-page-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .stats-page-controls-right {
    justify-content: flex-end;
  }

  /* Chart options popover renders as a fixed bottom sheet on narrow
     viewports — the absolute-positioned desktop popover risks clipping
     against the chart-box edge. */
  .chart-options-popover {
    position: fixed;
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: none;
    border-radius: 0.75rem 0.75rem 0 0;
    box-shadow: 0 -8px 24px rgb(0 0 0 / 0.18);
    padding: 1rem 1rem 1.5rem;
    z-index: 5100;
  }

  /* Top parties compact */
  .top-party-name {
    width: 5rem;
    font-size: 0.75rem;
  }

  .top-party-bar {
    height: 0.75rem;
  }

  /* Treemap minimum height */
  .ipc-treemap-wrap {
    min-height: 200px;
  }

  /* Gantt scroll */
  .gantt-scroll {
    max-height: 350px;
    overflow-x: auto;
  }

  .gantt-controls {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  /* Duration section toggle compact */
  .dur-section-toggle {
    font-size: 0.75rem;
    padding: 0.375rem 0.5rem;
  }

  /* Sankey needs horizontal scroll on small screens */
  #sankey-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  #sankey-container svg {
    min-width: 500px;
  }

  /* Cross-links stack */
  .stats-cross-links {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.375rem;
    padding: 0.5rem 0.75rem;
  }

  /* Duration stats table horizontal scroll */
  .duration-stats-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* IPC grid compact */
  .stats-ipc-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.5rem;
  }

  /* Box plot grouping */
  .duration-toggle-row {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
}

/* ── Touch-friendly interactions ────────────────────── */

@media (hover: none) and (pointer: coarse) {
  /* Larger tap targets */
  .stats-tab {
    padding: 0.75rem 1rem;
    min-height: 44px;
  }

  .stats-filter-tag {
    padding: 0.375rem 0.625rem;
    min-height: 36px;
  }

  .stats-filter-tag .filter-remove {
    font-size: 1.25rem;
    padding: 0 0.25rem;
    min-width: 28px;
    min-height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .chart-reset,
  .chart-drill-back {
    padding: 0.25rem 0.5rem;
    min-height: 32px;
    display: inline-flex;
    align-items: center;
  }

  .stats-reset-all {
    padding: 0.375rem 1rem;
    min-height: 36px;
  }

  /* Treemap tiles: tap-friendly */
  .ipc-tile rect {
    cursor: pointer;
  }

  /* Row chart bars: larger tap area */
  .dc-chart g.row {
    cursor: pointer;
  }

  .dc-chart g.row rect {
    min-height: 24px;
  }

  /* Top party rows */
  .top-party-row {
    min-height: 36px;
    padding: 0.25rem 0;
  }

  /* KPI cards */
  .stats-kpi-card--link {
    min-height: 72px;
  }

  /* Pie chart slices */
  .dc-chart .pie-slice {
    cursor: pointer;
  }
}

/* ── Tablet breakpoint ──────────────────────────────── */

@media (min-width: 640px) and (max-width: 1023px) {
  .stats-kpi-row {
    grid-template-columns: repeat(4, 1fr);
  }

  .stats-chart-grid {
    grid-template-columns: 1fr 1fr;
  }

  .stats-chart-row-3 {
    grid-template-columns: 1fr 1fr;
  }

  .stats-chart-row-3 > :last-child {
    grid-column: 1 / -1;
  }
}

/* ── Insights cards — outcome / validity pills ───────── */

.insights-card .stats-card-footer {
  gap: 0.375rem;
  align-items: center;
}

.insights-outcome-pill,
.insights-validity-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  /* Neutral default — overridden by modifiers below. */
  background: rgb(var(--color-bg-tertiary));
  color: rgb(var(--color-text-secondary));
}

.insights-outcome-pill--successful {
  background: rgb(var(--color-success) / 0.15);
  color: rgb(var(--color-success-dark));
}

.insights-outcome-pill--partially-successful {
  background: rgb(var(--color-warning) / 0.15);
  color: rgb(var(--color-warning-dark));
}

.insights-outcome-pill--rejected {
  background: rgb(var(--color-error) / 0.15);
  color: rgb(var(--color-error-dark));
}

.insights-outcome-pill--not-decided {
  background: rgb(var(--color-bg-tertiary));
  color: rgb(var(--color-text-muted));
}

.insights-validity-pill--patent-survived {
  background: rgb(var(--color-success) / 0.15);
  color: rgb(var(--color-success-dark));
}

.insights-validity-pill--partially-invalidated {
  background: rgb(var(--color-warning) / 0.15);
  color: rgb(var(--color-warning-dark));
}

.insights-validity-pill--patent-invalidated {
  background: rgb(var(--color-error) / 0.15);
  color: rgb(var(--color-error-dark));
}

.insights-validity-pill--not-decided {
  background: rgb(var(--color-bg-tertiary));
  color: rgb(var(--color-text-muted));
}

/* ── Insights sub-tabs ─────────────────────────────────── */

.insights-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.insights-subtab-bar {
  display: flex;
  gap: 0.375rem;
  border-bottom: none;
  margin-bottom: 0.75rem;
  padding: 0.25rem 0;
  overflow-x: auto;
  /* Pinning overflow-y: hidden so overflow-x: auto doesn't get promoted into a
     vertical scrollbar by the browser's overflow-axis-coupling rule. */
  overflow-y: hidden;
}

/* Pill-style subtab buttons inside the Insights subtab bar — visually lighter
   than the underline-tab style used for the top-level tab strip, so the
   hierarchy reads as "you are inside a tab" instead of "this is a sibling tab". */
.insights-subtab-bar .stats-tab {
  padding: 0.375rem 0.875rem;
  font-size: 0.8125rem;
  border: 1px solid rgb(var(--color-border));
  border-radius: 999px;
  background: rgb(var(--color-bg-primary));
  color: rgb(var(--color-text-secondary));
  margin-bottom: 0;
  flex-shrink: 0;
}

.insights-subtab-bar .stats-tab:hover {
  background: rgb(var(--color-bg-secondary));
  color: rgb(var(--color-text-primary));
}

.insights-subtab-bar .stats-tab.stats-tab--active {
  background: rgb(var(--color-primary));
  border-color: rgb(var(--color-primary));
  color: rgb(var(--color-text-on-primary));
}

.insights-subtab-select {
  display: none;
}

@media (max-width: 640px) {
  .insights-subtab-bar { display: none; }
  .insights-subtab-select { display: block; }
}

.insights-subtab {
  display: none;
  flex-direction: column;
  gap: 1.25rem;
}

/* ── Parties subtabs (Parties / Representatives / Law Firms) ─────────── */
.parties-subtab-bar {
  display: flex;
  gap: 0.375rem;
  border-bottom: none;
  margin-bottom: 1rem;
  padding: 0.25rem 0;
  overflow-x: auto;
  overflow-y: hidden;
}

.parties-subtab-bar .stats-tab {
  padding: 0.375rem 0.875rem;
  font-size: 0.8125rem;
  border: 1px solid rgb(var(--color-border));
  border-radius: 999px;
  background: rgb(var(--color-bg-primary));
  color: rgb(var(--color-text-secondary));
  margin-bottom: 0;
  flex-shrink: 0;
}

.parties-subtab-bar .stats-tab:hover {
  background: rgb(var(--color-bg-secondary));
  color: rgb(var(--color-text-primary));
}

.parties-subtab-bar .stats-tab.stats-tab--active {
  background: rgb(var(--color-primary));
  border-color: rgb(var(--color-primary));
  color: rgb(var(--color-text-on-primary));
}

.parties-subtab-select {
  display: none;
}

@media (max-width: 640px) {
  .parties-subtab-bar { display: none; }
  .parties-subtab-select { display: block; margin-bottom: 1rem; }
}

.parties-subtab {
  display: none;
  flex-direction: column;
  gap: 1.25rem;
}

.parties-subtab.parties-subtab--active {
  display: flex;
}

.parties-firms-placeholder {
  background: rgb(var(--color-bg-secondary));
  border: 1px dashed rgb(var(--color-border));
  border-radius: 0.5rem;
  padding: 2rem;
  text-align: center;
}

.parties-firms-placeholder h3 {
  font-size: 1rem;
  font-weight: 600;
  color: rgb(var(--color-text-primary));
  margin-bottom: 0.5rem;
}

.parties-firms-placeholder a {
  color: rgb(var(--color-primary));
  text-decoration: underline;
  cursor: pointer;
}

.insights-subtab--active {
  display: flex;
}

.insights-subtab-intro {
  font-size: 0.875rem;
  color: rgb(var(--color-text-secondary));
  margin: 0 0 0.25rem 0;
  line-height: 1.55;
  max-width: 72ch;
}

.insights-tab-loader {
  padding: 3rem 1rem;
}

/* ── Filter inputs reused across insights sub-tabs ─────── */

.stats-input,
.stats-select {
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: rgb(var(--color-text-primary));
  background: rgb(var(--color-bg-primary));
  border: 1px solid rgb(var(--color-border));
  border-radius: 0.375rem;
  min-height: 2.25rem;
  transition: border-color 0.15s;
}

.stats-input:focus,
.stats-select:focus {
  outline: none;
  border-color: rgb(var(--color-primary));
  box-shadow: 0 0 0 3px rgb(var(--color-primary) / 0.2);
}

.stats-input {
  flex: 1 1 14rem;
  min-width: 12rem;
}

.stats-select {
  flex: 0 1 10rem;
}

/* ── Validity cards (matching judgments below the dashboard) ── */

.insights-validity-cards-section {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.insights-validity-cards-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgb(var(--color-border));
}

.insights-validity-cards-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* ── Landmarks gallery ─────────────────────────────────── */

.insights-landmarks {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.insights-landmarks-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: rgb(var(--color-bg-secondary));
  border: 1px solid rgb(var(--color-border));
  border-radius: 0.5rem;
}

.insights-landmarks-kpi {
  display: flex;
  flex-direction: column;
  min-width: 7rem;
}

.insights-landmarks-kpi .kpi-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: rgb(var(--color-primary));
  line-height: 1.1;
}

.insights-landmarks-kpi .kpi-label {
  font-size: 0.75rem;
  color: rgb(var(--color-text-muted));
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.insights-landmarks-filters {
  display: flex;
  flex: 1 1 20rem;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.insights-tag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-bottom: 0.25rem;
}

.insights-tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: rgb(var(--color-text-secondary));
  background: rgb(var(--color-bg-secondary));
  border: 1px solid rgb(var(--color-border));
  border-radius: 9999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.insights-tag-chip:hover {
  background: rgb(var(--color-bg-tertiary));
  color: rgb(var(--color-text-primary));
}

.insights-tag-chip--active {
  background: rgb(var(--color-primary) / 0.15);
  color: rgb(var(--color-primary-dark));
  border-color: rgb(var(--color-primary) / 0.4);
}

.insights-tag-chip-count {
  font-weight: 500;
  font-size: 0.6875rem;
  color: rgb(var(--color-text-muted));
}

.insights-tag-chip--active .insights-tag-chip-count {
  color: rgb(var(--color-primary-dark));
}

.insights-landmark-summary {
  font-size: 0.8125rem;
  color: rgb(var(--color-text-secondary));
  line-height: 1.5;
  margin: 0.5rem 0 0 0;
}

.insights-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.5rem;
}

.insights-card-tag {
  font-size: 0.6875rem;
  padding: 0.15rem 0.45rem;
  border-radius: 9999px;
  background: rgb(var(--color-bg-tertiary));
  color: rgb(var(--color-text-secondary));
  white-space: nowrap;
}

.insights-cited-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.6875rem;
  padding: 0.1rem 0.45rem;
  border-radius: 9999px;
  background: rgb(var(--color-info) / 0.15);
  color: rgb(var(--color-info-dark));
  margin-left: 0.25rem;
}

/* ── Rulings: provisions + holdings feed ───────────────── */

.insights-provisions-box .chart-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.insights-provisions {
  width: 100%;
  overflow-x: auto;
}

.insights-provisions svg {
  display: block;
  max-width: 100%;
}

.insights-holdings-box {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
  background: rgb(var(--color-bg-secondary));
  border: 1px solid rgb(var(--color-border));
  border-radius: 0.5rem;
}

.insights-holdings-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.insights-holdings-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.insights-holdings-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.insights-holding-row {
  padding: 0.75rem 0.875rem;
  background: rgb(var(--color-bg-primary));
  border: 1px solid rgb(var(--color-border));
  border-radius: 0.375rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.insights-holding-row:hover {
  border-color: rgb(var(--color-primary) / 0.4);
  box-shadow: 0 1px 4px rgb(0 0 0 / 0.05);
}

.insights-holding-row-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  align-items: center;
}

.insights-holding-issue {
  font-size: 0.75rem;
  color: rgb(var(--color-text-muted));
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.insights-holding-name {
  font-weight: 600;
  font-size: 0.9375rem;
  color: rgb(var(--color-text-primary));
}

.insights-holding-summary {
  font-size: 0.8125rem;
  color: rgb(var(--color-text-secondary));
  line-height: 1.5;
}

.insights-holding-foot {
  font-size: 0.75rem;
  color: rgb(var(--color-text-muted));
  margin-top: 0.125rem;
}

.insights-holding-case {
  font-weight: 600;
  color: rgb(var(--color-primary));
  text-decoration: none;
}

.insights-holding-case:hover {
  text-decoration: underline;
}

.insights-holding-meta {
  color: rgb(var(--color-text-muted));
}

/* ── Patents subtabs (Overview / Technology Sectors / IPC Classes) ───── */
.patents-subtab-bar {
  display: flex;
  gap: 0.375rem;
  border-bottom: none;
  margin-bottom: 1rem;
  padding: 0.25rem 0;
  overflow-x: auto;
  overflow-y: hidden;
}

.patents-subtab-bar .stats-tab {
  padding: 0.375rem 0.875rem;
  font-size: 0.8125rem;
  border: 1px solid rgb(var(--color-border));
  border-radius: 999px;
  background: rgb(var(--color-bg-primary));
  color: rgb(var(--color-text-secondary));
  margin-bottom: 0;
  flex-shrink: 0;
}

.patents-subtab-bar .stats-tab:hover {
  background: rgb(var(--color-bg-secondary));
  color: rgb(var(--color-text-primary));
}

.patents-subtab-bar .stats-tab.stats-tab--active {
  background: rgb(var(--color-primary));
  border-color: rgb(var(--color-primary));
  color: rgb(var(--color-text-on-primary));
}

.patents-subtab-select {
  display: none;
}

@media (max-width: 640px) {
  .patents-subtab-bar { display: none; }
  .patents-subtab-select { display: block; margin-bottom: 1rem; }
}

.patents-subtab {
  display: none;
  flex-direction: column;
  gap: 1rem;
}

.patents-subtab--active {
  display: flex;
}

.patents-subtab-intro {
  font-size: 0.875rem;
  color: rgb(var(--color-text-secondary));
  margin: 0 0 0.25rem 0;
  line-height: 1.55;
  max-width: 72ch;
}

.patents-sector-source-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 0.25rem 0 0.75rem 0;
}

.patents-sector-source-label {
  font-size: 0.8125rem;
  color: rgb(var(--color-text-secondary));
  margin-right: 0.25rem;
}

.patents-sector-source-btn {
  padding: 0.35rem 0.75rem;
  font-size: 0.8125rem;
  border-radius: 999px;
  border: 1px solid rgb(var(--color-border));
  background: rgb(var(--color-bg-secondary));
  color: rgb(var(--color-text-secondary));
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}

.patents-sector-source-btn:hover {
  border-color: rgb(var(--color-primary));
  color: rgb(var(--color-text));
}

.patents-sector-source-btn--active {
  background: rgb(var(--color-primary));
  border-color: rgb(var(--color-primary));
  color: rgb(var(--color-text-on-primary));
}

.patents-sector-source-drift-link {
  margin-left: auto;
  font-size: 0.8125rem;
  color: rgb(var(--color-text-muted));
  text-decoration: none;
}

.patents-sector-source-drift-link:hover {
  color: rgb(var(--color-primary));
  text-decoration: underline;
}

.patents-sector-toolbar {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.patents-sector-search {
  flex: 1 1 260px;
  min-width: 200px;
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  border: 1px solid rgb(var(--color-border));
  background: rgb(var(--color-bg-secondary));
  color: rgb(var(--color-text));
  font-size: 0.875rem;
}

.patents-sector-search:focus {
  outline: none;
  border-color: rgb(var(--color-primary));
}

.patents-sector-summary {
  font-size: 0.75rem;
  color: rgb(var(--color-text-muted));
}

.patents-sector-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem;
}

.patents-sector-card {
  background: rgb(var(--color-bg-secondary));
  border: 1px solid rgb(var(--color-border));
  border-radius: 0.5rem;
  padding: 0.875rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.patents-sector-card--empty {
  opacity: 0.6;
}

.patents-sector-card-empty {
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.4;
  color: rgb(var(--color-text-muted));
  font-style: italic;
}

.patents-sector-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.patents-sector-card-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: rgb(var(--color-primary));
}

.patents-sector-card-count {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 0.95rem;
  color: rgb(var(--color-text));
}

.patents-sector-card-bar {
  width: 100%;
  height: 4px;
  background: rgb(var(--color-border) / 0.5);
  border-radius: 2px;
  overflow: hidden;
}

.patents-sector-card-bar > span {
  display: block;
  height: 100%;
  background: rgb(var(--color-primary) / 0.7);
  transition: width 200ms ease-out;
}

.patents-sector-card-prefixes {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.patents-sector-card-prefixes li code {
  display: inline-block;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  background: rgb(var(--color-primary) / 0.08);
  border: 1px solid rgb(var(--color-primary) / 0.18);
  color: rgb(var(--color-primary));
  font-size: 0.75rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.patents-sector-reverse {
  margin-top: 0.5rem;
  padding: 0.75rem 1rem;
  background: rgb(var(--color-bg-secondary));
  border: 1px solid rgb(var(--color-border));
  border-radius: 0.5rem;
}

.patents-sector-reverse > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.875rem;
  color: rgb(var(--color-text));
}

.patents-sector-reverse-body {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.patents-sector-reverse-input {
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  border: 1px solid rgb(var(--color-border));
  background: rgb(var(--color-bg));
  color: rgb(var(--color-text));
  font-size: 0.875rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  text-transform: uppercase;
  max-width: 320px;
}

.patents-sector-reverse-input:focus {
  outline: none;
  border-color: rgb(var(--color-primary));
}

.patents-sector-reverse-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.875rem;
}

.patents-sector-reverse-list code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem;
}

/* ─── IPC Classes subtab — hierarchical tree, full-width, cards below ─── */
.patents-ipc-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.patents-ipc-search { flex: 1 1 240px; min-width: 200px; max-width: 520px; }

.patents-ipc-tree-action {
  padding: 0.375rem 0.75rem;
  border-radius: 0.375rem;
  border: 1px solid rgb(var(--color-border));
  background: rgb(var(--color-bg));
  color: rgb(var(--color-text-muted));
  font-size: 0.8125rem;
  cursor: pointer;
}

.patents-ipc-tree-action:hover {
  color: rgb(var(--color-text));
  border-color: rgb(var(--color-primary) / 0.4);
}

.patents-ipc-tree-wrap { width: 100%; margin-bottom: 1rem; }

.patents-ipc-tree {
  width: 100%;
  border: 1px solid rgb(var(--color-border));
  border-radius: 0.5rem;
  background: rgb(var(--color-bg));
  overflow: hidden;
}

.patents-ipc-node + .patents-ipc-node { border-top: 1px solid rgb(var(--color-border)); }

.patents-ipc-node--class + .patents-ipc-node--class { border-top: 1px dashed rgb(var(--color-border)); }

.patents-ipc-children {
  display: flex;
  flex-direction: column;
  background: rgb(var(--color-bg-secondary) / 0.4);
}

.patents-ipc-node--class > .patents-ipc-children {
  background: rgb(var(--color-bg-secondary) / 0.7);
}

.patents-ipc-row {
  display: flex;
  align-items: stretch;
  gap: 0;
  width: 100%;
  font-size: 0.875rem;
  color: rgb(var(--color-text));
}

.patents-ipc-row-caret {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: rgb(var(--color-text-muted));
  font-size: 0.75rem;
  cursor: pointer;
}

.patents-ipc-row-caret--leaf { cursor: default; }

.patents-ipc-row-caret:hover:not(.patents-ipc-row-caret--leaf) {
  color: rgb(var(--color-primary));
}

.patents-ipc-row-toggle {
  display: grid;
  grid-template-columns: 1.5rem auto 1fr auto;
  gap: 0.5rem;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.5rem 0.75rem 0.5rem 0;
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font-size: inherit;
  color: inherit;
}

.patents-ipc-row-toggle:hover {
  background: rgb(var(--color-primary) / 0.06);
}

.patents-ipc-row--section .patents-ipc-row-toggle {
  font-weight: 600;
  font-size: 0.9375rem;
}

.patents-ipc-row--class .patents-ipc-row-toggle {
  font-weight: 500;
  padding-left: 1rem;
}

.patents-ipc-row--subclass .patents-ipc-row-toggle {
  padding-left: 2rem;
  font-size: 0.8125rem;
}

.patents-ipc-row--selected .patents-ipc-row-toggle,
.patents-ipc-row--selected .patents-ipc-row-toggle:hover {
  background: rgb(var(--color-primary) / 0.14);
  color: rgb(var(--color-primary));
}

.patents-ipc-row--partial .patents-ipc-row-toggle {
  background: rgb(var(--color-primary) / 0.05);
}

.patents-ipc-row-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  border: 1px solid rgb(var(--color-border));
  border-radius: 0.25rem;
  background: rgb(var(--color-bg));
  font-size: 0.875rem;
  line-height: 1;
  color: rgb(var(--color-primary));
}

.patents-ipc-row--selected .patents-ipc-row-check {
  border-color: rgb(var(--color-primary));
  background: rgb(var(--color-primary) / 0.2);
}

.patents-ipc-row--partial .patents-ipc-row-check {
  border-color: rgb(var(--color-primary) / 0.6);
  background: rgb(var(--color-primary) / 0.1);
}

.patents-ipc-row-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  background: rgb(var(--color-primary) / 0.08);
  border: 1px solid rgb(var(--color-primary) / 0.18);
  color: rgb(var(--color-primary));
  white-space: nowrap;
}

.patents-ipc-row-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.patents-ipc-row-count {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: rgb(var(--color-text-muted));
}

.patents-ipc-row--selected .patents-ipc-row-count { color: rgb(var(--color-primary)); }

@media (max-width: 640px) {
  .patents-ipc-row-toggle { grid-template-columns: 1.25rem auto 1fr auto; gap: 0.375rem; }
  .patents-ipc-row--class .patents-ipc-row-toggle { padding-left: 0.5rem; }
  .patents-ipc-row--subclass .patents-ipc-row-toggle { padding-left: 1.25rem; }
  .patents-ipc-row-title { font-size: 0.75rem; }
}

.patents-ipc-selection {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  padding: 0.5rem 0.75rem;
  background: rgb(var(--color-bg-secondary));
  border: 1px solid rgb(var(--color-border));
  border-radius: 0.375rem;
  align-items: center;
  margin-bottom: 1rem;
}

.patents-ipc-selection-label {
  font-size: 0.75rem;
  color: rgb(var(--color-text-muted));
  margin-right: 0.25rem;
}

.patents-ipc-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  background: rgb(var(--color-primary) / 0.15);
  color: rgb(var(--color-primary));
  border: 1px solid rgb(var(--color-primary) / 0.3);
  font-size: 0.75rem;
  cursor: pointer;
}

.patents-ipc-chip:hover { background: rgb(var(--color-primary) / 0.25); }
.patents-ipc-chip code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem;
  background: transparent;
}

.patents-ipc-clear {
  margin-left: auto;
  padding: 0.125rem 0.5rem;
  font-size: 0.75rem;
  color: rgb(var(--color-text-muted));
  background: transparent;
  border: 1px solid rgb(var(--color-border));
  border-radius: 0.25rem;
  cursor: pointer;
}

.patents-ipc-clear:hover { color: rgb(var(--color-text)); }

.patents-ipc-cards-wrap { width: 100%; }

.patents-ipc-cards-head {
  margin-bottom: 0.75rem;
  font-size: 0.875rem;
  color: rgb(var(--color-text-muted));
}

.patents-ipc-cards { display: flex; flex-direction: column; gap: 0.75rem; }

.patents-ipc-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
}

/* People type-filter chips (issue #128 — unified Browse). Tailwind-equivalent
   via CSS so the active state can flip without re-applying util classes from
   JS. Colours mirror the existing People chooser palette: judges=blue,
   reps=emerald, firms=purple. */
.people-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.875rem;
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  background: rgb(var(--color-bg-secondary));
  color: rgb(var(--color-text-secondary));
  transition: background-color 120ms, color 120ms, border-color 120ms;
}
.people-chip:hover { background: rgb(var(--color-bg-tertiary)); }
.people-chip__count {
  font-size: 0.75rem;
  font-weight: 400;
  color: rgb(var(--color-text-muted));
  margin-left: 0.125rem;
}
.people-chip--all.people-chip--active {
  background: rgb(var(--color-bg-tertiary));
  color: rgb(var(--color-text-primary));
  border-color: rgb(var(--color-border));
}
/* Per-type tints (idle and hover/active). Tailwind palette values inlined so
   we don't depend on classes at runtime. */
.people-chip--judges { background: rgb(219 234 254); color: rgb(29 78 216); }
.people-chip--judges:hover,
.people-chip--judges.people-chip--active { background: rgb(191 219 254); }
:is(.dark) .people-chip--judges { background: rgba(30, 58, 138, 0.3); color: rgb(147 197 253); }
:is(.dark) .people-chip--judges:hover,
:is(.dark) .people-chip--judges.people-chip--active { background: rgba(30, 58, 138, 0.5); }

.people-chip--reps { background: rgb(209 250 229); color: rgb(4 120 87); }
.people-chip--reps:hover,
.people-chip--reps.people-chip--active { background: rgb(167 243 208); }
:is(.dark) .people-chip--reps { background: rgba(6, 78, 59, 0.3); color: rgb(110 231 183); }
:is(.dark) .people-chip--reps:hover,
:is(.dark) .people-chip--reps.people-chip--active { background: rgba(6, 78, 59, 0.5); }

.people-chip--firms { background: rgb(243 232 255); color: rgb(126 34 206); }
.people-chip--firms:hover,
.people-chip--firms.people-chip--active { background: rgb(233 213 255); }
:is(.dark) .people-chip--firms { background: rgba(88, 28, 135, 0.3); color: rgb(216 180 254); }
:is(.dark) .people-chip--firms:hover,
:is(.dark) .people-chip--firms.people-chip--active { background: rgba(88, 28, 135, 0.5); }

.people-chip--active {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

/* People Stats — sub-tab strip between cross-cutting top section and the
   per-type drill-down panels (Judges / Representatives / Law Firms).
   Mirrors .parties-subtab-* so the two read consistently across the site. */
.people-stats-subtab-bar {
  display: flex;
  gap: 0.375rem;
  border-bottom: none;
  margin: 2rem 0 1rem 0;
  padding: 0.25rem 0;
  overflow-x: auto;
  overflow-y: hidden;
}

.people-stats-subtab-bar .stats-tab {
  padding: 0.375rem 0.875rem;
  font-size: 0.8125rem;
  border: 1px solid rgb(var(--color-border));
  border-radius: 999px;
  background: rgb(var(--color-bg-primary));
  color: rgb(var(--color-text-secondary));
  margin-bottom: 0;
  flex-shrink: 0;
}

.people-stats-subtab-bar .stats-tab:hover {
  background: rgb(var(--color-bg-secondary));
  color: rgb(var(--color-text-primary));
}

.people-stats-subtab-bar .stats-tab.stats-tab--active {
  background: rgb(var(--color-primary));
  border-color: rgb(var(--color-primary));
  color: rgb(var(--color-text-on-primary));
}

.people-stats-subtab-select {
  display: none;
}

@media (max-width: 640px) {
  .people-stats-subtab-bar { display: none; }
  .people-stats-subtab-select { display: block; margin: 1.5rem 0 1rem 0; }
}

/* Panels stack inside .people-stats-subtabs (position: relative). The
   inactive panels are absolute-positioned (width:100%, top:0) and hidden
   via visibility — that keeps their clientWidth honest so dc.js charts
   that get mounted on an inactive panel (e.g. judges.js during a
   ?tab=firms deep link) still measure the parent width and don't log
   negative-svg-width warnings. The active panel is in normal flow so it
   contributes height to the wrapper. */
.people-stats-subtabs {
  position: relative;
}

.people-stats-subtab {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  position: absolute;
  inset: 0 0 auto 0;
  width: 100%;
  visibility: hidden;
  pointer-events: none;
}

.people-stats-subtab.people-stats-subtab--active {
  position: static;
  visibility: visible;
  pointer-events: auto;
}

.people-stats-subtab-intro {
  font-size: 0.8125rem;
  color: rgb(var(--color-text-secondary));
  margin: 0 0 0.25rem 0;
}

.people-stats-subtab-intro .text-link {
  color: rgb(var(--color-accent));
  text-decoration: none;
}

.people-stats-subtab-intro .text-link:hover { text-decoration: underline; }

/* Firm autocomplete dropdown — anchored under the rep firm filter input. */
.people-firm-suggest {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 30;
  background: rgb(var(--color-bg-primary));
  border: 1px solid rgb(var(--color-border));
  border-radius: 0.375rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  max-height: 16rem;
  overflow-y: auto;
  margin-top: 0.25rem;
}
.people-firm-suggest-item {
  padding: 0.4rem 0.75rem;
  font-size: 0.8125rem;
  color: rgb(var(--color-text-primary));
  cursor: pointer;
}
.people-firm-suggest-item:hover {
  background: rgb(var(--color-bg-tertiary));
}
