/* Production display: four fixed rows, with larger text at 4K. */
:root {
  color-scheme: dark;
  --ink: #fff;
  --ink-soft: #edf5ff;
  --line: #285592;
  --line-strong: #4388c8;
  --paper: #0a2a5c;
  --canvas: #061d49;
  --mint: #69d6ff;
  --shadow: 0 10px 28px #00102f66;
  --gutter: clamp(20px, 1.3vw, 50px);
  --display-font: clamp(22px, 1.46vw, 56px);
  --label-font: clamp(17px, 1.05vw, 40px);
  --kpi-icon-size: clamp(24px, 1.67vw, 64px);
  --kpi-icon-gap: clamp(5px, 0.45vw, 17px);
  --table-header-height: clamp(64px, 5.93vh, 128px);
  --row-height: calc((100vh - 370px) / 4);
}

html,
body,
html.kiosk-mode,
html.kiosk-mode body {
  height: 100%;
  min-height: 0;
  color: #fff;
  font-size: 17px;
  overflow: hidden;
  background: #061d49;
}
body { background-image: radial-gradient(ellipse at 50% 0, #104985 0, transparent 65%); }
[hidden] { display: none !important; }
.board-shell,
html.kiosk-mode .board-shell { height: 100vh; min-height: 0; overflow: hidden; background: transparent; }

.topbar,
html.kiosk-mode .topbar {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  --topbar-gap: 0;
  align-items: center;
  gap: clamp(14px, 1vw, 38px);
  flex: 0 0 auto;
  min-height: clamp(76px, 7.04vh, 152px);
  padding: clamp(4px, 0.37vh, 8px) var(--gutter);
  background: linear-gradient(110deg, #082455, #103e7b 50%, #082455);
  border-bottom: 3px solid #48c2ff;
  box-shadow: 0 4px 24px #1689ff24;
}
.brand-block,
html.kiosk-mode .brand-block {
  position: static;
  --brand-gap: 0;
  transform: none;
  grid-column: 2;
  min-width: 0;
  display: flex;
  justify-content: center;
  text-align: center;
}
.brand-mark,
.brand-block .eyebrow { display: none; }
h1,
html.kiosk-mode h1 { margin: 0; font-size: clamp(32px, 2.3vw, 88px); line-height: 1.2; font-weight: 700; letter-spacing: 0.035em; white-space: nowrap; text-shadow: 0 2px 20px #0d8cdf66; }
.topbar-live { grid-column: 1; grid-row: 1; display: flex; flex-direction: column; align-items: flex-start; --live-gap: 8px; min-width: 0; }
.connection,
.clock { color: #fff; font-size: clamp(13px, 0.78vw, 28px); }
.connection { display: inline-flex; padding: 0; border: 0; }
.connection-dot { background: #79e3ff; box-shadow: 0 0 12px #56ccff; }
.clock { min-width: 0; text-align: left; white-space: nowrap; }
.topbar-status,
html.kiosk-mode .topbar-status { grid-column: 3; grid-row: 1; justify-self: end; justify-content: flex-end; flex-wrap: nowrap; min-width: 0; margin: 0; --status-gap: clamp(6px, 0.4vw, 16px); }
.topbar-update { display: flex; flex-direction: column; align-items: flex-end; --update-gap: 8px; min-width: 0; font-size: clamp(11px, 0.67vw, 25px); line-height: 1.35; text-align: right; }
.topbar-live > * + * { margin-top: var(--live-gap); }
.topbar-update > * + * { margin-top: var(--update-gap); }
#lastUpdated { overflow-wrap: anywhere; }
.auto-refresh { color: #d9efff; white-space: nowrap; font-size: inherit; }
.auto-refresh svg { width: 1.1em; height: 1.1em; }
.icon-button,
.icon-button.dark { flex: 0 0 auto; width: clamp(30px, 1.85vw, 64px); height: clamp(30px, 1.85vw, 64px); color: #fff; background: #123d75; border-color: #396aab; }
.icon-button:hover:not(:disabled),
.icon-button.dark:hover { color: #fff; background: #1e5a9a; border-color: #6bd6ff; }
.icon-button svg { width: 56%; height: 56%; }
/* Chromium 83 ignores :focus-visible, so keep a plain :focus fallback. */
button:focus { outline: 2px solid #8ce5ff; outline-offset: 3px; }
button:focus:not(:focus-visible) { outline: none; }

.control-band { flex-shrink: 0; padding: 12px var(--gutter); background: #092755; }
.field-group > span,
.input-with-icon > svg,
.clear-search { color: #edf5ff; }
.field-group > span,
.segmented button { font-size: 15px; }
select,
input { color: #fff; background: #061f49; height: 42px; border-color: #3c65a0; }
input::placeholder { color: #d1e4fa; }
select:focus,
input:focus { background: #0b3268; border-color: #74d9ff; box-shadow: 0 0 0 3px #42baff22; }
.segmented { background: #061f49; }
.segmented.compact { height: 42px; }
.segmented button { color: #fff; }
.segmented button.active { color: #fff; background: #1d5899; }
html.kiosk-mode .control-band { display: none; }

.kpi-band { display: grid; grid-template-columns: 1.05fr 1.05fr 1.2fr; flex: 0 0 auto; margin: clamp(8px, 0.74vh, 16px) var(--gutter) 0; background: linear-gradient(100deg, #0b3068, #0d3973 50%, #0b3068); border: 1px solid #32639c; box-shadow: inset 0 1px 0 #88ccff1a, var(--shadow); }
.kpi-item,
html.kiosk-mode .kpi-item { position: relative; min-width: 0; min-height: clamp(68px, 6.3vh, 136px); padding: clamp(4px, 0.37vh, 8px) clamp(12px, 1vw, 38px); display: flex; flex-direction: column; align-items: center; justify-content: center; grid-column: auto; --kpi-gap: 0; border-top: 0; border-bottom: 0; border-right: 1px solid var(--line); }
.kpi-item:last-child { border-right: 0; }
.kpi-line { display: flex; align-items: baseline; justify-content: center; --metric-gap: clamp(6px, 0.5vw, 19px); white-space: nowrap; }
.kpi-item p { position: relative; margin: 0; padding-left: calc(var(--kpi-icon-size) + var(--kpi-icon-gap)); color: #fff; font-size: clamp(17px, 1.12vw, 43px); line-height: 1.1; font-weight: 500; }
/* Reserve the icon's width inside each label without increasing the KPI row's
   height. Margin/padding spacing also works in Chromium 83. */
.kpi-item .kpi-icon { position: absolute; top: 50%; left: 0; display: block; width: var(--kpi-icon-size); height: var(--kpi-icon-size); flex: 0 0 auto; transform: translateY(-50%); color: #b8eaff; background: none; border-radius: 0; }
.kpi-item .kpi-icon svg { display: block; width: 100%; height: 100%; stroke-width: 2; }
.kpi-item strong,
.day-meta-value,
html.kiosk-mode .kpi-item strong,
html.kiosk-mode .day-meta-value { color: #fff; font-size: clamp(27px, 1.85vw, 70px); line-height: 1; letter-spacing: 0; }
.kpi-item .unit { margin: 0; color: #dceeff; font-size: clamp(15px, 0.88vw, 34px); }
.kpi-item .kpi-line > * + * { margin-left: var(--metric-gap); }
.kpi-item strong.metric-unavailable,
html.kiosk-mode .kpi-item strong.metric-unavailable { font-size: clamp(20px, 1.35vw, 52px); color: #dceeff; }
.metric-note { margin-top: clamp(2px, 0.19vh, 4px); color: #c4def5; font-size: clamp(11px, 0.62vw, 24px); line-height: 1.15; white-space: nowrap; }

.day-tabs,
html.kiosk-mode .day-tabs { flex: 0 0 auto; padding: clamp(8px, 0.74vh, 16px) var(--gutter) 0; gap: clamp(10px, 0.5vw, 20px); }
html.kiosk-mode .day-tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.day-tab,
html.kiosk-mode .day-tab { position: relative; min-height: clamp(64px, 5.93vh, 128px); padding: clamp(4px, 0.37vh, 8px) clamp(16px, 1.2vw, 46px); color: #fff; background-color: #0b2c60; border-color: #2f5893; transition: background-color 180ms, box-shadow 180ms; }
.day-tab:hover,
html.kiosk-mode .day-tab:hover { color: #fff; background-color: #14427e; }
/* 旧版浏览器兜底：不支持 linear-gradient 时会丢弃整条 background 简写，
   于是 selected 页签退回 styles.css 里的白色底（白字 + 白底 = 看不见）。
   这里把纯色写成 background-color、渐变只放 background-image，并补 -webkit-
   前缀给旧版 WebKit/Android 终端；同时把 8 位 hex 阴影换成 rgba()。
   选择器带上 html.kiosk-mode 前缀，避免被上面特异性更高的 kiosk 基础规则覆盖。 */
.day-tab.active,
html.kiosk-mode .day-tab.active { color: #fff; background-color: #1553a1; background-image: -webkit-linear-gradient(105deg, #1553a1, #1762b3); background-image: linear-gradient(105deg, #1553a1, #1762b3); border-color: #6dcfff; box-shadow: inset 0 0 30px rgba(69, 182, 255, 0.14); }
.day-tab.active::before { height: 4px; background-color: #2d9eff; background-image: -webkit-linear-gradient(90deg, #2d9eff, #b2f2ff, #2d9eff); background-image: linear-gradient(90deg, #2d9eff, #b2f2ff, #2d9eff); }
.day-name { font-size: clamp(19px, 1.25vw, 48px); line-height: 1.2; }
.day-date,
html.kiosk-mode .day-date { font-size: clamp(21px, 1.35vw, 52px); line-height: 1.2; }
.day-meta,
html.kiosk-mode .day-meta { margin-top: 0; color: #dceeff; font-size: clamp(14px, 0.85vw, 32px); line-height: 1.1; font-weight: 600; }

.table-section,
html.kiosk-mode .table-section { position: relative; isolation: isolate; flex: 1 1 0; min-height: 0; margin: 0 var(--gutter) clamp(12px, 1.11vh, 24px); overflow: hidden; background: #082653; border: 1px solid #4a98db; box-shadow: 0 0 22px #2088ff26, var(--shadow); }
.table-section::before { content: ""; position: absolute; z-index: 5; top: 0; left: 0; width: 30%; height: 3px; background: linear-gradient(90deg, transparent, #4fc8ff, #e2faff, transparent); box-shadow: 0 0 14px #45baff; pointer-events: none; animation: table-edge-flow 8s linear infinite; }
.table-section::after { content: ""; position: absolute; z-index: 5; top: 0; right: 0; bottom: 0; left: 0; border: 1px solid #3b9eff; pointer-events: none; animation: table-blue-glow 5s ease-in-out infinite; }
.table-scroll,
html.kiosk-mode .table-scroll { position: relative; flex: 1 1 0; min-height: 0; overflow: hidden; background: #082653; scrollbar-color: #4b94d7 #08234f; }
/* Chromium 83 uses the WebKit scrollbar selectors instead of scrollbar-color. */
.table-scroll::-webkit-scrollbar { width: 10px; height: 10px; }
.table-scroll::-webkit-scrollbar-track { background: #08234f; }
.table-scroll::-webkit-scrollbar-thumb { background: #4b94d7; border: 2px solid #08234f; border-radius: 6px; }
table,
html.kiosk-mode table { width: 100%; min-width: 0; table-layout: fixed; border-collapse: separate; border-spacing: 0; }
.col-date { width: 6%; }
.col-bill { width: 14%; }
.col-code { width: 8%; }
.col-name { width: 10.5%; }
.col-spec { width: 19%; }
.col-number { width: 4%; }
.col-contract { width: 6%; }
.col-remark { width: 28.5%; }
thead { position: relative; z-index: 3; }
th,
html.kiosk-mode th { position: sticky; z-index: 3; top: 0; height: var(--table-header-height); padding: 4px clamp(3px, 0.3vw, 12px); color: #fff; background: #154786; border-color: #28538b; border-bottom: 2px solid #549bd7; font-size: var(--label-font); line-height: 1.25; white-space: normal; overflow-wrap: anywhere; text-align: center; }
tbody { transform: translateY(0); }
tbody.rows-moving { transform: translateY(calc(-1 * var(--scroll-distance, var(--row-height)))); transition: transform 700ms ease-in-out; }
tbody tr { height: var(--row-height); }
td,
html.kiosk-mode td { height: var(--row-height); max-height: var(--row-height); padding: 0; overflow: hidden; color: #fff; background: #0a2b5e; border-color: #28538b; font-size: var(--display-font); line-height: 1.2; }
/* Auto cross-axis margins centre short values, while overflowing text starts
   at its first line and remains available through manual cell scrolling. */
td .cell-content { display: flex; align-items: flex-start; height: calc(var(--row-height) - 1px); max-height: calc(var(--row-height) - 1px); min-width: 0; padding: clamp(4px, 0.37vh, 8px) clamp(3px, 0.3vw, 12px); overflow-x: hidden; overflow-y: auto; overflow-wrap: anywhere; white-space: normal; text-overflow: clip; font-size: inherit; line-height: 1.2; }
td .cell-content::-webkit-scrollbar { width: 5px; }
td .cell-content::-webkit-scrollbar-track { background: transparent; }
td .cell-content::-webkit-scrollbar-thumb { background: #4b94d7; border-radius: 4px; }
td.cell-center .cell-content { justify-content: center; text-align: center; }
td.cell-date.is-overdue-date .cell-content { color: #ff707a; }
.cell-content > span { display: block; flex: 0 0 auto; width: 100%; max-width: 100%; margin-top: auto; margin-bottom: auto; }
.cell-truncate { white-space: normal; text-overflow: clip; }
.cell-clamp { display: block; overflow: visible; overflow-wrap: anywhere; -webkit-line-clamp: unset; line-height: inherit; }
tbody tr.row-even td { background: #0e346c; }
tbody tr.row-odd td { background: #0a2b5e; }
/* Empty placeholders inherit the base table's even-row white background unless
   the kiosk theme overrides that higher-specificity selector explicitly. */
tbody tr.empty-row:nth-child(even) td,
tbody tr.empty-row:nth-child(odd) td { background: #082653; }
tbody tr:hover td { background: #184986; }
.cell-strong,
.normal-mark { color: #fff; }
.empty-state { position: absolute; z-index: 2; top: var(--table-header-height); right: 0; bottom: 0; left: 0; min-height: 0; color: #fff; background: radial-gradient(ellipse at center, #103c79, #082653); }
.empty-state strong { color: #fff; font-size: clamp(22px, 1vw, 38px); }
.empty-state span { font-size: var(--label-font); }
.empty-state svg { color: #89d9ff; }

.table-footer { flex: 0 0 auto; min-height: clamp(44px, 4.07vh, 88px); padding: clamp(4px, 0.37vh, 8px) clamp(14px, 1vw, 38px); color: #fff; background: #0a2b5f; font-size: clamp(14px, 0.82vw, 31px); --footer-gap: 14px; }
#recordRange { flex: 0 1 auto; }
.rotation-status { display: inline-flex; align-items: center; justify-content: center; --rotation-gap: 10px; min-width: 0; text-align: center; font-variant-numeric: tabular-nums; }
.rotation-status::before { content: ""; width: 8px; height: 8px; flex: 0 0 8px; border-radius: 50%; background: #7fe1ff; box-shadow: 0 0 10px #4abfff; }
.rotation-status::before { margin-right: var(--rotation-gap); }
.pagination { flex: 0 0 auto; --page-gap: clamp(8px, 0.55vw, 21px); }
.pagination .icon-button { width: clamp(28px, 1.6vw, 56px); height: clamp(28px, 1.6vw, 56px); }
.detail-dialog { color: #fff; background: #082653; border-color: #579ed9; font-size: clamp(17px, 0.85vw, 32px); }
.detail-dialog::backdrop { background: #000e2dbb; }
.dialog-head { background: #103b79; }
.dialog-head .eyebrow,
.detail-item dt { color: #e7f3ff; }
.detail-item dt { font-size: var(--label-font); }
.detail-item dd { font-size: inherit; }
.toast { color: #fff; background: #144883; border-left-color: #8adfff; pointer-events: none; }

@keyframes table-edge-flow { from { transform: translateX(-110%); } to { transform: translateX(345%); } }
@keyframes table-blue-glow { 0%, 100% { box-shadow: inset 0 0 7px #1b85ff18; opacity: 0.45; } 50% { box-shadow: inset 0 0 22px #2499ff30; opacity: 0.95; } }

@media (max-width: 1399px) {
  .topbar,
  html.kiosk-mode .topbar { grid-template-columns: 1fr auto; gap: 10px; }
  .brand-block,
  html.kiosk-mode .brand-block { grid-column: 1 / -1; grid-row: 1; }
  .topbar-live { grid-row: 2; flex-direction: row; align-items: center; }
  .topbar-live > * + * { margin-top: 0; margin-left: var(--live-gap); }
  .topbar-status,
  html.kiosk-mode .topbar-status { grid-column: 2; grid-row: 2; }
  .topbar-update { flex-direction: row; align-items: center; }
  .topbar-update > * + * { margin-top: 0; margin-left: var(--update-gap); }
  .kpi-item,
  html.kiosk-mode .kpi-item { padding-right: 8px; padding-left: 8px; }
  .kpi-line { --metric-gap: 5px; }
  .kpi-item p { font-size: 15px; }
  .kpi-item strong,
  .day-meta-value,
  html.kiosk-mode .kpi-item strong,
  html.kiosk-mode .day-meta-value { font-size: 24px; }
  th,
  html.kiosk-mode th { padding-left: 3px; padding-right: 3px; }
}

@media (max-width: 900px) {
  :root { --gutter: 12px; }
  h1,
  html.kiosk-mode h1 { font-size: clamp(22px, 3.6vw, 32px); }
  .topbar-live .connection { display: none; }
  .topbar-live .clock { margin-left: 0; }
  .topbar-update .auto-refresh { display: none; }
  .kpi-band { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi-line { flex-wrap: wrap; --metric-gap: 3px; }
  .kpi-item .kpi-line > strong { margin-left: 0; }
  .kpi-item .kpi-line > p { margin-bottom: var(--metric-gap); }
  .kpi-item p { width: 100%; padding-left: 0; text-align: center; font-size: 12px; }
  .kpi-item .kpi-icon { position: static; display: inline-block; margin-right: var(--kpi-icon-gap); vertical-align: middle; transform: none; }
  .kpi-item .unit { font-size: 12px; }
  .kpi-item strong,
  .day-meta-value,
  html.kiosk-mode .kpi-item strong,
  html.kiosk-mode .day-meta-value { font-size: 20px; }
  .day-name { font-size: 16px; }
  .day-date,
  html.kiosk-mode .day-date { font-size: 17px; }
  .day-meta,
  html.kiosk-mode .day-meta { font-size: 13px; }
  .metric-note { white-space: normal; }
  .table-scroll,
  html.kiosk-mode .table-scroll { overflow-x: auto; }
  table,
  html.kiosk-mode table { min-width: 1080px; }
  .table-footer { flex-wrap: wrap; --footer-gap: 6px; font-size: 12px; }
  .rotation-status { order: 3; width: 100%; }
  .table-footer > .rotation-status { margin-top: var(--footer-gap); margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .table-section::before,
  .table-section::after { animation: none; }
  tbody.rows-moving { transition-duration: 0.01ms; }
}

/* A kiosk link is normally viewed from a few metres away. Use the full
   1080p table area and a larger reading scale for that physical display. */
html.kiosk-mode.projection-mode {
  --gutter: clamp(20px, 1.4vw, 54px);
  --label-font: clamp(20px, 1.12vw, 43px);
}
html.kiosk-mode.projection-mode h1 { font-size: clamp(38px, 2.7vw, 104px); }
html.kiosk-mode.projection-mode .connection,
html.kiosk-mode.projection-mode .clock { font-size: clamp(15px, 0.9vw, 32px); }
html.kiosk-mode.projection-mode .topbar-update { font-size: clamp(13px, 0.78vw, 29px); }
html.kiosk-mode.projection-mode .kpi-item p { font-size: clamp(20px, 1.35vw, 52px); }
html.kiosk-mode.projection-mode .kpi-item strong,
html.kiosk-mode.projection-mode .day-meta-value { font-size: clamp(32px, 2.2vw, 84px); }
html.kiosk-mode.projection-mode .kpi-item .unit { font-size: clamp(17px, 1vw, 38px); }
html.kiosk-mode.projection-mode .metric-note { font-size: clamp(13px, 0.72vw, 27px); }
html.kiosk-mode.projection-mode .day-name { font-size: clamp(22px, 1.45vw, 52px); }
html.kiosk-mode.projection-mode .day-date { font-size: clamp(24px, 1.55vw, 56px); }
html.kiosk-mode.projection-mode .day-meta { font-size: clamp(16px, 0.95vw, 36px); }
html.kiosk-mode.projection-mode .table-footer { font-size: clamp(18px, 1vw, 36px); }

/* 生产看板：统计栏位于日期页签下方，页签改为独立卡片，指标与表格之间留出间距。 */
body:not(.operations-board) .kpi-band { margin-bottom: clamp(8px, 0.74vh, 16px); }
body:not(.operations-board) .day-tab { border-bottom: 1px solid #2f5893; border-radius: 8px; }

