/* Report shell  -  shared layout for every named report under #/reports/...
   Tokens come from app/shell/shell.css. */

.report-view { display: flex; flex-direction: column; gap: 16px; }

.report-header { display: flex; justify-content: space-between; align-items: baseline; }

/* Pattern B title treatment: Saira Condensed in accent gold, no per-report
   cannabinoid acronym. The `description` line below acts as the lead. */
.report-title {
  margin: 0;
  font-family: 'Saira Condensed', 'DM Sans', sans-serif;
  font-weight: 800;
  font-size: 1.6rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--accent);
  line-height: 1.1;
}
.report-header__desc {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 4px;
}

.report-filters {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}
.report-filters input,
.report-filters select {
  background: var(--input-bg);
  color: var(--text-primary);
  border: 1px solid var(--input-border);
  border-radius: 6px;
  padding: 6px 10px;
  font: inherit;
}

.report-chip {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: 14px;
  cursor: pointer;
  font-size: 12px;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.report-chip:not(.is-active):hover {
  border-color: var(--accent);
  color: var(--text-primary);
}
.report-chip.is-active {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
}

.report-export { position: relative; }
.report-export__btn {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 6px;
  padding: 6px 14px;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}
.report-export__btn:hover { background: var(--accent-hover); }
.report-export__menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 0;
  min-width: 140px;
  z-index: 10;
  display: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.report-export.is-open .report-export__menu { display: block; }
.report-export__item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--text-primary);
  padding: 8px 14px;
  cursor: pointer;
  font: inherit;
}
.report-export__item:hover { background: rgba(255,255,255,0.05); }

.report-table { width: 100%; border-collapse: collapse; }
.report-table th,
.report-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.report-table th {
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  user-select: none;
}
.report-table th:hover { color: var(--text-primary); }
.report-table th.is-sorted { color: var(--accent); }
.report-table th[title] { cursor: help; }
.report-th-tip {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-left: 4px;
  border-radius: 50%;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 9px;
  line-height: 10px;
  text-align: center;
  font-weight: 700;
  vertical-align: middle;
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
}
.report-table th:hover .report-th-tip { color: var(--accent); border-color: var(--accent); }

.leaders-product { display: flex; flex-direction: column; gap: 2px; }
.leaders-product__name { color: var(--text-primary); }
.leaders-imbalance-link {
  display: inline-block;
  font-size: 11px;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: 0.02em;
  align-self: flex-start;
  padding: 1px 6px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: rgba(230, 180, 80, 0.06);
  transition: background 0.12s, color 0.12s;
}
.leaders-imbalance-link:hover {
  background: var(--accent);
  color: #000;
}

.report-empty {
  text-align: center;
  padding: 40px;
  color: var(--text-secondary);
}

/* Wrap report tables so wide columns scroll on narrow viewports instead of
   crushing readability. min-width keeps the headers legible. */
.report-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.report-table { min-width: 720px; }

/* Velocity pills used by /reports/sales-velocity. Matches the inventory
   status pill scale: green / amber / red. */
.velocity-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.velocity-pill--fast   { background: rgba(46,160,67,0.22);  color: #3fb950; }
.velocity-pill--normal { background: rgba(187,128,9,0.20);  color: #d29922; }
.velocity-pill--slow   { background: rgba(248,81,73,0.18);  color: #f85149; }

.report-prefilter {
  color: var(--text-secondary);
  font-size: 12px;
  padding: 8px 10px;
  border-left: 2px solid var(--accent);
  background: rgba(255,255,255,0.02);
}

.report-expand-col { width: 28px; }
.report-expand-cell {
  width: 28px;
  padding: 6px !important;
  text-align: center;
}
.report-expand-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  padding: 4px 6px;
  line-height: 1;
  transition: transform 0.15s, color 0.15s;
}
.report-expand-btn:hover { color: var(--accent); }
.report-expand-btn.is-open {
  transform: rotate(90deg);
  color: var(--accent);
}
.report-expand-row td { background: rgba(255,255,255,0.02); }
.report-expand-detail { padding: 12px 16px !important; }

.report-bar-chart {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 480px;
}
.report-bar-chart__row {
  display: grid;
  grid-template-columns: 90px 1fr 90px;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}
.report-bar-chart__label { color: var(--text-secondary); }
.report-bar-chart__track {
  height: 14px;
  background: var(--bg);
  border-radius: 7px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.report-bar-chart__fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.2s;
}
.report-bar-chart__fill--regular { background: var(--text-secondary); }
.report-bar-chart__value {
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* ---------- Compound Leaders prefilter chrome ---------- */

.leaders-prefilter {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.leaders-prefilter__pickerrow {
  display: flex;
  align-items: center;
  gap: 10px;
}
.leaders-prefilter__label {
  color: var(--text-secondary);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
#compound-leaders-select {
  background: var(--input-bg);
  color: var(--text-primary);
  border: 1px solid var(--input-border);
  border-radius: 6px;
  padding: 6px 10px;
  font: inherit;
  font-size: 13px;
  min-width: 180px;
}

.leaders-indicator { display: flex; flex-direction: column; gap: 2px; }
.leaders-indicator__top {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.leaders-indicator__count {
  font-family: 'Saira Condensed', 'DM Sans', sans-serif;
  font-weight: 800;
  font-size: 1.6rem;
  color: var(--accent);
  line-height: 1;
}
.leaders-indicator__sub {
  color: var(--text-secondary);
  font-size: 12px;
}
.leaders-indicator__hint {
  color: var(--text-secondary);
  font-size: 11px;
  opacity: 0.8;
}
.leaders-indicator__why {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  cursor: help;
  padding: 0;
  line-height: 16px;
}
.leaders-indicator__why:hover { color: var(--accent); border-color: var(--accent); }
.leaders-indicator__why[aria-expanded="true"] {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
}

/* ---------- Threshold popover ---------- */

.leaders-threshold-anchor {
  position: relative;
  display: inline-block;
}
.threshold-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: -8px;
  width: 380px;
  max-width: calc(100vw - 32px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  z-index: 100;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
  pointer-events: none;
}
.threshold-popover[hidden] { display: none; }
.threshold-popover.is-open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.threshold-popover::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 14px;
  width: 10px;
  height: 10px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
  transform: rotate(45deg);
}
.threshold-popover__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px 8px 14px;
  border-bottom: 1px solid var(--border);
}
.threshold-popover__title {
  font-family: 'Saira Condensed', 'DM Sans', sans-serif;
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
}
.threshold-popover__close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}
.threshold-popover__close:hover { color: var(--text-primary); background: rgba(255,255,255,0.06); }
.threshold-popover__body {
  padding: 12px 14px 14px 14px;
  font-size: 12px;
  color: var(--text-primary);
}
.threshold-popover__body p {
  margin: 0 0 10px 0;
  color: var(--text-secondary);
  line-height: 1.45;
}
.threshold-popover__body p strong { color: var(--text-primary); }
.threshold-popover__rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}
.threshold-popover__row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "compounds pct"
    "why why"
    "counts counts";
  gap: 4px 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(255,255,255,0.02);
  transition: border-color 0.12s, background 0.12s;
}
.threshold-popover__row.is-active {
  border-color: var(--accent);
  background: rgba(230, 180, 80, 0.06);
}
.threshold-popover__compounds {
  grid-area: compounds;
  font-weight: 600;
  color: var(--text-primary);
  font-size: 12px;
}
.threshold-popover__row.is-active .threshold-popover__compounds { color: var(--accent); }
.threshold-popover__pct {
  grid-area: pct;
  font-family: 'Saira Condensed', 'DM Sans', sans-serif;
  font-weight: 800;
  font-size: 14px;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.threshold-popover__row.is-active .threshold-popover__pct { color: var(--accent); }
.threshold-popover__why {
  grid-area: why;
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1.4;
}
.threshold-popover__counts {
  grid-area: counts;
  font-size: 11px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  border-top: 1px dashed var(--border);
  padding-top: 4px;
  margin-top: 2px;
}
.threshold-popover__counts-of { opacity: 0.7; }
.threshold-popover__foot {
  margin-bottom: 0 !important;
  font-size: 11px !important;
  font-style: italic;
  opacity: 0.85;
}

/* ---------- Catalog distribution strip ---------- */

.cat-dist {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255,255,255,0.02);
}
.cat-dist__head {
  color: var(--text-secondary);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.cat-dist__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 4px 12px;
}
.cat-dist__item {
  display: grid;
  grid-template-columns: 70px 1fr 32px;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  padding: 3px 4px;
  cursor: pointer;
  border-radius: 4px;
  text-align: left;
  color: var(--text-primary);
  font: inherit;
}
.cat-dist__item:hover { background: rgba(255,255,255,0.04); }
.cat-dist__item.is-active .cat-dist__label { color: var(--accent); font-weight: 600; }
.cat-dist__item.is-active .cat-dist__count { color: var(--accent); }
.cat-dist__label { font-size: 12px; color: var(--text-secondary); }
.cat-dist__track {
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.cat-dist__fill {
  height: 100%;
  background: var(--text-secondary);
  transition: width 0.2s, background 0.15s;
}
.cat-dist__item.is-active .cat-dist__fill { background: var(--accent); }
.cat-dist__item:hover .cat-dist__fill { background: var(--accent); opacity: 0.7; }
.cat-dist__count {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--text-secondary);
  text-align: right;
}

/* ---------- Compound profile inline bar ---------- */

.profile-bar {
  display: inline-grid;
  grid-template-columns: 1fr 36px;
  gap: 6px;
  align-items: center;
  width: 140px;
}
.profile-bar--empty { color: var(--text-secondary); }
.profile-bar__track {
  display: flex;
  width: 100%;
  height: 12px;
  background: var(--bg);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.profile-bar__seg {
  height: 100%;
  background: var(--text-secondary);
  opacity: 0.5;
}
.profile-bar__seg--active {
  background: var(--accent);
  opacity: 1;
}
.profile-bar__label {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  text-align: right;
}

/* ---------- Trend cell ---------- */

.trend-cell {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}
.trend-cell--up { color: #6fcf6f; }
.trend-cell--down { color: #f08a8a; }
.trend-cell--flat { color: var(--text-secondary); }
.trend-cell--neutral { color: var(--text-secondary); }
.trend-cell__arrow { font-size: 10px; }

/* ---------- Days of supply cell ---------- */

.dos-cell {
  display: inline-block;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 4px;
}
.dos-cell--urgent { background: rgba(240,138,138,0.12); color: #f08a8a; }
.dos-cell--ok { color: var(--text-primary); }
.dos-cell--slow { background: rgba(230,180,80,0.12); color: #e6b450; }
.dos-cell--stale { color: var(--text-secondary); font-style: italic; }

/* ---------- Numeric cell baseline ---------- */

.num-cell { font-variant-numeric: tabular-nums; }

/* ---------- Row-expand drawer (Compound Leaders) ---------- */

.leaders-detail {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(320px, 2fr);
  gap: 24px;
}
.leaders-detail__h {
  margin: 0 0 8px 0;
  font-family: 'Saira Condensed', 'DM Sans', sans-serif;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.leaders-detail__legend {
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-secondary);
}
.leaders-detail__swatch {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--text-secondary);
  border-radius: 2px;
  margin-right: 4px;
  vertical-align: -1px;
  opacity: 0.5;
}
.leaders-detail__swatch--sale { background: var(--accent); opacity: 1; }

.profile-detail {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.profile-detail__row {
  display: grid;
  grid-template-columns: 90px 1fr 50px 70px;
  gap: 8px;
  align-items: center;
  font-size: 12px;
}
.profile-detail__label { color: var(--text-secondary); }
.profile-detail__label.is-active { color: var(--accent); font-weight: 600; }
.profile-detail__bar {
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.profile-detail__fill {
  height: 100%;
  background: var(--text-secondary);
  opacity: 0.6;
}
.profile-detail__fill.is-active { background: var(--accent); opacity: 1; }
.profile-detail__share { font-variant-numeric: tabular-nums; text-align: right; }
.profile-detail__abs {
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--text-secondary);
}

.spark { width: 100%; }
.spark__bars {
  display: flex;
  align-items: flex-end;
  gap: 1px;
  height: 56px;
  padding: 4px 0;
}
.spark__bar {
  flex: 1 1 0;
  min-width: 2px;
  background: var(--text-secondary);
  opacity: 0.45;
  border-radius: 1px 1px 0 0;
  transition: opacity 0.1s;
}
.spark__bar--sale { background: var(--accent); opacity: 1; }
.spark__bar:hover { opacity: 1; outline: 1px solid var(--accent); }

.report-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  padding: 12px 16px;
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  z-index: 1000;
}

/* Manifest Receipts: structured per-row detail */
.report-shell .mr-detail {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.4rem;
  font-size: 0.8rem;
  padding: 0.4rem 0;
}
.report-shell .mr-detail .mr-row {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 0.6rem;
  align-items: start;
}
.report-shell .mr-detail .mr-key {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  font-weight: 600;
  padding-top: 0.1rem;
}
.report-shell .mr-detail .mr-val { color: var(--text-primary); line-height: 1.5; }
.report-shell .mr-detail .mr-muted { color: var(--text-secondary); }
.report-shell .mr-items-wrap { margin-top: 0.6rem; overflow-x: auto; }
.report-shell .mr-items {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.74rem;
}
.report-shell .mr-items th {
  text-align: left;
  font-size: 0.66rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.3rem 0.5rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.report-shell .mr-items td {
  padding: 0.3rem 0.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  color: var(--text-primary);
}
