/* =========================================================================
   TCGDash — Product Explorer styles + shared .tcgd-* component library.

   Design tokens and theming live in tcgd-base.css (loaded before this file).
   This file holds the Product Explorer's own layout PLUS the shared .tcgd-*
   component classes (buttons, fields, tags, stat/stripe, section, tabs, the
   drawer/sheet system, pagination, state/error, description) that the Set
   Explorer, Compare, and Research dashboards also consume. All rules are
   namespaced under .tcgd- so the WordPress theme can't fight us. Desktop-first;
   analytical-software feel, not ecommerce.
   ========================================================================= */

#tcgd-product-explorer,
#tcgd-product-explorer * { box-sizing: border-box; }

#tcgd-product-explorer {
  font-family: var(--tcgd-font);
  color: var(--tcgd-text);
  background: var(--tcgd-bg);
  font-size: 13.5px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;

  /* === Dashboard container system ===
     WordPress wraps page content in a narrow, centered "marketing" column
     (~1080px), which made the dashboard feel tiny and cramped charts/grids.
     Break out to the full viewport width (the block stays centered, so the
     negative margins are symmetric), then cap + center the content with the
     horizontal padding: content = min(100vw − 2·gutter, --tcgd-app-max). This
     gives an app-width dashboard (Linear/Stripe), not a centered content page,
     while still bounding line length on ultra-wide screens. */
  width: auto;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  padding: 20px max(var(--tcgd-app-gutter), (100vw - var(--tcgd-app-max)) / 2) 64px;
}

/* ---------- topbar / search ---------- */

.tcgd-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.tcgd-title {
  margin: 0;
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.01em;
  color: var(--tcgd-text);
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.tcgd-title .tcgd-title-sub {
  font-weight: 500;
  color: var(--tcgd-text-muted);
  font-size: 12.5px;
  letter-spacing: 0;
}
.tcgd-search {
  flex: 1 1 320px;
  position: relative;
  max-width: 480px;
}
.tcgd-search input {
  width: 100%;
  height: 34px;
  padding: 0 12px 0 32px;
  border: 1px solid var(--tcgd-border);
  border-radius: var(--tcgd-radius-sm);
  background: var(--tcgd-surface);
  font-family: var(--tcgd-font);
  font-size: 13px;
  color: var(--tcgd-text);
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.tcgd-search input::placeholder { color: var(--tcgd-text-faint); }
.tcgd-search input:focus {
  border-color: var(--tcgd-accent);
  box-shadow: 0 0 0 3px var(--tcgd-accent-soft);
}
.tcgd-search::before {
  content: "";
  position: absolute;
  left: 11px; top: 50%;
  width: 14px; height: 14px;
  transform: translateY(-50%);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%236b7280' stroke-width='1.5'><circle cx='7' cy='7' r='5'/><line x1='11' y1='11' x2='14.5' y2='14.5'/></svg>");
  background-size: contain;
  background-repeat: no-repeat;
}

/* ---------- filter bar ---------- */

.tcgd-filterbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
  padding: 10px 12px;
  background: var(--tcgd-surface);
  border: 1px solid var(--tcgd-border);
  border-radius: var(--tcgd-radius);
}
.tcgd-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 140px;
}
.tcgd-field-grow { flex: 1 1 200px; }
.tcgd-field label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--tcgd-text-muted);
  font-weight: 600;
}
.tcgd-field select,
.tcgd-field input[type="date"] {
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--tcgd-border);
  border-radius: var(--tcgd-radius-sm);
  background: var(--tcgd-surface);
  font-family: var(--tcgd-font);
  font-size: 12.5px;
  color: var(--tcgd-text);
  cursor: pointer;
}
.tcgd-field select:focus,
.tcgd-field input[type="date"]:focus {
  outline: none;
  border-color: var(--tcgd-accent);
  box-shadow: 0 0 0 3px var(--tcgd-accent-soft);
}
.tcgd-actions {
  margin-left: auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.tcgd-btn {
  height: 30px;
  padding: 0 12px;
  background: var(--tcgd-surface);
  border: 1px solid var(--tcgd-border);
  border-radius: var(--tcgd-radius-sm);
  font-family: var(--tcgd-font);
  font-size: 12px;
  font-weight: 600;
  color: var(--tcgd-text);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.tcgd-btn:hover { background: var(--tcgd-surface-2); border-color: var(--tcgd-border-strong); }
.tcgd-btn-ghost { background: transparent; }
.tcgd-btn-primary {
  background: var(--tcgd-accent);
  color: #fff;
  border-color: var(--tcgd-accent);
}
.tcgd-btn-primary:hover { filter: brightness(1.05); }

/* ---------- result meta ---------- */

.tcgd-resultbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 6px 2px 10px;
  font-size: 12px;
  color: var(--tcgd-text-muted);
}
.tcgd-resultbar strong { color: var(--tcgd-text); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- product grid ---------- */

.tcgd-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(196px, 1fr));
  gap: 10px;
}
.tcgd-card {
  background: var(--tcgd-surface);
  border: 1px solid var(--tcgd-border);
  border-radius: var(--tcgd-radius);
  padding: 8px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: inherit;
  transition: border-color 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}
.tcgd-card:hover {
  border-color: var(--tcgd-border-strong);
  background: var(--tcgd-surface-2);
  box-shadow: var(--tcgd-shadow);
}
.tcgd-card:focus-visible {
  outline: 2px solid var(--tcgd-accent);
  outline-offset: 2px;
}

/* Image is intentionally compact — data software, not a card-shop. The
   3:2 ratio reads as less ecommerce-y than 4:3 and trims overall card
   height without making the image feel cropped. */
.tcgd-card-image {
  width: 100%;
  aspect-ratio: 3 / 2;
  background: var(--tcgd-surface-2);
  border-radius: var(--tcgd-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.tcgd-card-image img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}
.tcgd-card-image .tcgd-noimage {
  font-size: 11px;
  color: var(--tcgd-text-faint);
}
.tcgd-card-name {
  font-weight: 600;
  font-size: 12.5px;
  color: var(--tcgd-text);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  /* Reserve 2 lines so cards line up even when names are short. */
  min-height: 2.6em;
  word-break: break-word;
}
.tcgd-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  font-size: 11px;
  color: var(--tcgd-text-soft);
  min-height: 18px;
}
.tcgd-tag {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--tcgd-tag-bg);
  color: var(--tcgd-tag-text);
  font-size: 10.5px;
  font-weight: 500;
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.tcgd-tag-game { color: var(--tcgd-accent-text); background: var(--tcgd-accent-soft); }
.tcgd-tag-set  { background: var(--tcgd-tag-bg); color: var(--tcgd-tag-text); font-variant-numeric: tabular-nums; }

.tcgd-card-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 10px;
  margin-top: auto;
  padding-top: 6px;
  border-top: 1px solid var(--tcgd-divider);
}
.tcgd-stat {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.tcgd-stat-label {
  font-size: 10px;
  letter-spacing: 0.4px;
  color: var(--tcgd-text-muted);
  text-transform: uppercase;
  font-weight: 600;
}
.tcgd-stat-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--tcgd-text);
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
}
.tcgd-stat-value.tcgd-na { color: var(--tcgd-text-faint); font-weight: 500; }
.tcgd-stat-value.tcgd-positive { color: var(--tcgd-positive); }
.tcgd-stat-value.tcgd-negative { color: var(--tcgd-negative); }

/* ---------- state / empty / loading ---------- */

.tcgd-state {
  padding: 32px 16px;
  text-align: center;
  color: var(--tcgd-text-muted);
  font-size: 13.5px;
  background: var(--tcgd-surface);
  border: 1px dashed var(--tcgd-border);
  border-radius: var(--tcgd-radius);
}
.tcgd-state strong { color: var(--tcgd-text); font-weight: 600; }
.tcgd-error {
  border-style: solid;
  border-color: var(--tcgd-negative);
  color: var(--tcgd-negative);
  background: var(--tcgd-negative-soft);
}

/* ---------- pagination ---------- */

.tcgd-paginate {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  margin-top: 22px;
  padding: 6px;
  border: 1px solid var(--tcgd-border);
  border-radius: var(--tcgd-radius);
  background: var(--tcgd-surface);
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
}
.tcgd-paginate .tcgd-btn {
  height: 28px;
  padding: 0 10px;
  font-size: 11.5px;
  border-color: transparent;
  background: transparent;
}
.tcgd-paginate .tcgd-btn:hover:not([disabled]) {
  background: var(--tcgd-surface-2);
  border-color: var(--tcgd-border);
}
.tcgd-paginate .tcgd-pg-info {
  font-size: 12px;
  color: var(--tcgd-text-soft);
  padding: 0 10px;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}
.tcgd-paginate .tcgd-btn[disabled] { opacity: 0.35; cursor: not-allowed; }

/* ---------- drawer / sheet ----------
   Desktop : right-side drawer (≥721px), slides in from the right.
   Mobile  : bottom sheet (≤720px), slides up from the bottom. Full width,
             rounded top corners, sticky compact header + sticky pill tabs.
             The same DOM serves both — only the positioning, transform
             axis, and a few sizing tokens swap at the breakpoint.        */

.tcgd-drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.42);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
  z-index: 9998;
}
.tcgd-drawer-overlay.tcgd-open { opacity: 1; pointer-events: auto; }

.tcgd-drawer {
  position: fixed;
  top: 0; bottom: 0; right: 0;
  width: 75%;
  /* On ultrawide, cap width so content doesn't stretch unreadable. */
  max-width: min(1400px, 75vw);
  background: var(--tcgd-bg);
  border-left: 1px solid var(--tcgd-border-strong);
  box-shadow: var(--tcgd-shadow-drawer);
  transform: translateX(100%);
  transition: transform 240ms cubic-bezier(0.32, 0.72, 0, 1);
  z-index: 9999;
  display: flex;
  flex-direction: column;
}
.tcgd-drawer.tcgd-open { transform: translateX(0); }

/* Sticky head + tabs so they remain visible while the body scrolls. */
.tcgd-drawer-head,
.tcgd-tabs {
  background: var(--tcgd-surface);
  position: sticky;
  z-index: 2;
}
.tcgd-drawer-head {
  top: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--tcgd-border);
}
.tcgd-drawer-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--tcgd-text);
  line-height: 1.3;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tcgd-drawer-sub {
  font-size: 12px;
  color: var(--tcgd-text-muted);
  font-weight: 500;
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Compact header thumbnail — hidden on desktop drawer (image lives in the
   Overview pane), visible on the mobile sheet so the header reads as a
   native-app title bar. */
.tcgd-drawer-thumb {
  display: none;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: var(--tcgd-radius-sm);
  background: var(--tcgd-surface-2);
  overflow: hidden;
  align-items: center;
  justify-content: center;
}
.tcgd-drawer-thumb img { width: 100%; height: 100%; object-fit: contain; }

.tcgd-drawer-close {
  border: none;
  background: transparent;
  cursor: pointer;
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  color: var(--tcgd-text-soft);
  margin-left: auto;
  flex-shrink: 0;
  transition: background 120ms ease, color 120ms ease;
}
.tcgd-drawer-close:hover { background: var(--tcgd-surface-2); color: var(--tcgd-text); }
.tcgd-drawer-close:active { background: var(--tcgd-surface-3); }

/* Underline tabs — identical at all sizes. The mobile media query bumps
   padding for touch targets only; color/active treatment never changes. */
.tcgd-tabs {
  top: 60px; /* sit just below the sticky head */
  display: flex;
  gap: 2px;
  padding: 0 20px;
  border-bottom: 1px solid var(--tcgd-border);
  overflow-x: auto;
  scrollbar-width: none;
}
.tcgd-tabs::-webkit-scrollbar { display: none; }
.tcgd-tab {
  background: transparent;
  border: none;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--tcgd-text-soft);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color 120ms ease, border-color 120ms ease;
}
.tcgd-tab:hover { color: var(--tcgd-text); }
.tcgd-tab.tcgd-active {
  color: var(--tcgd-text);
  border-bottom-color: var(--tcgd-accent);
}

.tcgd-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  -webkit-overflow-scrolling: touch;
}

/* ---------- Overview pane ---------- */

.tcgd-overview {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 22px;
  align-items: start;
}
.tcgd-overview-image {
  width: 200px;
  aspect-ratio: 5 / 7;
  background: var(--tcgd-surface-2);
  border: 1px solid var(--tcgd-border);
  border-radius: var(--tcgd-radius);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.tcgd-overview-image img { width: 100%; height: 100%; object-fit: contain; }
.tcgd-overview-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.tcgd-description {
  font-size: 13.5px;
  color: var(--tcgd-text);
  line-height: 1.55;
  margin: 0 0 14px;
}
.tcgd-description-empty {
  color: var(--tcgd-text-faint);
  font-style: italic;
}

/* Long descriptions clamp to 2 lines with a Read more / Read less toggle.
   The wrap holds both <p> and the button; the wrap carries the bottom
   margin so the toggle sits flush under the text. */
.tcgd-description-wrap { margin: 0 0 14px; }
.tcgd-description-wrap .tcgd-description { margin: 0; }
.tcgd-description.tcgd-description-clamped {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tcgd-description-toggle {
  background: none;
  border: none;
  padding: 4px 0 0;
  margin: 0;
  color: var(--tcgd-accent-text);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.tcgd-description-toggle:hover { text-decoration: underline; }
.tcgd-description-toggle:focus-visible {
  outline: 2px solid var(--tcgd-accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ---------- Overview CTA bar (top-of-Overview buy actions) ----------
   Two side-by-side CTAs: TCGplayer (primary, dark fill) and eBay
   (secondary, ghost). At mobile widths they stretch full-width to be
   thumb-friendly. */
.tcgd-cta-bar {
  display: flex;
  gap: 8px;
  margin: 0 0 18px;
  flex-wrap: wrap;
}
/* CTAs are the external/forward-action variant of the button system.
   Colors match .tcgd-btn-primary / .tcgd-btn (accent-blue and ghost)
   so there is one visual language for "act on this product" surfaces.
   The trailing "→" is the only visual difference from regular buttons. */
.tcgd-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--tcgd-radius-sm);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  min-height: 34px;
  transition: filter 120ms ease, background 120ms ease, border-color 120ms ease;
  white-space: nowrap;
}
.tcgd-cta::after {
  content: "→";
  font-weight: 600;
  margin-left: 2px;
}
.tcgd-cta-primary {
  background: var(--tcgd-accent);
  color: #fff;
  border-color: var(--tcgd-accent);
}
.tcgd-cta-primary:hover { filter: brightness(1.05); }
.tcgd-cta-secondary {
  background: var(--tcgd-surface);
  color: var(--tcgd-text);
  border-color: var(--tcgd-border-strong);
}
.tcgd-cta-secondary:hover { background: var(--tcgd-surface-2); }
@media (max-width: 720px) {
  /* On mobile the CTA bar stretches edge-to-edge; each button takes
     equal share of the row width. Min-height bumps to 40px for touch. */
  .tcgd-cta { flex: 1 1 0; min-width: 0; min-height: 40px; }
}

/* Stat strip (used in Overview "key stats" row and in market tab). Uses
   auto-fit so the same component handles the 4-cell Overview stripe and
   the 6-cell market summary stripe without bespoke breakpoints. */
.tcgd-stripe {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 1px;
  background: var(--tcgd-border);
  border: 1px solid var(--tcgd-border);
  border-radius: var(--tcgd-radius);
  overflow: hidden;
  margin-bottom: 18px;
}
.tcgd-stripe-cell {
  background: var(--tcgd-surface);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tcgd-stripe-cell .tcgd-stat-label { color: var(--tcgd-text-muted); }
.tcgd-stripe-cell .tcgd-stat-value { font-size: 15px; }

/* The Overview stripe's primary cell — EV for sealed products. Neutral
   light-grey background (surface-2, theme-aware) carries the emphasis
   without competing with the value's polarity color. Larger / bolder
   value; the green/red comes from .tcgd-stat-value.tcgd-positive |
   .tcgd-negative which still applies on top. */
.tcgd-stripe-cell.tcgd-stripe-cell-primary {
  /* ~2% of the text color mixed into the surface — fainter than
     surface-2, just enough to register as "highlighted" without
     competing with the green/red value text. */
  background: color-mix(in oklab, var(--tcgd-text) 2%, var(--tcgd-surface));
}
.tcgd-stripe-cell.tcgd-stripe-cell-primary .tcgd-stat-label {
  color: var(--tcgd-text-muted);
  font-weight: 600;
}
.tcgd-stripe-cell.tcgd-stripe-cell-primary .tcgd-stat-value {
  font-size: 18px;
  font-weight: 700;
}

.tcgd-section { margin-top: 20px; }
.tcgd-section h3 {
  margin: 0 0 10px 0;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--tcgd-text-muted);
}

/* ---------- BOM ---------- */

.tcgd-bom-path {
  background: var(--tcgd-surface);
  border: 1px solid var(--tcgd-border);
  border-radius: var(--tcgd-radius);
  padding: 8px 12px;
  margin-bottom: 10px;
}
.tcgd-bom-path.tcgd-open { padding: 8px 12px 10px; }
/* PRIMARY card gets a subtle inset accent rule on the left — keeps the
   outer dimensions identical to the other cards but lets the eye land on
   the canonical breakdown without having to read the badge. */
.tcgd-bom-path:has(.tcgd-bom-primary) {
  box-shadow: inset 3px 0 0 var(--tcgd-accent);
}

/* Header is now a clickable button that collapses/expands the table. Reset
   button chrome, lay out as: chevron · label/notes · totals. Totals stay
   visible when collapsed so breakdown/EV are always readable. */
.tcgd-bom-path-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  padding: 6px 4px;
  background: transparent;
  border: none;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  border-radius: var(--tcgd-radius-sm);
  transition: background 120ms ease;
}
.tcgd-bom-path-head:hover { background: var(--tcgd-surface-2); }
.tcgd-bom-path-head:focus-visible {
  outline: 2px solid var(--tcgd-accent);
  outline-offset: 2px;
}
.tcgd-bom-path.tcgd-open .tcgd-bom-path-head { margin-bottom: 4px; }

.tcgd-bom-chevron {
  flex: 0 0 auto;
  width: 14px;
  display: inline-flex;
  justify-content: center;
  color: var(--tcgd-text-muted);
  font-size: 12px;
  transition: transform 140ms ease;
}
.tcgd-bom-chevron.tcgd-open { transform: rotate(90deg); }

.tcgd-bom-path-id { flex: 1 1 auto; min-width: 0; }
.tcgd-bom-path-label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--tcgd-text);
}
.tcgd-bom-primary {
  background: var(--tcgd-accent-soft);
  color: var(--tcgd-accent-text);
  font-size: 10px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 999px;
  margin-left: 8px;
  font-weight: 600;
}
.tcgd-bom-path-notes {
  font-size: 12px;
  color: var(--tcgd-text-muted);
  margin-top: 3px;
}
.tcgd-bom-totals {
  display: flex; gap: 18px; text-align: right;
}
.tcgd-bom-totals .tcgd-stat-value { font-size: 15px; }

/* Single-line Estimated Value cell:
       $4,119.48 (+$693.36 / +20.2%)
   The total amount and the parentheses + slash separator stay in the
   neutral text color; only the signed dollar and percent inside the
   parens take the polarity color. Right-aligned, tabular-nums so the
   numbers line up across stacked cards. */
.tcgd-bom-value { align-items: flex-end; }
.tcgd-bom-value-line {
  text-align: right;
  font-size: 14px;
  font-weight: 700;
  color: var(--tcgd-text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.tcgd-bom-value-line .tcgd-bom-value-total,
.tcgd-bom-value-line .tcgd-bom-value-paren,
.tcgd-bom-value-line .tcgd-bom-value-sep { color: var(--tcgd-text); }
.tcgd-bom-value-line .tcgd-bom-value-delta.tcgd-positive { color: var(--tcgd-positive); }
.tcgd-bom-value-line .tcgd-bom-value-delta.tcgd-negative { color: var(--tcgd-negative); }
.tcgd-bom-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.tcgd-bom-table th {
  text-align: left;
  font-size: 10.5px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--tcgd-text-muted);
  font-weight: 600;
  padding: 4px 8px 6px;
  /* Lighter rule under the column-header row so the table reads as one block
     attached to the header pill above, not a second framed zone. */
  border-bottom: 1px solid var(--tcgd-divider);
}
.tcgd-bom-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--tcgd-divider);
  vertical-align: middle;
}
.tcgd-bom-table tr:last-child td { border-bottom: none; }
/* Right-align numeric columns on BOTH header and data rows so QTY / UNIT /
   TOTAL labels sit directly over their right-aligned numbers (was: headers
   left-aligned, data right-aligned — they didn't line up). */
.tcgd-bom-table .tcgd-num { text-align: right; font-variant-numeric: tabular-nums; }
/* Pin the numeric columns to fixed widths so Qty / Unit / Total line up
   tightly on wide drawers instead of spreading across the whole row. The
   first column (Item) gets the remaining width. */
.tcgd-bom-table th:nth-child(2),
.tcgd-bom-table td:nth-child(2) { width: 60px;  }   /* Qty   */
.tcgd-bom-table th:nth-child(3),
.tcgd-bom-table td:nth-child(3) { width: 110px; }   /* Unit  */
.tcgd-bom-table th:nth-child(4),
.tcgd-bom-table td:nth-child(4) { width: 130px; }   /* Total */

/* Summary bar above the BOM cards: Market Price chip on the left,
   Price Basis segmented control on the right. Wraps to two rows on
   narrow drawers so the segmented control stays tappable. */
.tcgd-bom-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 18px;
  margin: 0 0 14px;
  padding: 0 2px;
}

/* Market Price headline above the collapsable BOM cards. */
.tcgd-bom-market {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 14px;
}
.tcgd-bom-market-label {
  color: var(--tcgd-text-muted);
  font-weight: 500;
}
.tcgd-bom-market-value {
  color: var(--tcgd-text);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.tcgd-bom-child {
  display: flex;
  align-items: center;
  gap: 10px;
}
.tcgd-bom-child img {
  width: 28px; height: 40px; object-fit: contain;
  border-radius: 3px; background: var(--tcgd-surface-2);
}
.tcgd-bom-child-name { font-weight: 500; color: var(--tcgd-text); }
.tcgd-bom-child-type { font-size: 10.5px; color: var(--tcgd-text-muted); text-transform: uppercase; letter-spacing: 0.4px; }

/* ---------- Retailers ----------
   Per-SKU card in a responsive grid, grouped under a retailer-name
   section heading. Same component identity at all sizes — the grid
   naturally collapses to 1-up at narrow widths via auto-fill. */

/* Flat list, dashed separator between rows — no surrounding cards, no
   chip backgrounds. Retailer name (linked when we have a listing URL)
   UPPERCASE accent on the left, SKU plain monospace muted on the right.
   Matches the old mobile reference: high data-to-chrome ratio. */
.tcgd-retailer-list {
  display: flex;
  flex-direction: column;
}
.tcgd-retailer {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 14px;
  padding: 6px 2px;
  background: transparent;
  border: none;
  border-bottom: 1px dashed var(--tcgd-border);
  border-radius: 0;
}
.tcgd-retailer:last-child { border-bottom: none; }

.tcgd-retailer-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--tcgd-text);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}
a.tcgd-retailer-name {
  color: var(--tcgd-accent-text);
  text-decoration: none;
  transition: color 120ms ease;
}
a.tcgd-retailer-name:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.tcgd-retailer-sku {
  font-family: var(--tcgd-mono);
  font-size: 12.5px;
  color: var(--tcgd-text-muted);
  padding: 0;
  margin: 0;
  background: transparent;
  border: none;
  cursor: copy;
  user-select: all;
  font-weight: 400;
  justify-self: end;
  text-align: right;
  white-space: nowrap;
  word-break: normal;
  line-height: 1.4;
  /* <button> reset — looks like inline text, not a chip. */
  appearance: none;
  -webkit-appearance: none;
  display: inline;
  transition: color 120ms ease;
}
.tcgd-retailer-sku:hover { color: var(--tcgd-text); }
.tcgd-retailer-sku:focus-visible {
  outline: 2px solid var(--tcgd-accent);
  outline-offset: 2px;
  border-radius: 2px;
}
.tcgd-retailer-sku.tcgd-copied { color: var(--tcgd-positive); }

/* ---------- Signals (observational, restrained) ---------- */

/* Full strip lives on Market tab — one row per signal with detail line.
   Compact strip lives on Overview — text-only chips, no detail.            */

.tcgd-signals {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 6px 0 14px;
}
.tcgd-signals.tcgd-signals-compact {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0 18px;
}
.tcgd-signal {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--tcgd-surface);
  border: 1px solid var(--tcgd-border);
  border-radius: var(--tcgd-radius-sm);
  font-size: 12px;
  color: var(--tcgd-text);
  line-height: 1.3;
}
.tcgd-signals-compact .tcgd-signal {
  padding: 4px 8px;
  font-size: 11.5px;
  background: var(--tcgd-surface-2);
  border-color: transparent;
}
.tcgd-signal-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--tcgd-text-faint);
}
.tcgd-signal-positive { background: var(--tcgd-positive); }
.tcgd-signal-negative { background: var(--tcgd-negative); }
.tcgd-signal-neutral  { background: var(--tcgd-text-muted); }
.tcgd-signal-label {
  font-weight: 600;
  color: var(--tcgd-text);
}
.tcgd-signal-detail {
  font-size: 11.5px;
  color: var(--tcgd-text-muted);
  font-variant-numeric: tabular-nums;
  margin-left: auto;
  padding-left: 12px;
}

/* ---------- Market tab ---------- */

.tcgd-market-current {
  display: flex;
  align-items: baseline;
  gap: 12px;
  font-size: 24px;
  font-weight: 700;
  color: var(--tcgd-text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  margin: 4px 0 14px;
}
.tcgd-market-current .tcgd-market-source {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--tcgd-text-muted);
}
.tcgd-market-window {
  display: inline-flex;
  background: var(--tcgd-surface-2);
  border-radius: var(--tcgd-radius-sm);
  padding: 2px;
  gap: 0;
  margin-bottom: 14px;
}
.tcgd-market-window button {
  border: none;
  background: transparent;
  color: var(--tcgd-text-muted);
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.02em;
}
.tcgd-market-window button.tcgd-active {
  background: var(--tcgd-surface);
  color: var(--tcgd-text);
  box-shadow: var(--tcgd-shadow);
}

/* Generic segmented control — same aesthetic as .tcgd-market-window so
   it reads as a native dashboard primitive. Used by the Details tab's
   Price Basis selector; leave market-window alone to keep its diff
   surface area minimal. */
.tcgd-bom-basis {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.tcgd-bom-basis-label {
  font-size: 11px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--tcgd-text-muted);
  font-weight: 600;
}
.tcgd-segmented {
  display: inline-flex;
  background: var(--tcgd-surface-2);
  border-radius: var(--tcgd-radius-sm);
  padding: 2px;
  gap: 0;
}
.tcgd-segmented-btn {
  border: none;
  background: transparent;
  color: var(--tcgd-text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.02em;
}
.tcgd-segmented-btn.tcgd-active {
  background: var(--tcgd-surface);
  color: var(--tcgd-text);
  box-shadow: var(--tcgd-shadow);
}
.tcgd-segmented-btn:focus-visible {
  outline: 2px solid var(--tcgd-accent-text);
  outline-offset: 1px;
}

.tcgd-chart {
  width: 100%;
  background: var(--tcgd-surface);
  border: 1px solid var(--tcgd-border);
  border-radius: var(--tcgd-radius);
  padding: 16px 12px 8px;
  margin-bottom: 12px;
  position: relative;
}
.tcgd-chart svg { display: block; width: 100%; height: 200px; }
.tcgd-chart-line {
  fill: none;
  stroke: var(--tcgd-accent);
  stroke-width: 1.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.tcgd-chart-area { fill: var(--tcgd-accent-soft); }
.tcgd-chart-grid { stroke: var(--tcgd-divider); stroke-width: 1; }
.tcgd-chart-axis {
  font-size: 10px;
  fill: var(--tcgd-text-muted);
  font-family: var(--tcgd-mono);
}
.tcgd-chart-empty {
  display: flex; align-items: center; justify-content: center;
  height: 200px;
  color: var(--tcgd-text-faint);
  font-size: 13px;
}

/* ----- chart hover crosshair + tooltip -----
   The hit rect catches mouse/touch; the cursor line + dot snap to the
   nearest data point. The tooltip is the headline-first layout: market
   price is the visual anchor, date is a small caption above it, and
   low/mid/high sit underneath in much smaller text. */
.tcgd-chart-hit         { cursor: crosshair; }
.tcgd-chart-cursor-line {
  stroke: var(--tcgd-text-muted);
  stroke-width: 1;
  stroke-dasharray: 2 3;
  pointer-events: none;
}
.tcgd-chart-cursor-dot {
  fill: var(--tcgd-accent);
  stroke: var(--tcgd-surface);
  stroke-width: 2;
  pointer-events: none;
}
.tcgd-chart-tooltip {
  position: absolute;
  background: var(--tcgd-surface);
  border: 1px solid var(--tcgd-border-strong);
  border-radius: var(--tcgd-radius-sm);
  padding: 6px 10px 7px;
  box-shadow: var(--tcgd-shadow-hover);
  pointer-events: none;
  white-space: nowrap;
  z-index: 2;
  /* Sits above the cursor point by default; bumped down when the point is
     too close to the chart top (see .tcgd-chart-tooltip-below). */
  transform: translateY(calc(-100% - 8px));
}
.tcgd-chart-tooltip.tcgd-chart-tooltip-below {
  transform: translateY(10px);
}
.tcgd-chart-tooltip-date {
  font-size: 10.5px;
  letter-spacing: 0.4px;
  color: var(--tcgd-text-muted);
  font-variant-numeric: tabular-nums;
  text-transform: uppercase;
}
.tcgd-chart-tooltip-price {
  font-size: 16px;
  font-weight: 700;
  color: var(--tcgd-text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin: 1px 0 2px;
}
.tcgd-chart-tooltip-lmh {
  font-size: 10.5px;
  color: var(--tcgd-text-faint);
  font-variant-numeric: tabular-nums;
}

.tcgd-market-history-toggle {
  background: none;
  border: 1px solid var(--tcgd-border);
  border-radius: var(--tcgd-radius-sm);
  padding: 6px 10px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--tcgd-text-soft);
  cursor: pointer;
}
.tcgd-market-history-toggle:hover {
  color: var(--tcgd-text);
  border-color: var(--tcgd-border-strong);
}
.tcgd-market-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  margin-top: 10px;
}
.tcgd-market-table th, .tcgd-market-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--tcgd-divider);
  text-align: left;
}
.tcgd-market-table th {
  font-size: 10.5px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--tcgd-text-muted);
  background: var(--tcgd-surface);
  position: sticky; top: 0;
}
.tcgd-market-table td.tcgd-num,
.tcgd-market-table th.tcgd-num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Details pane (de-emphasised metadata) ---------- */

.tcgd-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 6px;
}
.tcgd-list-item {
  background: var(--tcgd-surface);
  border: 1px solid var(--tcgd-border);
  border-radius: var(--tcgd-radius-sm);
  padding: 8px 10px;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tcgd-list-item .tcgd-kv-label {
  font-size: 10px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--tcgd-text-muted);
  font-weight: 600;
}
.tcgd-list-item .tcgd-kv-value {
  font-size: 12.5px;
  color: var(--tcgd-text);
  font-weight: 500;
  font-family: var(--tcgd-font);
  word-break: normal;
  overflow-wrap: anywhere;
}
/* Mono is reserved for machine-readable identifiers (Product ID, UPC, SKU). */
.tcgd-list-item .tcgd-kv-value.tcgd-kv-mono {
  font-family: var(--tcgd-mono);
  font-size: 12px;
  word-break: break-all;
}

/* ---------- responsive ---------- */
@media (max-width: 1200px) {
  .tcgd-drawer { width: 86%; max-width: 86vw; }
}
@media (max-width: 1024px) {
  .tcgd-drawer { width: 92%; max-width: 92vw; }
  .tcgd-overview { grid-template-columns: 1fr; }
  .tcgd-overview-image { width: 180px; }
}

/* ---------- mobile bottom sheet (≤720px) ----------
   Drawer becomes a bottom-anchored sheet: full width, rounded top corners,
   slides up from offscreen. The visual drag handle at the top is a cue
   that this is a sheet, not a page; clicking the overlay or the × button
   still dismisses (no JS gesture handling in this pass — that can come
   later as a polish, not a blocker). */
@media (max-width: 720px) {
  /* Root: only horizontal padding shrinks; font-size, colors, and other
     style tokens stay identical to desktop. */
  #tcgd-product-explorer { padding: 12px 12px 48px; }

  /* ----- stat stripe -----
     Layout-only change: cells stack as one-per-row with label-left,
     value-right. Typography (label uppercase + letter-spacing + muted
     color, value 15px) is INHERITED from the base stripe styles — no
     overrides. */
  .tcgd-stripe { grid-template-columns: 1fr; }
  .tcgd-stripe-cell {
    flex-direction: row;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
  }

  /* ----- BOM table → stacked rows (layout-only) -----
     Hide column headers and let each <tr> stack as a block. Cell
     typography stays identical to the desktop table — only flow
     direction changes. The "qty × unit = line" expression is built
     from CSS ::after on existing cells, no markup change. */
  .tcgd-bom-path-head {
    flex-wrap: wrap;
    gap: 6px 12px;
  }
  .tcgd-bom-totals {
    width: 100%;
    justify-content: flex-end;
  }
  .tcgd-bom-table thead { display: none; }
  .tcgd-bom-table,
  .tcgd-bom-table tbody,
  .tcgd-bom-table tr {
    display: block;
    width: 100%;
  }
  .tcgd-bom-table tr {
    padding: 8px 0;
    border-bottom: 1px solid var(--tcgd-divider);
  }
  .tcgd-bom-table tr:last-child { border-bottom: none; }
  .tcgd-bom-table td {
    display: inline-block;
    border-bottom: none;
    padding: 0;
  }
  /* Reset the desktop fixed widths — mobile uses the inline-block math
     expression layout where the cells flow naturally. */
  .tcgd-bom-table th:nth-child(n),
  .tcgd-bom-table td:nth-child(n) { width: auto; }
  .tcgd-bom-table td:nth-child(1) { display: block; width: 100%; margin-bottom: 4px; }
  .tcgd-bom-table td:nth-child(2)::after { content: " × "; color: var(--tcgd-text-muted); }
  .tcgd-bom-table td:nth-child(3)::after { content: " = "; color: var(--tcgd-text-muted); margin: 0 2px; }
  .tcgd-bom-table td:nth-child(2),
  .tcgd-bom-table td:nth-child(3),
  .tcgd-bom-table td:nth-child(4) { text-align: left; }

  /* ----- market window selector -----
     Larger tap targets only; same colors/typography as desktop. */
  .tcgd-market-window button { padding: 8px 14px; min-height: 34px; }

  /* ----- product cards -----
     Single-column grid is the only adaptation. All card typography,
     image ratio, padding, and stats styling are inherited from the
     base .tcgd-card rules. */
  .tcgd-grid { grid-template-columns: 1fr; }

  /* ----- drawer becomes a bottom sheet -----
     Position/transform change only. All inner content uses the same
     tokens, padding, and components as the desktop drawer. */
  .tcgd-drawer {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100vw;
    height: calc(100vh - 24px);
    height: calc(100dvh - 24px);
    border-left: none;
    border-top-left-radius: 18px;
    border-top-right-radius: 18px;
    transform: translateY(100%);
    box-shadow: 0 -8px 32px rgba(15, 23, 42, 0.18);
  }
  .tcgd-drawer.tcgd-open { transform: translateY(0); }

  /* Drag-handle pill — purely a sheet-pattern cue. */
  .tcgd-drawer::before {
    content: "";
    position: absolute;
    top: 8px; left: 50%;
    transform: translateX(-50%);
    width: 40px; height: 4px;
    background: var(--tcgd-border-strong);
    border-radius: 999px;
    pointer-events: none;
  }

  /* Sheet head: rounded top corners to match the sheet shape, extra
     top padding so the drag handle has breathing room. Typography
     (title 16px, sub 12px) is INHERITED from base — no font overrides. */
  .tcgd-drawer-head {
    padding: 16px 14px 12px;
    border-top-left-radius: 18px;
    border-top-right-radius: 18px;
  }
  /* Compact thumbnail visible only on the sheet — the Overview pane's
     image is below the fold, so the sticky head carries product identity. */
  .tcgd-drawer-thumb { display: flex; }

  /* Tabs: same underline styling as desktop; just bigger tap targets
     and slightly tighter horizontal padding for narrow widths. */
  .tcgd-tabs { padding: 0 14px; }
  .tcgd-tab { padding: 12px 12px; min-height: 44px; }

  .tcgd-drawer-body { padding: 16px 14px 32px; }

  .tcgd-filterbar { padding: 8px 10px; gap: 8px; }
  .tcgd-field { min-width: 120px; }
  .tcgd-actions { margin-left: 0; }
}