/* Pantalla / TV — a fixed 1920×1080 stage scaled to the screen. Colors are roles (validated palette:
   series blue + 7-day-average aqua + status red, adjacent and all-pairs CVD checks pass in both modes);
   dark is the default for a TV, light is its own selected set, not an automatic flip. */
.tv {
  --page: #0d0d0d; --surface: #1a1a19; --ink: #ffffff; --ink-2: #c3c2b7; --muted: #9a988f;
  --grid: #2c2c2a; --axis: #46463f; --ring: rgba(255, 255, 255, 0.10);
  --s1: #3987e5; --ma: #199e70; --crit: #d03b3b; --good: #0ca30c; --warn: #fab219; --pend: #898781;
  color-scheme: dark;
  position: fixed; inset: 0; z-index: 20; overflow: hidden; background: var(--page); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
.tv[data-theme="light"] {
  --page: #f1f0ec; --surface: #fcfcfb; --ink: #0b0b0b; --ink-2: #52514e; --muted: #6b6963;
  --grid: #e1e0d9; --axis: #c3c2b7; --ring: rgba(11, 11, 11, 0.12);
  --s1: #2a78d6; --ma: #1baf7a; --crit: #d03b3b; --good: #0ca30c; --warn: #e09a00; --pend: #898781;
  color-scheme: light;
}
.tv-stage {
  position: absolute; left: 50%; top: 50%; width: 1920px; height: 1080px; transform-origin: center;
  display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; gap: 20px; padding: 26px 40px 20px;
  cursor: default; user-select: none;
}
/* reset the app's global button / table chrome inside the TV (zero specificity so .tab etc. win) */
:where(.tv) button { all: unset; cursor: pointer; }
:where(.tv) th, :where(.tv) td { border: 0; padding: 0; vertical-align: middle; }
.tv .eyebrow { display: block; font-size: 15px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

/* status roles: color + icon + word, never color alone */
.tv .st-ok { --st: var(--good); } .tv .st-off { --st: var(--crit); } .tv .st-miss { --st: var(--warn); }
.tv .st-pend { --st: var(--pend); } .tv .st-info { --st: var(--axis); }

/* ---- header */
.tv-h { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; align-items: center; gap: 44px; }
.tv-plant h1 { margin: 2px 0 0; font-size: 50px; line-height: 1.05; font-weight: 750; letter-spacing: -.01em; }
.tv-meta b { display: block; font-size: 28px; font-weight: 700; margin-top: 4px; }
.tv-meta .sub { display: block; font-size: 17px; color: var(--ink-2); margin-top: 2px; }
.tv-meta.right { text-align: right; }
.tv-fresh { display: flex; align-items: center; gap: 12px; padding: 14px 24px; border-radius: 999px; font-size: 21px; font-weight: 650;
  background: color-mix(in srgb, var(--st) 16%, var(--surface)); box-shadow: inset 0 0 0 2px var(--st); max-width: 560px; }
.tv-fresh i { font-style: normal; font-weight: 800; color: var(--st); font-size: 24px; }

/* ---- KPI strip */
.tv-kpis { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 16px; }
.kpi { position: relative; background: var(--surface); border-radius: 14px; box-shadow: inset 0 0 0 1px var(--ring);
  padding: 16px 18px 10px 24px; display: grid; grid-template-rows: auto auto auto 52px; min-width: 0; overflow: hidden; }
.kpi::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 7px; background: var(--st); }
.kpi-lbl { font-size: 21px; font-weight: 650; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-val { font-size: 56px; font-weight: 750; line-height: 1.08; margin-top: 2px; white-space: nowrap; letter-spacing: -.01em; }
.kpi-val.long { font-size: 47px; line-height: 1.29; }
.kpi-val small { font-size: 24px; font-weight: 650; color: var(--ink-2); margin-left: 6px; letter-spacing: 0; }
.kpi-meta { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; min-width: 0; }
.chip { font-size: 18px; font-weight: 700; white-space: nowrap; }
.chip i { font-style: normal; color: var(--st); margin-right: 6px; font-weight: 900; }
.chip i:empty { display: none; }
.kpi-sub { font-size: 16px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-spark { min-height: 0; margin: 4px -6px 0 -10px; }
.spark { display: block; }
.sp-line { fill: none; stroke: var(--ink-2); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; opacity: .75; }
.sp-target { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 5 5; }
.sp-dot { fill: var(--s1); stroke: var(--surface); stroke-width: 2.5; }
.sp-dot.off { fill: var(--crit); } .sp-dot.ok { fill: var(--good); }

/* ---- department page */
.tv-page { display: flex; flex-direction: column; min-height: 0; }
.tv-page > .pg-body { flex: 1; }
.pg-h { display: flex; align-items: center; gap: 20px; margin-bottom: 14px; min-width: 0; }
.pg-h h2 { margin: 0; font-size: 42px; font-weight: 750; white-space: nowrap; }
.pg-owner { font-size: 26px; color: var(--ink-2); font-weight: 600; white-space: nowrap; }
.pg-owner::before { content: '· '; color: var(--muted); }
.legend { margin-left: auto; display: flex; gap: 26px; font-size: 19px; color: var(--ink-2); white-space: nowrap; }
.lg { display: inline-flex; align-items: center; gap: 8px; }
.lg-bar { fill: var(--s1); }
.lg-ma { stroke: var(--ma); stroke-width: 3; stroke-linecap: round; }
.lg-target { stroke: var(--ink-2); stroke-width: 2.5; stroke-dasharray: 7 5; }
.lg-off { fill: var(--crit); stroke: var(--surface); stroke-width: 2; }
.lg-exp { stroke: var(--ink); stroke-width: 4; stroke-linecap: round; }
.pg-legend-row:empty { display: none; }
.pg-legend-row .legend { margin: -4px 0 12px; justify-content: flex-end; }
.pg-facts { margin-left: auto; display: flex; gap: 14px; }
.fact { display: inline-flex; align-items: baseline; gap: 10px; padding: 8px 16px; border-radius: 10px; background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--ring); font-size: 18px; color: var(--ink-2); white-space: nowrap; }
.fact b { font-size: 24px; color: var(--ink); font-weight: 700; }

.pg-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; min-height: 0; }
.pg-body.with-grid { grid-template-columns: minmax(0, 1fr) 640px; }
.pg-body.grid-only { grid-template-columns: minmax(0, 1fr); }
.charts { display: grid; gap: 18px; min-height: 0; grid-template-rows: minmax(0, 1fr); }
.charts.n1 { grid-template-columns: minmax(0, 1fr); }
.charts.n2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.charts.n3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.charts.n4, .charts.n3.side { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); }
.charts.n2.side { grid-template-columns: minmax(0, 1fr); grid-template-rows: repeat(2, minmax(0, 1fr)); }
.card { margin: 0; background: var(--surface); border-radius: 14px; box-shadow: inset 0 0 0 1px var(--ring);
  padding: 14px 18px 6px; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.card figcaption { display: flex; align-items: baseline; gap: 16px; }
.c-t { font-size: 25px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.c-tgt { margin-left: auto; font-size: 19px; color: var(--ink-2); font-weight: 600; white-space: nowrap; }
.c-plot { flex: 1; min-height: 0; position: relative; overflow: hidden; }
.chart { display: block; position: absolute; inset: 0; }

/* chart marks (see public/charts.js) */
.ch-grid { stroke: var(--grid); stroke-width: 1; }
.ch-axis { stroke: var(--axis); stroke-width: 1.5; }
.ch-tick { fill: var(--muted); font-size: 18px; font-variant-numeric: tabular-nums; }
.ch-bar { fill: var(--s1); }
.ch-bar.off { fill: var(--crit); }
.ch-line { fill: none; stroke: var(--s1); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.ch-ma { fill: none; stroke: var(--ma); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.ch-target { stroke: var(--ink-2); stroke-width: 2; stroke-dasharray: 9 7; }
.ch-dot { fill: var(--s1); stroke: var(--surface); stroke-width: 2.5; }
.ch-dot.off { fill: var(--crit); }
.ch-expected { stroke: var(--ink); stroke-width: 3.5; stroke-linecap: round; }
.ch-last { fill: var(--ink); font-size: 24px; font-weight: 750; paint-order: stroke; stroke: var(--surface); stroke-width: 6px; stroke-linejoin: round; }
.ch-hit { fill: transparent; }
.ch-hit:hover { fill: var(--ink); fill-opacity: .06; }
.ch-empty { fill: var(--muted); font-size: 24px; }

/* manual numbers: compact status grid of the last 7 days */
.mgrid { background: var(--surface); border-radius: 14px; box-shadow: inset 0 0 0 1px var(--ring); padding: 16px 20px; min-height: 0;
  display: flex; flex-direction: column; overflow: hidden; }
.mgrid h3 { margin: 0 0 10px; font-size: 23px; font-weight: 700; }
.mgrid table { width: 100%; border-collapse: separate; border-spacing: 4px; table-layout: fixed; }
.mgrid thead th { font-size: 16px; font-weight: 650; color: var(--muted); text-align: center; padding: 0 0 4px; border: 0; }
.mgrid thead th:first-child { width: 30%; }
.mgrid thead th:last-child { width: 70px; }
.mgrid tbody th { font-size: 19px; font-weight: 600; text-align: left; color: var(--ink); padding: 4px 8px 4px 0; line-height: 1.2; border: 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mc { height: 50px; text-align: center; vertical-align: middle; font-size: 21px; font-weight: 750; border-radius: 8px; padding: 0; border: 0;
  background: color-mix(in srgb, var(--st) 30%, var(--surface)); font-variant-numeric: tabular-nums; }
.mc.st-info, .mc.st-pend { background: color-mix(in srgb, var(--ink) 6%, var(--surface)); color: var(--ink-2); }
.mc { position: relative; }
.mc.long { font-size: 18px; letter-spacing: -.02em; }
.mc i { position: absolute; top: 1px; right: 4px; font-style: normal; font-weight: 900; font-size: 14px; line-height: 1; }
.mc b { font-weight: 900; }
.mg-legend i { font-style: normal; font-weight: 900; }
.mg-tgt { font-size: 17px; color: var(--ink-2); text-align: center; border: 0; padding: 0; white-space: nowrap; }
.mg-legend { margin-top: auto; padding-top: 10px; display: flex; gap: 22px; font-size: 17px; color: var(--ink-2); }
.mg-legend i { color: var(--st); margin: 0 4px 0 0; }
.grid-only .mgrid { max-width: 1240px; width: 100%; justify-self: center; padding: 22px 30px; }
.grid-only .mgrid h3 { font-size: 27px; }
.grid-only .mc { height: 76px; font-size: 28px; }
.grid-only .mc i { font-size: 20px; top: 5px; right: 8px; }
.grid-only .mgrid tbody th { font-size: 24px; }
.grid-only .mgrid thead th { font-size: 19px; }
.pg-empty { font-size: 28px; color: var(--ink-2); }

/* ---- footer */
.tv-f { display: flex; align-items: center; gap: 24px; min-width: 0; }
.tabs { display: flex; gap: 6px; min-width: 0; }
.tab { position: relative; padding: 10px 14px 12px; border-radius: 10px; font-size: 18px; font-weight: 600; color: var(--muted); white-space: nowrap; overflow: hidden; }
.tab.on { background: var(--surface); color: var(--ink); font-weight: 750; box-shadow: inset 0 0 0 1px var(--ring); }
.tab:focus-visible { outline: 3px solid var(--s1); outline-offset: 2px; }
.prog { position: absolute; left: 0; bottom: 0; height: 4px; width: 0; background: var(--s1); border-radius: 2px; transition: width .25s linear; }
.tv-ctl { margin-left: auto; display: flex; align-items: center; gap: 16px; font-size: 16px; color: var(--muted); white-space: nowrap; }
.tv-ctl b { font-size: 18px; color: var(--ink-2); }
.tv-ctl b.paused { color: var(--ink); background: color-mix(in srgb, var(--warn) 30%, var(--surface)); padding: 6px 12px; border-radius: 8px; }
