/* CIPHET Mango Line — v14 reference layout, with recorded batch results.
   Supplied machine photographs, Fraunces / IBM Plex Sans, glass cards,
   golden station proportions and a responsive production summary. */

/* ---------------------------------------------------------------- tokens */

:root {
  color-scheme: light;

  --font-ui: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --font-display: "Fraunces", Georgia, serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, "Roboto Mono", monospace;

  /* type scale — ratio 1.272, every second step golden */
  --t-xs: 12.4px; --t-sm: 13.6px; --t-md: 15.8px; --t-lg: 20.1px;
  --t-xl: 25.6px; --t-2xl: 32.6px; --t-3xl: 41.4px;
  /* φ spacing */
  --s1: 4px; --s2: 6px; --s3: 10px; --s4: 16px; --s5: 26px; --s6: 42px; --s7: 68px;
  --r-lg: 34px; --r-md: 21px; --r-sm: 13px;
  --ease: cubic-bezier(.2, .8, .2, 1);

  /* ---- light: husk paper ---- */
  --paper: #ECEADF;
  --text: #1C1E17;
  --text-2: rgba(28, 30, 23, .72);
  --text-3: rgba(28, 30, 23, .55);
  --text-secondary: var(--text-2);   /* aliases read by charts.js */
  --text-muted: var(--text-3);
  --panel: rgba(255, 255, 255, .62);
  --panel-2: rgba(255, 255, 255, .70);
  --panel-solid: #F6F5EF;            /* opaque twin of --panel: chart surface, marker rings */
  --line: rgba(28, 30, 23, .15);
  --line-soft: rgba(28, 30, 23, .08);
  --track: rgba(28, 30, 23, .09);
  --grid: rgba(28, 30, 23, .08);
  --baseline: rgba(28, 30, 23, .18);
  --shine: rgba(255, 255, 255, .95);
  --sheen-top: rgba(255, 255, 255, .55);
  --sheen-bot: rgba(255, 255, 255, 0);
  --shadow: 0 1px 1px rgba(255, 255, 255, .5) inset, 0 1px 2px rgba(28, 30, 23, .05), 0 14px 34px -16px rgba(28, 30, 23, .28);

  --bg-image:
    radial-gradient(ellipse 1000px 620px at 88% -10%, rgba(217, 147, 43, .16), transparent 62%),
    radial-gradient(ellipse 820px 660px at -5% 108%, rgba(63, 125, 83, .13), transparent 62%),
    linear-gradient(170deg, #ECEADF, #E3E2D4);

  --kesar: #C8841F;
  --reject: #B8412F;
  --leaf: #35704A;
  --teal: #2A737C;
  --plum: #61508F;
  --amber: #D9930E;                  /* only for the STALE state, which the file has no colour for */
  --on-kesar: #241802;
  --grade-big: #E3A41F;
  --grade-medium: #EBD177;
  --grade-small: #4E9A68;
  --grade-misc: #8B7BC4;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --paper: #12140F;
    --text: #F0EFE7;
    --text-2: rgba(240, 239, 231, .74);
    --text-3: rgba(240, 239, 231, .55);
    --panel: rgba(255, 255, 255, .08);
    --panel-2: rgba(255, 255, 255, .045);
    --panel-solid: #1F211C;
    --line: rgba(255, 255, 255, .16);
    --line-soft: rgba(255, 255, 255, .09);
    --track: rgba(255, 255, 255, .10);
    --grid: rgba(255, 255, 255, .09);
    --baseline: rgba(255, 255, 255, .2);
    --shine: rgba(255, 255, 255, .5);
    --sheen-top: rgba(255, 255, 255, .16);
    --sheen-bot: rgba(255, 255, 255, 0);
    --shadow: 0 1px 1px rgba(255, 255, 255, .10) inset, 0 1px 2px rgba(0, 0, 0, .4), 0 22px 46px -20px rgba(0, 0, 0, .7);
    --bg-image:
      radial-gradient(ellipse 1000px 620px at 88% -10%, rgba(217, 147, 43, .20), transparent 62%),
      radial-gradient(ellipse 820px 660px at -5% 108%, rgba(63, 125, 83, .16), transparent 62%),
      linear-gradient(168deg, #1A1710 0%, #14140F 46%, #0D0F0C 100%);
    --kesar: #E8A93C;
    --reject: #E0695A;
    --leaf: #5CA97B;
    --teal: #4FADB6;
    --plum: #9683CF;
    --amber: #E5A62A;
    --on-kesar: #241802;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #12140F;
  --text: #F0EFE7;
  --text-2: rgba(240, 239, 231, .74);
  --text-3: rgba(240, 239, 231, .55);
  --panel: rgba(255, 255, 255, .08);
  --panel-2: rgba(255, 255, 255, .045);
  --panel-solid: #1F211C;
  --line: rgba(255, 255, 255, .16);
  --line-soft: rgba(255, 255, 255, .09);
  --track: rgba(255, 255, 255, .10);
  --grid: rgba(255, 255, 255, .09);
  --baseline: rgba(255, 255, 255, .2);
  --shine: rgba(255, 255, 255, .5);
  --sheen-top: rgba(255, 255, 255, .16);
  --sheen-bot: rgba(255, 255, 255, 0);
  --shadow: 0 1px 1px rgba(255, 255, 255, .10) inset, 0 1px 2px rgba(0, 0, 0, .4), 0 22px 46px -20px rgba(0, 0, 0, .7);
  --bg-image:
    radial-gradient(ellipse 1000px 620px at 88% -10%, rgba(217, 147, 43, .20), transparent 62%),
    radial-gradient(ellipse 820px 660px at -5% 108%, rgba(63, 125, 83, .16), transparent 62%),
    linear-gradient(168deg, #1A1710 0%, #14140F 46%, #0D0F0C 100%);
  --kesar: #E8A93C;
  --reject: #E0695A;
  --leaf: #5CA97B;
  --teal: #4FADB6;
  --plum: #9683CF;
  --amber: #E5A62A;
  --on-kesar: #241802;
}

/* ---------------------------------------------------------------- base */

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font-ui);
  font-size: var(--t-md);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg-image);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  padding: var(--s5) clamp(var(--s4), 3vw, var(--s6)) var(--s6);
  transition: background .35s ease, color .35s ease;
}
button { font: inherit; color: inherit; }
input, select { font: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.batch-browser, .batch-focus, .scan-gallery { padding: var(--s5); }
.batch-browser h1, .batch-focus h2, .scan-gallery h2 { margin: 0; font-family: var(--font-display); font-size: var(--t-lg); font-weight: 600; overflow-wrap: anywhere; }
.batch-intro { margin: var(--s1) 0 0; font-size: var(--t-sm); color: var(--text-2); }
.batch-tools { display: flex; gap: var(--s3); flex-wrap: wrap; }
.batch-tools input, .batch-tools select { min-height: 40px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel-solid); color: var(--text); padding: 8px 12px; font-size: var(--t-sm); }
.batch-tools input { width: min(260px, 100%); }
.batch-cards { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: var(--s4); margin-top: var(--s5); }
.batch-card { display: flex; flex-direction: column; gap: var(--s2); text-align: left; padding: var(--s4); min-width: 0; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--panel-2); cursor: pointer; }
.batch-card:hover { background: var(--track); }
.batch-card[aria-pressed="true"] { border-color: var(--kesar); box-shadow: inset 0 0 0 1px var(--kesar); background: color-mix(in srgb, var(--kesar) 9%, var(--panel-solid)); }
.batch-card-title { font-family: var(--font-display); font-size: var(--t-md); font-weight: 600; overflow-wrap: anywhere; }
.eyebrow, .batch-card-date { font-size: var(--t-xs); color: var(--text-2); }
.eyebrow { font-weight: 600; }
.batch-card-metrics { font-size: var(--t-sm); margin-top: var(--s2); font-variant-numeric: tabular-nums; }
.batch-card-action { font-size: var(--t-xs); font-weight: 600; color: var(--text-2); margin-top: auto; padding-top: var(--s3); }
.batch-browser { padding: var(--s4); }
.batch-browser h1 { font-size: var(--t-md); }
.batch-browser .batch-intro { font-size: var(--t-xs); }
.batch-browser .batch-tools { display: grid; grid-template-columns: minmax(0, 220px) auto; max-width: 100%; }
.batch-browser .batch-tools input { width: 100%; min-width: 0; }
.batch-browser .batch-tools input, .batch-browser .batch-tools select { min-height: 36px; padding: 6px 10px; }
.batch-browser .batch-cards { gap: var(--s3); margin-top: var(--s3); max-height: 220px; overflow-y: auto; padding: var(--s1); }
.batch-browser .batch-card { gap: var(--s1); padding: var(--s3); border-radius: var(--r-sm); }
.batch-browser .batch-card-title { font-size: var(--t-sm); }
.batch-browser .batch-card-metrics { font-size: var(--t-xs); margin-top: 0; }
.batch-browser .batch-card-action { padding-top: var(--s1); }
.batch-browser .pager { margin-top: var(--s3); }
.batch-guidance { margin: var(--s4) 0 0; border-left: 3px solid var(--kesar); padding: var(--s2) 0 var(--s2) var(--s4); font-size: var(--t-sm); color: var(--text-2); }
.pager { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); margin-top: var(--s4); font-size: var(--t-xs); color: var(--text-2); }
.pager > div { display: flex; gap: var(--s2); }
.plain-btn { min-height: 36px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel-solid); color: var(--text); padding: 7px 12px; font-size: var(--t-sm); cursor: pointer; }
.plain-btn:hover:enabled { background: var(--track); }
button:disabled { opacity: .45; cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible, a:focus-visible { outline: 2px solid var(--kesar); outline-offset: 3px; }
.empty-state { grid-column: 1 / -1; color: var(--text-2); font-size: var(--t-sm); }
.page[data-station="color-1"] .scan-card { display: none; }
.page[data-station="color-1"] .analytics-top { grid-template-columns: 1fr; }
.classification-note { margin: 0; color: var(--text-2); font-size: var(--t-xs); }
.scan-cards { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: var(--s4); margin-top: var(--s4); }
.scan-result { overflow: hidden; border: 1px solid var(--line); border-radius: var(--r-md); min-width: 0; }
.scan-open { position: relative; display: grid; place-items: center; width: 100%; aspect-ratio: 1; background: #101010; color: #ddd; border: 0; padding: 0; cursor: zoom-in; font-size: var(--t-xs); }
.scan-open img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.scan-result-body { padding: var(--s3); display: flex; flex-direction: column; gap: var(--s2); font-size: var(--t-xs); }
.scan-result-name { overflow-wrap: anywhere; font-weight: 600; }
.scan-result-body .dl-original { color: var(--text); text-decoration: underline; min-height: 28px; }
.lightbox-close { position: absolute; right: 16px; top: 16px; z-index: 1; }
:focus-visible { outline: 2px solid var(--kesar); outline-offset: 3px; border-radius: var(--r-sm); }

.num {
  font-family: var(--font-display);
  font-optical-sizing: auto;
  font-weight: 600;
  letter-spacing: -0.012em;
}
.num.tick { animation: tick .9s ease-out; }
@keyframes tick { from { color: var(--kesar); } }

.page { max-width: 1152px; margin: 0 auto; display: flex; flex-direction: column; gap: var(--s4); }

/* ---------------------------------------------------------------- panel */

.panel {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  box-shadow: var(--shadow);
  overflow: hidden;
  isolation: isolate;
  min-width: 0;
  transition: background .35s ease, border-color .35s ease;
}
.panel::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 1px; z-index: 2;
  background: linear-gradient(90deg, transparent, var(--shine) 30%, var(--shine) 70%, transparent);
}
.panel::after {
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: linear-gradient(165deg, var(--sheen-top) 0%, var(--sheen-bot) 46%);
}
.panel > * { position: relative; z-index: 2; }

/* ---------------------------------------------------------------- header */

header {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s4); flex-wrap: wrap; padding: 0 var(--s1) var(--s1);
}
.brand { display: flex; align-items: baseline; gap: var(--s3); min-width: 0; }
.brand-name { font-family: var(--font-display); font-weight: 600; font-size: var(--t-lg); letter-spacing: -0.015em; white-space: nowrap; }
.brand-sub { font-size: var(--t-xs); color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head-right { display: flex; align-items: center; gap: var(--s4); font-size: var(--t-xs); color: var(--text-2); flex-wrap: wrap; }
.status { display: inline-flex; align-items: center; gap: var(--s2); white-space: nowrap; }
.clock { white-space: nowrap; font-variant-numeric: tabular-nums; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex-shrink: 0; background: var(--text-3); }
.dot.off { background: var(--text-3); }
.dot.live { background: var(--kesar); }
.dot.warn { background: var(--amber); }
.dot.bad { background: var(--reject); }
.dot.live.pulse { animation: pulse 1.8s ease-out infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--kesar) 50%, transparent); }
  70% { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.head-btns { display: flex; gap: var(--s2); }
.head-btn {
  width: 34px; height: 34px; border-radius: 50%; padding: 0;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text-2);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  transition: background .2s ease, color .2s ease;
}
.head-btn:hover { background: var(--track); color: var(--text); }
.head-btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; }

/* ---------------------------------------------------------------- alerts */

.alert-strip { display: flex; flex-direction: column; gap: var(--s2); }
.alert-strip:empty { display: none; }
.alert { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); font-size: var(--t-sm); color: var(--text-2); border-radius: var(--r-md); }
.alert.warning { box-shadow: inset 3px 0 0 var(--amber); }
.alert.critical { box-shadow: inset 3px 0 0 var(--reject); }
.alert .badge { flex-shrink: 0; }

/* ---------------------------------------------------------------- hero: the line itself */

.line { padding: var(--s5) var(--s5) var(--s6); }
.line-stops { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); position: relative; gap: var(--s4); }
.rail {
  position: absolute; left: 5px; right: 5px; bottom: -22px; height: 2px;
  background: linear-gradient(90deg, var(--kesar), var(--leaf));
  opacity: .5; transform-origin: left center; transform: scaleX(0);
  transition: transform .8s var(--ease);
}
.rail.drawn { transform: scaleX(1); }
.stop { position: relative; padding-bottom: var(--s5); min-width: 0; }
.stop .v { font-size: var(--t-2xl); font-weight: 600; line-height: 1; display: inline-block; }
.stop-2 .v { color: var(--kesar); }
.stop .l { font-size: var(--t-xs); color: var(--text-2); margin-top: var(--s2); }
.stop .tag { font-family: var(--font-ui); font-size: var(--t-xs); font-weight: 600; color: var(--reject); margin-left: var(--s2); letter-spacing: 0; white-space: nowrap; }
.stop .tag:empty { display: none; }
.stop::after {
  content: ""; position: absolute; left: 0; bottom: -26px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--kesar); box-shadow: 0 0 0 4px var(--paper);
}
.stop-2::after { background: var(--leaf); }
.stop-3::after { background: var(--teal); }
.stop-4::after { background: var(--plum); }

/* ---------------------------------------------------------------- the three stations, one panel */

/* columns in golden proportion: 1 : φ : 1 */
.combo { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.618fr) minmax(0, 1fr); align-items: stretch; }
.seg { padding: var(--s5); display: flex; flex-direction: column; gap: var(--s4); border-right: 1px solid var(--line-soft); min-width: 0; }
.combo .seg:last-child { border-right: none; }

.icon-chip {
  width: 34px; height: 34px; border-radius: var(--r-sm); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--track); border: 1px solid var(--line-soft);
}
.icon-chip svg { width: 18px; height: 18px; fill: none; }
.icon-chip.kesar { background: var(--kesar); border-color: transparent; }
.seg-head-left { display: flex; align-items: center; gap: var(--s3); min-width: 0; }
.seg-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3); }
.seg-title { font-family: var(--font-display); font-weight: 600; font-size: var(--t-md); letter-spacing: -0.01em; }
.seg-sub { font-size: var(--t-xs); color: var(--text-3); margin-top: 2px; display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.badge { font-size: var(--t-xs); color: var(--text-2); display: inline-flex; align-items: center; gap: var(--s2); white-space: nowrap; }

/* donut — outer 152, label well 152/φ ≈ 94 */
.donut-wrap { display: flex; align-items: center; gap: var(--s5); flex: 1; }
.donut { position: relative; width: 152px; height: 152px; flex-shrink: 0; }
.donut svg { transform: rotate(-90deg); display: block; width: 100%; height: 100%; }
.donut .ring-ok { transition: stroke-dashoffset .9s var(--ease); }
.donut-label {
  position: absolute; top: 29px; left: 29px; width: 94px; height: 94px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
}
.donut-label .n { font-size: var(--t-xl); font-weight: 600; line-height: 1; }
.donut-label .l { font-size: var(--t-xs); color: var(--text-2); margin-top: var(--s1); }
.legend { display: flex; flex-direction: column; gap: var(--s4); min-width: 0; }
.leg { display: flex; align-items: center; gap: var(--s3); }
.leg-sw { width: 11px; height: 11px; border-radius: 3px; flex-shrink: 0; }
.leg .n { font-size: var(--t-lg); font-weight: 600; line-height: 1; }
.leg .l { font-size: var(--t-xs); color: var(--text-2); display: block; }
.seg-foot {
  font-size: var(--t-xs); color: var(--text-3);
  border-top: 1px solid var(--line-soft); padding-top: var(--s3); margin-top: auto;
  display: flex; justify-content: space-between; gap: var(--s3); flex-wrap: wrap;
}
.scan-activity { display: flex; flex-direction: column; gap: var(--s3); }
.scan-activity-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }
.scan-activity-data { font-size: var(--t-xs); color: var(--text-2); }
.scan-activity-data summary { cursor: pointer; padding: var(--s2) 0; }

/* toggle */
.toggle { display: flex; background: var(--track); border-radius: var(--r-sm); padding: 3px; gap: 3px; flex-shrink: 0; }
.toggle button {
  border: none; background: transparent; color: var(--text-2); cursor: pointer;
  font-family: inherit; font-size: var(--t-xs); font-weight: 500;
  padding: 5px 12px; border-radius: 6px; white-space: nowrap;
  transition: background .18s ease, color .18s ease;
}
.toggle button:hover { color: var(--text); }
.toggle button[aria-pressed="true"] { background: var(--kesar); color: var(--on-kesar); font-weight: 600; }

/* grade bars */
.bars { display: flex; align-items: flex-end; gap: var(--s4); height: 152px; position: relative; margin: auto 0; }
.gridline { position: absolute; left: 0; right: 0; height: 1px; background: var(--line-soft); }
.bar-col {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  height: 100%; gap: var(--s2); z-index: 1; min-width: 0; border-radius: var(--r-sm); outline: none;
}
.bar-val { font-size: var(--t-md); font-weight: 600; line-height: 1; }
.bar-shell { width: 100%; max-width: 44px; height: 100%; display: flex; align-items: flex-end; border-radius: var(--r-sm); background: var(--track); overflow: hidden; }
.bar-fill { width: 100%; height: 0%; border-radius: var(--r-sm) var(--r-sm) 0 0; transition: height .55s var(--ease), filter .2s ease; }
.bar-col:hover .bar-fill, .bar-col:focus-visible .bar-fill { filter: brightness(1.1); }
.bar-name { font-size: var(--t-xs); color: var(--text-2); text-align: center; line-height: 1.3; }

/* exit lanes */
.lanes { display: flex; flex-direction: column; gap: var(--s4); justify-content: center; flex: 1; }
.lane { display: flex; align-items: center; gap: var(--s3); border-radius: var(--r-sm); outline: none; }
.lane .name { font-size: var(--t-xs); color: var(--text-2); width: 100px; flex-shrink: 0; }
.lane-track { flex: 1; height: 10px; border-radius: 5px; background: var(--track); overflow: hidden; }
.lane-fill { height: 100%; width: 0%; border-radius: 5px; transition: width .55s var(--ease), filter .2s ease; }
.lane:hover .lane-fill { filter: brightness(1.1); }
.lane .n { font-size: var(--t-md); font-weight: 600; min-width: 34px; text-align: right; flex-shrink: 0; }

/* ---------------------------------------------------------------- KPI strip */

.strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.strip .cell { padding: var(--s4) var(--s5); border-right: 1px solid var(--line-soft); min-width: 0; }
.strip .cell:last-child { border-right: none; }
.strip .v { font-size: var(--t-xl); font-weight: 600; line-height: 1; }
.strip .v.reject { color: var(--reject); }
.strip .l { font-size: var(--t-xs); color: var(--text-3); margin-top: var(--s2); }

/* ---------------------------------------------------------------- details */

details.panel { padding: 0 var(--s5); }
summary {
  cursor: pointer; list-style: none; padding: var(--s4) 0; user-select: none;
  font-size: var(--t-sm); color: var(--text-2); display: flex; align-items: center; gap: var(--s2);
}
summary::-webkit-details-marker { display: none; }
summary::before { content: "›"; display: inline-block; color: var(--text-3); transition: transform .2s ease; }
summary svg { width: 15px; height: 15px; stroke: var(--text-2); fill: none; flex-shrink: 0; }
summary:hover { color: var(--text); }
details[open] summary::before { transform: rotate(90deg); }
.detail-grid {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s4);
  border-top: 1px solid var(--line-soft); padding: var(--s4) 0 var(--s5);
}
.detail-cell { min-width: 0; }
.detail-cell .v { font-size: var(--t-sm); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detail-cell .v.mono { font-family: var(--font-mono); font-size: var(--t-xs); }
.detail-cell .l { font-size: var(--t-xs); color: var(--text-3); margin-top: 2px; }

/* ---------------------------------------------------------------- analytics (inside the second disclosure) */

.details-body { display: flex; flex-direction: column; gap: var(--s4); border-top: 1px solid var(--line-soft); padding: var(--s4) 0 var(--s5); }
.analytics-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.618fr); gap: var(--s4); }
.card { background: var(--panel-2); border: 1px solid var(--line-soft); border-radius: var(--r-md); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s4) var(--s4) 0; }
.card-title { font-family: var(--font-display); font-weight: 600; font-size: var(--t-md); letter-spacing: -0.01em; }
.card-meta { font-size: var(--t-xs); color: var(--text-3); display: flex; align-items: center; gap: var(--s3); }
.card-body { padding: var(--s3) var(--s4) var(--s4); }

/* latest scan */
.scan-frame {
  position: relative; border-radius: var(--r-sm); overflow: hidden;
  background: #101010; border: 1px solid var(--line);
  aspect-ratio: 16 / 10; cursor: zoom-in; display: grid; place-items: center;
}
/* out of the grid flow: as a grid item a tall scan grew its row past the
   16:10 frame and was cropped instead of letterboxed */
.scan-frame img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; }
.scan-frame .placeholder { color: #8A887F; font-size: var(--t-sm); text-align: center; display: grid; gap: var(--s2); padding: var(--s3); }
.scan-frame .placeholder a { color: #D9D6C9; }
.scan-caption {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 12px 8px;
  background: linear-gradient(transparent, rgba(0, 0, 0, .72));
  color: #E8E6DD; font-size: var(--t-xs); font-variant-numeric: tabular-nums;
  display: flex; justify-content: space-between; gap: var(--s2);
}
.scan-caption span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scan-caption-right { display: flex; align-items: center; gap: var(--s3); flex-shrink: 0; }
.dl-original { color: inherit; opacity: .85; text-decoration: none; white-space: nowrap; }
.dl-original:hover { opacity: 1; text-decoration: underline; }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }
.charts-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4); }
.chart-host { position: relative; height: 240px; }
.chart-host.loading { opacity: .45; transition: opacity .2s ease; }
.chart-host svg { display: block; }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-3); font-size: var(--t-sm); }
.chart-legend { display: flex; align-items: center; gap: var(--s4); flex-wrap: wrap; font-size: var(--t-xs); color: var(--text-2); }
.chart-legend .item { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend .key-line { width: 14px; height: 2px; border-radius: 2px; }
.chart-legend .key-rect { width: 10px; height: 10px; border-radius: 3px; }
.mini-btn {
  width: 28px; height: 28px; border-radius: 50%; padding: 0;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text-2);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  transition: background .2s ease, color .2s ease;
}
.mini-btn:hover { background: var(--track); color: var(--text); }
.mini-btn[aria-pressed="true"] { background: var(--kesar); border-color: transparent; color: var(--on-kesar); }
.mini-btn svg { width: 13px; height: 13px; stroke: currentColor; fill: none; }

/* chart table-view twin */
.chart-table { height: 240px; overflow: auto; border: 1px solid var(--line-soft); border-radius: var(--r-sm); }
.chart-table table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.chart-table th, .chart-table td { padding: 6px 10px; text-align: right; font-variant-numeric: tabular-nums; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
.chart-table th:first-child, .chart-table td:first-child { text-align: left; }
.chart-table th { position: sticky; top: 0; background: var(--panel-solid); color: var(--text-3); font-weight: 600; z-index: 1; }

/* tooltip (singleton, fixed-position) */
.viz-tooltip {
  position: fixed; z-index: 90; pointer-events: none;
  background: color-mix(in srgb, var(--panel-solid) 94%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .35);
  padding: 8px 11px; font-size: var(--t-sm); min-width: 130px;
  opacity: 0; transition: opacity .1s ease;
}
.viz-tooltip.show { opacity: 1; }
.viz-tooltip .tt-title { color: var(--text-3); font-size: var(--t-xs); margin-bottom: 5px; font-variant-numeric: tabular-nums; }
.viz-tooltip .tt-row { display: flex; align-items: center; gap: 7px; padding: 1.5px 0; }
.viz-tooltip .tt-key { width: 12px; height: 2px; border-radius: 2px; flex-shrink: 0; }
.viz-tooltip .tt-name { color: var(--text-2); flex: 1; padding-right: 10px; }
.viz-tooltip .tt-val { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }

/* events */
.events-card .card-body { padding-top: var(--s3); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line-soft); background: transparent; border-radius: 999px;
  height: 24px; padding: 0 11px; font-size: var(--t-xs); font-weight: 500; color: var(--text-2); cursor: pointer;
  transition: background .18s ease, color .18s ease;
}
.chip:hover { color: var(--text); background: var(--track); }
.chip[aria-pressed="true"] { background: var(--kesar); border-color: transparent; color: var(--on-kesar); font-weight: 600; }
.events-table-wrap { max-height: 360px; overflow: auto; border: 1px solid var(--line-soft); border-radius: var(--r-sm); }
.events-table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.events-table th, .events-table td { text-align: left; padding: 7px 12px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
.events-table th { position: sticky; top: 0; z-index: 1; background: var(--panel-solid); font-size: var(--t-xs); color: var(--text-3); font-weight: 600; }
.events-table td.time { font-variant-numeric: tabular-nums; color: var(--text-2); width: 86px; }
.events-table td.summary { max-width: 520px; overflow: hidden; text-overflow: ellipsis; color: var(--text-2); font-family: var(--font-mono); font-size: var(--t-xs); }
.events-table tr.flash td { animation: rowflash 1.2s ease-out; }
@keyframes rowflash { from { background: color-mix(in srgb, var(--kesar) 16%, transparent); } to { background: transparent; } }
.tag-pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: var(--t-xs); font-weight: 600; border: 1px solid var(--line-soft); color: var(--text-2); background: var(--track); }

/* ---------------------------------------------------------------- gate */

.gate { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: var(--bg-image); padding: var(--s4); }
.gate-card { width: min(420px, 100%); padding: var(--s6) var(--s5); display: flex; flex-direction: column; gap: var(--s4); align-items: center; text-align: center; }
.gate-card .icon-chip { width: 52px; height: 52px; border-radius: var(--r-md); }
.gate-card .icon-chip svg { width: 28px; height: 28px; }
.gate-card h1 { font-family: var(--font-display); font-size: var(--t-xl); font-weight: 600; margin: 0; letter-spacing: -0.015em; }
.gate-card p { margin: 0; color: var(--text-3); font-size: var(--t-sm); }
.gate-card input {
  width: 100%; height: 42px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--track); color: var(--text);
  padding: 0 16px; font: inherit; text-align: center;
}
.gate-card .err { color: var(--reject); font-size: var(--t-sm); min-height: 16px; }
.btn-primary {
  width: 100%; height: 42px; border-radius: var(--r-sm); border: none; cursor: pointer;
  background: var(--kesar); color: var(--on-kesar); font-weight: 600; font-size: var(--t-sm);
  transition: filter .2s ease;
}
.btn-primary:hover { filter: brightness(.94); }

/* ---------------------------------------------------------------- lightbox */

.lightbox {
  position: fixed; inset: 0; z-index: 95;
  background: rgba(8, 8, 6, .88);
  display: grid; grid-template-rows: minmax(0, 1fr) auto; place-items: center;
  gap: 18px; padding: 64px 32px 24px; cursor: zoom-out;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.lightbox img { min-width: 0; min-height: 0; max-width: 100%; max-height: 100%; object-fit: contain; border-radius: var(--r-sm); }
.lightbox-error { color: #C9C8C0; font-size: var(--t-md); }
.lightbox .meta {
  width: 100%; min-width: 0;
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 14px;
  text-align: center;
  color: #C9C8C0; font-size: var(--t-sm); font-variant-numeric: tabular-nums;
}
.lightbox .meta span { min-width: 0; overflow-wrap: anywhere; }
.lightbox .meta .dl-original { white-space: normal; overflow-wrap: anywhere; }

.hidden { display: none !important; }

footer { font-size: var(--t-xs); color: var(--text-3); padding: 0 var(--s1); }

/* ---------------------------------------------------------------- responsive */

@media (max-width: 1100px) {
  .seg { border-right: none; }
}
@media (max-width: 980px) {
  .batch-cards, .scan-cards { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .charts-grid, .analytics-top { grid-template-columns: 1fr; }
  .clock { display: none; }
}
@media (max-width: 640px) {
  .lightbox { padding: 64px 16px 16px; }
  .lightbox .meta { flex-direction: column; gap: 8px; }
  .batch-cards { grid-template-columns: 1fr; }
  .batch-tools, .batch-tools input, .batch-tools select { width: 100%; }
  .batch-browser .batch-tools { grid-template-columns: 1fr; }
  .batch-browser, .batch-focus, .scan-gallery { padding: var(--s4); }
  .pager { flex-wrap: wrap; }
  .line { padding-bottom: var(--s5); }
  .line-stops { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s5) var(--s4); }
  .rail { display: none; }
  .stop { padding: 0 0 0 18px; }
  .stop::after { top: 9px; bottom: auto; box-shadow: none; }
  .stop .tag { display: block; margin-left: 0; }
  .stop .tag:empty { display: none; }
  .strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .strip .cell:nth-child(2) { border-right: none; }
  .strip .cell:nth-child(-n+2) { border-bottom: 1px solid var(--line-soft); }
  .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .brand-sub, #stations-status { display: none; }
}
@media (max-width: 420px) {
  .detail-grid { grid-template-columns: 1fr; }
  .donut { width: 120px; height: 120px; }
  .donut-label { top: 23px; left: 23px; width: 74px; height: 74px; }
  .donut-label .n { font-size: var(--t-lg); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .rail { transform: none; }
}

/* ---------------------------------------------------------------- v14 homepage */

body { padding: 21px clamp(14px, 2.4vw, 34px) 34px; background-color: var(--paper); }
.page { max-width: 1360px; gap: 13px; }
header { min-height: 40px; flex-wrap: wrap; }
.brand { gap: 12px; }
.brand > .icon-chip { width: 40px; height: 40px; border-radius: 13px; background: linear-gradient(145deg, #F2BC52, #D58A1E); box-shadow: 0 8px 18px -8px #D58A1E; }
.brand-copy { display: flex; flex-direction: column; }
.brand-name { font-size: 21px; line-height: 1.2; }
.brand-sub { display: block; }
.head-right { gap: 8px; }
.head-right .status { padding: 5px 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--panel); backdrop-filter: blur(16px); font-size: 12.4px; white-space: nowrap; }
.head-btn { width: 36px; height: 36px; background: var(--panel); }
.clock { font-size: 11.5px; }
.production-hero { overflow: hidden; padding: 0; }
.production-banner { min-height: 225px; padding: 18px 21px; display: flex; flex-direction: column; gap: 10px; color: #fff; background: linear-gradient(180deg, rgba(12,12,9,.42), rgba(12,12,9,.80)), url('/assets/production-line.jpg') center 52% / cover #1d1d17; }
.production-banner h1 { margin: 0; font: 600 27px / 1.15 var(--font-display); }
.banner-meta { display: flex; gap: 8px; flex-wrap: wrap; }
.meta-field { padding: 5px 11px; border-radius: 12px; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.24); backdrop-filter: blur(14px); min-width: 0; }
.meta-field > span { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: rgba(255,255,255,.72); }
.meta-field b { display: block; font: 600 13.6px / 1.4 var(--font-display); overflow-wrap: anywhere; }
.production-stops { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 13px; margin-top: auto; }
.production-stop { position: relative; padding: 12px 16px; border-radius: 13px; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.24); backdrop-filter: blur(18px); }
.production-stop:not(:last-child)::after { content: '›'; position: absolute; right: -12px; top: 50%; transform: translateY(-50%); width: 12px; text-align: center; color: rgba(255,255,255,.8); font-size: 18px; }
.production-stop .v { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; font-size: 34px; line-height: 1.15; }
.production-stop:nth-child(2) .v { color: #FFD27A; }
.production-stop .l { font-size: 12.4px; color: rgba(255,255,255,.82); margin-top: 6px; }
.reject-pill { font: 600 11.5px var(--font-ui); color: #fff; padding: 2px 8px; border-radius: 99px; background: rgba(192,67,47,.92); }
.progress-track { height: 4px; margin-top: 9px; border-radius: 3px; background: rgba(255,255,255,.2); overflow: hidden; }
.progress-track i { display: block; height: 100%; background: linear-gradient(90deg,#F6C25E,#fff); border-radius: inherit; transition: width .5s var(--ease); }
.combo { grid-template-columns: minmax(0,1fr) minmax(0,1.618fr) minmax(0,1fr); gap: 13px; padding: 13px; align-items: stretch; }
.seg, .combo .seg:last-child { padding: 8px; gap: 12px; border: 1px solid var(--line-soft); border-radius: 21px; background: var(--panel-2); box-shadow: 0 1px 0 rgba(255,255,255,.15) inset; }
.station-photo { position: relative; height: 125px; flex-shrink: 0; border-radius: 13px; overflow: hidden; background-size: cover; background-position: center; }
.xray-photo { background-image: url('/assets/xray-machine.jpg'); }
.vision-photo { background-image: url('/assets/vision-grader.jpg'); }
.station-photo::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg,rgba(0,0,0,.05) 50%,rgba(0,0,0,.6)); }
.photo-tag { position: absolute; left: 12px; bottom: 10px; z-index: 1; color: #fff; font-size: 13.6px; font-weight: 600; }
.station-photo .badge { position: absolute; right: 10px; top: 10px; z-index: 1; padding: 3px 10px; border-radius: 99px; color: #fff; background: rgba(0,0,0,.55); backdrop-filter: blur(10px); font-size: 11.5px; }
.seg-head { padding: 0 8px; }
.seg-head-left { gap: 0; }
.seg-head-left > .icon-chip { display: none; }
.seg-title { font-size: 17px; line-height: 1.25; }
.seg-sub { font-size: 12.4px; }
.seg-grade .seg-head { flex-wrap: wrap; gap: 8px; }
.seg-exits .seg-head { padding-top: 8px; flex-wrap: wrap; gap: 6px; }
.seg-exits .seg-head .badge { font-size: 11.5px; }
.toggle { margin-left: auto; }
.toggle button { padding: 4px 9px; }
.donut-wrap { padding: 0 8px; gap: 14px; flex-wrap: wrap; flex: 0; }
.donut { width: 132px; height: 132px; }
.donut-label { inset: 0; width: auto; height: auto; }
.donut-label .n { font-size: 30px; }
.donut .ring-ok { filter: drop-shadow(0 0 7px rgba(232,169,60,.4)); }
.legend { gap: 12px; }
.leg .n { font-size: 21px; }
.seg-foot { margin: auto 8px 6px; padding-top: 10px; font-size: 12.4px; }
.scan-activity { padding: 0 8px; gap: 6px; }
.scan-activity-head .seg-title { font-size: 14px; }
.scan-activity-summary, #scan-activity-summary { font-size: 11.5px; }
.scan-activity .chart-host { height: 160px; }
.scan-activity-data { font-size: 11.5px; }
.scan-activity-data summary { padding: 4px 0; }
.bars { height: 154px; gap: 13px; margin: 4px 8px 0; }
.bar-val { font-size: 18px; }
.bar-shell { max-width: 55px; border-radius: 13px; }
.bar-fill { border-radius: 13px 13px 0 0; background-image: linear-gradient(90deg,rgba(255,255,255,.20),transparent 55%); }
.bar-name { max-width: 100%; overflow-wrap: anywhere; font-size: 12.4px; color: var(--text-2); }
.grade-legend { display: flex; gap: 12px; flex-wrap: wrap; padding: 0 8px; font-size: 11.5px; color: var(--text-2); }
.grade-legend span { display: inline-flex; gap: 6px; align-items: center; }
.grade-legend i { width: 10px; height: 10px; border-radius: 4px; }
.classification-note { padding: 0 8px 6px; margin-top: auto; font-size: 11.5px; line-height: 1.4; }
.lanes { gap: 9px; padding: 0 8px 8px; justify-content: flex-start; }
.lane { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px 10px; padding: 10px 12px; border-radius: 13px; border: 1px solid var(--line-soft); border-left: 3px solid var(--lane-color); background: linear-gradient(90deg,color-mix(in srgb,var(--lane-color) 12%,transparent),transparent 65%),var(--panel); }
.lane .name { width: auto; min-width: 0; font-size: 13.6px; line-height: 1.25; color: var(--text); font-weight: 600; }
.lane-caption { display: block; font-size: 11.5px; font-weight: 400; color: var(--text-3); margin-top: 2px; }
.lane .n { font-size: 24px; min-width: 0; text-align: right; }
.lane-track { grid-column: 1 / -1; width: 100%; height: 6px; }
.run-footer { display: flex; align-items: center; gap: 8px 18px; flex-wrap: wrap; padding: 0 8px; font-size: 11.5px; color: var(--text-3); }
.run-footer b { color: var(--text); font-weight: 500; }
.run-footer .mono { font-family: var(--font-mono); font-size: 10.5px; overflow-wrap: anywhere; }
.run-note { margin-left: auto; }
.report-button { border: 0; padding: 8px 16px; border-radius: 99px; color: #241802; background: linear-gradient(145deg,#F2BC52,#D58A1E); box-shadow: 0 8px 18px -10px #D58A1E; cursor: pointer; font: 600 13px var(--font-ui); white-space: nowrap; }
.batch-report { padding: 0 21px; }
.batch-report:not([open]) { display: none; }
.batch-report > summary { display: flex; align-items: center; gap: 12px; padding: 16px 0; }
.batch-report > summary::before { content: '›'; font-size: 20px; transform: none; }
.batch-report[open] > summary::before { transform: rotate(90deg); }
.batch-report > summary .badge { margin-left: auto; }
.batch-report .batch-browser, .batch-report .batch-focus { border: none; border-radius: 0; box-shadow: none; background: none; backdrop-filter: none; padding: 0 0 18px; }
.batch-browser h2 { font-size: 17px; margin: 0; font-family: var(--font-display); }
.batch-table-wrap { overflow: auto; max-height: 460px; border: 1px solid var(--line-soft); border-radius: 13px; margin-top: 13px; }
.batch-table { width: 100%; min-width: 850px; border-collapse: collapse; font-size: 12.4px; }
.batch-table th { position: sticky; top: 0; padding: 11px 14px; background: var(--panel-solid); color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; font-size: 10.5px; text-align: left; }
.batch-table td { padding: 11px 14px; border-top: 1px solid var(--line-soft); font-variant-numeric: tabular-nums; }
.batch-table .selected-batch td { background: color-mix(in srgb,var(--grade-small) 12%,transparent); }
.batch-table .selected-batch td:first-child { box-shadow: inset 3px 0 var(--grade-small); }
.batch-table-name { min-width: 185px; overflow-wrap: anywhere; }
.batch-table-name strong { display: block; font-weight: 500; }
.batch-table-kind { display: block; font-size: 11px; color: var(--text-3); }
.batch-view { min-height: 32px; white-space: nowrap; font-size: 11.5px; }
.station-diagnostics { padding: 0 21px; }
.station-diagnostics > summary { padding: 11px 0; font-size: 12.4px; }
.station-diagnostics .alert-strip { padding-bottom: 13px; }

@media (max-width: 1020px) and (min-width: 761px) {
  .head-right .clock { display: none; }
  .production-banner { padding: 16px; }
  .combo { gap: 9px; padding: 9px; }
  .seg { padding: 6px; }
  .seg-head, .scan-activity, .classification-note, .grade-legend, .lanes { padding-left: 4px; padding-right: 4px; }
  .donut { width: 105px; height: 105px; }
  .donut-label .n { font-size: 25px; }
  .lane { padding: 8px; }
  .lane .n { font-size: 20px; }
}
@media (max-width: 760px) {
  header { gap: 12px; }
  .brand-sub { display: block; }
  .head-right { width: 100%; }
  .head-right .status { padding: 4px 9px; font-size: 11.5px; }
  .head-btns { margin-left: auto; }
  .production-banner { padding: 18px; }
  .production-stops { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; margin-top: 6px; }
  .production-stop:nth-child(2)::after { display: none; }
  .production-stop .v { font-size: 28px; }
  .combo { grid-template-columns: 1fr; }
  .station-photo { height: 180px; }
  .bars { height: 190px; }
  .scan-activity .chart-host { height: 210px; }
  .donut { width: 132px; height: 132px; }
  .donut-label { inset: 0; width: auto; height: auto; }
  .run-note { margin-left: 0; }
  .report-button { margin-left: auto; }
  .banner-meta { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); }
  .meta-field:first-child { grid-column: 1 / -1; }
}
