/* Proof - Bond Bakery Brands
   Dark control-room theme. Draft palette; official brand kit not yet installed. */

:root {
  color-scheme: dark;

  --bg:        #0F1216;
  --panel:     #161B22;
  --raised:    #1C232C;
  --border:    #262D37;
  --border-lo: #1E242D;
  --text:      #E6E9ED;
  --muted:     #9AA4B2;
  --gold:      #D9A441;
  --gold-dim:  rgba(217, 164, 65, 0.14);

  --running:    #34C08B;
  --down:       #E5484D;
  --changeover: #5B9BD5;
  --nosignal:   #78828E;

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --r-sm: 3px;
  --r-md: 4px;
  --r-lg: 6px;

  --head-h: 60px;
  --tabs-h: 46px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

button { font-family: inherit; font-size: inherit; color: inherit; cursor: pointer; }
select { font-family: inherit; font-size: inherit; color: inherit; }
table { border-collapse: collapse; width: 100%; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #2C3541; border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #3A4552; }

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

.app-head {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--head-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 20px;
  background: linear-gradient(180deg, #171D25 0%, var(--panel) 100%);
  border-bottom: 1px solid var(--border);
}

.head-brand { display: flex; align-items: center; gap: 11px; min-width: 0; }

.monogram {
  width: 34px; height: 34px;
  flex: 0 0 34px;
  border-radius: 8px;
  background: var(--gold);
  color: #14181D;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 19px;
  letter-spacing: 0.01em;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.28);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-name { font-size: 17px; font-weight: 650; letter-spacing: 0.01em; }
.brand-sub { font-size: 11px; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; }

.head-tools { display: flex; align-items: center; gap: 14px; }

.scope-pill {
  display: flex; align-items: center; gap: 8px;
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 6px 4px 13px;
}
.scope-label { font-size: 10px; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); }
.scope-pill select {
  background: #232B35;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12.5px;
  outline: none;
}
.scope-pill select:focus-visible { border-color: var(--gold); }

.display-toggle .seg { background: var(--raised); }
.display-toggle button { padding: 5px 13px; font-size: 11.5px; letter-spacing: 0.04em; }
.head-clock { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.clock-day { font-size: 10.5px; color: var(--muted); letter-spacing: 0.05em; }
.clock-time { font-size: 14px; color: var(--text); letter-spacing: 0.02em; }

.user-chip { display: flex; align-items: center; gap: 9px; padding-left: 14px; border-left: 1px solid var(--border); }
.user-initials {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--raised); border: 1px solid var(--border);
  display: grid; place-items: center;
  font-size: 11.5px; font-weight: 650; letter-spacing: 0.03em; color: var(--gold);
}
.user-meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-name { font-size: 12.5px; }
.user-role { font-size: 10.5px; color: var(--muted); letter-spacing: 0.05em; text-transform: uppercase; }

/* ------------------------------------------------------------------ tabs */

.tabs {
  position: sticky;
  top: var(--head-h);
  z-index: 39;
  height: var(--tabs-h);
  display: flex;
  align-items: stretch;
  gap: 2px;
  padding: 0 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.tab {
  appearance: none;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 0 15px;
  font-size: 13px;
  letter-spacing: 0.03em;
  color: var(--muted);
  white-space: nowrap;
}
.tab:hover { color: var(--text); background: rgba(255,255,255,0.02); }
.tab[aria-selected="true"] { color: var(--gold); border-bottom-color: var(--gold); font-weight: 600; }
.tab-badge {
  display: inline-block; margin-left: 7px; padding: 1px 6px;
  border-radius: 999px; background: rgba(229,72,77,0.16); color: var(--down);
  font-size: 10.5px; font-weight: 650; font-family: var(--mono);
}

/* ------------------------------------------------------------------ view */

.view { max-width: 1680px; margin: 0 auto; padding: 22px 20px 40px; }
.view:focus { outline: none; }

.app-foot {
  border-top: 1px solid var(--border);
  padding: 16px 20px 26px;
  color: var(--muted);
  font-size: 11.5px;
  letter-spacing: 0.03em;
  text-align: center;
}

/* --------------------------------------------------------------- generic */

.section-title {
  font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 10px;
}
.panel {
  background: linear-gradient(180deg, rgba(255,255,255,0.014), rgba(255,255,255,0));
  background-color: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}
.panel-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 13px 16px; border-bottom: 1px solid var(--border-lo);
}
.panel-head h3 { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: 0.02em; }
.panel-body { padding: 14px 16px; }
.source-tag {
  font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 2px 8px;
  white-space: nowrap;
}
.hint { color: var(--muted); font-size: 12px; }
.empty {
  border: 1px dashed var(--border); border-radius: var(--r-md);
  padding: 26px; text-align: center; color: var(--muted); font-size: 12.5px;
}

/* ------------------------------------------------------------------- kpi */

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(196px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}
.kpi {
  background-color: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px 16px 13px;
  position: relative;
  overflow: hidden;
}
/* No accent sheen: the KPI value is the signal, the border is the frame. */
.kpi-label { font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.kpi-value { font-family: var(--mono); font-size: 30px; line-height: 1.15; margin-top: 5px; letter-spacing: -0.01em; }
.kpi-value.is-down { color: var(--down); }
.kpi-sub { font-size: 11.5px; color: var(--muted); margin-top: 3px; }

/* ---------------------------------------------------------------- chips */

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 999px; padding: 3px 10px;
  font-size: 11px; letter-spacing: 0.05em; font-weight: 600;
  border: 1px solid transparent; white-space: nowrap;
}
.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip-running    { color: var(--running);    background: rgba(52,192,139,0.11); border-color: rgba(52,192,139,0.30); }
.chip-down       { color: var(--down);       background: rgba(229,72,77,0.12);  border-color: rgba(229,72,77,0.34); }
.chip-changeover { color: var(--changeover); background: rgba(91,155,213,0.12); border-color: rgba(91,155,213,0.32); }
.chip-nosignal   { color: var(--nosignal);   background: rgba(120,130,142,0.12);border-color: rgba(120,130,142,0.30); }
.chip-pending    { color: var(--gold);       background: var(--gold-dim);       border-color: rgba(217,164,65,0.32); }
.chip-neutral    { color: var(--muted);      background: rgba(255,255,255,0.03);border-color: var(--border); }

/* ------------------------------------------------- needs-attention strip */
/* The company/site order below stays fixed so tile position is memorable.
   This strip is the exception channel: anything stopped, behind pace, or
   blind gets surfaced here without reordering the board underneath. */
.attn {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 8px 12px; margin-bottom: 18px;
  background-color: var(--panel);
  border: 1px solid var(--border); border-radius: var(--r-md);
}
.attn-title {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted);
}
.attn-count {
  font-family: var(--mono); font-size: 11px; padding: 1px 7px; border-radius: 999px;
  background: rgba(229,72,77,0.16); color: var(--down);
}
.attn-items { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; min-width: 0; }
.attn-item {
  appearance: none; display: inline-flex; align-items: center; gap: 8px;
  background: var(--raised); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 5px 11px; font-size: 12px; color: var(--text); text-align: left;
}
.attn-item:hover { border-color: #3E4956; }
.ai-dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 7px; background: var(--nosignal); }
.ai-name { font-weight: 600; white-space: nowrap; }
.ai-state { font-size: 10px; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.ai-clock { font-size: 12px; color: var(--muted); }
.ai-note { color: var(--muted); font-size: 11.5px; max-width: 250px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attn-item.is-down .ai-dot, .attn-item.is-down .ai-state, .attn-item.is-down .ai-clock { background-color: var(--down); color: var(--down); }
.attn-item.is-down .ai-dot { background: var(--down); }
.attn-item.is-changeover .ai-dot { background: var(--changeover); }
.attn-item.is-changeover .ai-state, .attn-item.is-changeover .ai-clock { color: var(--changeover); }
.attn-item.is-behind .ai-dot { background: var(--gold); }
.attn-item.is-behind .ai-state { color: var(--gold); }
.attn-clear { border-color: rgba(52,192,139,0.26); }
.attn-clear .attn-none { color: var(--running); font-size: 12px; }

/* --------------------------------------------------------- filter chips */

.filter-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.filter-row .filter-label {
  font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-right: 2px;
}
.fchip {
  appearance: none; background: var(--panel); border: 1px solid var(--border);
  border-radius: 999px; padding: 5px 13px; font-size: 12px; color: var(--muted);
}
.fchip:hover { color: var(--text); border-color: #333D49; }
.fchip[aria-pressed="true"] { background: var(--gold-dim); border-color: rgba(217,164,65,0.45); color: var(--gold); font-weight: 600; }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; background: var(--panel); }
.seg button { appearance: none; background: transparent; border: 0; padding: 5px 12px; font-size: 12px; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--border); }
.seg button[aria-pressed="true"] { background: var(--gold-dim); color: var(--gold); font-weight: 600; }
.seg button:hover:not([aria-pressed="true"]) { color: var(--text); }

/* ------------------------------------------------------------- grouping */

.company-block { margin-bottom: 30px; }
/* Company identity colour (shared with Sales Intelligence) lives ONLY at the
   company-section register: swatch, name, and the rule under the header.
   It never enters a tile. Inside a tile colour means machine state, and every
   company hue sits within 8 degrees of a status hue, so mixing the two
   registers would make Running and Portofino, or Down and Coco, ambiguous. */
.company-head {
  display: flex; align-items: center; flex-wrap: wrap; gap: 12px;
  padding-bottom: 10px; margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
  border-bottom-color: color-mix(in oklab, var(--co, transparent) 42%, var(--border));
}
.co-swatch {
  width: 10px; height: 10px; border-radius: 2px; flex: 0 0 10px;
  background: var(--co, var(--muted));
}
.company-name { font-size: 17px; font-weight: 640; letter-spacing: 0.01em; color: var(--co, var(--text)); }
.company-roll { display: flex; gap: 18px; margin-left: auto; flex-wrap: wrap; }
.roll-item { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.25; }
.roll-item .v { font-family: var(--mono); font-size: 14px; }
.roll-item .k { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

.site-block { margin: 0 0 18px; }
.site-head {
  display: flex; align-items: baseline; gap: 10px; margin: 0 0 11px;
}
.site-name { font-size: 12.5px; font-weight: 600; letter-spacing: 0.03em; color: var(--text); }
.site-meta { font-size: 11px; color: var(--muted); }

/* ----------------------------------------------------------- line tiles */

.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(322px, 1fr)); gap: 12px; }

.tile {
  background-color: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: border-color 0.14s ease, transform 0.14s ease;
}
.tile:hover { border-color: #35404E; }
.tile:hover .tile-name { color: var(--gold); }
.tile.is-down { border-color: rgba(229,72,77,0.42); }

.tile-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  padding: 11px 13px 9px; cursor: pointer;
}
.tile-ident { min-width: 0; }
.tile-name { font-size: 14.5px; font-weight: 620; letter-spacing: 0.01em; transition: color 0.14s; }
.tile-where { font-size: 11px; color: var(--muted); margin-top: 2px; }

.still-wrap { position: relative; margin: 0 14px; border-radius: var(--r-md); overflow: hidden; border: 1px solid var(--border-lo); background: #0B0E12; }
/* Tile thumb: the brief asks for numbers by default and pixels on demand,
   so the still is an affordance here, not the headline. */
.still-thumb { width: 104px; flex: 0 0 104px; margin: 0; align-self: flex-start; }
.still-thumb .live-badge { top: 4px; left: 4px; padding: 1px 5px; font-size: 8px; letter-spacing: 0.1em; gap: 3px; }
.still-thumb .live-badge .pulse { width: 4px; height: 4px; }
.still-thumb .still-tag { top: 4px; left: 4px; right: auto; padding: 1px 5px; font-size: 7.5px; letter-spacing: 0.08em; }
.still-wrap.clickable { cursor: pointer; }
.still-wrap.clickable:hover .live-badge { background: var(--down); color: #fff; }
.still-wrap svg { display: block; width: 100%; height: auto; }
.scene { display: block; width: 100%; height: auto; }
.still-overlay {
  position: absolute; inset: auto 0 0 0;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 8px;
  background: linear-gradient(0deg, rgba(8,10,13,0.86), rgba(8,10,13,0));
  font-size: 10.5px; color: #C9D1DA; font-family: var(--mono);
}
.live-badge {
  position: absolute; top: 8px; left: 8px;
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: var(--r-sm);
  background: rgba(229,72,77,0.85); color: #fff;
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.14em;
  transition: background 0.14s;
}
.live-badge .pulse { width: 5px; height: 5px; border-radius: 50%; background: #fff; animation: pulse 1.9s infinite ease-in-out; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.25; } }
.still-tag {
  position: absolute; top: 8px; right: 8px;
  padding: 2px 8px; border-radius: var(--r-sm);
  background: rgba(15,18,22,0.82); border: 1px solid var(--border);
  font-size: 9.5px; letter-spacing: 0.1em; color: var(--muted);
}

/* Readout row: one dominant numeral per tile. Running lines show rate;
   stopped lines show the elapsed clock, because a stopped line's rate is
   zero and tells you nothing. On a stopped line this row IS the red
   downtime banner the brief asks for. */
.tile-readout {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 11px 13px;
  border-top: 1px solid var(--border-lo);
  border-bottom: 1px solid var(--border-lo);
  cursor: pointer;
}
.tile-readout.is-down { background: rgba(229,72,77,0.10); border-color: rgba(229,72,77,0.30); }
.tile-readout.is-changeover { background: rgba(91,155,213,0.09); border-color: rgba(91,155,213,0.28); }
.readout-primary { flex: 1; min-width: 0; }
.ro-value { font-size: 34px; line-height: 1; letter-spacing: -0.025em; }
.tile-readout.is-down .ro-value { color: var(--down); }
.tile-readout.is-changeover .ro-value { color: var(--changeover); }
.ro-unit { font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin-top: 6px; }
.ro-note { font-size: 11.5px; color: var(--muted); margin-top: 5px; text-wrap: pretty; }
.tile-readout.is-down .ro-note { color: #F1B5B7; }
.tile-readout.is-changeover .ro-note { color: #BBD6EE; }
.ro-note.pos { color: var(--running); }

.count-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.count-row .k { font-size: 10px; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); }
.count-row .v { font-family: var(--mono); font-size: 16px; }
.count-row .v small { font-size: 11px; color: var(--muted); }
.count-sub { font-size: 11px; color: var(--muted); margin-top: 5px; }

.tile-body { padding: 11px 13px 13px; display: flex; flex-direction: column; gap: 11px; flex: 1; }

.metric-row { display: flex; align-items: center; gap: 14px; }
.oee-ring { flex: 0 0 auto; }
.apq-list { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.apq-line { display: flex; align-items: center; gap: 8px; font-size: 11.5px; }
.apq-line .k { color: var(--muted); width: 78px; flex: 0 0 78px; letter-spacing: 0.04em; }
.apq-line .v { font-family: var(--mono); color: var(--text); width: 48px; text-align: right; }
.apq-line .bar { flex: 1; height: 4px; border-radius: 2px; background: var(--raised); overflow: hidden; min-width: 30px; }
.apq-line .bar i { display: block; height: 100%; background: var(--gold); border-radius: 2px; }
.apq-line .bar i.a { background: #7FB3E0; }
.apq-line .bar i.p { background: var(--gold); }
.apq-line .bar i.q { background: var(--running); }

.stat { min-width: 0; }
.stat .k { font-size: 10px; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); }
.stat .v { font-family: var(--mono); font-size: 18px; line-height: 1.2; }
.stat .v small { font-size: 11px; color: var(--muted); letter-spacing: 0; }
.stat .d { font-size: 11px; color: var(--muted); }
.stat .d.pos { color: var(--running); }
/* Below standard is the normal condition, not an alarm. Red is reserved
   for stopped lines so it keeps meaning something. */
.stat .d.neg { color: var(--muted); }

.progress { height: 5px; border-radius: 3px; background: var(--raised); overflow: hidden; margin-top: 6px; }
.progress i { display: block; height: 100%; background: #5A6675; }
.progress i.ok { background: var(--running); }
.progress i.low { background: var(--down); }

.spark-wrap { border-top: 1px solid var(--border-lo); padding-top: 10px; }
.spark-head { display: flex; justify-content: space-between; font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.spark-wrap svg { display: block; width: 100%; height: auto; }

.detected {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  border-top: 1px solid var(--border-lo); padding-top: 10px;
  font-size: 11.5px;
}
.detected .dk { color: var(--muted); letter-spacing: 0.05em; }
.detected .dv { font-family: var(--mono); }

.station-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

/* ------------------------------------------------------------ downtime */

.dt-list { display: flex; flex-direction: column; }
.dt-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) 128px 74px 108px minmax(200px, 2fr);
  gap: 14px; align-items: start;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-lo);
}
.dt-row:last-child { border-bottom: 0; }
.dt-row.is-open { background: rgba(229,72,77,0.05); }
.dt-line { font-size: 13px; font-weight: 600; }
.dt-where { font-size: 11px; color: var(--muted); }
.dt-when { font-family: var(--mono); font-size: 12.5px; }
.dt-dur { font-family: var(--mono); font-size: 14px; }
.dt-dur.open { color: var(--down); }
.dt-cause { font-size: 12.5px; color: #C6CDD6; }
.clip-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; grid-column: 1 / -1; }
.clip-link {
  appearance: none; background: var(--raised); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 3px 9px;
  font-family: var(--mono); font-size: 11px; color: #AEBAC8;
}
.clip-link:hover { border-color: var(--gold); color: var(--gold); }
.dt-head-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) 128px 74px 108px minmax(200px, 2fr);
  gap: 14px; padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted);
}

/* ------------------------------------------------------------- cameras */

.cam-grid { display: grid; gap: 12px; }
.cam-grid.d1 { grid-template-columns: minmax(0, 900px); }
.cam-grid.d2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cam-grid.d3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cam-grid.d4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.cam-cell {
  background-color: var(--panel); border: 1px solid var(--border);
  border-radius: var(--r-md); overflow: hidden;
  display: flex; flex-direction: column;
}
.cam-cell:hover { border-color: #35404E; }
.cam-still { position: relative; cursor: pointer; background: #0B0E12; }
.cam-still svg { display: block; width: 100%; height: auto; }
.cam-foot { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-top: 1px solid var(--border-lo); }
.cam-id { font-size: 12px; font-weight: 600; }
.cam-area { font-size: 11px; color: var(--muted); }
.cam-foot .mono { font-size: 10.5px; color: var(--muted); margin-left: auto; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 7px; }
.sd-online { background: var(--running); }
.sd-nosignal { background: var(--nosignal); }
.sd-pending { background: var(--gold); }
.pin-btn {
  appearance: none; background: transparent; border: 0; padding: 2px; line-height: 0;
  color: var(--nosignal); border-radius: var(--r-sm);
}
.pin-btn:hover { color: var(--gold); }
.pin-btn[aria-pressed="true"] { color: var(--gold); }
.pinned-band { border: 1px solid rgba(217,164,65,0.28); border-radius: var(--r-lg); padding: 14px; margin-bottom: 22px; background: rgba(217,164,65,0.035); }

/* ------------------------------------------------------------- detail */

.crumb { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.back-btn {
  appearance: none; background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 5px 12px; font-size: 12px; color: var(--muted);
}
.back-btn:hover { color: var(--gold); border-color: var(--gold); }
.crumb-path { font-size: 11.5px; color: var(--muted); letter-spacing: 0.03em; }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.detail-hero { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.hero-metrics { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 22px; align-items: center; }
.big-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 14px; }
.stack { display: grid; gap: 16px; }

.kv { display: grid; grid-template-columns: 128px minmax(0, 1fr); gap: 6px 14px; font-size: 12.5px; }
.kv dt { color: var(--muted); letter-spacing: 0.03em; }
.kv dd { margin: 0; }

.run-list { display: flex; flex-direction: column; gap: 8px; }
.run-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border-lo); border-radius: var(--r-md); background: var(--raised); }
.run-item .when { font-family: var(--mono); font-size: 11.5px; color: var(--muted); width: 100px; flex: 0 0 100px; }
.run-item .what { font-size: 12.5px; min-width: 0; }
.run-item .what small { display: block; color: var(--muted); font-size: 11px; }

.cam-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }

/* -------------------------------------------------------------- charts */

.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); gap: 16px; }
.chart-box svg { display: block; width: 100%; height: auto; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; font-size: 11.5px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 2px; border-radius: 1px; display: inline-block; }

.data-table th, .data-table td { padding: 9px 12px; text-align: left; font-size: 12.5px; border-bottom: 1px solid var(--border-lo); }
.data-table th { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.data-table td.num, .data-table th.num { text-align: right; font-family: var(--mono); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: rgba(255,255,255,0.018); }
.table-scroll { overflow-x: auto; }

.controls-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px; margin-bottom: 20px; }
.ctl { display: flex; flex-direction: column; gap: 5px; }
.ctl label { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.ctl select, .ctl input[type="date"] {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 6px 10px; font-size: 12.5px; color: var(--text); outline: none;
  font-family: var(--sans);
}
.ctl input[type="date"] { font-family: var(--mono); }
.ctl select:focus-visible, .ctl input:focus-visible { border-color: var(--gold); }

/* --------------------------------------------------------------- admin */

.notice {
  border: 1px solid rgba(217,164,65,0.34); background: rgba(217,164,65,0.07);
  border-radius: var(--r-lg); padding: 14px 16px; margin-bottom: 20px;
  font-size: 13px; color: #EBD5A8;
}
.notice strong { color: var(--gold); }

.tree { font-family: var(--mono); font-size: 12.5px; line-height: 1.85; }
.tree .t-co { color: var(--co, var(--text)); }
.tree .co-swatch { display: inline-block; vertical-align: middle; margin-right: 8px; }
.tree .t-site { color: #B9C3CE; padding-left: 22px; }
.tree .t-line { color: var(--muted); padding-left: 46px; }
.tree .t-cam { color: #6F7A87; padding-left: 46px; }

/* -------------------------------------------------------------- modals */

.modal-back {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(6,8,11,0.78);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: fade 0.14s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: min(900px, 100%); max-height: 92vh; overflow: auto;
  background-color: var(--panel); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: 0 24px 70px rgba(0,0,0,0.6);
}
.modal:focus { outline: none; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 15px 18px; border-bottom: 1px solid var(--border-lo); }
.modal-title { font-size: 15px; font-weight: 620; }
.modal-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.modal-close {
  appearance: none; background: var(--raised); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 4px 11px; font-size: 12px; color: var(--muted);
}
.modal-close:hover { color: var(--text); border-color: #3A4552; }
.modal-body { padding: 18px; }
.modal-still { border-radius: var(--r-md); overflow: hidden; border: 1px solid var(--border); position: relative; background: #0B0E12; }
.modal-still svg { display: block; width: 100%; height: auto; }
.modal-note {
  margin-top: 14px; padding: 11px 13px;
  border: 1px dashed var(--border); border-radius: var(--r-md);
  font-size: 12.5px; color: var(--muted);
}

.scrub { margin-top: 16px; }
.scrub-track { position: relative; height: 40px; background: var(--raised); border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; }
.scrub-event { position: absolute; top: 0; bottom: 0; background: rgba(229,72,77,0.20); border-left: 2px solid var(--down); border-right: 2px solid var(--down); }
.scrub-event.chg { background: rgba(91,155,213,0.18); border-left-color: var(--changeover); border-right-color: var(--changeover); }
.scrub-head { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--gold); }
.scrub-ticks { display: flex; justify-content: space-between; margin-top: 6px; font-family: var(--mono); font-size: 10.5px; color: var(--muted); }
.scrub-ctl { display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.scrub-ctl button {
  appearance: none; background: var(--raised); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 5px 14px; font-size: 12px; color: var(--text);
}
.scrub-ctl button:hover { border-color: var(--gold); color: var(--gold); }
.scrub-time { font-family: var(--mono); font-size: 13px; margin-left: auto; color: var(--gold); }

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

@media (max-width: 1180px) {
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .cam-grid.d4 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .app-head { height: auto; flex-wrap: wrap; padding: 10px 14px; gap: 10px; }
  .tabs { top: 0; position: sticky; }
  .head-tools { width: 100%; justify-content: space-between; gap: 10px; }
  .view { padding: 18px 14px 34px; }
  .dt-row, .dt-head-row { grid-template-columns: minmax(0, 1fr) 118px 70px; }
  .dt-head-row span:nth-child(4), .dt-head-row span:nth-child(5) { display: none; }
  .dt-row .dt-cat-cell { grid-column: 1 / -1; }
  .dt-row .dt-cause { grid-column: 1 / -1; }
  .cam-grid.d3, .cam-grid.d4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero-metrics { grid-template-columns: minmax(0, 1fr); }
  .company-roll { margin-left: 0; width: 100%; justify-content: flex-start; }
}
@media (max-width: 900px) {
  /* Wall mode targets a mounted screen; it has no meaning on a tablet. */
  .display-toggle { display: none; }
}
@media (max-width: 620px) {
  .tile-grid { grid-template-columns: minmax(0, 1fr); }
  .cam-grid.d2, .cam-grid.d3, .cam-grid.d4 { grid-template-columns: minmax(0, 1fr); }
  .head-clock { display: none; }
  .user-meta { display: none; }
}

/* =========================================================================
   WALL MODE - mounted control-room screen, read from across the room.
   Type scales up, the board drops to two columns, and camera walls cap at
   2-up regardless of the density selector. Desk mode is the default.
   ========================================================================= */
body.wall { font-size: 16px; }
body.wall .view { max-width: none; padding: 26px 28px 44px; }

body.wall .kpi-strip { grid-template-columns: repeat(auto-fit, minmax(268px, 1fr)); gap: 14px; }
body.wall .kpi { padding: 17px 19px 16px; }
body.wall .kpi-label { font-size: 12px; }
body.wall .kpi-value { font-size: 46px; }
body.wall .kpi-sub { font-size: 13.5px; }

body.wall .attn { padding: 11px 15px; gap: 14px; }
body.wall .attn-title { font-size: 12px; }
body.wall .attn-item { font-size: 14px; padding: 7px 14px; gap: 10px; }
body.wall .ai-state { font-size: 11.5px; }
body.wall .ai-clock { font-size: 15px; }
body.wall .ai-note { font-size: 13px; max-width: 340px; }
body.wall .ai-dot { width: 9px; height: 9px; flex-basis: 9px; }

body.wall .company-name { font-size: 21px; }
body.wall .roll-item .v { font-size: 17px; }
body.wall .roll-item .k { font-size: 11.5px; }
body.wall .site-name { font-size: 15px; }
body.wall .site-meta { font-size: 13px; }

body.wall .tile-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
body.wall .tile-name { font-size: 19px; }
body.wall .tile-where { font-size: 13px; }
body.wall .chip { font-size: 12.5px; padding: 4px 12px; }
body.wall .tile-readout { padding: 15px 17px; gap: 16px; }
body.wall .ro-value { font-size: 52px; }
body.wall .ro-unit { font-size: 12px; }
body.wall .ro-note { font-size: 14px; }
body.wall .still-thumb { width: 148px; flex-basis: 148px; }
body.wall .tile-body { padding: 15px 17px 17px; gap: 14px; }
body.wall .metric-row { gap: 20px; }
body.wall .apq-line { font-size: 14px; }
body.wall .apq-line .k { width: 100px; flex-basis: 100px; }
body.wall .apq-line .v { width: 58px; }
body.wall .apq-line .bar { height: 5px; }
body.wall .count-row .k { font-size: 12px; }
body.wall .count-row .v { font-size: 21px; }
body.wall .count-row .v small { font-size: 14px; }
body.wall .count-sub { font-size: 13px; }
body.wall .progress { height: 7px; }
body.wall .spark-head { font-size: 11.5px; }
body.wall .detected { font-size: 13.5px; }
body.wall .station-stats .stat .v { font-size: 21px; }

body.wall .cam-grid.d3, body.wall .cam-grid.d4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
body.wall .cam-id { font-size: 14px; }
body.wall .cam-area { font-size: 13px; }
body.wall .cam-foot .mono { font-size: 12.5px; }

body.wall .data-table th { font-size: 11.5px; }
body.wall .data-table td { font-size: 14px; padding: 11px 14px; }
body.wall .dt-head-row { font-size: 11.5px; }
body.wall .dt-line { font-size: 15px; }
body.wall .dt-when { font-size: 14px; }
body.wall .dt-dur { font-size: 16px; }
body.wall .dt-cause { font-size: 14px; }
body.wall .clip-link { font-size: 12.5px; padding: 4px 11px; }
body.wall .tab { font-size: 14.5px; padding: 0 18px; }
body.wall .panel-head h3 { font-size: 15px; }
