.sales-analysis-host { min-width:0; max-width:100%; }
.sales-analysis { min-width:0; max-width:100%; background:var(--panel); border:1px solid var(--line); border-radius:var(--workspace-panel-radius); padding:var(--workspace-panel-padding); color:var(--ink); font-size:14px; line-height:1.7; }
.sales-analysis *, .sales-analysis *::before, .sales-analysis *::after { box-sizing:border-box; }
.sales-analysis h2, .sales-analysis h3, .sales-analysis h4, .sales-analysis p, .sales-analysis dl { margin:0; }
.sales-analysis h2 { font-size:20px; line-height:1.55; }
.sales-analysis h3 { font-size:16px; line-height:1.6; }
.sales-analysis h4 { font-size:14px; line-height:1.65; }
.sales-analysis :is(.sa-heading h2, .sa-section-head h3) { font-size:var(--workspace-section-heading-size); font-weight:var(--workspace-heading-weight); line-height:var(--workspace-section-heading-leading); }
.sales-analysis button { cursor:pointer; }
.sales-analysis button:disabled { cursor:not-allowed; opacity:.55; }
.sales-analysis :is(button,select,input,summary,[tabindex]):focus-visible { outline:3px solid var(--brand); outline-offset:3px; }
.sales-analysis .text-button { min-height:44px; padding:4px 0; color:var(--brand-dark); text-align:left; font-size:14px; line-height:1.6; white-space:normal; overflow-wrap:anywhere; }
.sales-analysis .text-button:hover { text-decoration:underline; text-underline-offset:3px; }
.sales-analysis .secondary-button { min-height:44px; padding:8px 14px; font-size:14px; white-space:nowrap; }
.sa-caption { color:var(--muted); font-size:13px; line-height:1.7; overflow-wrap:anywhere; }
.sa-heading { display:flex; gap:16px; justify-content:space-between; align-items:flex-start; margin-bottom:18px; }
.sa-heading .sa-caption { margin-top:5px; }
.sa-filters { display:grid; grid-template-columns:auto minmax(135px,.8fr) minmax(140px,1fr) minmax(140px,1fr) minmax(80px,.5fr); gap:10px 14px; align-items:end; padding-bottom:18px; border-bottom:1px solid var(--line); }
.sa-field, .sa-period-field { display:grid; gap:5px; min-width:0; }
.sa-field > span, .sa-period-field > span { font-size:13px; font-weight:600; color:var(--muted); }
.sa-field select, .sa-field input { min-width:0; width:100%; min-height:44px; border:1px solid var(--line); border-radius:8px; background:var(--panel); color:var(--ink); padding:8px 10px; font-size:16px; }
.sa-field select { cursor:pointer; }
.sa-period-switch { display:flex; min-height:44px; border:1px solid var(--line); border-radius:8px; overflow:hidden; }
.sa-period-switch button { min-height:44px; min-width:56px; padding:7px 10px; border:0; background:var(--panel); color:var(--muted); font-weight:700; font-size:14px; }
.sa-period-switch button + button { border-left:1px solid var(--line); }
.sa-period-switch button[aria-pressed="true"] { background:var(--brand); color:var(--panel); }
.sa-period-switch button:hover { box-shadow:inset 0 0 0 2px var(--brand); }
.sa-period-switch button:focus-visible { outline-offset:-4px; }
.sa-filter-summary { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:8px 0; font-size:13px; color:var(--muted); }
.sa-metrics { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:16px; padding:16px 0; border-bottom:1px solid var(--line); }
.sa-metrics > div { padding-right:12px; border-right:1px solid var(--line); min-width:0; }
.sa-metrics > div:last-child { border-right:0; }
.sa-metrics dt { color:var(--muted); font-size:13px; font-weight:600; }
.sa-metrics dd { margin:5px 0 0; font-size:22px; font-weight:750; line-height:1.4; font-variant-numeric:tabular-nums; overflow-wrap:anywhere; }
.sa-metrics + .sa-caption { margin-top:10px; }
.sa-negative { color:var(--loss); }
.sa-facts { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px; margin-top:16px; }
.sa-facts article { padding:12px 14px; background:var(--panel-strong); border-radius:8px; min-width:0; }
.sa-facts summary { cursor:pointer; min-height:44px; font-size:13px; }
.sa-facts summary strong { font-size:14px; line-height:1.6; }
.sa-facts summary > span { display:block; margin-top:6px; line-height:1.75; }
.sa-facts details > div { margin-top:10px; padding-top:8px; border-top:1px solid var(--line); }
.sa-facts summary:hover { color:var(--brand-dark); }
.sa-tabs { display:flex; gap:24px; margin-top:6px; border-bottom:1px solid var(--line); }
.sa-tabs button { min-height:48px; padding:8px 2px; border:0; border-bottom:3px solid transparent; margin-bottom:-1px; background:var(--panel); color:var(--muted); font-size:15px; font-weight:700; white-space:nowrap; }
.sa-tabs button[aria-selected="true"] { color:var(--brand-dark); border-bottom-color:var(--brand); }
.sa-tabs button:hover { color:var(--brand-dark); }
.sales-analysis [role="tabpanel"] { padding-top:0; min-width:0; }
.sales-analysis [role="tabpanel"] > .sa-section { margin-top:20px; }
.sa-section { min-width:0; }
.sa-section-head { display:flex; align-items:start; justify-content:space-between; gap:14px; margin-bottom:14px; }
.sa-section-head .sa-caption { margin-top:4px; }
.sa-chart-controls { display:flex; gap:12px; align-items:end; flex:0 0 auto; }
.sa-chart-controls .sa-field { min-width:112px; }
.sa-check { display:flex; align-items:center; gap:7px; min-height:44px; font-size:13px; cursor:pointer; white-space:nowrap; }
.sa-check input { width:18px; height:18px; margin:0; accent-color:var(--brand); flex:0 0 auto; }
.sa-chart-legend { display:flex; flex-wrap:wrap; gap:8px 18px; font-size:13px; color:var(--muted); margin-bottom:6px; }
.sa-chart-legend span { display:flex; align-items:center; gap:7px; }
.sa-legend-bar { width:14px; height:12px; background:var(--brand); opacity:.5; }
.sa-legend-average { width:20px; height:0; border-top:3px solid var(--brand-dark); }
.sa-legend-previous { width:20px; height:0; border-top:2px dashed var(--muted); }
.sa-chart-scroll { overflow-x:auto; max-width:100%; scrollbar-gutter:stable; padding-bottom:4px; }
.sa-chart-frame { position:relative; min-width:0; }
.sa-fixed-axis { position:absolute; left:0; top:0; z-index:2; pointer-events:none; background:var(--panel); }
.sa-trend-canvas { position:relative; min-width:100%; max-width:none; }
.sa-trend-canvas svg { display:block; width:100%; height:auto; }
.sa-chart-grid { stroke:var(--line); stroke-width:1; }
.sa-chart-zero { stroke:var(--muted); }
.sa-chart-tick, .sa-chart-label { fill:var(--muted); font-family:inherit; font-size:12px; }
.sa-chart-partial-label, .sa-chart-missing { fill:var(--muted); font-family:inherit; font-size:11px; }
.sa-chart-bar { fill:var(--brand); opacity:.45; }
.sa-chart-loss { fill:var(--loss); }
.sa-chart-partial { opacity:.25; stroke:var(--brand); stroke-dasharray:3 2; stroke-width:1.5; }
.sa-chart-average { stroke:var(--brand-dark); stroke-width:3; fill:none; stroke-linecap:round; stroke-linejoin:round; }
.sa-chart-previous { stroke:var(--muted); stroke-width:2; stroke-dasharray:5 4; fill:none; stroke-linecap:round; stroke-linejoin:round; }
.sa-chart-hit-targets { position:absolute; inset:0; }
.sa-trend-point { position:absolute; top:15px; bottom:1px; min-width:44px; border:1px solid transparent; border-radius:6px; background:transparent; padding:0; }
.sa-trend-point:hover { background:color-mix(in srgb,var(--brand) 6%,transparent); }
.sa-trend-point[aria-pressed="true"] { border-color:var(--line); background:color-mix(in srgb,var(--brand) 4%,transparent); }
.sa-trend-point:focus-visible { outline-offset:-3px; }
.sa-chart-selection { display:flex; align-items:center; gap:20px; padding:12px 14px; margin-top:6px; border:1px solid var(--line); border-radius:8px; font-size:13px; }
.sa-chart-selection > strong { flex:0 0 auto; font-size:14px; }
.sa-chart-selection > strong small { display:block; font-size:12px; color:var(--muted); font-weight:500; }
.sa-chart-selection dl { display:flex; flex:1; flex-wrap:wrap; gap:8px 22px; }
.sa-chart-selection dt { color:var(--muted); font-size:12px; }
.sa-chart-selection dd { margin:0; font-weight:700; font-variant-numeric:tabular-nums; }
.sa-chart-selection > .text-button { flex:0 0 auto; font-size:13px; }
.sa-chart-note { margin-top:10px!important; }
.sa-disclosure { border-top:1px solid var(--line); margin-top:16px; min-width:0; }
.sa-disclosure summary { cursor:pointer; min-height:48px; padding:12px 0; font-size:14px; font-weight:650; color:var(--ink); }
.sa-disclosure summary:hover { color:var(--brand-dark); }
.sa-disclosure-content { padding:0 0 14px; display:grid; grid-template-columns:minmax(0,1fr); gap:12px; }
.sa-disclosure-content .sa-caption { margin:0; }
.sa-basis { margin-top:22px; }
.sa-basis summary { color:var(--muted); font-weight:500; font-size:13px; }
.sa-table-scroll { min-width:0; max-width:100%; overflow-x:auto; }
.sa-table { width:100%; border-collapse:collapse; text-align:left; font-size:14px; }
.sa-table th, .sa-table td { padding:11px 12px; border-bottom:1px solid var(--line); vertical-align:middle; }
.sa-table th:first-child, .sa-table td:first-child { padding-left:0; }
.sa-table th:last-child, .sa-table td:last-child { padding-right:0; }
.sa-table thead th { background:var(--panel); color:var(--muted); font-size:12px; font-weight:600; white-space:nowrap; }
.sa-table tbody th { font-weight:600; min-width:160px; max-width:310px; overflow-wrap:anywhere; }
.sa-table td { font-variant-numeric:tabular-nums; white-space:nowrap; }
.sa-table .text-button { line-height:1.6; }
.sa-section-divider { margin-top:22px; padding-top:16px; border-top:1px solid var(--line); }
.sa-section-divider > h4 { margin-bottom:6px; }
.sa-equation { display:flex; flex-wrap:wrap; align-items:center; gap:10px 18px; padding:12px 14px; border:1px solid var(--line); border-radius:8px; }
.sa-equation dt { font-size:13px; color:var(--muted); }
.sa-equation dd { margin:2px 0 0; font-size:18px; font-weight:700; font-variant-numeric:tabular-nums; }
.sa-equation > span { color:var(--muted); }
.sa-simulation-fields { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px; }
.sa-simulation-actions { display:flex; align-items:center; gap:12px; margin-top:12px; }
.sa-form-error { color:var(--loss); font-size:13px; }
.sa-field input[aria-invalid="true"] { border-color:var(--loss); }
.sa-simulation-result { border:1px solid var(--line); border-radius:8px; padding:14px; }
.sa-simulation-result dl { display:flex; flex-wrap:wrap; gap:10px 28px; margin-top:8px; }
.sa-simulation-result dt { font-size:13px; color:var(--muted); }
.sa-simulation-result dd { margin:3px 0 0; font-size:16px; font-weight:700; }
.sa-price-result { font-size:14px; }
.sa-composition { display:grid; grid-template-columns:230px minmax(0,1fr); gap:24px; align-items:center; max-width:820px; }
.sa-donut { position:relative; width:230px; height:230px; }
.sa-donut svg { display:block; width:100%; height:100%; }
.sa-donut > div { position:absolute; inset:0; display:flex; flex-direction:column; justify-content:center; align-items:center; pointer-events:none; }
.sa-donut span { font-size:12px; color:var(--muted); }
.sa-donut strong { font-size:18px; font-variant-numeric:tabular-nums; line-height:1.5; }
.sa-palette-0 { --sa-segment:var(--brand); }
/* Categorical colors: the same index identifies a customer in every chart and legend. */
.sa-palette-1 { --sa-segment:#d17000; }
.sa-palette-2 { --sa-segment:#17866a; }
.sa-palette-3 { --sa-segment:#8554c7; }
.sa-palette-4 { --sa-segment:#cf4568; }
.sa-palette-5 { --sa-segment:#7b8798; }
.sa-donut-segment { stroke:var(--sa-segment); }
.sa-composition-list { list-style:none; padding:0; margin:0; display:grid; gap:3px; }
.sa-composition-list li { display:flex; align-items:center; gap:10px; padding:5px 0; }
.sa-swatch { width:12px; height:12px; border-radius:3px; background:var(--sa-segment); flex:0 0 auto; }
.sa-composition-list li > div { flex:1; min-width:0; display:flex; justify-content:space-between; align-items:center; gap:16px; }
.sa-composition-list li > div > span { flex:0 0 auto; text-align:right; font-weight:700; font-variant-numeric:tabular-nums; }
.sa-composition-list small { display:block; font-size:12px; font-weight:500; color:var(--muted); }
.sa-composition-list .text-button { padding-block:4px; }
.sa-donut-empty { padding:20px 0; }
.sa-donut-empty strong { font-size:24px; }
.sa-pagination { display:flex; align-items:center; justify-content:space-between; gap:10px; padding-top:10px; font-size:13px; color:var(--muted); }
.sa-pagination > div { display:flex; gap:8px; }
.sa-case-customer { display:block; font-size:12px; color:var(--muted); font-weight:500; }
.sa-amount-bands { list-style:none; display:grid; gap:12px; margin:0; padding:0; max-width:600px; }
.sa-amount-bands li { display:grid; grid-template-columns:110px minmax(0,1fr) 48px; gap:14px; align-items:center; font-size:13px; }
.sa-amount-bands li > div { height:12px; background:var(--panel-strong); border-radius:2px; }
.sa-amount-bands i { display:block; height:100%; background:var(--brand); border-radius:2px; }
.sa-amount-bands strong { text-align:right; font-variant-numeric:tabular-nums; }
.sa-mini-metrics { display:flex; flex-wrap:wrap; gap:16px; }
.sa-mini-metrics dt { font-size:13px; color:var(--muted); }
.sa-mini-metrics dd { margin:0; font-weight:700; }
.sa-monthly-composition { display:grid; gap:10px; }
.sa-monthly-composition > div { display:grid; grid-template-columns:100px minmax(0,1fr); gap:12px; align-items:center; }
.sa-monthly-composition > div > span { font-size:12px; color:var(--muted); }
.sa-monthly-composition small { font-size:11px; }
.sa-composition-bar { display:flex; height:18px; background:var(--panel-strong); overflow:hidden; border-radius:3px; }
.sa-composition-bar > i { height:100%; background:var(--sa-segment); border-right:1px solid var(--panel); }
.sa-composition-bar > span { padding-inline:8px; font-size:11px; color:var(--muted); }
.sa-monthly-legend { list-style:none; display:flex; flex-wrap:wrap; gap:7px 14px; padding:0; margin:0; font-size:12px; color:var(--muted); }
.sa-monthly-legend li { display:flex; align-items:center; gap:6px; }
.sa-profit-discovery { display:flex; justify-content:space-between; align-items:center; gap:12px; border-top:1px solid var(--line); margin-top:10px; padding-top:10px; font-size:13px; color:var(--muted); }
.sa-profit-discovery .text-button { flex:0 0 auto; }
.sa-empty { padding:20px 0; color:var(--muted); font-size:14px; }
.sa-state { min-height:260px; padding:28px 0; display:grid; align-content:center; justify-items:start; gap:12px; }
.sa-state p { max-width:48em; color:var(--muted); }
.sa-sr-only { position:absolute!important; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
@media(max-width:1100px) {
  .sa-filters { grid-template-columns:auto minmax(135px,1fr) minmax(120px,1fr); }
  .sa-metrics { grid-template-columns:repeat(2,minmax(0,1fr)); gap:16px; }
  .sa-metrics > div { border-right:0; padding-right:0; }
  .sa-section-head { flex-wrap:wrap; }
  .sa-chart-controls { width:100%; }
  .sa-facts { grid-template-columns:minmax(0,1fr); }
  .sa-facts details:not([open]) summary > span { display:none; }
}
@media(max-width:760px) {
  .sales-analysis h2 { font-size:18px; }
  .sa-heading { margin-bottom:14px; }
  .sa-filters { grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; padding-bottom:14px; }
  .sa-period-switch button { flex:1; min-width:0; }
  .sa-filters > .sa-field:last-child { grid-column:2; }
  .sales-analysis .sa-metrics { margin-top:14px; }
  .sa-metrics { grid-template-columns:repeat(2,minmax(0,1fr)); padding:0 0 14px; gap:14px 16px; }
  .sa-metrics > div { border-right:0; padding-right:0; }
  .sa-metrics dt { line-height:1.6; }
  .sa-metrics dd { font-size:20px; }
  .sa-facts { gap:8px; }
  .sa-facts article { padding:8px 12px; }
  .sa-tabs { gap:0; justify-content:space-between; margin-top:4px; }
  .sa-tabs button { flex:1; font-size:14px; padding-inline:4px; }
  .sa-chart-controls { gap:10px; }
  .sa-chart-selection { flex-direction:column; align-items:flex-start; gap:8px; padding:10px 12px; }
  .sa-chart-selection > strong small { display:inline; margin-left:8px; }
  .sa-chart-selection dl { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); width:100%; gap:8px 14px; }
  .sa-composition { grid-template-columns:minmax(0,1fr); gap:10px; }
  .sa-donut { width:200px; height:200px; justify-self:center; }
  .sa-composition-list li > div { gap:10px; }
  .sa-table-scroll { overflow:visible; }
  .sa-table, .sa-table tbody { display:block; }
  .sa-table thead { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; }
  .sa-table tbody tr { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:5px 12px; padding:12px 0; border-bottom:1px solid var(--line); }
  .sa-table tbody th { grid-column:1/-1; min-width:0; max-width:none; }
  .sa-table th, .sa-table td { border:0; padding:0!important; min-width:0; white-space:normal; overflow-wrap:anywhere; }
  .sa-table td::before { content:attr(data-label); display:block; color:var(--muted); font-size:12px; font-weight:500; }
  .sa-table tbody th .text-button { min-height:44px; padding-block:4px; }
  .sa-simulation-fields { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .sa-simulation-fields .sa-field:last-child { grid-column:1/-1; max-width:230px; }
  .sa-equation { gap:8px; display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); }
  .sa-equation > span { display:none; }
  .sa-equation > div:last-child { grid-column:1/-1; padding-top:8px; border-top:1px solid var(--line); }
  .sa-equation dd { font-size:17px; }
  .sa-filter-summary { align-items:flex-start; }
  .sa-filter-summary .text-button { flex:0 0 auto; max-width:100px; }
}
@media(max-width:360px) {
  .sales-analysis { padding:12px; }
  .sa-metrics dd { font-size:18px; }
  .sa-simulation-fields { grid-template-columns:minmax(0,1fr); }
  .sa-simulation-fields .sa-field:last-child { grid-column:auto; max-width:none; }
  .sa-amount-bands li { grid-template-columns:90px minmax(0,1fr) 40px; gap:8px; }
}
@media(forced-colors:active) {
  .sa-period-switch button[aria-pressed="true"], .sa-tabs button[aria-selected="true"], .sa-trend-point[aria-pressed="true"] { outline:2px solid Highlight; outline-offset:-3px; }
  .sa-chart-bar, .sa-donut-segment, .sa-amount-bands i { forced-color-adjust:none; }
  .sa-chart-average, .sa-chart-previous { stroke:CanvasText; }
  .sa-chart-tick, .sa-chart-label, .sa-chart-partial-label, .sa-chart-missing { fill:CanvasText; }
}
@media(prefers-reduced-motion:reduce) { .sales-analysis * { scroll-behavior:auto; transition:none; animation:none; } }
