/* Data display: tables, thumbnails + hover preview, sales/forecast chart, progress bars. */

/* ---------- Table ---------- */
.tbl-wrap { border: 1px solid var(--border-subtle); border-radius: var(--r-md); background: var(--bg-card); }
.tbl-wrap--flush { border: 0; border-radius: 0; background: transparent; }
.tbl-topscroll { overflow-x: auto; overflow-y: hidden; height: 14px; border-bottom: 1px solid var(--border-subtle); }
.tbl-topscroll__inner { height: 1px; }
.tbl-scroll { overflow: auto; border-radius: 0 0 var(--r-md) var(--r-md); }
.tbl-scroll--tall { max-height: 68vh; }
.tbl { width: 100%; }
.tbl th {
  padding: 12px 8px; text-align: left; font-size: var(--fs-caption); font-weight: 500; color: var(--text-tertiary);
  background: var(--bg-card); box-shadow: inset 0 -1px 0 var(--border-subtle); white-space: nowrap;
}
.tbl--sticky th { position: sticky; top: 0; z-index: var(--z-sticky); }
.tbl th.is-sortable { cursor: pointer; user-select: none; }
.tbl th.is-sorted { color: var(--text-primary); }
.tbl th.is-right, .tbl td.is-right { text-align: right; }
.tbl__th-inner { display: inline-flex; align-items: center; gap: 4px; }
.tbl__sort { color: var(--accent); opacity: 0; }
.is-sorted .tbl__sort { opacity: 1; }
.tbl__sort.is-asc { transform: rotate(180deg); }
.tbl td { padding: 11px 8px; font-size: var(--fs-body); border-bottom: 1px solid var(--border-subtle); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: var(--bg-row-hover); }
.tbl tbody tr.is-clickable { cursor: pointer; }
.tbl tbody tr.is-selected { background: var(--bg-row-hover); }
.tbl th:first-child, .tbl td:first-child { padding-left: 20px; }
.tbl th:last-child, .tbl td:last-child { padding-right: 20px; }
.tbl--roomy td { padding-top: 12px; padding-bottom: 12px; }
.tbl--roomy th { padding-top: 10px; padding-bottom: 10px; }
.tbl--roomy th:first-child, .tbl--roomy td:first-child { padding-left: 24px; }
.tbl--roomy th:last-child, .tbl--roomy td:last-child { padding-right: 24px; }
.tbl td.is-mono { font-family: var(--font-mono); font-size: var(--fs-meta); font-variant-numeric: tabular-nums; }
.tbl td.is-muted { color: var(--text-secondary); }
.tbl__empty { padding: 48px 20px !important; text-align: center; color: var(--text-tertiary); font-size: var(--fs-body); }
.tbl tbody tr.tbl__empty-row:hover { background: transparent; }

/* ---------- Product thumbnail + hover preview ---------- */
.thumb {
  display: grid; place-items: center; width: 32px; height: 32px; flex: none; overflow: hidden;
  border-radius: var(--r-sm); background: var(--bg-raised); color: var(--text-tertiary);
}
.thumb--zoom { cursor: zoom-in; }
.thumb__img { display: block; width: 100%; height: 100%; object-fit: cover; }
.preview {
  position: fixed; transform: translateY(-50%); z-index: var(--z-preview); display: flex; flex-direction: column; gap: 6px;
  padding: 8px; border: 1px solid var(--border-default); border-radius: var(--r-lg); background: var(--bg-raised);
  box-shadow: var(--shadow-dropdown); pointer-events: none;
}
.preview__img { display: block; width: 200px; height: 200px; border-radius: var(--r-sm); object-fit: cover; }
.preview__ph {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; width: 200px; height: 200px;
  border-radius: var(--r-sm); background: repeating-linear-gradient(135deg, var(--bg-input) 0 8px, var(--ph-stripe) 8px 16px);
  color: var(--text-tertiary); font-family: var(--font-mono); font-size: var(--fs-micro);
}
.preview__name { max-width: 200px; font-size: var(--fs-meta); font-weight: 500; }
.preview__code { color: var(--text-tertiary); font-family: var(--font-mono); font-size: var(--fs-micro); }

/* ---------- Sales + forecast chart (Model card) ---------- */
.chart-legend { display: flex; align-items: center; gap: 6px; color: var(--text-secondary); font-size: var(--fs-caption); }
.chart-legend__bar { width: 8px; height: 8px; border-radius: 2px; background: var(--chart-bar); }
.chart-legend__line { width: 14px; border-top: 2px dotted var(--chart-forecast); }
.chart { position: relative; height: 230px; margin-top: 18px; }
.chart__plot { position: absolute; left: 28px; right: 4px; top: 10px; bottom: 24px; }
.chart__grid { position: absolute; left: 0; right: 0; border-top: 1px solid var(--chart-grid); }
.chart__grid.is-axis { border-top-color: var(--chart-axis); }
.chart__ytick {
  position: absolute; left: -28px; top: -7px; width: 20px; text-align: right;
  color: var(--text-tertiary); font-family: var(--font-mono); font-size: var(--fs-tiny);
}
.chart__bars { position: absolute; inset: 0; display: flex; align-items: flex-end; gap: 2px; }
.chart__bar { flex: 1; min-width: 0; background: var(--chart-bar); border-radius: 1px 1px 0 0; }
.chart__zone {
  position: absolute; top: 0; bottom: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; padding-top: 4px;
  background: var(--danger-tint); border-left: 1px solid var(--st-out); border-right: 1px solid var(--st-transit);
}
.chart__zone-top { color: var(--st-transit); font-size: var(--fs-tiny); white-space: nowrap; }
.chart__zone-bottom { color: var(--st-out); font-size: var(--fs-tiny); white-space: nowrap; }
.chart__svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.chart__forecast { stroke: var(--chart-forecast); stroke-width: 1.5; stroke-dasharray: 2 3; vector-effect: non-scaling-stroke; }
.chart__x {
  position: absolute; left: 0; right: 0; bottom: -22px; height: 16px;
  color: var(--text-tertiary); font-family: var(--font-mono); font-size: var(--fs-tiny);
}
.chart__xlabel { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.chart__xlabel.is-first { transform: none; }
.chart__xlabel.is-last { transform: none; }

/* ---------- Progress: order stages, shipment stages, lead time ---------- */
.stages { display: grid; gap: 4px; }
.stages--6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.stages--5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.stage { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.stage__bar { display: block; height: 3px; border-radius: 2px; background: var(--track); }
.stage.is-done .stage__bar { background: var(--accent); }
.stages--transit .stage.is-done .stage__bar { background: var(--st-transit); }
.stage.is-warn .stage__bar { background: var(--st-order); }
.stages.is-cancelled .stage__bar { background: var(--track); }
.stage__label { font-size: var(--fs-micro); line-height: 1.3; color: var(--text-disabled); font-weight: 450; }
.stage.is-done .stage__label { color: var(--text-secondary); }
.stage.is-current .stage__label { color: var(--text-primary); font-weight: 600; }
.stage__date { color: var(--text-tertiary); font-family: var(--font-mono); font-size: var(--fs-tiny); min-height: 1em; }

.lead__head { display: flex; align-items: baseline; gap: 12px; }
.lead__title { font-size: var(--fs-body); font-weight: 600; }
.lead__total { margin-left: auto; font-family: var(--font-mono); font-size: var(--fs-body); font-weight: 600; }
.lead__bar { display: flex; gap: 2px; height: 6px; margin-top: 10px; border-radius: 3px; overflow: hidden; }
.lead__prod { background: var(--accent); }
.lead__ship { background: var(--st-transit); }
.lead__legend { display: flex; gap: 20px; margin-top: 10px; flex-wrap: wrap; }
.lead__key { display: flex; align-items: center; gap: 6px; }
.lead__swatch { width: 8px; height: 8px; border-radius: 2px; }
.lead__swatch.is-prod { background: var(--accent); }
.lead__swatch.is-ship { background: var(--st-transit); }
.lead__name { color: var(--text-secondary); font-size: var(--fs-small); }
.lead__val { font-family: var(--font-mono); font-size: var(--fs-small); }

.events { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border-subtle); }
.event { display: flex; gap: 10px; }
.event__dot { width: 8px; height: 8px; flex: none; margin-top: 5px; border-radius: var(--r-full); background: var(--event-dot-old); }
.event.is-latest .event__dot { background: var(--st-transit); }
.event__body { display: flex; flex-direction: column; gap: 2px; }
.event__title { font-size: var(--fs-meta); }
.event__meta { color: var(--text-tertiary); font-family: var(--font-mono); font-size: var(--fs-micro); }
