/* ─────────────────────────────────────────────────────────────────────────────
   DAVLE FACTORY — OPERATOR COCKPIT
   Phase R7B | 2026-04-18
   Doctrine: /opt/factory/docs/OPERATOR_VISUAL_SIGNOFF_GATE_V1.md
   ───────────────────────────────────────────────────────────────────────────── */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* HTML hidden attribute must not be overridden by display:flex/block rules */
[hidden] { display: none !important; }

/* ── Design tokens (spec-locked) ─────────────────────────────────────────── */
:root {
  --bg:          #0A0A0A;
  --surface:     #141414;
  --surface-el:  #1C1C1C;
  --border:      #2A2A2A;
  --text-1:      #F0F0F0;
  --text-2:      #9A9A9A;
  --text-3:      #6A6A6A;
  --accent:      #D8E8F0;
  --green:       #5FB878;
  --amber:       #D4A84B;
  --red:         #C7513F;
  --unknown:     #6A6A6A;

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", Menlo, "Courier New", monospace;

  /* Permitted sizes: 11 13 15 22 36 */
  --sz-11: 11px;
  --sz-13: 13px;
  --sz-15: 15px;
  --sz-22: 22px;
  --sz-36: 36px;
}

/* ── Reset & base ─────────────────────────────────────────────────────────── */
html {
  background: var(--bg);
  color: var(--text-1);
  font-family: var(--sans);
  font-size: var(--sz-13);
  font-weight: 400;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px 80px;
}

.mono { font-family: var(--mono); }

/* ── State color classes ──────────────────────────────────────────────────── */
.state-green   { color: var(--green); }
.state-amber   { color: var(--amber); }
.state-red     { color: var(--red); }
.state-unknown { color: var(--unknown); }
.state-neutral { color: var(--text-3); }

/* ── Header ───────────────────────────────────────────────────────────────── */
#cockpit-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 18px 0 16px;
  border-bottom: 1px solid var(--border);
}

.header-brand {
  font-size: var(--sz-15);
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--accent);
  font-family: var(--sans);
  text-transform: uppercase;
}

.header-sep {
  color: var(--border);
  font-size: var(--sz-15);
}

.header-tagline {
  font-size: var(--sz-11);
  font-weight: 500;
  letter-spacing: 0.12em;
  color: var(--text-3);
  text-transform: uppercase;
}

.header-clock {
  margin-left: auto;
  font-size: var(--sz-11);
  color: var(--text-3);
  letter-spacing: 0.04em;
}

/* ── Sections ─────────────────────────────────────────────────────────────── */
.cockpit-section {
  padding: 28px 0 0;
  margin-bottom: 0;
  border-bottom: 1px solid var(--border);
}

.section-label {
  font-size: var(--sz-11);
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--text-3);
  text-transform: uppercase;
  margin-bottom: 22px;
}

/* ── Section footer (stale visibility — MANDATORY) ────────────────────────── */
.section-footer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 0 20px;
  font-size: var(--sz-11);
  border-top: 1px solid rgba(42, 42, 42, 0.5);
  margin-top: 20px;
}

.footer-interval {
  font-family: var(--mono);
  font-size: var(--sz-11);
  font-weight: 500;
  color: var(--text-3);
  letter-spacing: 0.08em;
}

.footer-age {
  font-size: var(--sz-11);
  color: var(--text-3);
  letter-spacing: 0.04em;
}

.footer-stale {
  font-size: var(--sz-11);
  font-weight: 700;
  color: var(--amber);
  letter-spacing: 0.10em;
}

.footer-error {
  font-size: var(--sz-11);
  color: var(--red);
  letter-spacing: 0.04em;
}

/* ── Section 1: LIVE ──────────────────────────────────────────────────────── */
.live-layout {
  display: flex;
  gap: 48px;
  align-items: flex-start;
}

.stream-wrapper {
  position: relative;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
}

.stream-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.stream-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 10, 0.88);
  font-size: var(--sz-11);
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--red);
  text-align: center;
}

/* R8D: crash-fallback visual treatment.
   When truth_verdict=BROKEN, the stream image is de-emphasised (operator cannot
   trust its content) and a dominant red label takes visual priority.
   The BROKEN label's visual weight must exceed the image itself. */
.stream-wrapper.stream-broken {
  border: 2px solid var(--red);
}

.stream-wrapper.stream-broken img {
  opacity: 0.3;
}

.stream-broken-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: var(--sz-15);
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--red);
  text-align: center;
  line-height: 1.4;
  pointer-events: none;
  z-index: 10;
  /* Subtle dark backing so text reads over the faded image */
  background: rgba(10, 10, 10, 0.55);
}

.truth-strip {
  flex: 1;
  min-width: 0;
}

.truth-verdict-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 20px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.strip-key {
  font-size: var(--sz-11);
  font-weight: 500;
  letter-spacing: 0.12em;
  color: var(--text-3);
  text-transform: uppercase;
}

.truth-verdict {
  font-size: var(--sz-36);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-1);
  line-height: 1;
}

.strip-rows {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.strip-row {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(42, 42, 42, 0.4);
}

.strip-row:last-child {
  border-bottom: none;
}

.strip-key {
  min-width: 110px;
  flex-shrink: 0;
}

.strip-val {
  font-size: var(--sz-13);
  font-weight: 400;
  color: var(--text-1);
}

.strip-val.small {
  font-size: var(--sz-11);
  word-break: break-all;
  color: var(--text-2);
}

/* ── Section 2: FACTORY READINESS ─────────────────────────────────────────── */
.readiness-header {
  display: flex;
  align-items: baseline;
  gap: 20px;
  margin-bottom: 22px;
}

.readiness-value {
  font-size: var(--sz-22);
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-1);
}

.readiness-overall {
  font-size: var(--sz-13);
  font-weight: 500;
  letter-spacing: 0.10em;
  color: var(--text-2);
  text-transform: uppercase;
}

.checks-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.checks-loading {
  font-size: var(--sz-11);
  font-family: var(--mono);
  color: var(--text-3);
  letter-spacing: 0.08em;
  padding: 12px 0;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px solid rgba(42, 42, 42, 0.4);
}

.check-row:last-child {
  border-bottom: none;
}

.check-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 1px;
}

.check-name {
  font-size: var(--sz-13);
  font-weight: 500;
  font-family: var(--mono);
  color: var(--text-2);
  min-width: 230px;
  flex-shrink: 0;
}

.check-detail {
  font-size: var(--sz-13);
  font-weight: 400;
  color: var(--text-3);
  flex: 1;
}

/* ── Section 3: FACES INVENTORY ───────────────────────────────────────────── */
.ovsg-notice {
  font-size: var(--sz-11);
  font-family: var(--mono);
  color: var(--text-3);
  letter-spacing: 0.06em;
  padding: 0 0 18px;
  line-height: 1.6;
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--sz-11);
  font-family: var(--mono);
}

thead th {
  font-size: var(--sz-11);
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text-3);
  text-align: left;
  padding: 0 14px 11px 0;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  font-family: var(--sans);
}

thead th:last-child { padding-right: 0; }

tbody tr {
  border-bottom: 1px solid rgba(42, 42, 42, 0.45);
  transition: background 100ms ease;
}

tbody tr:last-child { border-bottom: none; }

tbody tr:hover {
  background: rgba(255, 255, 255, 0.015);
}

tbody td {
  padding: 10px 14px 10px 0;
  vertical-align: middle;
  white-space: nowrap;
  color: var(--text-2);
}

tbody td:last-child { padding-right: 0; }

.td-id {
  font-size: var(--sz-11);
  font-weight: 500;
  color: var(--text-1);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.td-loading {
  color: var(--text-3);
  font-size: var(--sz-11);
  letter-spacing: 0.08em;
  padding: 18px 0;
}

/* Inline state labels */
.st {
  font-family: var(--mono);
  font-size: var(--sz-11);
  font-weight: 700;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

/* ── Section 4: PIPELINE & SERVICES ───────────────────────────────────────── */
.pipeline-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 0;
}

.pipeline-item {
  padding: 14px 16px 14px 0;
  border-bottom: 1px solid rgba(42, 42, 42, 0.4);
}

.pipeline-item:last-child {
  border-bottom: none;
}

.pipeline-key {
  font-size: var(--sz-11);
  font-weight: 500;
  letter-spacing: 0.10em;
  color: var(--text-3);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.pipeline-val {
  font-size: var(--sz-13);
  font-family: var(--mono);
  color: var(--text-1);
  word-break: break-all;
  line-height: 1.4;
}

.pipeline-val .small {
  font-size: var(--sz-11);
  color: var(--text-2);
}

.pipeline-loading {
  font-size: var(--sz-11);
  font-family: var(--mono);
  color: var(--text-3);
  letter-spacing: 0.08em;
  padding: 12px 0;
}

/* ── Mobile responsive (primary viewport: 390px) ─────────────────────────── */
@media (max-width: 600px) {

  body {
    padding: 0 14px 60px;
  }

  /* Header: wrap clock below brand on narrow screens */
  #cockpit-header {
    flex-wrap: wrap;
    gap: 6px 12px;
    padding: 14px 0 12px;
  }

  .header-clock {
    margin-left: 0;
    width: 100%;
    order: 10;
  }

  /* Section 1: stack circle above truth strip */
  .live-layout {
    flex-direction: column;
    gap: 24px;
    align-items: stretch;
  }

  .stream-wrapper {
    /* Center the circle; scale down gracefully on very narrow screens */
    width: min(220px, 72vw);
    height: min(220px, 72vw);
    margin: 0 auto;
  }

  /* TRUTH VERDICT: smaller on mobile so it fits */
  .truth-verdict {
    font-size: var(--sz-22);
  }

  /* Strip rows: relax the key min-width so values have room */
  .strip-key {
    min-width: 90px;
  }

  /* Active face: break at spaces not mid-character */
  .strip-val.small {
    word-break: break-word;
    overflow-wrap: anywhere;
    white-space: normal;
  }

  /* Section 2: check-name min-width too wide for mobile; identifiers need break-all */
  .check-name {
    min-width: 0;
    flex: 1 1 auto;
    word-break: break-all;
  }

  .check-detail {
    word-break: break-all;
  }

  /* Stack check rows on very narrow screens */
  .check-row {
    flex-wrap: wrap;
    gap: 4px 14px;
  }

  .readiness-header {
    flex-direction: column;
    gap: 6px;
  }

  /* Section 4: single column on mobile (270px minmax is too wide) */
  .pipeline-grid {
    grid-template-columns: 1fr;
  }
}
