/* The spreadsheet view of the Pipeline (plan 32 §4.3, P4.3). Tokens from /static/app.css only, so light and dark both follow the theme.
   The grid scrolls inside its own box both ways; the first column and the header row stay put. */

.pl-sheet { display: flex; flex-direction: column; gap: 10px; min-width: 0; max-width: 100%; }
.sh-loading { padding: 24px 4px; }
.sh-empty { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }

.sh-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sh-bar .grow { flex: 1 1 auto; }
.sh-bar button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.sh-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; color: var(--ink); }
.sh-legend[hidden] { display: none; }
.sh-legend li { display: inline-flex; align-items: center; gap: 8px; }
.sh-sw { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 20px; border-radius: 5px; box-shadow: inset 0 0 0 1px var(--line-strong); }
.sh-cap { padding: 10px 14px; border-radius: 10px; background: var(--warn-soft); color: var(--warn-ink); font-size: 14px; }
.sh-cap .muted { color: inherit; opacity: 0.85; }
.sh-detail { padding: 10px 14px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); font-size: 13px; color: var(--ink); overflow-wrap: anywhere; min-height: 40px; }
.sh-detail a { color: var(--accent-ink); font-weight: 600; margin-left: 4px; }
.sh-exact { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* -- the box ------------------------------------------------------------------------------------------------------ */
.sh-box { max-width: 100%; max-height: min(72vh, 760px); overflow: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
  scroll-padding: 64px 0 0 200px; overscroll-behavior: contain; }
.sh-box:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.sh-table { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; font-size: 13px; }
.sh-table th, .sh-table td { border-bottom: 1px solid var(--line-2); border-right: 1px solid var(--line-2); padding: 6px 10px; background: var(--surface); }
.sh-table td.sh-c { width: 116px; min-width: 116px; max-width: 160px; text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; position: relative; color: var(--ink); }
.sh-table td.sh-t { text-align: left; font-family: var(--sans); }
.sh-table td.sh-none { color: var(--muted); }
.sh-table td.sh-neg { color: var(--bad); }
.sh-table td.sh-c:focus { outline: 2px solid var(--accent); outline-offset: -2px; }
.sh-table td[data-total] { border-left: 2px solid var(--line-strong); font-weight: 600; }

/* sticky first column and header row */
.sh-table th.sh-l { position: sticky; left: 0; z-index: 2; width: 200px; min-width: 200px; max-width: 200px; text-align: left; font-weight: 500; color: var(--ink); border-right: 2px solid var(--line-strong); }
.sh-table thead th { position: sticky; top: 0; z-index: 3; background: var(--surface-2); text-align: right; vertical-align: bottom; border-bottom: 2px solid var(--line-strong); padding: 8px 10px; }
.sh-table thead th.sh-corner { z-index: 4; text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; }
.sh-corner .sh-unit { display: block; text-transform: none; letter-spacing: 0; }
.sh-ph { min-width: 116px; }
.sh-pname { display: block; color: var(--ink); font-weight: 600; text-decoration: none; overflow-wrap: anywhere; white-space: normal; }
.sh-pname:hover { text-decoration: underline; }
.sh-pname:focus-visible, .sh-gbtn:focus-visible, .sh-detail a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.sh-pcode { display: block; font-family: var(--mono); font-size: 11px; font-weight: 400; color: var(--muted); }
.sh-totalh { border-left: 2px solid var(--line-strong); }
.sh-lab { display: block; overflow-wrap: anywhere; white-space: normal; }
.sh-unit { display: block; font-size: 11px; color: var(--muted); font-weight: 400; }

/* groups */
.sh-ghead th.sh-l { background: var(--surface-2); padding: 0; }
.sh-ghead .sh-gfill, .sh-table .sh-ghead td.sh-gtot { background: var(--surface-2); }
.sh-table td.sh-gtot { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; color: var(--ink); cursor: default; }
.sh-gtl { font-weight: 500; color: var(--ink-2); font-size: 12px; white-space: normal; }
.sh-gbtn { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 40px; padding: 0 10px; border: none; border-radius: 0; background: transparent; color: var(--ink);
  font: inherit; font-weight: 600; text-align: left; justify-content: flex-start; }
.sh-gbtn:hover { background: var(--chip); }
.sh-gbtn svg { width: 14px; height: 14px; flex-shrink: 0; transition: transform 0.15s ease; overflow: visible; }
.sh-gbtn[aria-expanded="true"] svg { transform: rotate(90deg); }
.sh-gname { white-space: normal; }
.sh-gbtn .count { font-weight: 400; font-size: 12px; color: var(--muted); }
.sh-estn { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--warn-soft); color: var(--warn-ink); }
.sh-margins .sh-ghead th.sh-l, .sh-margins .sh-ghead .sh-gfill { border-top: 3px solid var(--accent); }

/* sources on demand: a tint and a letter, never the tint alone */
.sh-mark { display: none; position: absolute; top: 1px; left: 3px; font-family: var(--sans); font-style: normal; font-size: 10px; font-weight: 700; line-height: 1; }
.sh-on .sh-mark { display: inline; }
.sh-sw .sh-mark { display: inline; position: static; font-size: 12px; }
.sh-on td.k-placeholder, .sh-sw.k-placeholder { background: var(--warn-soft); color: var(--warn-ink); }
.sh-on td.k-dashboard, .sh-sw.k-dashboard { background: var(--info-soft); color: var(--info-ink); }
.sh-on td.k-g3ac_typed, .sh-sw.k-g3ac_typed { background: var(--chip); color: var(--ink-2); }
.sh-on td.k-placeholder .sh-mark, .sh-on td.k-dashboard .sh-mark, .sh-on td.k-g3ac_typed .sh-mark { color: inherit; }

@media (max-width: 760px) {
  .sh-box { max-height: min(68vh, 560px); scroll-padding: 60px 0 0 132px; }
  .sh-table th.sh-l { width: 132px; min-width: 132px; max-width: 132px; padding: 6px 8px; }
  .sh-table td.sh-c { width: 104px; min-width: 104px; }
  .sh-ph { min-width: 104px; }
}
@media (prefers-reduced-motion: reduce) { .sh-gbtn svg { transition: none; } }
