/* ============ Tables ============ */
div:has(> table) {
  overflow: clip; /* rounds the corners without becoming a scroll container, so the header can stick */
  position: relative; /* holds anything absolute inside the table (the screen-reader words beside a GP): it hung out of the box and made the
                         whole dish page and option table scroll sideways on a phone (O-58) */
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  background: var(--card);
}
table { width: 100%; border-collapse: separate; border-spacing: 0; }
caption { padding: var(--space-3) var(--space-4); text-align: left; font-weight: 600; }
th, td { padding: var(--space-3) var(--space-4); text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
/* data-right is the markup's own "this is a number column": right on every page, not only where a page's sheet says so (owner, 2026-10-25:
   the Options on this dish columns sat half left, half right); a second line under the figure (before VAT) sits under it, on the right */
:is(th, td):is([data-num], [data-right]) { text-align: right; }
td[data-right] > small { display: block; }
/* a zero or a "None" in a row, in the muted step, so the real figures stand out (unslop, owner 2026-11-04) */
td [data-none] { display: inline; margin: 0; font: inherit; color: var(--muted-foreground); } /* not the small badge td > span is */
th > small[data-head-note] { font-weight: 400; color: var(--muted-foreground); } /* what all the rows share, said once (the count's day) */
/* the same figure in the same font everywhere: a price in a table reads as the price in the tile above it (typeset review T8, owner
   2026-10-22). Number columns are found by TableAlign (data-num) or marked in the markup (data-right); headings stay in the UI font. */
td:is([data-num], [data-right]), td > data[value] { font-family: var(--font-mono); }
/* tabular figures on the number cells only: on a whole table Inter widened the hyphen in words ("sign - ins", review 2026-10-30, E5) */
:is(th, td):is([data-num], [data-right]), td > data[value] { font-variant-numeric: tabular-nums; }
/* A table inside a card panel is not a second card: no border or fill of its own, a hairline above its header (layout review, owner
   2026-10-22). On the Dashboard and People overview the sections are not cards (10-home-dashboard.css), so there the table keeps its own. */
section[data-panel]:not([data-plain] > section) div:has(> table) { border: 0; border-top: 1px solid var(--border); border-radius: 0; background-color: transparent; }
/* a figure never breaks over two lines at any width ("16.85 / kg", "-฿1,397"): the table scrolls sideways in its box instead (layout
   review, owner 2026-10-22; it was phones only). The name column keeps a sensible width so a long name does not fold to a word a line. */
:is(th, td):is([data-num], [data-right]) { white-space: nowrap; }
:is(div[data-wide], div[data-self-scroll]) > table td:first-child { min-width: 10rem; }
th {
  position: sticky;
  top: var(--nav-h);
  z-index: 1;
  background: var(--muted);
  /* quieter (owner, 2026-10-22): small, muted, sentence case in the UI font, as the dish page; the figures keep the mono font */
  font-family: var(--font-ui);
  font-size: var(--text-label);
  font-weight: 500;
  color: var(--th-ink); /* a touch nearer the text colour than --muted-foreground: on the --muted header that keeps AA (4.5:1) in light themes */
  white-space: nowrap;
}
th button {
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  box-shadow: none;
}
th[aria-sort="ascending"], th[aria-sort="descending"] { color: color-mix(in srgb, var(--accent-ink) 85%, var(--foreground)); }
tbody tr:last-child td { border-bottom: 0; }
/* One table per category: share the same column widths so Pack size, Price, Yield and Actions line up down the page. */
@media (min-width: 721px) {
  table[data-aligned] { table-layout: fixed; }
  table[data-aligned] th:nth-child(2) { width: 9rem; }
  table[data-aligned] th:nth-child(3) { width: 9rem; }
  table[data-aligned] th:nth-child(4) { width: 6rem; }
  table[data-aligned] th:nth-child(5) { width: 10rem; }
}
/* All ingredients as a table: fixed columns, so a filter that leaves fewer or shorter rows does not move them (owner, 2026-10-29) */
table[data-ingredients-table] { table-layout: fixed; }
table[data-ingredients-table] th:nth-child(2) { width: 24%; }
table[data-ingredients-table] th:nth-child(3) { width: 8rem; }
table[data-ingredients-table] th:nth-child(4) { width: 8rem; }
table[data-ingredients-table] th:nth-child(5) { width: 11rem; }
@media (max-width: 720px) { table[data-ingredients-table] th:nth-child(4) { width: 6rem; } table[data-ingredients-table] th:nth-child(5) { width: 8.5rem; } }
td[data-gp="low"] { color: var(--danger); font-weight: 600; }
td[data-gp="good"] { color: var(--success); }
@media (hover: hover) { tbody tr:hover td { background: var(--muted); } }
/* 60-30-10: names in a table read in the text colour with no underline; the accent and the underline show on hover or keyboard focus, so a
   dense table is not all blue and lined (owner, 2026-10-22) */
td a { font-weight: 500; overflow-wrap: break-word; color: var(--foreground); text-decoration: none; }
td a:is(:hover, :focus-visible) { color: var(--accent-ink); text-decoration: underline; text-decoration-color: var(--accent-line); text-underline-offset: 3px; }
td { overflow-wrap: break-word; max-width: 28rem; }


/* Wide tables on a phone: one pattern for every table (UX-28, O-43, O-58, O-74, C4). The table scrolls inside its own box, never the page.
   The first column (the name) stays put while the rest slides under it, and a shadow on the right edge says there is more to see; it goes
   once you reach the end (the cover moves with the table, the shadow stays with the box). A list you work from on a phone can leave out
   the columns it does not need there: data-wide-only on their th and td. Such a table is no longer held at 620px, so its key columns
   (a supplier's phone number, an ingredient's price, a promotion's buttons) fit without a swipe. */
@media (max-width: 720px) {
  div:has(> table) {
    background-image: linear-gradient(to left, var(--card) 40%, transparent), radial-gradient(farthest-side at 100% 50%, color-mix(in srgb, var(--foreground) 24%, transparent), transparent);
    background-position: 100% 0, 100% 0;
    background-size: 48px 100%, 16px 100%;
    background-repeat: no-repeat;
    background-attachment: local, scroll;
  }
  :is(th, td):first-child { position: sticky; left: 0; z-index: 1; max-width: 11rem; background: var(--card); }
  thead th:first-child { z-index: 2; background: var(--muted); }
  tr[data-group] > th:first-child { position: static; } /* a heading row across the whole table */
  :is(th, td)[data-wide-only] { display: none; }
  table:has([data-wide-only]) { min-width: 0; }
}

/* The same right-edge shadow on an iPad (to 1100px) for the tables that are wider than the page there: the rota cut its Week column
   ("35 h ฿6,53…") with nothing to say it scrolls (UX-123), and Food and Drinks scroll too. It shows only while there is more to see. */
@media (min-width: 721px) and (max-width: 1100px) {
  div:has(> table:is([data-rota], [data-menu-table])) {
    overflow-x: auto;
    background-image: linear-gradient(to left, var(--card) 40%, transparent), radial-gradient(farthest-side at 100% 50%, color-mix(in srgb, var(--foreground) 24%, transparent), transparent);
    background-position: 100% 0, 100% 0;
    background-size: 48px 100%, 16px 100%;
    background-repeat: no-repeat;
    background-attachment: local, scroll;
  }
}

/* Stock on hand's Par box in its row (review 2026-11-08, stock 6): narrow, right-aligned like the figures beside it */
td input[data-par] { width: 6rem; text-align: right; }
