/* Smart Analysis Sidebar — pivot builder (analysisPivotUI.ts). Shared by the Data Domain
   console (vendored to apps/data-domain/public/analysis-pivot.css) and Market Supremacy.
   It INHERITS the host's font and colours and reads each console's own tokens, so the
   builder looks like part of the sidebar it sits in rather than a foreign dark island.
   Hairlines, no shadows; everything fits a 300 px column. */
.analysis-pivot {
  --ap-accent: var(--accent, var(--lt-core, #D4A535));
  --ap-line: var(--line, var(--br-1, rgba(127, 127, 127, 0.28)));
  --ap-muted: var(--mut, var(--tx-3, rgba(127, 127, 127, 0.9)));
  --ap-field: var(--panel2, var(--bg-2, rgba(127, 127, 127, 0.08)));
  --ap-mono: var(--mono, var(--font-mono, ui-monospace, 'SFMono-Regular', Menlo, monospace));
  font: inherit;
  font-size: 12px;
  color: inherit;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.analysis-pivot * { box-sizing: border-box; }
.analysis-pivot .ap-controls { display: flex; flex-direction: column; gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--ap-line); }
.analysis-pivot .ap-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; min-width: 0; }
.analysis-pivot .ap-word { color: var(--ap-muted); min-width: 52px; font-size: 11px; }
.analysis-pivot select {
  font: inherit; font-size: 12px; color: inherit; background: var(--ap-field);
  border: 1px solid var(--ap-line); border-radius: 4px; height: 26px; padding: 0 6px;
  max-width: 100%; min-width: 0; flex: 1 1 110px;
}
.analysis-pivot button {
  font: inherit; font-size: 12px; color: inherit; background: transparent; cursor: pointer;
  border: 1px solid var(--ap-line); border-radius: 4px; min-height: 24px; padding: 1px 8px;
}
.analysis-pivot button:disabled { opacity: 0.45; cursor: default; }
.analysis-pivot :focus-visible { outline: 2px solid var(--ap-accent); outline-offset: 1px; }
.analysis-pivot .ap-chip { border-radius: 999px; border-color: var(--ap-accent); padding: 1px 9px; white-space: nowrap; }
.analysis-pivot .ap-chip-filter { border-style: dashed; }
.analysis-pivot .ap-link { border-color: transparent; padding: 1px 6px; color: var(--ap-accent); }
.analysis-pivot .ap-link:hover:not(:disabled) { border-color: var(--ap-line); }
.analysis-pivot .ap-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 2px; }
.analysis-pivot .ap-seg { display: inline-flex; }
.analysis-pivot .ap-seg button { border-radius: 0; }
.analysis-pivot .ap-seg button:first-child { border-start-start-radius: 4px; border-end-start-radius: 4px; }
.analysis-pivot .ap-seg button:last-child { border-start-end-radius: 4px; border-end-end-radius: 4px; border-inline-start: 0; }
.analysis-pivot .ap-seg button[aria-pressed='true'] { border-color: var(--ap-accent); color: var(--ap-accent); font-weight: 600; }
.analysis-pivot .ap-result { padding-top: 6px; }
.analysis-pivot .ap-meta, .analysis-pivot .ap-empty { color: var(--ap-muted); font-size: 11px; margin: 2px 0 6px; }
.analysis-pivot .ap-scroll { overflow: auto; max-height: 60vh; max-width: 100%; }
.analysis-pivot table { border-collapse: collapse; width: 100%; font-size: 12px; }
.analysis-pivot th, .analysis-pivot td { padding: 3px 6px; border-bottom: 1px solid var(--ap-line); text-align: start; vertical-align: middle; }
.analysis-pivot thead th { color: var(--ap-muted); font-weight: 500; font-size: 11px; position: sticky; top: 0; background: var(--panel, var(--bg-1, Canvas)); }
.analysis-pivot tbody th { font-weight: 400; max-width: 160px; min-width: 5.5rem; }
/* A narrow sidebar column must not squeeze a row label into one letter per line. */
.analysis-pivot tbody th .ap-link, .analysis-pivot thead th { overflow-wrap: normal; word-break: keep-all; }
.analysis-pivot .ap-table { table-layout: auto; }
.analysis-pivot tbody th .ap-link { padding: 0; text-align: start; color: inherit; border: 0; }
.analysis-pivot tbody th .ap-link:hover { text-decoration: underline; }
.analysis-pivot .ap-num { text-align: end; font-family: var(--ap-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.analysis-pivot .ap-total { font-weight: 600; }
.analysis-pivot tfoot th, .analysis-pivot tfoot td { border-top: 1px solid var(--ap-line); border-bottom: 0; }
.analysis-pivot .ap-more { color: var(--ap-muted); }
.analysis-pivot .ap-cell { border: 0; padding: 0; width: 100%; text-align: end; font-family: var(--ap-mono); }
.analysis-pivot .ap-cell:hover { text-decoration: underline; }
.analysis-pivot .ap-see-all { margin-top: 4px; padding-inline-start: 0; }
.analysis-pivot .ap-bars { display: flex; flex-direction: column; gap: 5px; }
.analysis-pivot .ap-bar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 8px; align-items: center; }
.analysis-pivot .ap-bar-label { border: 0; padding: 0; text-align: start; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.analysis-pivot .ap-bar-label:hover { text-decoration: underline; }
.analysis-pivot .ap-track { grid-column: 1 / -1; display: flex; height: 6px; background: var(--ap-field); border-radius: 3px; overflow: hidden; }
.analysis-pivot .ap-track i { display: block; height: 100%; background: var(--ap-accent); }
.analysis-pivot .ap-legend { display: flex; flex-wrap: wrap; gap: 4px 10px; color: var(--ap-muted); font-size: 11px; margin-top: 4px; }
.analysis-pivot .ap-swatch { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-inline-end: 4px; }
.analysis-pivot .ap-drill:not(:empty) { margin-top: 8px; padding-top: 6px; border-top: 1px dashed var(--ap-line); }
.analysis-pivot .ap-drill-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 4px; }
.analysis-pivot .ap-records td { font-size: 11px; }
.analysis-pivot .ap-pager { display: flex; align-items: center; gap: 8px; margin-top: 6px; color: var(--ap-muted); }
.analysis-pivot-dialog {
  width: min(1100px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: auto; margin: auto;
  padding: 12px 18px 18px; border: 1px solid var(--ap-line); border-radius: 8px;
  background: var(--panel, var(--bg-1, Canvas)); color: var(--txt, var(--tx-1, CanvasText)); font-size: 13px;
}
.analysis-pivot-dialog::backdrop { background: rgb(8 10 14 / 60%); }
.analysis-pivot-dialog .ap-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.analysis-pivot-dialog h2 { margin: 0; font-size: var(--fz-lg, 16px); }
.analysis-pivot-dialog select { flex: 0 1 200px; }
@media (prefers-reduced-motion: reduce) { .analysis-pivot * { transition: none !important; } }
