/* =======================================================================
   NB2 Lamps Panel Digital Twin — Industrial Operations Interface
   Design: Bright daytime control-room interface, mature engineering SCADA
   ======================================================================= */

:root {
  /* Base UI Tokens */
  --page-bg: #F4F6F8;
  --surface: #FFFFFF;
  --surface-subtle: #F8FAFC;
  --border: #D9E0E7;
  --border-strong: #BAC5D0;
  --text: #18212B;
  --text-muted: #64748B;
  --heading: #0F172A;

  /* Brand / Primary */
  --primary: #006C6B;
  --primary-hover: #005A59;
  --primary-soft: #E6F4F2;

  /* Operational States */
  --success: #16803C;
  --success-soft: #EAF7EE;
  --warning: #A65B00;
  --warning-soft: #FFF4E5;
  --danger: #B42318;
  --danger-soft: #FDECEA;
  --info: #1D5F9C;
  --info-soft: #EAF3FA;

  /* 3D Viewport Stage Contrast Rule */
  --viewport-bg: #DCE3E8;
  --viewport-border: #C5D0D8;

  /* Legacy Variable Mapping for Untouched JS References */
  --accent-ok: var(--success);
  --accent-warn: var(--warning);
  --accent-bad: var(--danger);
  --muted: var(--text-muted);
  --bg-primary: var(--page-bg);
  --ok-bg: var(--success-soft);
  --ok-fg: var(--success);
  --ok-bd: var(--success);
  --warn-bg: var(--warning-soft);
  --warn-fg: var(--warning);
  --warn-bd: var(--warning);
  --bad-bg: var(--danger-soft);
  --bad-fg: var(--danger);
  --bad-bd: var(--danger);

  /* Layout Dimensions & Radii */
  --topbar-height: 50px;
  --nav-height: 38px;
  --tsb-height: 68px;
  --radius: 8px;
  --radius-sm: 4px;

  /* Restrained Operational Shadows */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.05), 0 2px 4px -2px rgba(15, 23, 42, 0.03);
}

/* -- Reset & Global Base ----------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  min-height: 100%;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--page-bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

input[type=range] {
  appearance: none;
  -webkit-appearance: none;
}

/* Accessibility & Keyboard Focus */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}

/* -- App Shell -------------------------------------------------------- */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* =====================================================================
   A. TOP APPLICATION HEADER
   ===================================================================== */
.topbar {
  height: var(--topbar-height);
  max-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-wrap {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}

.logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.uni-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--heading);
  letter-spacing: 0.01em;
}

.org-line {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}

.topbar-center {
  display: flex;
  align-items: center;
}

.project-pill {
  font-size: 16px;
  font-weight: 600;
  color: var(--heading);
  background: transparent;
  padding-left: 20px;
  border-left: 1px solid var(--border);
  line-height: 1.2;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.time-badge {
  font-size: 13px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  background: var(--surface-subtle);
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  background: var(--surface);
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  display: inline-block;
}

.dot.ok {
  background: var(--success);
}

.dot.bad {
  background: var(--danger);
}

/* =====================================================================
   B. MAIN NAVIGATION
   ===================================================================== */
.tab-nav {
  height: var(--nav-height);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 90;
}

.tab-btn {
  height: 100%;
  display: inline-flex;
  align-items: center;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 3px solid transparent;
  transition: color 150ms ease-out, border-color 150ms ease-out, background 150ms ease-out;
  border-radius: 0;
}

.tab-btn:hover:not(.active) {
  color: var(--text);
  background: var(--surface-subtle);
}

.tab-btn.active {
  color: var(--primary);
  font-weight: 600;
  border-bottom-color: var(--primary);
  background: var(--primary-soft);
}

/* =====================================================================
   MAIN WORKSPACE & TAB PANELS
   ===================================================================== */
.tab-content {
  flex: 1;
  padding: 12px 20px;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* =====================================================================
   TAB 1: DATA OVERVIEW
   ===================================================================== */
.section-hdr {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.sec-tag {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.sec-heading {
  font-size: 18px;
  font-weight: 600;
  color: var(--heading);
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  background: var(--success-soft);
  color: var(--success);
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--success-soft);
}

.live-pill.sm {
  padding: 2px 8px;
  font-size: 11px;
}

/* KPI Row */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  transition: border-color 150ms ease-out;
}

.kpi-card.accent-card {
  border-left: 3px solid var(--primary);
}

.kpi-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.kpi-val {
  font-size: 26px;
  font-weight: 600;
  color: var(--heading);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.kpi-unit {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  margin-left: 4px;
}

.kpi-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
}

/* Charts Row */
.charts-row,
.sim-charts-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(460px, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}

.chart-card,
.sim-chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.chart-eyebrow {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.chart-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--heading);
}

.chart-wrap {
  height: 280px;
  position: relative;
}

.chart-wrap-large {
  height: 340px;
  position: relative;
}

.chart-footer {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--surface-subtle);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.chart-badge-pill {
  font-size: 12px;
  font-weight: 500;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-variant-numeric: tabular-nums;
}

/* Industrial Section & Verified Data */
.industrial-section {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.badge-verified {
  font-size: 12px;
  font-weight: 600;
  color: var(--info);
  background: var(--info-soft);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--info-soft);
}

.real-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin: 20px 0;
}

.real-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.tile-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.tile-value {
  font-size: 22px;
  font-weight: 600;
  color: var(--heading);
  font-variant-numeric: tabular-nums;
}

.tile-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

.chart-legend-custom {
  display: flex;
  gap: 16px;
  align-items: center;
}

.leg-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
}

.leg-box {
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

.run-box {
  background: var(--success);
}

.zero-box {
  background: var(--text-muted);
}

/* =====================================================================
   C. SIMULATION WORKSPACE & 3D VIEWPORT (TAB 2 & TAB 3)
   ===================================================================== */
.model-layout,
.sim-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

@media (min-width: 1024px) {
  .model-layout {
    grid-template-columns: calc(100% - 364px) 340px;
    gap: 24px;
    align-items: stretch;
  }

  .sim-layout {
    grid-template-columns: 72% calc(28% - 24px);
    align-items: start;
  }
}

.model-col.primary-col,
.sim-main,
.sim-model-section {
  width: 100%;
}

.model-card,
.sim-model-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 12px;
  overflow: hidden;
}

.model-hdr {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.model-badge-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.model-chip {
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.live-chip {
  background: var(--success-soft);
  color: var(--success);
}

.sim-chip {
  background: var(--info-soft);
  color: var(--info);
}

.model-title-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--heading);
}

.model-meta-text,
.sim-state-badge {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.sim-state-badge.active {
  color: var(--success);
  font-weight: 600;
}

/* 3D Viewport Dedicated Stage */
.viewer-wrap {
  position: relative;
  width: 100%;
  height: clamp(390px, calc(100vh - 240px), 450px);
  background: var(--viewport-bg);
  border-bottom: 1px solid var(--viewport-border);
  overflow: hidden;
  display: flex;
  flex-direction: row;
  justify-content: flex-end;
}

model-viewer {
  width: calc(100% - 470px);
  margin-left: auto;
  height: 100%;
  background: transparent;
  outline: none;
  --poster-color: transparent;
}

.viewer-overlay {
  position: absolute;
  bottom: 14px;
  left: 14px;
  display: flex;
  flex-direction: row;
  gap: 8px;
  z-index: 10;
  pointer-events: none;
}

.overlay-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.90);
  backdrop-filter: blur(4px);
  border: 1px solid var(--viewport-border);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 12px;
  pointer-events: auto;
}

.oc-key {
  color: var(--text-muted);
  font-weight: 500;
}

.oc-val {
  color: var(--heading);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* =====================================================================
   D. OPERATIONAL STRIPS (UNDER 3D VIEWPORT)
   ===================================================================== */
.tele-strip,
.sim2-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  background: var(--surface);
  padding: 6px 16px;
  align-items: center;
  gap: 10px;
}

.tele-item,
.sim2-tele-item,
.sim2-toggle-row,
.sim2-load-wrap,
.sim2-lamp-row {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 4px 8px;
  position: relative;
}

.tele-sep {
  display: none;
  /* replaced by grid layout clean alignment */
}

.tele-label,
.sim2-tele-label,
.sim2-ctrl-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 4px;
  line-height: 1.2;
}

.tele-val,
.sim2-tele-val,
#sim2-watt-val,
#sim2-lamps-val {
  font-size: 20px;
  font-weight: 600;
  color: var(--heading);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.tele-unit {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  margin-left: 2px;
}

/* Predictive Forecasting Row */
.forecast-row-container {
  border-top: 1px solid var(--border);
  background: var(--surface-subtle);
}

.forecast-hdr {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px 0 16px;
  background: var(--surface);
}

.forecast-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.forecast-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--heading);
  letter-spacing: 0.01em;
}

.tele-strip.forecast-strip {
  background: var(--surface);
  border-bottom: none;
  padding: 4px 16px 6px 16px;
}

.tele-sub {
  font-size: 11px;
  font-weight: 500;
  color: var(--info);
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
  background: var(--info-soft);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  display: inline-block;
}

.state-pill.info-pill {
  background: var(--info-soft);
  color: var(--info);
  border: 1px solid var(--info);
}

.sim2-toggle-btn {
  height: 42px;
  padding: 0 20px;
  background: var(--surface-subtle);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  transition: all 150ms ease-out;
}

.sim2-toggle-btn.active {
  background: var(--success);
  color: #FFFFFF;
  border-color: var(--success);
}

.sim2-toggle-btn:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

.sim2-toggle-btn.active:hover {
  background: #136E33;
  color: #FFFFFF;
}

/* Sliders */
.styled-slider {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
  margin-top: 6px;
}

.styled-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border-strong);
  cursor: pointer;
  transition: transform 150ms ease-out;
}

.styled-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.spec-ref-card {
  grid-column: 1 / -1;
  margin-top: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--surface-subtle);
}

.spec-ref-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 8px;
}

.spec-ref-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 12px;
}

.spec-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.spec-k {
  color: var(--text-muted);
  font-weight: 500;
}

.spec-v {
  font-weight: 600;
  color: var(--heading);
}

/* Command Interface — Dedicated Right Column Panel (Full Height) */
.model-col.secondary-col {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.control-column-card {
  height: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.control-section {
  position: static;
  width: 100%;
  height: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: none;
  box-shadow: none;
  padding: 24px 20px;
}

.ctrl-link-specs {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.ctrl-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.panel-eyebrow {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  display: block;
  margin-bottom: 2px;
}

.ctrl-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--heading);
}

.state-pill {
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  color: var(--text);
}

.ctrl-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 14px;
  line-height: 1.4;
}

/* Vertical Column Buttons Layout */
.ctrl-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cmd-btn {
  width: 100%;
  height: 44px;
  background: var(--surface-subtle);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: all 150ms ease-out;
}

.cmd-btn:hover:not(:disabled) {
  background: var(--primary);
  color: #FFFFFF;
  border-color: var(--primary);
}

.cmd-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* =====================================================================
   E. SCENARIO RAIL & SIMULATION GAUGES (TAB 3)
   ===================================================================== */
.gauge-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.gauge-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 12px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.gauge-svg {
  width: 110px;
  height: 60px;
  margin: 0 auto;
  display: block;
}

.g-track {
  fill: none;
  stroke: var(--surface-subtle);
  stroke-width: 10;
  stroke-linecap: round;
}

.g-arc {
  fill: none;
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dasharray 250ms ease-out;
}

.temp-arc {
  stroke: var(--warning);
}

.power-arc {
  stroke: var(--primary);
}

.voltage-arc {
  stroke: var(--info);
}

.eff-arc {
  stroke: var(--success);
}

.lumen-arc {
  stroke: var(--primary);
}

.gauge-center {
  margin-top: -12px;
  margin-bottom: 8px;
}

.gauge-num {
  font-size: 22px;
  font-weight: 600;
  color: var(--heading);
  font-variant-numeric: tabular-nums;
  display: inline;
}

.gauge-unit-label {
  font-size: 13px;
  color: var(--text-muted);
  display: inline;
  margin-left: 2px;
}

.gauge-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.gauge-status {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Event Log Card */
.event-log-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 80px;
  /* buffer for time bar */
}

.log-hdr {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.log-clear-btn {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: all 150ms ease-out;
}

.log-clear-btn:hover {
  background: var(--surface-subtle);
  color: var(--text);
}

.log-body {
  max-height: 220px;
  overflow-y: auto;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.log-entry {
  display: flex;
  gap: 12px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  border-left: 3px solid var(--border-strong);
}

.log-entry.info {
  border-left-color: var(--info);
}

.log-entry.ok {
  border-left-color: var(--success);
}

.log-entry.bad {
  border-left-color: var(--danger);
}

.log-entry.warn {
  border-left-color: var(--warning);
}

.log-ts {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  font-weight: 500;
}

.log-msg {
  color: var(--text);
  line-height: 1.4;
}

/* Scenario Rail */
.scenario-panel {
  background: transparent;
}

@media (min-width: 1024px) {
  .scenario-panel {
    position: sticky;
    top: calc(var(--topbar-height) + 16px);
  }

  .scenario-close-btn,
  .scenario-fab {
    display: none !important;
  }
}

@media (max-width: 1023px) {
  .scenario-panel {
    display: none;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 320px;
    background: var(--surface);
    box-shadow: var(--shadow-md);
    z-index: 200;
    padding: 24px;
    overflow-y: auto;
  }

  .scenario-panel.open {
    display: block;
  }

  .scenario-fab {
    position: fixed;
    bottom: 80px;
    right: 24px;
    background: var(--primary);
    color: #FFFFFF;
    padding: 12px 20px;
    border-radius: 24px;
    font-weight: 600;
    box-shadow: var(--shadow-md);
    z-index: 150;
    display: flex;
    align-items: center;
  }

  .scenario-fab.visible {
    display: flex;
  }
}

.scenario-inner {
  background: transparent;
}

.scenario-hdr {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.scenario-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--heading);
}

.scenario-close-btn {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 4px 8px;
}

.scenario-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: calc(100vh - 160px);
  overflow-y: auto;
  padding-right: 4px;
}

/* Custom minimal scrollbar for scenario rail */
.scenario-list::-webkit-scrollbar,
.log-body::-webkit-scrollbar {
  width: 6px;
}

.scenario-list::-webkit-scrollbar-track,
.log-body::-webkit-scrollbar-track {
  background: var(--surface-subtle);
  border-radius: 3px;
}

.scenario-list::-webkit-scrollbar-thumb,
.log-body::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 3px;
}

.scenario-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  transition: all 150ms ease-out;
}

.scenario-card:hover {
  border-color: var(--border-strong);
}

.scenario-card.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
  background: var(--surface-subtle);
}

.sc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.sc-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--heading);
  line-height: 1.3;
}

/* Compact severity badges */
.sc-risk {
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: none;
  flex-shrink: 0;
}

.sc-risk.normal,
.sc-risk.LOW {
  background: var(--success-soft);
  color: var(--success);
  border: 1px solid var(--success-soft);
}

.sc-risk.advisory,
.sc-risk.MEDIUM {
  background: var(--info-soft);
  color: var(--info);
  border: 1px solid var(--info-soft);
}

.sc-risk.warning,
.sc-risk.HIGH {
  background: var(--warning-soft);
  color: var(--warning);
  border: 1px solid var(--warning-soft);
}

.sc-risk.fault,
.sc-risk.CRITICAL {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid var(--danger-soft);
}

.sc-desc {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
  margin-bottom: 14px;
}

.sc-params {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--surface-subtle);
}

.sc-param {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--page-bg);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-variant-numeric: tabular-nums;
}

.sc-run-btn {
  width: 100%;
  height: 40px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius);
  border: 1px solid transparent;
  transition: all 150ms ease-out;
}

.sc-run-btn:hover,
.scenario-card.active .sc-run-btn {
  background: var(--primary);
  color: #FFFFFF;
  border-color: var(--primary);
}

/* =====================================================================
   F. BOTTOM SIMULATION CONTROL BAR
   ===================================================================== */
.tsb-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 12px rgba(15, 23, 42, 0.04);
  z-index: 100;
  display: none;
}

.tsb-bar.visible {
  display: block;
}

.tsb-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  max-width: 1600px;
  margin: 0 auto;
  gap: 20px;
  flex-wrap: wrap;
}

.tsb-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tsb-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--heading);
}

.tsb-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-variant-numeric: tabular-nums;
}

.tsb-center {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.tsb-edge {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.tsb-slider {
  width: 140px;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
}

.tsb-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border-strong);
  cursor: pointer;
  transition: transform 150ms ease-out;
}

.tsb-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.tsb-presets {
  display: inline-flex;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2px;
  gap: 2px;
}

.tsb-preset {
  height: 32px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: 6px;
  transition: all 150ms ease-out;
}

.tsb-preset:hover:not(.active) {
  color: var(--text);
  background: rgba(0, 0, 0, 0.03);
}

.tsb-preset.active {
  background: var(--surface);
  color: var(--primary);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.tsb-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sim-run-btn {
  height: 40px;
  padding: 0 24px;
  background: var(--primary);
  color: #FFFFFF;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius);
  transition: background 150ms ease-out;
}

.sim-run-btn:hover {
  background: var(--primary-hover);
}

.sim-pause-btn {
  height: 40px;
  padding: 0 20px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius);
  transition: all 150ms ease-out;
}

.sim-pause-btn:hover:not(:disabled) {
  border-color: var(--text);
  background: var(--surface-subtle);
}

.sim-pause-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.sim-reset-btn {
  height: 40px;
  padding: 0 16px;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius);
  transition: color 150ms ease-out, background 150ms ease-out;
}

.sim-reset-btn:hover {
  color: var(--text);
  background: var(--surface-subtle);
}

/* =====================================================================
   TAB 4: ABOUT
   ===================================================================== */
.about-layout {
  max-width: 1200px;
  margin: 0 auto;
}

.about-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px;
  display: flex;
  gap: 32px;
  align-items: center;
  margin-bottom: 32px;
  box-shadow: var(--shadow-sm);
}

.about-logo-ring {
  width: 100px;
  height: 100px;
  flex-shrink: 0;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 50%;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.about-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.eyebrow {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}

.about-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--heading);
  margin-bottom: 12px;
  line-height: 1.2;
}

.about-subtitle {
  font-size: 15px;
  color: var(--text);
  line-height: 1.6;
  margin-bottom: 24px;
}

.about-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.meta-chip {
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.about-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
}

.about-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.about-card.wide-card {
  grid-column: 1 / -1;
}

.about-card-icon-ind {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-soft);
  border: 1px solid var(--primary-soft);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  margin-bottom: 12px;
}

.about-card-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--heading);
  margin-bottom: 12px;
}

.about-card p {
  font-size: 14px;
  color: var(--text);
  line-height: 1.6;
  margin-bottom: 10px;
}

.about-info-box {
  padding: 12px 14px;
  background: var(--surface-subtle);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}

.about-info-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.about-info-val {
  font-size: 14px;
  font-weight: 600;
  color: var(--heading);
}

.spec-table-grid {
  display: grid;
  grid-template-columns: 2fr 3fr;
  border-top: 1px solid var(--border);
  margin-top: 16px;
}

.spec-th {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.spec-td {
  font-size: 14px;
  color: var(--text);
  padding: 12px 0;
  border-bottom: 1px solid var(--surface-subtle);
}

/* =====================================================================
   RESPONSIVE HMI ENGINE (100% FIT FOR IPAD, TABLET & MOBILE PHONES)
   ===================================================================== */

/* ── Tablet / iPad Resolution (up to 1024px) ────────────────────────── */
@media (max-width: 1024px) {
  .topbar {
    padding: 8px 16px;
    flex-wrap: wrap;
    height: auto;
    min-height: var(--topbar-height);
    gap: 10px;
  }

  .viewer-wrap {
    height: 540px;
  }

  /* Narrower docked camera panel on tablet screens */
  .cam-overlay-box {
    flex-basis: 260px;
    width: 260px;
    padding: 8px;
  }

  .tele-strip,
  .sim2-controls {
    padding: 14px 16px;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }

  .kpi-grid,
  .real-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .about-card,
  .about-card.wide-card {
    grid-column: 1 / -1;
  }
}

/* ── Portrait Tablets & Small iPads (up to 768px) ──────────────────── */
@media (max-width: 768px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    padding: 12px 16px;
  }

  .topbar-center {
    display: none;
    /* remove center decoration on smaller tablets to preserve space */
  }

  .topbar-right {
    width: 100%;
    justify-content: space-between;
    padding-top: 8px;
    border-top: 1px solid var(--border);
  }

  .viewer-wrap {
    height: 480px;
  }

  /* Stack the camera panel below the 3D canvas instead of squeezing it
     into a narrow side column — keeps both fully visible, no overlap. */
  #model-viewport-placeholder {
    flex-direction: column;
    height: auto !important;
  }

  #model-canvas-wrap {
    height: 320px;
    flex: 0 0 auto;
  }

  .cam-overlay-box {
    flex: 0 0 220px;
    width: 100%;
    max-width: 100%;
    height: 220px;
    border-left: none;
    border-top: 1px solid var(--border);
  }

  .chart-wrap,
  .chart-wrap-large {
    height: 260px;
  }

  .spec-table-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Mobile Phone Resolution (up to 640px) ─────────────────────────── */
@media (max-width: 640px) {

  body,
  html {
    overflow-x: hidden;
  }

  /* Smooth horizontally scrollable navigation on smartphones */
  .tab-nav {
    padding: 0 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    gap: 2px;
    scrollbar-width: none;
  }

  .tab-nav::-webkit-scrollbar {
    display: none;
  }

  .tab-btn {
    padding: 0 12px;
    flex-shrink: 0;
    font-size: 13px;
  }

  .viewer-wrap {
    height: 400px;
  }

  #model-canvas-wrap {
    height: 260px;
  }

  /* Compact stacked camera panel for phone viewports */
  .cam-overlay-box {
    flex: 0 0 170px;
    height: 170px;
    padding: 6px;
  }

  .cam-overlay-hdr {
    margin-bottom: 4px;
    padding-bottom: 4px;
  }

  .cam-overlay-badge,
  .cam-overlay-status {
    font-size: 9px;
  }

  /* 2-column grid for telemetry & forecasting on smartphones */
  .tele-strip,
  .sim2-controls,
  .tele-strip.forecast-strip {
    grid-template-columns: repeat(2, 1fr);
    padding: 12px;
    gap: 10px;
  }

  .tele-val,
  .sim2-tele-val,
  #sim2-watt-val,
  .kpi-val {
    font-size: 18px;
  }

  .forecast-hdr {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 12px 12px 0 12px;
  }

  .forecast-title {
    font-size: 12px;
  }

  .ctrl-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  /* Full-width touch command buttons on phone */
  .ctrl-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .cmd-btn {
    height: 48px;
    /* optimized touch target height */
    font-size: 15px;
  }

  .kpi-grid,
  .real-kpi-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .chart-card,
  .about-card,
  .control-section {
    padding: 14px;
  }
}

/* ── Ultra Small Smartphones (up to 380px) ─────────────────────────── */
@media (max-width: 380px) {

  .tele-strip,
  .sim2-controls,
  .tele-strip.forecast-strip {
    grid-template-columns: 1fr;
  }

  .cam-overlay-box {
    flex-basis: 150px;
    height: 150px;
  }
}

   / *   - - -   F a u l t   I n j e c t i o n   &   C o s t   - - -   * /   . f a u l t - i n j - c a r d    {
         m a r g i n - t o p :    1 6 p x ;
         b a c k g r o u n d :    v a r ( - - s u r f a c e ) ;
         b o r d e r :    1 p x   s o l i d   v a r ( - - b o r d e r ) ;
         b o r d e r - r a d i u s :    8 p x ;
         p a d d i n g :    1 2 p x ;
     
}

   . f a u l t - i n j - t i t l e    {
         f o n t - s i z e :    1 1 p x ;
         f o n t - w e i g h t :    7 0 0 ;
         c o l o r :    v a r ( - - t e x t - m u t e d ) ;
         t e x t - t r a n s f o r m :    u p p e r c a s e ;
         l e t t e r - s p a c i n g :    0 . 0 5 e m ;
         m a r g i n - b o t t o m :    8 p x ;
     
}

   . f a u l t - i n j - g r i d    {
         d i s p l a y :    f l e x ;
         f l e x - d i r e c t i o n :    c o l u m n ;
         g a p :    6 p x ;
     
}

   . f a u l t - b t n    {
         f o n t - f a m i l y :    ' I n t e r '  ,    s a n s - s e r i f ;
         f o n t - s i z e :    1 2 p x ;
         f o n t - w e i g h t :    6 0 0 ;
         p a d d i n g :    8 p x   1 2 p x ;
         b o r d e r - r a d i u s :    6 p x ;
         b o r d e r :    1 p x   s o l i d   v a r ( - - b o r d e r ) ;
         c u r s o r :    p o i n t e r ;
         b a c k g r o u n d :    v a r ( - - s u r f a c e ) ;
         c o l o r :    v a r ( - - t e x t ) ;
         t r a n s i t i o n :    a l l   0 . 2 s ;
         t e x t - a l i g n :    l e f t ;
     
}

   . f a u l t - b t n : h o v e r    {
         f i l t e r :    b r i g h t n e s s ( 0 . 9 ) ;
     
}

   . f a u l t - b t n : a c t i v e    {
         t r a n s f o r m :    s c a l e ( 0 . 9 8 ) ;
     
}

   . f a u l t - b t n . w a r n : h o v e r    {
         b a c k g r o u n d :    v a r ( - - w a r n i n g - s o f t ) ;
         c o l o r :    v a r ( - - w a r n i n g ) ;
         b o r d e r - c o l o r :    v a r ( - - w a r n i n g ) ;
     
}

   . f a u l t - b t n . b a d : h o v e r    {
         b a c k g r o u n d :    v a r ( - - d a n g e r - s o f t ) ;
         c o l o r :    v a r ( - - d a n g e r ) ;
         b o r d e r - c o l o r :    v a r ( - - d a n g e r ) ;
     
}

   . f a u l t - b t n . i n f o : h o v e r    {
         b a c k g r o u n d :    v a r ( - - p r i m a r y - s o f t ) ;
         c o l o r :    v a r ( - - p r i m a r y ) ;
         b o r d e r - c o l o r :    v a r ( - - p r i m a r y ) ;
     
}

       

/* Fault Injection Card */
.fault-inj-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 16px;
  margin-top: 16px;
}

.fault-inj-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.fault-inj-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fault-btn {
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s;
  background: #f1f5f9;
  color: #334155;
  text-align: center;
}

.fault-btn:hover {
  background: #e2e8f0;
}

.fault-btn.warn {
  background: #fffbeb;
  color: #b45309;
  border-color: #fde68a;
}

.fault-btn.warn:hover {
  background: #fef3c7;
}

.fault-btn.bad {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}

.fault-btn.bad:hover {
  background: #fee2e2;
}

.fault-btn.info {
  background: #f0fdfa;
  color: #0f766e;
  border-color: #ccfbf1;
}

.fault-btn.info:hover {
  background: #ccfbf1;
}
/* Loading Screen — full-viewport splash shown until the GLB asset finishes
   loading, so the dashboard never renders behind an unstyled loading box. */
#loading-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--heading);
}

.loader-content {
  text-align: center;
  max-width: 360px;
  padding: 0 24px;
}

.loader-eyebrow {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
}

.loader-title {
  margin: 0 0 20px;
  font-size: 26px;
  font-weight: 700;
  color: #FFFFFF;
}

.loader-bar {
  position: relative;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  overflow: hidden;
  margin: 0 0 16px;
}

.loader-bar::after {
  content: "";
  position: absolute;
  top: 0;
  left: -40%;
  width: 40%;
  height: 100%;
  border-radius: 999px;
  background: var(--primary);
  animation: loader-bar-sweep 1.1s ease-in-out infinite;
}

@keyframes loader-bar-sweep {
  0% { left: -40%; }
  100% { left: 100%; }
}

.loader-path {
  margin: 0;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.6);
  font-family: 'SFMono-Regular', Consolas, monospace;
}

/* Babylon Canvas */
#canvas3d { width: 100%; height: 100%; outline: none; background: transparent; }
#canvas3d.hidden { display: none !important; }
#model-viewport-placeholder { position: relative; }
#model-canvas-wrap > #canvas3d { position: absolute; inset: 0; }

.hidden { display: none !important; }

/* Live Camera Feed — docked sidebar panel inside #model-viewport-placeholder.
   A flex sibling of #model-canvas-wrap (not absolutely positioned), so it
   always reserves its own space and never overlaps the 3D canvas or the
   Component Inspector overlay. */
.cam-overlay-box {
  position: relative;
  flex: 0 0 320px;
  width: 320px;
  max-width: 40%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: 10px 12px 12px 12px;
  overflow-y: auto;
  transition: flex-basis 0.2s ease-in-out, width 0.2s ease-in-out;
}

.cam-overlay-hdr {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
  flex-shrink: 0;
}

.camfeed-rec-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10B981;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
  animation: rec-pulse 1.8s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes rec-pulse {
  0% { transform: scale(0.95); opacity: 0.7; box-shadow: 0 0 4px rgba(16, 185, 129, 0.4); }
  50% { transform: scale(1.15); opacity: 1; box-shadow: 0 0 10px rgba(16, 185, 129, 0.8); }
  100% { transform: scale(0.95); opacity: 0.7; box-shadow: 0 0 4px rgba(16, 185, 129, 0.4); }
}

.cam-overlay-badge {
  font-size: 13px;
  font-weight: 600;
  color: var(--heading);
  letter-spacing: 0.01em;
}

.camfeed-viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  background: #060d1a;
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
}

.cam-media {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border: none;
}

.camfeed-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 4px 0 4px;
  gap: 1rem;
  flex-shrink: 0;
}

.camfeed-zoom-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 1;
}

.camfeed-zoom-track {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  position: relative;
  overflow: hidden;
}

.camfeed-zoom-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  width: 0%;
  transition: width 0.15s ease;
}

.cam-ctrl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.12s, border-color 0.12s, color 0.12s, transform 0.08s;
}

.cam-ctrl-btn:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

.cam-ctrl-btn:active {
  transform: scale(0.92);
}

.cam-ctrl-btn-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 24px;
  padding: 0 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.12s, color 0.12s;
}

.cam-ctrl-btn-sm:hover {
  background: var(--surface-subtle);
  color: var(--heading);
}

.camfeed-dpad {
  display: grid;
  grid-template-areas:
    ".    up    ."
    "left ctr   right"
    ".    down  .";
  grid-template-columns: 26px 26px 26px;
  grid-template-rows: 26px 26px 26px;
  gap: 2px;
  flex-shrink: 0;
}

.dpad-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.1s, color 0.1s, transform 0.08s;
}

.dpad-btn:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

.dpad-btn:active {
  transform: scale(0.88);
  background: var(--primary-soft);
}

.dpad-up { grid-area: up; }
.dpad-left { grid-area: left; }
.dpad-right { grid-area: right; }
.dpad-down { grid-area: down; }

.dpad-center {
  grid-area: ctr;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  position: relative;
}

.dpad-center::after {
  content: "";
  width: 4px;
  height: 4px;
  background: var(--border-strong);
  border-radius: 50%;
}
