/* Forecast by SKU — a wide, export-oriented datatable. Loaded via the app-wide
   stylesheet_link_tag :app glob (no per-view link tag — see design-system §19). */

/* Sits directly under the standard .page-header (h1 + top-right .csv-btn). */
.fbs-subtitle {
  margin: -0.25rem 0 1rem;
  color: var(--muted);
  font-size: 13px;
  max-width: 70ch;
  line-height: 1.5;
}

.fbs-num-input {
  max-width: 110px;
}

/* CSV export button loading state (csv-download-button controller). */
.fbs-csv-loading {
  opacity: 0.7;
  pointer-events: none;
}
.fbs-csv-spinner {
  display: inline-block;
  width: 11px;
  height: 11px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: fbs-csv-spin 0.6s linear infinite;
  vertical-align: -1px;
}
@keyframes fbs-csv-spin {
  to { transform: rotate(360deg); }
}
.fbs-select {
  max-width: 260px;
}

/* Forward-vs-demand change cells: green when the forecast is above last year's
   demand (growth), red when below. */
.fbs-table .fbs-pos {
  color: var(--green);
}
.fbs-table .fbs-neg {
  color: var(--red);
}

/* ── Recent background exports ── */
.fbs-exports {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  margin: 0 0 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--surface-alt);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 12px;
}
.fbs-exports-label {
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 11px;
}
/* Opens the Recent exports modal; styled as a quiet text link. */
.fbs-exports-more {
  margin-left: auto;
  padding: 0;
  border: 0;
  background: none;
  color: var(--blue);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.fbs-exports-more:hover {
  text-decoration: underline;
}
.fbs-exports-note {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 12px;
}
.fbs-exports-heading {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 1rem 0 0.5rem;
  font-size: 13px;
  font-weight: 700;
}
.fbs-exports-heading:first-of-type {
  margin-top: 0;
}
.fbs-admin-badge {
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  background: var(--purple-tint);
  color: var(--purple);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.fbs-exports-table {
  font-size: 12px;
}
.fbs-exports-table .fbs-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.fbs-exports-summary {
  white-space: normal;
  max-width: 320px;
}
.fbs-export {
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
}
.fbs-export-link {
  font-weight: 600;
  color: var(--red);
}
.fbs-export-meta {
  color: var(--muted);
}
.fbs-export-failed {
  color: var(--red);
  font-weight: 600;
}
.fbs-export-preparing {
  color: var(--amber);
  font-weight: 600;
}

/* ── Table ── */

/* Frozen header row. A page-level sticky thead can't latch while .table-wrapper
   keeps overflow-x:auto for the wide column set (the wrapper, not the page, is
   then the sticky scroll ancestor), so the wrapper becomes the scroll container
   on BOTH axes and the header sticks to its top edge. Same approach as
   replenishment's .replen-grid-scroll (replenishment_v2.css, a page stylesheet
   not loaded here). max-height = viewport minus the 49px sticky navbar and 31px
   clearance so the horizontal scrollbar isn't flush with the viewport edge; the
   vh line is the no-dvh fallback. Divider via inset box-shadow, not border:
   collapsed table borders are unreliably painted under position:sticky. */
.table-wrapper.fbs-grid-scroll {
  overflow: auto;
  max-height: calc(100vh - 80px);
  max-height: calc(100dvh - 80px);
  isolation: isolate;
}
.fbs-grid-scroll > table > thead > tr > th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--surface-alt);
  box-shadow: inset 0 -1px 0 var(--border-light);
}
/* Window columns keep their blue top rule alongside the divider. */
.fbs-grid-scroll .fbs-table th.fbs-win {
  box-shadow: inset 0 2px 0 var(--blue), inset 0 -1px 0 var(--border-light);
}

.fbs-table {
  font-size: 12px;
  white-space: nowrap;
}
.fbs-table th,
.fbs-table td {
  padding: 0.4rem 0.55rem;
  vertical-align: middle;
}
.fbs-table .fbs-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.fbs-table th.fbs-num {
  text-align: right;
}
/* Subtle tint grouping the forecast-figure columns so the eye can find them in
   a wide table (30d / 180d units, ADD, horizon $). */
.fbs-table .fbs-fc {
  background: var(--surface-alt);
}
.fbs-table .fbs-muted {
  color: var(--muted);
}
/* Days on Mkt for a not-yet-launched SKU ("in 133d"); launch date on hover. */
.fbs-table .fbs-launch {
  color: var(--muted);
  cursor: help;
}
.fbs-table .fbs-strong {
  font-weight: 700;
}

/* Product cell — link + variant/season subline (self-contained; does not lean on
   replenishment_v2's per-page .prod-* rules). Wider than the other text cells so
   the product name has room; the name weight is intentionally softer than
   replenishment's .prod-link (toned down here only, pending review). */
.fbs-prod-cell {
  min-width: 240px;
  white-space: normal;
}
.fbs-prod-link {
  font-weight: 500;
  color: var(--ink);
}

/* Vendor cell — capped so a long vendor name doesn't crowd the forecast columns;
   full name on hover via the title attribute. */
.fbs-table .fbs-vendor {
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fbs-variant-sub {
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
}
.fbs-variant-sub .fbs-sep {
  margin: 0 4px;
  color: var(--border-hover, var(--muted));
}
.fbs-abc {
  display: inline-block;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}
.fbs-kit-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  background: var(--tint-info-bg, var(--surface-alt));
  color: var(--blue);
  font-size: 11px;
  font-weight: 600;
}

/* Supersession badges */
.fbs-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.fbs-badge-succ {
  background: var(--tint-info-bg, var(--surface-alt));
  color: var(--blue);
}
.fbs-badge-pred {
  background: var(--amber-tint, var(--surface-alt));
  color: var(--amber);
}
.fbs-badge-link {
  color: inherit;
  text-decoration: underline;
}
/* Two-line variant (Supersession column): small label over the linked code, so
   the column is as wide as the code instead of "Superseded by <code>". */
.fbs-badge-stack {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  padding: 2px 6px;
  line-height: 1.25;
}
.fbs-badge-label {
  font-size: 10px;
  font-weight: 500;
  opacity: 0.85;
}

.fbs-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--muted);
}
.fbs-empty p {
  margin: 0 0 0.75rem;
}

/* Configurable ColumnProfile columns (custom fields / standard fields),
   appended after the built-in block — mirrors replenishment's .rcc-* pair. */
.fbs-table th.fbs-cc-head {
  text-align: left;
  white-space: nowrap;
}
.fbs-table td.fbs-cc-cell {
  text-align: left;
  font-size: 12px;
  color: var(--ink);
}

/* ── Custom forecast window (ForecastWindow) ──
   The window block is the one the user asked for, so it reads as "selected"
   (design-system blue): a blue-tinted band with blue headers, set apart from the
   neutral-tinted fixed 30/90/180/365d windows that follow it. */
.fbs-window-inputs {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.fbs-date-input {
  max-width: 150px;
}
.fbs-window-to {
  color: var(--muted);
  font-size: 12px;
}
.fbs-window-error {
  flex-basis: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--red);
  border-radius: var(--radius-sm);
  background: var(--red-tint);
  color: var(--red);
  font-size: 12px;
  font-weight: 600;
}
.fbs-window-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.75rem;
  margin: 0 0 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--blue-tint);
  font-size: 12px;
}
.fbs-window-banner-label {
  color: var(--blue);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.fbs-window-banner-range {
  color: var(--ink);
  font-weight: 700;
}
.fbs-window-banner-meta {
  color: var(--muted);
}
.fbs-table .fbs-win {
  background: var(--blue-tint);
}
.fbs-table th.fbs-win,
.fbs-table th.fbs-win a {
  color: var(--blue);
  font-weight: 700;
}
.fbs-table th.fbs-win {
  box-shadow: inset 0 2px 0 var(--blue);
}
