/* Loaded after legacy styles. Keep controls and service messages outside footage. */
/* The alert occupies layout space; the workspace uses the remaining viewport. */
body.operator-shell { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
body.operator-shell > .app-container { flex: 1 1 0; min-height: 0; height: auto; }
body.operator-shell .main-content, body.operator-shell .content-body { min-height: 0; }
body.operator-shell.wall-monitor-mode .main-content { height: 100%; }
body.operator-shell.wall-monitor-mode #tab-live-grid:not(:fullscreen) { height: 100% !important; }

.control-room-alert-bar {
  flex: 0 0 auto; flex-wrap: wrap; align-items: flex-start; gap: 10px 12px;
  width: 100%; min-width: 0; max-height: 45vh; max-height: 45dvh;
  overflow: auto; padding: 12px 16px; line-height: 1.5;
}
.control-room-alert-bar > i { flex: 0 0 auto; margin-top: 4px; }
.control-room-alert-copy { flex: 1 1 20rem; min-width: 0; overflow-wrap: anywhere; }
.control-room-alert-copy > span { display: block; }
.control-room-alert-copy .alert-camera-label {
  padding: 0; margin-top: 4px; border: 0; color: #fff; font-size: 12px;
}
.control-room-alert-actions {
  display: flex; flex: 0 1 auto; flex-wrap: wrap; gap: 8px; min-width: 0; max-width: 100%;
}
.control-room-alert-actions > button {
  min-height: 44px; max-width: 100%; padding: 8px 12px; margin: 0;
  border: 1px solid #f8fafc; border-radius: 6px; background: #172033;
  color: #fff; font-size: 13px; font-weight: 700; line-height: 1.4;
  white-space: normal; overflow-wrap: anywhere; cursor: pointer; box-shadow: none;
}
.control-room-alert-actions > button:hover { background: #28364d; color: #fff; border-color: #fff; }
.control-room-alert-actions > button:focus-visible {
  outline: 3px solid #fff !important; outline-offset: 2px !important;
  box-shadow: 0 0 0 5px #172033 !important;
}
.control-room-alert-actions > button:disabled { opacity: 1; color: #cbd5e1; border-color: #94a3b8; cursor: not-allowed; }
@media (max-width: 800px) {
  .control-room-alert-copy { flex-basis: calc(100% - 36px); }
  .control-room-alert-actions { flex: 1 1 100%; }
  .control-room-alert-actions > button { flex: 1 1 9rem; }
}

/* Counting labels and unknown values must remain legible at narrow widths. */
#rank-people-panel { min-width: 0; }
#rank-people-panel .rank-counting-card { min-width: 0; margin-bottom: 20px; }
#rank-people-panel .rank-counting-header { display: grid; gap: 8px; align-items: start; }
#rank-people-panel .rank-counting-header h3 { font-size: 18px; line-height: 1.35; overflow-wrap: anywhere; }
#rank-people-panel .rank-counting-header p { color: var(--text-body); font-size: 14px; line-height: 1.6; }
#rank-people-panel .card-body > p, #rank-people-panel .rank-counting-area > p {
  margin: 10px 0; line-height: 1.6; overflow-wrap: anywhere;
}
.rank-counting-area { min-width: 0; border: 1px solid var(--border-color); padding: 16px; margin: 16px 0; border-radius: 8px; }
.rank-counting-area h4 { margin-bottom: 12px; line-height: 1.4; overflow-wrap: anywhere; }
#rank-people-panel .operations-metrics {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 9.5rem), 1fr));
  gap: 1px; border: 0; background: var(--border-color);
}
#rank-people-panel .operation-metric { align-items: flex-start; border: 0; padding: 14px; background: var(--bg-card); }
#rank-people-panel .operation-metric strong { font-size: 20px; line-height: 1.3; overflow-wrap: anywhere; }
#rank-people-panel .operation-metric small {
  margin-top: 6px; font-size: 12px; line-height: 1.5; letter-spacing: normal;
  text-transform: none; white-space: normal; overflow: visible; overflow-wrap: anywhere;
}
.rank-counting-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0; }
#rank-people-panel .btn { min-height: 44px; max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
.rank-counting-actions > .btn { flex: 0 1 auto; }
.rank-counting-table { max-width: 100%; overflow: auto; margin: 16px 0; border: 1px solid var(--border-color); border-radius: 8px; }
.rank-counting-table table { width: 100%; min-width: 44rem; border-collapse: collapse; }
.rank-counting-table th, .rank-counting-table td { padding: 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border-color); }
.rank-counting-table th { background: var(--bg-input); color: var(--text-label); font-size: 12px; }
.rank-counting-table td { font-size: 13px; line-height: 1.5; }
.rank-counting-table td:first-child { min-width: 12rem; max-width: 22rem; overflow-wrap: anywhere; }
@media (max-width: 480px) {
  #rank-people-panel .card-body, #rank-people-panel .card-header { padding: 12px; }
  .rank-counting-area { padding: 12px; }
  .rank-counting-actions > .btn { flex: 1 1 100%; }
}

.top-bar { flex-wrap: wrap !important; height: auto !important; gap: 12px !important; }
.header-title { min-width: 0; flex: 1 1 260px; }
.header-controls { flex: 1 1 100%; flex-wrap: wrap !important; overflow: visible !important; gap: 8px !important; min-width: 0; }
.header-controls .grid-selector { flex-wrap: wrap; max-width: 100%; }
.header-controls > .btn { flex-shrink: 0; }
.operator-tools { flex: 0 1 auto; }
.operator-tools[open] { flex-basis: 100%; }
.operator-tools summary, .camera-tools summary {
  cursor: pointer; padding: 8px 10px; border: 1px solid var(--border-color);
  border-radius: 6px; color: var(--text-main); background: var(--bg-card); font-size: 13px;
}
.ux-disclosure-body { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 0; }
.operator-tools:not([open]) > .ux-disclosure-body, .camera-tools:not([open]) > .ux-disclosure-body { display: none; }
button:focus-visible, summary:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid #2563eb !important; outline-offset: 3px !important;
}
.camera-grid { flex: 0 0 auto !important; width: 100% !important; max-width: 100%; height: auto !important; grid-template-rows: none !important; grid-auto-rows: max-content !important; align-items: start; align-content: start; }
.camera-tile { min-width: 0 !important; aspect-ratio: auto !important; height: auto !important; min-height: 0 !important; background: var(--bg-card) !important; box-shadow: 0 2px 8px #0002 !important; }
.camera-tile .camera-header {
  position: relative !important; inset: auto !important; padding: 8px !important;
  background: var(--bg-card) !important; flex-wrap: wrap !important; pointer-events: auto !important; flex-shrink: 0 !important;
}
.camera-tile .camera-viewport { position: relative !important; inset: auto !important; height: auto !important; aspect-ratio: 16 / 9; flex: 0 0 auto; }
.camera-tile .cam-title { flex-basis: 100%; color: var(--text-main) !important; background: var(--bg-card) !important; box-shadow: none !important; border: none !important; font-size: 13px !important; max-width: 100%; }
.cam-name-text { overflow: hidden; text-overflow: ellipsis; }
.camera-tile .cam-header-right { min-width: 0; max-width: 100%; flex: 1 1 auto; }
.camera-tile .cam-badges { opacity: 1 !important; transform: none !important; display: flex !important; flex-wrap: wrap; width: 100%; border: 0 !important; border-radius: 0 !important; background: none !important; box-shadow: none !important; padding: 0 !important; }
.camera-tile .cam-badges .btn-icon { width: 34px !important; height: 34px !important; flex-shrink: 0; color: var(--text-main) !important; border-radius: 6px !important; }
.camera-tools[open] { flex: 1 1 100%; }
.camera-tools .ux-disclosure-body .btn-icon { width: auto !important; height: auto !important; min-height: 36px; padding: 8px !important; gap: 8px; text-align: left; font-size: 13px !important; border: 1px solid var(--border-color) !important; }
.camera-tools .cam-status-badges { flex-wrap: wrap; }
.camera-analysis-status { display: block; padding: 8px 10px; color: var(--text-main); background: var(--bg-card); font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; border-top: 1px solid var(--border-color); }
.camera-analysis-status[hidden] { display: none; }
@media (max-width: 600px) {
  #tab-live-grid .camera-grid { grid-template-columns: minmax(0, 1fr) !important; }
  .top-bar { padding: 12px !important; }
  .header-title h1 { font-size: 18px; }
  .header-title p { display: none; }
  .header-controls .command-clock { display: none; }
  .header-controls .grid-selector { flex-basis: 100%; }
}
/* Dedicated wall mode keeps the selected matrix on one screen. */
.grid-layout-1 { --wall-rows: 1; }
.grid-layout-4 { --wall-rows: 2; }
.grid-layout-9 { --wall-rows: 3; }
.grid-layout-16 { --wall-rows: 4; }
.grid-layout-25 { --wall-rows: 5; }
.grid-layout-36 { --wall-rows: 6; }
/* Wall presentation is deliberately independent of the operator's light/dark theme. */
:is(#tab-live-grid:fullscreen, body.wall-monitor-mode #tab-live-grid) {
  --bg-card: #10151c; --text-main: #e8edf4; --text-muted: #b0bac7; --border-color: #303a47;
  height: 100dvh !important; min-height: 0 !important; width: 100%;
  padding: 2px !important; margin: 0 !important; gap: 0 !important;
  background: #05080c !important; color: #e8edf4; overflow: hidden; color-scheme: dark;
}
body.wall-monitor-mode .content-body { padding: 0 !important; overflow: hidden; }
:is(#tab-live-grid:fullscreen, body.wall-monitor-mode #tab-live-grid) > :is(.operations-overview, .wall-command-bar) { display: none !important; }
:is(#tab-live-grid:fullscreen, body.wall-monitor-mode #tab-live-grid) .live-wall-wrapper {
  flex: 1 1 0; min-height: 0; height: 0; gap: 0;
}
:is(#tab-live-grid:fullscreen, body.wall-monitor-mode #tab-live-grid) .camera-grid {
  flex: 1 1 0 !important; height: 100% !important; min-height: 0; padding: 0 !important; gap: 2px !important;
  grid-template-columns: repeat(var(--wall-rows, 2), minmax(0, 1fr)) !important;
  grid-template-rows: repeat(var(--wall-rows, 2), minmax(0, 1fr)) !important;
  grid-auto-rows: minmax(0, 1fr) !important; align-items: stretch; align-content: stretch;
}
:is(#tab-live-grid:fullscreen, body.wall-monitor-mode #tab-live-grid) .camera-tile {
  height: 100% !important; min-height: 0 !important; border-radius: 0 !important;
  border: 1px solid #252e38 !important; background: #000 !important; box-shadow: none !important;
}
:is(#tab-live-grid:fullscreen, body.wall-monitor-mode #tab-live-grid) .camera-tile:is(:hover, :focus-within) { border-color: #45b8e8 !important; }
:is(#tab-live-grid:fullscreen, body.wall-monitor-mode #tab-live-grid) .camera-header {
  position: absolute !important; inset: auto 0 0 !important; height: 26px; padding: 0 7px !important;
  background: #10151c !important; flex-wrap: nowrap !important; border-top: 1px solid #252e38;
}
:is(#tab-live-grid:fullscreen, body.wall-monitor-mode #tab-live-grid) .cam-title {
  flex: 1 1 auto !important; min-width: 0; padding: 0 !important; height: 100%; gap: 6px;
  border-radius: 0 !important; background: transparent !important; color: #e8edf4 !important;
  font-size: 12px !important; font-weight: 500;
}
:is(#tab-live-grid:fullscreen, body.wall-monitor-mode #tab-live-grid) .cam-title > .fa-grip-vertical { display: none; }
:is(#tab-live-grid:fullscreen, body.wall-monitor-mode #tab-live-grid) .cam-badge {
  font-size: 10px !important; padding: 2px 5px !important; border-radius: 3px !important; box-shadow: none !important;
  color: #f8fafc !important; background: #354151;
}
:is(#tab-live-grid:fullscreen, body.wall-monitor-mode #tab-live-grid) .cam-badge.recording { background: #862d35 !important; animation: none !important; }
:is(#tab-live-grid:fullscreen, body.wall-monitor-mode #tab-live-grid) .cam-header-right { display: none !important; }
:is(#tab-live-grid:fullscreen, body.wall-monitor-mode #tab-live-grid) .camera-viewport {
  position: absolute !important; inset: 0 0 26px !important; height: auto !important; min-height: 0;
  width: 100%; aspect-ratio: auto; background: #000 !important;
}
:is(#tab-live-grid:fullscreen, body.wall-monitor-mode #tab-live-grid) video { object-fit: contain !important; }
:is(#tab-live-grid:fullscreen, body.wall-monitor-mode #tab-live-grid) .camera-analysis-status {
  position: absolute; bottom: 28px; right: 4px; max-width: 65%; z-index: 7;
  background: #10151ce6; color: #e8edf4; border: 1px solid #596575;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 3px 6px;
}
:is(#tab-live-grid:fullscreen, body.wall-monitor-mode #tab-live-grid) .ai-feed-info {
  bottom: 5px; left: 5px; font-size: 10px; border-color: #526578; color: #dae6f3; background: #10151ce6;
}
.wall-focus-camera, .wall-presentation-bar { display: none; }
:is(#tab-live-grid:fullscreen, body.wall-monitor-mode #tab-live-grid) .wall-focus-camera {
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 26px;
  height: 24px; padding: 0; border: 0; border-radius: 2px; background: #253141; color: #e8edf4;
  opacity: 0; cursor: pointer;
}
:is(#tab-live-grid:fullscreen, body.wall-monitor-mode #tab-live-grid) .camera-tile:is(:hover, :focus-within) .wall-focus-camera { opacity: 1; }
:is(#tab-live-grid:fullscreen, body.wall-monitor-mode #tab-live-grid) .wall-presentation-bar {
  display: flex; align-items: center; gap: 10px; flex: 0 0 34px; min-width: 0;
  padding: 0 6px; background: #10151c; color: #b0bac7; font-size: 11px;
}
.wall-presentation-brand { color: #e8edf4; font-weight: 700; letter-spacing: .1em; }
.wall-presentation-health { margin-right: auto; white-space: nowrap; }
.wall-presentation-health[data-attention="true"] { color: #ffd18a; }
.wall-presentation-bar button, .wall-presentation-bar select {
  height: 26px; min-width: 0; width: auto; padding: 2px 7px; margin: 0;
  border: 1px solid #465364 !important; border-radius: 3px !important; background: #1b2633 !important; color: #e8edf4 !important; font: inherit;
}
.wall-presentation-bar button { cursor: pointer; }
.wall-presentation-bar button:hover { background: #304258; }
.wall-presentation-page { white-space: nowrap; }
.wall-rotation-status { min-width: 80px; color: #b9d5ee; font-variant-numeric: tabular-nums; white-space: nowrap; }
.wall-presentation-bar button[data-active="true"] { background: #0b473d !important; border-color: #37bca0 !important; color: #dcfff5 !important; }
.wall-presentation-bar :is(button, select):focus-visible { outline: 2px solid #7dd3fc; outline-offset: 2px; }
.wall-presentation-bar button:disabled { opacity: .5; cursor: default; }
@media (max-width: 1100px) { .wall-presentation-hint { display: none; } }
@media (max-width: 800px) {
  :is(#tab-live-grid:fullscreen, body.wall-monitor-mode #tab-live-grid) .wall-presentation-bar { flex-wrap: wrap; flex-basis: auto; padding: 5px; }
  .wall-presentation-health { flex: 1 1 auto; }
}
.wall-presentation-alarm { display: none; }
:is(#tab-live-grid:fullscreen, body.wall-monitor-mode #tab-live-grid) .wall-presentation-alarm:not([hidden]) {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex: 0 0 auto;
  padding: 7px 10px; background: #713b08; color: #fff; font-size: 12px; border-bottom: 2px solid #fbbf24;
}
:is(#tab-live-grid:fullscreen, body.wall-monitor-mode #tab-live-grid) .wall-presentation-alarm[data-severity="CRITICAL"] { background: #7f1d1d; border-color: #f87171; }
.wall-presentation-alarm button { flex-shrink: 0; padding: 4px 8px; border: 1px solid #fff8; background: #0004; color: #fff; border-radius: 3px; cursor: pointer; }
@media (max-width: 640px) {
  .wall-presentation-brand, .wall-presentation-hint { display: none; }
  :is(#tab-live-grid:fullscreen, body.wall-monitor-mode #tab-live-grid) .wall-presentation-bar { gap: 4px; font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .camera-tile, .cam-badges, .btn { transition: none !important; }
}
/* Always-visible, independent live AI control, including dark fullscreen walls. */
.camera-tile .cam-title .camera-live-ai-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  gap: 4px;
  min-height: 24px;
  padding: 2px 7px;
  border: 1px solid #64748b;
  border-radius: 4px;
  background: #f1f5f9;
  color: #334155;
  line-height: 1.2;
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.camera-tile .cam-title .camera-live-ai-toggle.active {
  background: #065f46 !important;
  border-color: #047857 !important;
  color: #ffffff !important;
}
.camera-tile .cam-title .camera-live-ai-toggle.active i { color: inherit !important; }
.camera-tile .cam-title .camera-live-ai-toggle:focus-visible {
  outline: 2px solid #38bdf8;
  outline-offset: 2px;
}
:is(#tab-live-grid:fullscreen, body.wall-monitor-mode #tab-live-grid, .dark-theme) .camera-tile .cam-title .camera-live-ai-toggle {
  min-height: 22px;
  background: #1e293b;
  border-color: #94a3b8;
  color: #e2e8f0;
}
:is(#tab-live-grid:fullscreen, body.wall-monitor-mode #tab-live-grid, .dark-theme) .camera-tile .cam-title .camera-live-ai-toggle.active {
  background: #065f46 !important;
  border-color: #34d399 !important;
  color: #ffffff !important;
}
