/* =============================================================
   AutoProcess — Shared Components
   Drop in at: frontend/static/css/components.css
   Linked AFTER tokens.css.
   ============================================================= */

/* ── Layout primitives ──────────────────────────── */
.container       { max-width: 1280px; margin: 0 auto; padding: 0 var(--sp-4); }
.container--md   { max-width: 960px; }
.container--sm   { max-width: 700px; }

.stack > * + *   { margin-top: var(--sp-4); }
.stack-sm > * + *{ margin-top: var(--sp-2); }
.row             { display: flex; gap: var(--sp-3); align-items: center; flex-wrap: wrap; }
.row--end        { justify-content: flex-end; }
.row--between    { justify-content: space-between; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap-grid); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gap-grid); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--gap-grid); }
@media (max-width: 800px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ── Topbar ─────────────────────────────────────── */
.topbar {
  background: var(--brand-primary);
  color: #fff;
  min-height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: 0 var(--sp-4);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-1);
}
.topbar__brand { display: flex; align-items: center; gap: var(--sp-3); }
.topbar__logo {
  /* refined wordmark: clean spaced caps  */
  font-weight: 800;
  font-size: var(--fs-lg);
  letter-spacing: .22em;
  color: #fff;
  padding-right: 6px;
}
.topbar__app-name { font-weight: 600; font-size: var(--fs-md); }
.topbar__part {
  background: rgba(255,255,255,.1);
  border-radius: 4px;
  padding: 2px 10px;
  font-size: var(--fs-xs);
}
.topbar__actions { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; min-width: 0; }

/* The owner-only "View as…" switcher is a <select>, so it self-sizes to its longest option.
   The 2026-07 TST→IMQ rename made that option much longer ("IMQ — Incoming Material
   Quality" vs "TST — Tester"), which pushed the topbar past a phone viewport and gave the
   role pages a real horizontal page scroll. Clamp it — the options stay fully readable in
   the opened dropdown, which is not constrained by the control's width. */
#role-switcher { min-width: 0; max-width: 210px; }
@media (max-width: 600px) { #role-switcher { max-width: 130px; } }
.topbar__user { font-size: var(--fs-sm); opacity: .85; }
.topbar__role-badge {
  background: var(--brand-accent);
  border-radius: 3px;
  padding: 2px 10px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .5px;
}
.topbar__role-badge--opr { background: #2E7D32; }
.topbar__role-badge--imq { background: var(--brand-accent); }
.topbar__role-badge--qc  { background: #6A1B9A; }   /* violet — matches the QC/violet badge family */
.topbar__role-badge--tec,
.topbar__role-badge--eng { background: var(--brand-accent); }

/* topbar buttons (icon + label) */
.topbar__btn {
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.2);
  color: #fff;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: var(--fs-sm);
  font-family: inherit;
  cursor: pointer;
  height: 40px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background var(--dur-1) var(--ease-out);
}
.topbar__btn:hover { background: rgba(255,255,255,.2); }
/* the AutoCal / AutoDT links (an <a>, so no underline) — templates/_other_apps.html */
.topbar__app-link { text-decoration: none; }
.topbar__app-link:hover, .topbar__app-link:focus-visible { color: #fff; text-decoration: none; }
.topbar__btn--icon { padding: 7px 12px; font-size: 19px; line-height: 1; position: relative; }

/* role switcher select inside topbar */
.topbar select {
  background: var(--brand-primary-soft);
  border: 1px solid rgba(255,255,255,.4);
  color: #fff;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: var(--fs-md);
  font-family: inherit;
  cursor: pointer;
  height: 40px;
  color-scheme: light;
}
.topbar select option { color: var(--ink); background: #fff; }

/* notification dot */
.notif-dot {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--bad);
  color: #fff;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: 13px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  display: none;
}
.notif-dot[data-count]:not([data-count="0"]) { display: block; }

/* notification panel */
.notif-panel {
  display: none;
  position: absolute;
  top: 48px;
  right: 0;
  width: 360px;
  max-height: 420px;
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-pop);
  z-index: 999;
  overflow: hidden;
}
.notif-panel__head {
  background: var(--brand-primary);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.notif-panel__title { font-weight: 700; font-size: var(--fs-md); }
.notif-panel__list { overflow-y: auto; max-height: 360px; padding: 6px 0; }
.notif-item {
  padding: 10px 16px;
  border-left: 3px solid transparent;
  font-size: var(--fs-sm);
  color: var(--ink);
}
.notif-item--unread { border-left-color: var(--brand-accent); background: var(--brand-accent-tint); }
.notif-item__time { font-size: var(--fs-xs); color: var(--muted); margin-top: 2px; }

/* ── Nav tabs ───────────────────────────────────── */
.navtabs {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 0 var(--sp-4);
  display: flex;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  /* Pinned directly under the sticky topbar, so the tab ribbon stays reachable at any
     scroll depth. The offset is the topbar's MEASURED height (kept in --topbar-actual-h
     by a ResizeObserver) because the topbar wraps to two rows on narrow viewports —
     the token is only the one-row fallback. z-index sits below the topbar's 100 so the
     bar always wins an overlap, and above page content. */
  position: sticky;
  top: var(--topbar-actual-h, var(--topbar-h));
  z-index: 90;
}
.navtab {
  padding: 14px 18px;
  border: none;
  cursor: pointer;
  background: transparent;
  font-size: var(--fs-md);
  font-weight: 500;
  color: var(--muted);
  border-bottom: 3px solid transparent;
  font-family: inherit;
  transition: color var(--dur-1) var(--ease-out), border-color var(--dur-1) var(--ease-out);
  min-height: 48px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.navtab:hover { color: var(--ink); }
.navtab[aria-current="page"],
.navtab.active {
  color: var(--brand-primary);
  font-weight: 700;
  border-bottom-color: var(--brand-primary);
}
[data-theme="dark"] .navtab[aria-current="page"],
[data-theme="dark"] .navtab.active {
  color: var(--brand-accent);
  border-bottom-color: var(--brand-accent);
}

/* ── Page intro ─────────────────────────────────── */
.page-intro { padding: var(--sp-5) 0 var(--sp-3); }
.page-intro h1 {
  color: var(--brand-primary);
  font-size: var(--fs-2xl);
  font-weight: 700;
  margin: 0;
  letter-spacing: -.01em;
}
.page-intro p {
  color: var(--muted);
  font-size: var(--fs-md);
  margin: 4px 0 0;
}
[data-theme="dark"] .page-intro h1 { color: var(--brand-accent); }

/* ── Panel (the main card) ──────────────────────── */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.panel__head {
  padding: 14px 18px;
  font-weight: 700;
  color: var(--brand-primary);
  font-size: var(--fs-md);
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
}
[data-theme="dark"] .panel__head { color: var(--ink); }
.panel__head h2,
.panel__head .panel__title { font-size: var(--fs-md); font-weight: 700; margin: 0; }
.panel__body { padding: var(--pad-card); flex: 1; min-height: 0; }

/* ── Form ───────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label,
label.field__label,
label {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--muted);
}
.input, .select, .textarea,
input[type=text], input[type=number], input[type=email], input[type=password], input[type=search],
select, textarea {
  width: 100%;
  padding: var(--pad-input) 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-input);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--fs-lg);
  font-family: inherit;
  outline: none;
  min-height: 44px;
  transition: border-color var(--dur-1) var(--ease-out), box-shadow var(--dur-1) var(--ease-out);
}
.input:focus, .select:focus, .textarea:focus,
input:focus, select:focus, textarea:focus { border-color: var(--brand-accent); }
textarea { min-height: 80px; resize: vertical; }

/* ── Buttons ────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border: none;
  border-radius: var(--radius-input);
  font-family: inherit;
  font-size: var(--fs-md);
  font-weight: 700;
  cursor: pointer;
  min-height: 44px;
  transition: background var(--dur-1) var(--ease-out), transform var(--dur-1) var(--ease-out);
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn--primary { background: var(--brand-primary); color: #fff; }
.btn--primary:hover:not(:disabled) { background: var(--brand-accent); }
[data-theme="dark"] .btn--primary { background: var(--brand-accent); color: #fff; }

.btn--secondary {
  background: var(--surface);
  color: var(--brand-primary);
  border: 1.5px solid var(--line);
}
.btn--secondary:hover:not(:disabled) { border-color: var(--brand-accent); color: var(--brand-accent); }
[data-theme="dark"] .btn--secondary { background: var(--surface-tint); color: var(--ink); }

.btn--ghost   { background: transparent; color: var(--muted); }
.btn--ghost:hover { color: var(--brand-primary); }
.btn--success { background: var(--ok); color: #fff; }
.btn--danger  { background: var(--bad); color: #fff; }

.btn--lg { padding: 16px 22px; font-size: var(--fs-lg); min-height: 54px; }
.btn--xl { padding: 20px 28px; font-size: var(--fs-xl); min-height: 64px; }
.btn--block { width: 100%; }

/* ── Status verdict (the answer to "Is the process good?") ── */
.verdict {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--sp-4);
  padding: 18px 22px;
  border-radius: var(--radius-card);
  border: 1.5px solid;
  position: relative;
  overflow: hidden;
}
.verdict__lamp {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  position: relative;
}
.verdict__lamp::before {
  content: '';
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 6px color-mix(in srgb, currentColor 25%, transparent);
}
.verdict__copy { display: flex; flex-direction: column; gap: 2px; }
.verdict__headline {
  font-size: var(--fs-2xl);
  font-weight: 800;
  letter-spacing: -.01em;
  line-height: var(--lh-tight);
}
.verdict__detail { font-size: var(--fs-md); color: var(--muted); }
.verdict__cta {
  background: var(--brand-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-input);
  padding: 12px 20px;
  font-weight: 700;
  font-size: var(--fs-md);
  cursor: pointer;
  white-space: nowrap;
  min-height: 44px;
}
.verdict__cta:hover { background: var(--brand-accent); }

.verdict[data-status="green"]  { background: var(--ok-bg);   border-color: var(--ok-line);   color: var(--ok); }
.verdict[data-status="yellow"] { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
.verdict[data-status="red"]    { background: var(--bad-bg);  border-color: var(--bad-line);  color: var(--bad); }

.verdict[data-status="green"]  .verdict__cta { display: none; }

/* NO VERDICT is not a colour of the traffic light (review U4). An error, an expired session, a
   missing prediction or an unreachable model shows this: grey, dashed, the lamp unlit — it
   cannot be read as GREEN, YELLOW or RED. "unknown" is the operator hero's word for the same. */
.verdict[data-status="none"],
.verdict[data-status="unknown"] { background: var(--surface-alt); border: 1.5px dashed var(--muted-2); color: var(--muted); }
.verdict[data-status="none"] .verdict__lamp::before,
.verdict[data-status="unknown"] .verdict__lamp::before {
  background: transparent; border: 3px dashed currentColor; box-shadow: none;
}
.verdict[data-status="none"] .verdict__cta,
.verdict[data-status="unknown"] .verdict__cta { display: none; }

/* ── KPI tile ───────────────────────────────────── */
.kpi {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border-radius: var(--radius-input);
  border: 1px solid var(--line);
  background: var(--surface);
  border-left: 4px solid var(--line);
}
.kpi__label {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.kpi__value {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-2xl);
  font-weight: 700;
  color: var(--ink);
  line-height: var(--lh-tight);
}
.kpi__delta { font-size: var(--fs-xs); color: var(--muted); }

.kpi[data-status="green"]  { background: var(--ok-bg);   border-left-color: var(--ok); }
.kpi[data-status="green"]  .kpi__value { color: var(--ok); }
.kpi[data-status="yellow"] { background: var(--warn-bg); border-left-color: var(--warn); }
.kpi[data-status="yellow"] .kpi__value { color: var(--warn); }
.kpi[data-status="red"]    { background: var(--bad-bg);  border-left-color: var(--bad); }
.kpi[data-status="red"]    .kpi__value { color: var(--bad); }
.kpi[data-status="none"]   { background: var(--surface-alt); border-left: 4px dashed var(--muted-2); }
.kpi[data-status="none"]   .kpi__value { color: var(--muted); }

/* ── Industrial slider ──────────────────────────── */
.islider { display: flex; flex-direction: column; gap: 4px; }
.islider__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-2);
}
.islider__head label { font-size: var(--fs-md); font-weight: 600; color: var(--muted); }
.islider__head output {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: var(--fs-xl);
  color: var(--brand-primary);
}
[data-theme="dark"] .islider__head output { color: var(--brand-accent); }
.islider__track { display: flex; align-items: center; gap: 6px; }
.islider__step {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--brand-primary);
  font-size: 24px;
  font-weight: 700;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-family: inherit;
  line-height: 1;
  padding: 0;
  transition: background var(--dur-1), border-color var(--dur-1);
}
.islider__step:hover { background: var(--brand-accent-tint); border-color: var(--brand-accent); }
.islider__step:active { background: var(--brand-accent); color: #fff; border-color: var(--brand-accent); }

.islider input[type=range] {
  flex: 1;
  height: 28px;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  cursor: pointer;
}
.islider input[type=range]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, var(--brand-accent) var(--filled, 0%), var(--line-soft) var(--filled, 0%));
}
.islider input[type=range]::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: var(--line-soft);
}
.islider input[type=range]::-moz-range-progress {
  height: 6px;
  border-radius: 3px;
  background: var(--brand-accent);
}
.islider input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--brand-accent);
  border: 3px solid #fff;
  box-shadow: var(--shadow-2);
  margin-top: -8px;
  cursor: pointer;
}
.islider input[type=range]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--brand-accent);
  border: 3px solid #fff;
  box-shadow: var(--shadow-2);
  cursor: pointer;
}
.islider__range {
  display: flex;
  justify-content: space-between;
  font-size: var(--fs-xs);
  color: var(--muted-2);
  margin-top: 2px;
  font-family: var(--font-num);
}

/* ── SHAP row ───────────────────────────────────── */
.shap {
  display: grid;
  grid-template-columns: 100px 1fr;
  align-items: center;
  gap: var(--sp-3);
  padding: 8px 0;
}
.shap__name {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--ink);
}
.shap__bars { display: flex; flex-direction: column; gap: 4px; }
.shap__bar-row {
  display: grid;
  grid-template-columns: 30px 1fr 60px;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-xs);
}
.shap__legend { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.shap__track {
  position: relative;
  height: 10px;
  background: var(--line-soft);
  border-radius: 5px;
  overflow: hidden;
}
.shap__track::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--muted-2);
}
.shap__fill {
  position: absolute;
  top: 0;
  height: 100%;
  border-radius: 5px;
  transition: width var(--dur-3) var(--ease-out);
}
.shap__fill--pos { left: 50%; background: var(--bad); }
.shap__fill--neg { right: 50%; background: var(--ok); }
.shap__value {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-xs);
  text-align: right;
  color: var(--ink);
}

/* ── Banners / alerts ───────────────────────────── */
.banner {
  display: flex;
  gap: var(--sp-3);
  align-items: flex-start;
  padding: 12px 16px;
  border-radius: var(--radius-input);
  border: 1px solid;
  font-size: var(--fs-sm);
}
.banner--info { background: var(--info-bg); border-color: var(--info-line); color: var(--info); }
.banner--warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
.banner--ok   { background: var(--ok-bg);   border-color: var(--ok-line);   color: var(--ok); }
.banner--bad  { background: var(--bad-bg);  border-color: var(--bad-line);  color: var(--bad); }
/* no verdict / not available: grey and dashed, never a status colour (review U4) */
.banner--none { background: var(--surface-alt); border: 1px dashed var(--muted-2); color: var(--ink-2); }
.banner strong { font-weight: 700; }

/* ── Chip ───────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: var(--radius-chip);
  font-size: var(--fs-xs);
  font-weight: 600;
  background: var(--surface-alt);
  color: var(--muted);
  border: 1px solid var(--line);
}
.chip--ok    { background: var(--ok-bg);   color: var(--ok);   border-color: var(--ok-line); }
.chip--warn  { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.chip--bad   { background: var(--bad-bg);  color: var(--bad);  border-color: var(--bad-line); }
.chip--blue  { background: var(--brand-accent-tint); color: var(--brand-accent); border-color: var(--info-line); }
.chip__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ── Locked / disabled note ─────────────────────── */
.lock-note {
  background: var(--surface-tint);
  border: 1px dashed var(--line);
  border-radius: var(--radius-input);
  padding: 12px 16px;
  font-size: var(--fs-xs);
  color: var(--muted);
}
.lock-note__title {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 6px;
  letter-spacing: .03em;
  text-transform: uppercase;
}
.lock-tag {
  display: inline-block;
  background: var(--surface-alt);
  color: var(--muted);
  padding: 4px 10px;
  border-radius: var(--radius-chip);
  font-size: 13px;
  font-weight: 600;
  margin: 2px;
  border: 1px solid var(--line);
}

/* ── Modal ──────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 999;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay[data-open="true"],
.modal-overlay.is-open { display: flex; }
.modal-box {
  background: var(--surface);
  color: var(--ink);
  border-radius: 16px;
  width: min(420px, 100%);
  max-height: 92vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-pop);
}
.modal-box--md { width: min(620px, 100%); }
.modal-head {
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  border-bottom: 1px solid var(--line-soft);
}
.modal-title {
  font-weight: 700;
  font-size: var(--fs-lg);
  color: var(--brand-primary);
}
[data-theme="dark"] .modal-title { color: var(--brand-accent); }
.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 26px;
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
}
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 16px 20px;
  display: flex;
  gap: var(--sp-2);
  justify-content: flex-end;
  border-top: 1px solid var(--line-soft);
}

/* ── Recent rows / list ─────────────────────────── */
.list { display: flex; flex-direction: column; }
.list__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: var(--fs-sm);
  flex-wrap: wrap;
  gap: 6px;
}
.list__row:last-child { border-bottom: none; }
.list__time { color: var(--muted); font-family: var(--font-num); font-size: var(--fs-xs); }
.list__id { font-weight: 600; color: var(--ink); }

/* ── Empty state ────────────────────────────────── */
.empty {
  text-align: center;
  padding: 28px 16px;
  color: var(--muted);
}
.empty__glyph { font-size: 34px; opacity: .55; margin-bottom: 6px; }
.empty__msg { font-size: var(--fs-sm); }

/* ── Toast ──────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ok);
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--radius-input);
  font-size: var(--fs-md);
  font-weight: 600;
  z-index: 9999;
  box-shadow: var(--shadow-pop);
  animation: toastIn var(--dur-2) var(--ease-out);
}
.toast--bad { background: var(--bad); }
.toast--warn { background: var(--warn); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Spinner ────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2.5px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  vertical-align: middle;
}
.spinner--dark { border-color: rgba(20,48,59,.2); border-top-color: var(--brand-primary); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Theme toggle (placed in topbar) ─────────────── */
.theme-toggle {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.2);
  color: #fff;
  cursor: pointer;
  font-size: 19px;
  display: grid;
  place-items: center;
}
.theme-toggle:hover { background: rgba(255,255,255,.2); }

/* ── Utility ────────────────────────────────────── */
.hidden { display: none !important; }
.muted { color: var(--muted); }
.text-num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.flex-1 { flex: 1; }

/* ── Print (PDF report friendliness) ─────────────── */
@media print {
  .topbar, .navtabs, .modal-overlay { display: none !important; }
  body { background: #fff; }
  .panel { box-shadow: none; border-color: #ccc; }
}

/* ── Staging environment banner ─────────────────────────────────────────────────
   Rendered only when APP_ENV=staging (see main.py's Jinja global). Deliberately
   loud and deliberately NOT dismissible: the failure it prevents is an inspector
   entering real coil data into a throwaway database because two browser tabs look
   identical. Uses the amber status token so it reads as "caution", not "error".   */
.env-banner {
  position: sticky;
  top: 0;
  z-index: 900;
  padding: 6px 14px;
  background: var(--warn-bg);
  color: var(--warn);
  border-bottom: 2px solid var(--warn-line);
  font: 600 12px/1.5 var(--font-sans), sans-serif;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: center;
}
.env-banner a { color: inherit; text-decoration: underline; }

@media print { .env-banner { display: none !important; } }

/* ── Offline-safe draft notices (IMQ entry form) ────────────────────────────────
   Two states an inspector must be able to tell apart at a glance:
     .draft-note            informational — a draft was restored, nothing is at risk
     .draft-note--pending   ACTION NEEDED — a submission is held on this device only
   Both use theme-aware status tokens so they stay legible in light and dark.        */
.draft-note {
  margin: var(--sp-3) 0;
  padding: 8px 12px;
  border: 1px solid var(--info-line);
  border-left: 3px solid var(--info);
  border-radius: var(--radius-sm, 4px);
  background: var(--info-bg);
  color: var(--info);
  font-size: var(--fs-xs);
  line-height: 1.5;
}
.draft-note--pending {
  border-color: var(--warn-line);
  border-left-color: var(--warn);
  background: var(--warn-bg);
  color: var(--warn);
}
.draft-note .btn { margin-left: 6px; vertical-align: baseline; }

/* Compact button for use inline inside a notice. */
.btn--xs {
  padding: 2px 8px;
  font-size: var(--fs-xs);
  line-height: 1.6;
  min-height: 0;
}

/* ── Plant agents strip (static/js/agent_advice.js) ───────────────────────────
   What AutoDT-Agentic's agents say to the signed-in role. A strip, not a panel: one line
   until opened, so the screen's own task stays first (review U1). Its left edge carries the
   most urgent level, grey when the agents have gone quiet (U6). The agent's grade is a
   neutral outline, never a status colour: it says how far to trust the advice, not how bad
   things are. Status tokens only, so light and dark both hold.                        */
.agent-advice { margin: 0 0 var(--sp-4); }
.aa-strip {
  display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-2) var(--sp-3);
  padding: 8px 12px; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-left: 4px solid var(--line);
  border-radius: var(--radius-input); font-size: var(--fs-sm);
}
.aa-strip--alert { border-left-color: var(--bad); }
.aa-strip--warn  { border-left-color: var(--warn); }
.aa-strip--info  { border-left-color: var(--info); }
.aa-strip--ok    { border-left-color: var(--ok); }
.aa-strip--quiet { border-left-color: var(--muted-2); background: var(--surface-alt); color: var(--muted); }
.aa-strip__title { font-weight: 700; letter-spacing: .01em; }
.aa-strip__msg { color: var(--muted); }
.aa-strip__top { flex: 1 1 240px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aa-count {
  padding: 2px 10px; border: 1px solid; border-radius: var(--radius-chip);
  font-size: var(--fs-xs); font-weight: 700; font-variant-numeric: tabular-nums;
}
.aa-count--alert { background: var(--bad-bg);  color: var(--bad);  border-color: var(--bad-line); }
.aa-count--warn  { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.aa-count--info  { background: var(--info-bg); color: var(--info); border-color: var(--info-line); }
.aa-count--ok    { background: var(--ok-bg);   color: var(--ok);   border-color: var(--ok-line); }
.aa-syn {
  padding: 1px 8px; border: 1px dashed var(--muted-2); border-radius: var(--radius-chip);
  font-size: var(--fs-xs); color: var(--muted);
}
.aa-toggle { margin-left: auto; min-height: 32px; }
.aa-body {
  display: grid; gap: var(--sp-3); margin-top: var(--sp-2); padding: var(--sp-3);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-input);
}
.aa-list { display: grid; gap: var(--sp-2); margin: 0; padding: 0; list-style: none; }
.aa-item {
  padding: 10px 12px; background: var(--surface-tint);
  border: 1px solid var(--line-soft); border-left: 3px solid var(--line); border-radius: var(--radius-input);
}
.aa-item--alert { border-left-color: var(--bad); }
.aa-item--warn  { border-left-color: var(--warn); }
.aa-item--info  { border-left-color: var(--info); }
.aa-item--ok    { border-left-color: var(--ok); }
.aa-item__head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: var(--fs-xs); color: var(--muted); }
.aa-level { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.aa-level--alert { color: var(--bad); }
.aa-level--warn  { color: var(--warn); }
.aa-level--info  { color: var(--info); }
.aa-level--ok    { color: var(--ok); }
.aa-agent { font-weight: 600; color: var(--ink); }
.aa-grade { padding: 0 8px; border: 1px solid var(--line); border-radius: var(--radius-chip); font-size: 12px; cursor: help; }
.aa-grade--production { color: var(--ink); border-color: var(--muted-2); }
.aa-grade--research   { color: var(--muted); border-color: var(--muted-2); }
.aa-grade--indicative,
.aa-grade--meter      { color: var(--muted); border-style: dashed; font-style: italic; }
.aa-age { margin-left: auto; font-variant-numeric: tabular-nums; }
.aa-headline { margin: 6px 0 2px; font-size: var(--fs-md); line-height: var(--lh-base); color: var(--ink); }
.aa-action { margin: 0; font-size: var(--fs-sm); color: var(--ink-2); }
.aa-ack { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.aa-ack .btn { min-height: 32px; }
.aa-ack__done { font-size: var(--fs-xs); color: var(--muted); }
.aa-h { margin: 0 0 6px; font-size: var(--fs-sm); color: var(--ink); }
.aa-issue {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px;
  padding: 6px 0; border-top: 1px solid var(--line-soft); font-size: var(--fs-sm);
}
.aa-urg { font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.aa-urg--critical { color: var(--bad); }
.aa-urg--high     { color: var(--warn); }
.aa-issue__label { font-weight: 600; }
.aa-issue__where { font-family: var(--font-num); font-size: var(--fs-xs); color: var(--muted); }
.aa-forms { display: grid; gap: var(--sp-2); grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.aa-form { padding: 8px 12px; background: var(--surface-tint); border: 1px solid var(--line-soft); border-radius: var(--radius-input); }
.aa-form summary { min-height: 28px; cursor: pointer; font-size: var(--fs-sm); font-weight: 600; color: var(--brand-primary); }
[data-theme="dark"] .aa-form summary { color: var(--brand-accent); }
.aa-form .input { width: 100%; box-sizing: border-box; margin-top: 8px; }
.aa-form .btn { min-height: 36px; margin-top: 8px; }
.aa-msg { margin: 6px 0 0; font-size: var(--fs-xs); color: var(--muted); }
.aa-mine { display: grid; gap: 6px; margin-top: 8px; }
.aa-mine__row { display: grid; gap: 2px; font-size: var(--fs-xs); color: var(--muted); }
.aa-mine__text { color: var(--ink-2); }
.aa-mine__st--bad { color: var(--bad); }
.aa-answer { margin: 2px 0; font-size: var(--fs-sm); color: var(--ink); }
.aa-evidence { margin: 0; font-family: var(--font-num); font-size: 13px; color: var(--muted); }
.aa-empty, .aa-note { margin: 0; font-size: var(--fs-xs); color: var(--muted); }
.aa-more { justify-self: start; min-height: 32px; }
.aa-ev summary { cursor: pointer; font-size: var(--fs-xs); color: var(--muted); }
@media (max-width: 600px) {
  /* two lines at most: the strip stays a strip on a handheld */
  .aa-strip__top { flex-basis: 100%; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; }
  .aa-age { margin-left: 0; }
}

/* ── The integration chain on the role screens (static/js/chain.js) ──────────────
   Provenance: where a result comes from. "real" is the only green-ish label; every synthetic
   label and an undeclared one look alike, so a stand-in's number is never read as a camera's. */
.prov {
  display: inline-flex; align-items: center; padding: 2px 10px; border-radius: var(--radius-chip);
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: .02em; border: 1px solid; white-space: nowrap;
}
.prov--real       { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); }
.prov--synthetic,
.prov--undeclared { background: var(--violet-bg); color: var(--violet); border-color: currentColor; }
.prov--undeclared { border-style: dashed; }

.chain-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
/* these set a display of their own, which would beat the browser's [hidden] rule */
.chain-status[hidden], .chain-sets[hidden], .chain-card[hidden], .chain-confirm[hidden], .decision__btns[hidden],
.decision__form[hidden], .decision__details[hidden], .decision__answered[hidden], .photo-preview[hidden] { display: none !important; }
.chain-hint { font-size: var(--fs-sm); color: var(--muted); }
.chain-h3 { margin: 0; font-size: var(--fs-lg); color: var(--brand-primary); }
[data-theme="dark"] .chain-h3 { color: var(--ink); }
.chain-status { margin-top: var(--sp-3); padding: 10px 14px; border-radius: var(--radius-input); border: 1px solid var(--line);
                font-size: var(--fs-sm); display: grid; gap: 4px; }
.chain-status--wait { background: var(--info-bg); border-color: var(--info-line); color: var(--ink); }
.chain-status--done { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ink); }
.chain-status--bad  { background: var(--bad-bg); border-color: var(--bad-line); color: var(--ink); }
.chain-sets { margin-top: var(--sp-3); display: grid; gap: 6px; font-size: var(--fs-sm); }
.chain-sets__title { font-weight: 700; }
.chain-sets__row { display: flex; gap: 8px; align-items: center; min-height: 44px; cursor: pointer; }
.chain-sets__row input { width: 24px; height: 24px; }
.chain-sets .btn { justify-self: start; }
.chain-card { margin-top: var(--sp-3); padding: 12px 14px; border: 1px solid var(--ok-line); border-radius: var(--radius-input);
              background: var(--surface); display: grid; gap: 6px; }
.chain-card .btn { justify-self: start; }
.chain-kv { display: grid; grid-template-columns: minmax(120px, auto) 1fr; gap: 4px 14px; font-size: var(--fs-sm); margin: 0; }
.chain-kv dt { color: var(--muted); }
.chain-kv dd { margin: 0; color: var(--ink); font-weight: 600; overflow-wrap: anywhere; }
@media (max-width: 500px) { .chain-kv { grid-template-columns: 1fr; } .chain-kv dd { margin-bottom: 6px; } }
.chain-table-wrap { overflow-x: auto; }
.chain-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.chain-table th, .chain-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.chain-table th { color: var(--muted); font-weight: 600; }
.chain-note { margin: var(--sp-2) 0; }
.chain-link { min-height: 32px; padding: 2px 10px; }
.chain-confirm { margin-top: var(--sp-2); padding: 10px 12px; border: 1px dashed var(--bad-line); border-radius: var(--radius-input);
                 display: grid; gap: 8px; }
.chain-confirm textarea { width: 100%; box-sizing: border-box; }
.chain-confirm .btn { justify-self: start; }
.chain-pending { margin-top: var(--sp-3); }

/* The operator's decision: one lamp, one line, three answers. Glove-sized. */
.decision { grid-template-columns: auto 1fr; }
.decision__lamp { width: 84px; height: 84px; }
.decision__lamp::before { width: 52px; height: 52px; }
.decision__eyebrow { font-size: var(--fs-xs); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.decision__action { font-size: var(--fs-2xl); }
.decision__meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
.decision__source { font-size: var(--fs-xs); color: var(--muted); }
.decision__btns { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-3); margin-top: var(--sp-3); }
.decision__btns .btn { min-height: 64px; }
@media (max-width: 500px) {
  .decision { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .decision__meta { justify-content: center; }
  .decision__btns { grid-template-columns: 1fr; }
}
.decision__form { margin-top: var(--sp-3); display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.decision__form label { flex-basis: 100%; font-weight: 600; }
.decision__form input { flex: 1 1 180px; min-height: 48px; font-size: var(--fs-lg); }
.decision__form .btn { min-height: 48px; }
.decision__answered { margin-top: var(--sp-2); font-size: var(--fs-sm); color: var(--muted); }
.decision__msg { margin-top: var(--sp-2); font-size: var(--fs-sm); min-height: 1em; }
.decision__msg--ok { color: var(--ok); }
.decision__msg--bad { color: var(--bad); font-weight: 600; }
.decision__details { margin-top: var(--sp-3); padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius-input); background: var(--surface); }
.decision__details summary { cursor: pointer; font-weight: 600; min-height: 32px; }
.decision__details .chain-kv { margin-top: 8px; }

/* The report photo: a big Take-photo button on a phone, a preview the operator can check. */
.photo-take { position: relative; display: inline-flex; align-items: center; justify-content: center; min-height: 54px; cursor: pointer; }
.photo-take input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.photo-preview { display: block; width: auto; height: auto; max-width: 100%; max-height: 260px; margin-top: var(--sp-2); border-radius: var(--radius-input); border: 1px solid var(--line); }
.photo-error { color: var(--bad); font-size: var(--fs-sm); font-weight: 600; min-height: 1em; }
