/**
 * Steel Price Tables — front-end table styles.
 *
 * TWO RULES THIS FILE FOLLOWS
 * ---------------------------
 * 1. NO `!important`. The previous stylesheet marked nearly every declaration
 *    important because it lived in a child theme and was fighting the parent.
 *    A plugin does not have to fight: every selector here is prefixed `.spt-`,
 *    so nothing else on the page targets these elements, and the dynamic values
 *    arrive as custom properties rather than as competing rules.
 *
 * 2. EVERY TUNABLE IS A VARIABLE. The settings page writes the variables; this
 *    file never contains a colour or a size an administrator can change. That is
 *    what keeps the stylesheet static and cacheable while the design stays
 *    configurable.
 *
 * DIMENSIONS ARE PRESERVED. Cell padding, font clamps, the 768/600/400
 * breakpoints and the column-reclamation ladder are carried over unchanged from
 * the production build, because those numbers were tuned against real devices
 * and real Persian content and there is nothing to improve about them.
 */

/* ============================================================
   1 · SCOPE & FALLBACKS
   The fallbacks are what the plugin looks like before the
   settings page has ever been saved.
   ============================================================ */

.spt-scope,
.spt-table-container {
  --spt-header-bg: #1c39bb;
  --spt-header-color: #fff;
  --spt-header-size: 14px;
  --spt-body-size: 14px;
  --spt-row-odd: #fff;
  --spt-row-even: #fffbee;
  --spt-row-hover: #fdbb73;
  --spt-border: #ccc;
  --spt-text: #333;
  --spt-accent: #fc8200;

  --spt-muted: #666;
  --spt-surface: #fff;
  --spt-track: #f1f1f1;
  --spt-radius: 5px;
  --spt-radius-sm: 3px;
  --spt-radius-inner: 4px;
  --spt-ease: 0.2s ease;

  /* `inherit` is the correct default, not a named family. An unset font
     setting means "use the theme's font", and declaring a stack here would
     silently override a correctly-configured theme on every site that never
     opened the settings page. StyleTokens emits --spt-font only when the
     administrator actually chose one. */
  --spt-font: inherit;

  --spt-title-size: 20px;
  --spt-icon-size: 32px;
  --spt-chart-btn-bg: #0f172a;
  --spt-chart-btn-color: #fff;

  --spt-header-border: var(--spt-header-bg);
  --spt-header-border-style: hidden;
  --spt-border-style: solid;

  --spt-container-pad: 20px;
  --spt-container-margin-y: 12px;
  --spt-container-margin-x: 0px;
  --spt-container-width: 100%;
  --spt-container-bleed: 0px;

  --spt-up: #00b894;
  --spt-down: #d63031;
  --spt-stable: #2d3436;
  --spt-note: #fc0000;
  --spt-note-ok: #00a844;
}

/* Reserve the scrollbar gutter permanently, so locking <html> overflow while
   the chart dialog is open cannot shift the layout. This is a CLS fix. */
html:has(.spt-table-container) {
  scrollbar-gutter: stable;
}

/* ============================================================
   2 · CONTAINER & HEADER
   ============================================================ */

.spt-table-container {
  box-sizing: border-box;
  max-width: 94%;
  margin: 40px auto;
  padding: var(--spt-container-pad);
  background: var(--spt-surface);
  border: 1px solid var(--spt-border);
  border-radius: var(--spt-radius);
  box-shadow: 0 2px 10px rgb(0 0 0 / 0.1);
  font-family: var(--spt-font);
  direction: rtl;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;

  /* Skip offscreen render work and reserve intrinsic height.
     `contain-intrinsic-size` is what stops content-visibility from causing
     scroll jumps when a table below the fold is realised. */
  content-visibility: auto;
  contain-intrinsic-size: auto 500px;
}

/* A table hidden by the filter must not reserve space or be read aloud. */
.spt-table-container[hidden] {
  display: none;
}

.spt-table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--spt-accent);
}

.spt-table-title {
  margin: 0;
  padding: 20px 0 0;
  font-family: var(--spt-font);
  font-size: var(--spt-title-size);
  font-weight: 700;
  line-height: 1.4;
  color: var(--spt-text);
}

/* Title with icon.
   Flex on the heading itself: in the RTL container the first item (the icon)
   sits on the right and the text follows, with no physical-direction rules, so
   an LTR site mirrors correctly. `min-width: 0` lets a long title wrap next to
   the icon instead of pushing the date off the card. */
.spt-table-title--has-icon {
  display: flex;
  align-items: center;
  gap: 0.5em;
  min-width: 0;
}

.spt-table-title-text {
  min-width: 0;
  overflow-wrap: anywhere;
}

/* The box is fixed by the token, so the heading's height is known before the
   image decodes — zero CLS regardless of the file's intrinsic size. The
   explicit width/height override the HTML attributes, which only supply the
   aspect ratio. `contain` keeps a non-square upload undistorted. */
.spt-table-icon {
  display: block;
  flex: 0 0 var(--spt-icon-size);
  width: var(--spt-icon-size);
  height: var(--spt-icon-size);
  max-width: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  object-fit: contain;
}

.spt-update-date {
  margin: 0;
  font-size: 14px;
  line-height: 1.4;
  color: var(--spt-muted);
  white-space: nowrap;
}

/* ============================================================
   3 · VAT CONTROL
   ============================================================ */

.spt-vat-wrapper {
  margin: 0 0 20px;
  text-align: right;
}

.spt-vat-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 16px;
  color: var(--spt-text);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.spt-vat-checkbox {
  width: 18px;
  height: 18px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--spt-accent);
}

/* ============================================================
   4 · WRAPPER & SCROLLBAR
   ============================================================ */

.spt-table-wrapper {
  position: relative;
  width: 100%;
  overflow-x: auto;
  background: var(--spt-surface);
  border: 1px solid var(--spt-border);
  border-radius: var(--spt-radius-inner);
  scrollbar-width: thin;
  scrollbar-color: var(--spt-accent) var(--spt-track);
  -webkit-overflow-scrolling: touch;
}

.spt-table-wrapper::-webkit-scrollbar {
  height: 8px;
}

.spt-table-wrapper::-webkit-scrollbar-track {
  background: var(--spt-track);
  border-radius: var(--spt-radius-inner);
}

.spt-table-wrapper::-webkit-scrollbar-thumb {
  background: var(--spt-accent);
  border-radius: var(--spt-radius-inner);
}

/* ============================================================
   5 · TABLE
   ============================================================ */

.spt-table {
  width: 100%;
  min-width: 600px;
  border-collapse: collapse;
  background: var(--spt-surface);
  font-family: var(--spt-font);

  /* The <colgroup> percentages are only honoured under a fixed layout, and a
     fixed layout is also what guarantees that hiding rows cannot resize
     columns — which would be visible CLS on every filter interaction. */
  table-layout: fixed;
}

.spt-table th,
.spt-table td {
  padding: 12px 8px;
  /* `--spt-border-style` is `solid` or `hidden`, never a width change.
     Under `border-collapse: collapse` a TRANSPARENT border does not disappear —
     it lets the table's own background show through, which paints a white line
     exactly where the border was. `hidden` is the only value that genuinely
     removes a collapsed border, and the spec gives it the highest priority in
     conflict resolution, so one cell declaring it wins over its neighbour. */
  border: 1px var(--spt-border-style, solid) var(--spt-border);
  text-align: center;
  vertical-align: middle;
  line-height: 1.5;
  font-family: var(--spt-font);
}

/* Column widths.
   Declared on the header cells rather than in a <colgroup>, because a <col>
   cannot be hidden reliably and per-device columns depend on hiding one
   cleanly. Under `table-layout: fixed` a width on the first row governs the
   whole table exactly as a colgroup would. */
.spt-table th {
  width: var(--spt-w, auto);
}

/* The product name is the one column that must WRAP.
   Names in this catalogue run to eight or ten words, and with every cell set
   to nowrap the text simply overflowed into the neighbouring column — which is
   exactly the reported defect. Wrapping to two or three lines is correct here;
   the column is sized to absorb it. */
.spt-cell--name {
  white-space: normal;
  overflow-wrap: break-word;
  word-break: break-word;
  text-align: right;
  hyphens: auto;
}

/* A column dropped for small screens. Header and body cells carry the same
   class, so the column disappears as a unit and nothing goes out of
   alignment. */
.spt-hide-mobile {
  display: table-cell;
}

/* Whole-row links.
   The anchor in the name cell is the real link — crawlable, focusable,
   middle-clickable. This only extends the hit area to the rest of the row and
   is layered on top; it is never a substitute for the anchor. */
.spt-row--linked {
  cursor: pointer;
}

.spt-product-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color var(--spt-ease), color var(--spt-ease);
}

@media (hover: hover) and (pointer: fine) {
  .spt-product-link:hover {
    color: var(--spt-accent);
    border-bottom-color: currentColor;
  }
}

.spt-product-link:focus-visible {
  outline: 2px solid var(--spt-accent);
  outline-offset: 2px;
}

.spt-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--spt-header-bg);
  color: var(--spt-header-color);
  /* Header dividers: their own style AND colour token.
     When dividers are off the style is `hidden`, which actually removes the
     collapsed border; the colour falls back to the header background so that
     any edge the browser still resolves in favour of a neighbouring cell is
     invisible against the header rather than white. Belt and braces, because
     collapsed-border conflict resolution is decided per edge and the header's
     bottom edge is shared with a body row. */
  border-style: var(--spt-header-border-style, solid);
  border-color: var(--spt-header-border);
  font-size: var(--spt-header-size);
  font-weight: 700;
  white-space: nowrap;
}

.spt-table td {
  background: var(--spt-row-odd);
  color: var(--spt-text);
  font-size: var(--spt-body-size);
}

/* Zebra striping follows the VISIBLE order.
   `:nth-child(even)` counts DOM position, so once the filter hides rows the
   stripes double up and skip. A class applied by the runtime after each filter
   pass is the only way to stripe what the reader actually sees. */
.spt-row.is-even > td {
  background: var(--spt-row-even);
}

.spt-row[hidden] {
  display: none;
}

@media (hover: hover) and (pointer: fine) {
  .spt-table tbody tr:hover > td {
    background: var(--spt-row-hover);
    transition: background-color var(--spt-ease);
  }
}

.spt-cell--name {
  text-align: right;
}

.spt-price-note {
  margin-top: 10px;
  text-align: right;
  font-size: 14px;
  line-height: 1.5;
  color: var(--spt-note);
  font-family: var(--spt-font);
}

.spt-price-note.is-with-vat {
  color: var(--spt-note-ok);
}

.spt-no-match {
  margin: 0;
  padding: 24px 12px;
  text-align: center;
  color: var(--spt-muted);
  font-size: 14px;
}

.spt-th-inline {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* ============================================================
   6 · FLUCTUATION & CHART TRIGGER
   ============================================================ */

.spt-fluctuation {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.spt-chart-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: var(--spt-chart-btn-bg);
  color: var(--spt-chart-btn-color);
  cursor: pointer;
  transition: background-color var(--spt-ease), transform var(--spt-ease);
}

/* Same theme-proofing as the dialog's close button: a theme's
   `button:hover` / `button:focus` must not recolour the chart trigger. */
.spt-table-container .spt-chart-btn,
.spt-table-container .spt-chart-btn:focus,
.spt-table-container .spt-chart-btn:active {
  color: var(--spt-chart-btn-color);
  -webkit-text-fill-color: currentColor;
  background: var(--spt-chart-btn-bg);
  border: 0;
  box-shadow: none;
}

.spt-table-container .spt-chart-btn:focus-visible {
  outline: 2px solid var(--spt-accent);
  outline-offset: 2px;
}

.spt-table-container .spt-chart-btn svg {
  display: block;
  stroke: currentColor;
}

@media (hover: hover) and (pointer: fine) {
  .spt-table-container .spt-chart-btn:hover {
    color: var(--spt-chart-btn-color);
    background: var(--spt-accent);
    transform: translateY(-2px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .spt-table-container .spt-chart-btn:hover {
    transform: none;
  }
}

/* Chart note: shown under the chart when only one price is recorded. */
.spt-modal-note {
  position: absolute;
  inset-inline: 20px;
  inset-block-end: 6px;
  margin: 0;
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
  color: #64748b;
}

.spt-modal-note[hidden] {
  display: none;
}

.spt-trend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  min-width: 60px;
  font-size: 14px;
  font-weight: 700;

  /* Numbers read left-to-right even inside an RTL table. */
  direction: ltr;
}

.spt-trend--up {
  color: var(--spt-up);
}

.spt-trend--down {
  color: var(--spt-down);
}

.spt-trend--stable {
  justify-content: center;
  font-size: 13px;
  color: var(--spt-stable);
}

/* ============================================================
   7 · MARQUEE
   Requires two identical row groups; the renderer emits the
   clone, which the legacy build documented but never did.
   ============================================================ */

.spt-scroll .spt-table-wrapper {
  max-height: 450px;
  overflow-y: hidden;
}

.spt-scroll .spt-table {
  animation: spt-marquee var(--spt-scroll-duration, 45s) linear infinite;
  will-change: transform;
  backface-visibility: hidden;
}

.spt-scroll .spt-table thead {
  /* The head must not travel with the body. */
  animation: none;
}

.spt-scroll * {
  user-select: none;
  -webkit-user-select: none;
}

@keyframes spt-marquee {
  from { transform: translate3d(0, 0, 0); }
  to   { transform: translate3d(0, -50%, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .spt-scroll .spt-table {
    animation: none;
    will-change: auto;
  }

  .spt-scroll .spt-table-wrapper {
    max-height: none;
    overflow-y: visible;
  }

  /* With the animation off the duplicate is pure noise. */
  .spt-rows-clone {
    display: none;
  }
}

/* ============================================================
   8 · CHART DIALOG — native <dialog>
   ============================================================ */

.spt-chart-modal {
  width: 90%;
  max-width: 800px;
  max-height: 90vh;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: var(--spt-surface, #fff);
  color: var(--spt-text, #333);
  box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
  direction: rtl;
  font-family: var(--spt-font, Tahoma, sans-serif);
  overflow: hidden;
}

.spt-chart-modal::backdrop {
  background: rgb(15 23 42 / 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.spt-chart-modal[open] {
  animation: spt-modal-in 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes spt-modal-in {
  from { opacity: 0; transform: scale(0.95) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .spt-chart-modal[open] {
    animation: none;
  }
}

.spt-modal-inner {
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  overflow: hidden;
}

.spt-modal-header {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--spt-header-bg, #1c39bb);
  color: var(--spt-header-color, #fff);
}

.spt-modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.4;
  color: inherit;
}

.spt-modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid rgb(255 255 255 / 0.3);
  border-radius: 8px;
  background: rgb(255 255 255 / 0.15);
  color: inherit;
  cursor: pointer;
  transition: background-color var(--spt-ease);
}

/* THEME-PROOF STATES.
   <dialog> moves focus to the close button on open, and theme rules such as
   `button:hover, button:focus { color:#fff; background:#fff }` (Blocksy,
   Elementor kits, many others) then painted it white on white — an invisible
   close control. Every interactive state states BOTH colours, at a
   specificity above the usual theme button selectors, and pins
   -webkit-text-fill-color, which some themes use for button labels. */
.spt-chart-modal .spt-modal-close,
.spt-chart-modal .spt-modal-close:hover,
.spt-chart-modal .spt-modal-close:focus,
.spt-chart-modal .spt-modal-close:active {
  color: var(--spt-header-color, #fff);
  -webkit-text-fill-color: currentColor;
  box-shadow: none;
  transform: none;
  text-decoration: none;
}

.spt-chart-modal .spt-modal-close,
.spt-chart-modal .spt-modal-close:focus {
  background: rgb(255 255 255 / 0.15);
  border-color: rgb(255 255 255 / 0.3);
}

.spt-chart-modal .spt-modal-close:hover,
.spt-chart-modal .spt-modal-close:active {
  background: rgb(255 255 255 / 0.3);
  border-color: rgb(255 255 255 / 0.5);
}

.spt-chart-modal .spt-modal-close:focus-visible {
  outline: 2px solid var(--spt-header-color, #fff);
  outline-offset: 2px;
}

.spt-chart-modal .spt-modal-close svg {
  display: block;
  stroke: currentColor;
}

.spt-modal-body {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  height: 400px;
  padding: 20px;
  background: #f8fafc;
}

.spt-modal-body canvas {
  max-width: 100%;
}

.spt-modal-status {
  position: absolute;
  inset-block-start: 50%;
  inset-inline-start: 50%;
  transform: translate(-50%, -50%);
  width: 80%;
  text-align: center;
  font-size: 15px;
  line-height: 1.7;
  color: #64748b;
}

/* ============================================================
   9 · RESPONSIVE ≤768px
   Data cells hold their single line; headers may wrap, which is
   the lever that frees horizontal space.
   ============================================================ */

@media (max-width: 768px) {
  /* Container spacing is settings-driven.
     The default gave the table a wide margin and 10px of padding on a 360px
     screen, so roughly a fifth of the viewport was frame rather than data.
     Both are now tokens with much tighter defaults. */
  /* THE BLEED.
     Width and margin can only work inside the box the page builder gives us.
     When a Gutenberg / GreenShift / Elementor column applies its own horizontal
     padding, `width: 100%` means 100% of what is left AFTER that padding — so
     the table stays inset and no width setting can reach the gap, because the
     gap belongs to the column, not to us.

     A negative inline margin pulls the container back out through that padding,
     and the width grows by the same amount on each side so the two cancel
     exactly. At the default of 0 every calc() collapses to the plain value and
     the behaviour is identical to having no bleed at all. */
  .spt-table-container {
    width: calc(var(--spt-container-width) + (2 * var(--spt-container-bleed)));
    max-width: calc(100% + (2 * var(--spt-container-bleed)));
    margin-block: var(--spt-container-margin-y);
    margin-inline: calc(var(--spt-container-margin-x) - var(--spt-container-bleed));
    padding: var(--spt-container-pad);
    border-radius: var(--spt-radius-sm);
  }

  .spt-table-wrapper {
    border-radius: var(--spt-radius-sm);
    overflow-x: clip; /* No scrollbar; the sizing below guarantees fit. */
  }

  .spt-table {
    min-width: 0;
    width: 100%;
    max-width: 100%;
  }

  /* Mobile column widths.
     A different width per breakpoint, because a category may drop a column
     here and the remainder is then divided differently. Falls back to the
     desktop share when no mobile set was configured. */
  .spt-table th {
    width: var(--spt-w-mb, var(--spt-w, auto));
  }

  /* Columns excluded from this category's mobile set. Header and body cells
     carry the same class, so the column vanishes as a unit. */
  .spt-hide-mobile {
    display: none;
  }

  .spt-table th,
  .spt-table td {
    padding: 9px 4px;
    font-size: var(--spt-body-size);
  }

  .spt-table th {
    font-size: var(--spt-header-size);
    white-space: normal;
    overflow-wrap: break-word;
    line-height: 1.3;
  }

  /* THE OVERFLOW FIX.
     Every body cell was `white-space: nowrap`, so under `table-layout: fixed`
     any text wider than its column spilled visibly across the neighbouring
     one — which is precisely what the screenshots show. Cells now wrap by
     default; only the two columns whose values are short and must never break
     mid-number keep nowrap. */
  .spt-table td {
    white-space: normal;
    overflow-wrap: break-word;
  }

  .spt-cell--name {
    min-width: 0;
    white-space: normal;
    overflow-wrap: break-word;
    word-break: break-word;
    text-align: right;
    line-height: 1.55;
  }

  .spt-cell--price,
  .spt-cell--fluctuation {
    white-space: nowrap;
  }

  .spt-table-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
  }

  .spt-table-title {
    padding: 6px 0 0;
    font-size: var(--spt-title-size);
  }

  .spt-update-date,
  .spt-price-note {
    font-size: 12px;
  }

  .spt-vat-label {
    font-size: 14px;
  }

  .spt-fluctuation {
    gap: 6px;
  }

  .spt-chart-btn {
    width: 28px;
    height: 28px;
    border-radius: var(--spt-radius-sm);
  }

  .spt-chart-btn svg {
    width: 14px;
    height: 14px;
  }

  .spt-trend {
    min-width: 42px;
    gap: 2px;
    font-size: 12px;
  }

  .spt-chart-modal {
    width: calc(100% - 30px);
    max-width: 480px;
    max-height: 85dvh;
    margin: auto;
    inset: 0;
    border-radius: 16px;
  }

  .spt-modal-inner {
    max-height: 85dvh;
  }

  .spt-modal-header {
    padding: 15px;
  }

  .spt-modal-header h3 {
    font-size: 15px;
  }

  .spt-modal-body {
    height: 320px;
    padding: 15px 10px;
  }
}

/* ============================================================
   10 · COLUMN RECLAMATION ≤600px
   The fluctuation cell is the real bottleneck: a fixed button
   plus an indicator with a hard min-width. Releasing that
   min-width is what lets a fifth column render whole.
   ============================================================ */

@media (max-width: 600px) {
  /* No `max-width` on attribute columns any more, and no attribute slug named
     in CSS.
     Both were holdovers from the era of equal column shares: a hard ceiling was
     the only way to stop a wide heading from crowding its neighbours, and one
     steel-specific slug had to be singled out because the generic rule could
     not know which column held long text. Widths are now computed per column
     from the actual heading and cell content, so a ceiling here would fight the
     share that was calculated for exactly this reason — and a rule naming
     `pa_loading_location` would be dead weight on any shop that does not sell
     steel. */
  .spt-table th[data-col^="pa_"],
  .spt-table td.col-attr {
    padding-inline: 4px;
    white-space: normal;
    overflow-wrap: break-word;
    word-break: normal;
    line-height: 1.3;
  }

  /* A thousands-separated figure must never split across lines. */
  .spt-table td.col-price {
    padding-inline: 5px;
    white-space: nowrap;
  }

  .spt-cell--name {
    min-width: 0;
    padding-inline: 5px;
  }

  .spt-table th[data-col="fluctuation"],
  .spt-table td.spt-col-action {
    padding-inline: 4px;
    white-space: nowrap;
  }

  .spt-col-action .spt-fluctuation {
    gap: 4px;
  }

  .spt-col-action .spt-trend {
    min-width: 0;
    gap: 2px;
    justify-content: center;
    /* Derived from the configured body size, not fixed: the indicator should
       shrink relative to whatever the administrator chose, not override it. */
    font-size: calc(var(--spt-body-size) - 1px);
  }

  .spt-col-action .spt-chart-btn {
    width: 26px;
    height: 26px;
  }

  .spt-col-action .spt-chart-btn svg {
    width: 13px;
    height: 13px;
  }
}

/* ============================================================
   11 · ULTRA-NARROW ≤400px
   Final margin of safety for 360px and 375px devices, where a
   five-column row has roughly 336px of usable width.
   ============================================================ */

@media (max-width: 400px) {
  /* NO HARD-CODED FONT SIZES HERE ANY MORE.
     This block used to set 11px and 10.5px outright, which silently defeated
     every mobile font-size setting on the settings page — and since virtually
     every phone is narrower than 400px, the settings appeared to do nothing at
     all. Only spacing is tightened here now; size is the administrator's
     decision at every width. */
  .spt-table th,
  .spt-table td {
    padding: 8px 3px;
  }

  .spt-table td.col-attr {
    max-width: 4.5rem;
  }

  .spt-cell--name {
    min-width: 0;
  }

  .spt-table td.col-price {
    letter-spacing: -0.2px;
  }

  .spt-col-action .spt-chart-btn {
    width: 24px;
    height: 24px;
  }

  .spt-col-action .spt-chart-btn svg {
    width: 12px;
    height: 12px;
  }

  .spt-col-action .spt-trend {
    font-size: calc(var(--spt-body-size) - 1.5px);
  }
}

/* ============================================================
   12 · PRINT
   ============================================================ */

@media print {
  .spt-table-container {
    max-width: 100%;
    margin: 0;
    box-shadow: none;
    content-visibility: visible;
  }

  .spt-vat-wrapper,
  .spt-chart-btn,
  .spt-rows-clone {
    display: none;
  }

  .spt-table-icon {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .spt-table {
    animation: none;
  }
}

/* ============================================================
   CATEGORY BODY COPY — [spt_category_content]
   ------------------------------------------------------------
   The theme's own alignfull/alignwide classes do the real work where they
   exist (Blocksy, block themes). These rules are a low-specificity fallback
   for themes that ignore them, written with :where() so any theme rule wins.

   `max-width: none` matters more than the breakout itself: inside
   `is-layout-constrained` the child is capped at the text measure, which is
   what produced the narrow column with uneven space on desktop.
   ============================================================ */

:where(.spt-category-content) {
  width: 100%;
  max-width: none;
  margin-inline: auto;
}

:where(.spt-category-content--wide) {
  max-width: var(--spt-content-wide, 1200px);
}

/* Tables pasted into the body copy scroll instead of overflowing the page —
   the same guarantee the plugin's own tables have. Applies only when the
   author did not already set an overflow themselves. */
.spt-category-content table {
  max-width: 100%;
}

.spt-category-content :where(.spt-scrollable, .table-wrap, figure.wp-block-table) {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
  .spt-category-content :where(table) {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}
