/* ISA-101 High-Performance SCADA & Industrial Automation Theme */
:root {
  --bg-darkest: #0d1117;
  --bg-panel: #161b22;
  --bg-panel-header: #21262d;
  --border-subtle: #30363d;
  --border-active: #58a6ff;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --state-normal: #8b949e;
  --state-running: #2ea043;
  --state-warning: #d29922;
  --state-alarm: #f85149;
  --state-cyber: #bc8cff;
  --accent-blue: #58a6ff;
  --accent-cyan: #39c5bb;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

body {
  background-color: var(--bg-darkest);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.4;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  user-select: none;
}

/* App Grid */
.scada-layout {
  display: grid;
  grid-template-rows: 52px 1fr;
  height: 100vh;
  width: 100vw;
}

/* Header & Alarm Banner */
.scada-header {
  background: var(--bg-panel-header);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 10;
}

.plant-identity {
  display: flex;
  align-items: center;
  gap: 12px;
}

.plant-title {
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.8px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.isa-badge {
  background: rgba(88, 166, 255, 0.12);
  border: 1px solid var(--border-active);
  color: var(--accent-blue);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

/* Alarm Banner */
.alarm-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(248, 81, 73, 0.1);
  border: 1px solid rgba(248, 81, 73, 0.4);
  padding: 4px 14px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 12px;
}

.alarm-banner.clean {
  background: rgba(46, 160, 67, 0.1);
  border-color: rgba(46, 160, 67, 0.3);
  color: #3fb950;
}

.alarm-banner.active {
  color: #f85149;
  animation: flash-alarm 1.5s infinite;
}

@keyframes flash-alarm {
  0%, 100% { border-color: rgba(248, 81, 73, 0.4); }
  50% { border-color: #f85149; box-shadow: 0 0 12px rgba(248, 81, 73, 0.4); }
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Hardwired E-STOP Button */
.btn-estop {
  background: #b62324;
  border: 2px solid #f85149;
  color: #ffffff;
  padding: 6px 14px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 12px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(248, 81, 73, 0.4);
  transition: all 0.1s ease;
}

.btn-estop:hover {
  background: #f85149;
  box-shadow: 0 0 14px rgba(248, 81, 73, 0.7);
}

/* Main Workspace */
.workspace-grid {
  display: grid;
  grid-template-columns: 1fr 420px;
  overflow: hidden;
  height: 100%;
}

/* Left: Process Mimic & Trend Chart */
.left-viewport {
  display: grid;
  grid-template-rows: 1fr 200px;
  border-right: 1px solid var(--border-subtle);
  background: var(--bg-darkest);
  overflow: hidden;
}

.mimic-container {
  position: relative;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 40% 40%, #1c222c 0%, #0d1117 100%);
  overflow: hidden;
}

#process-canvas {
  width: 100%;
  height: 100%;
}

/* Bottom Trend Chart */
.trend-container {
  background: var(--bg-panel);
  border-top: 1px solid var(--border-subtle);
  display: grid;
  grid-template-rows: 28px 1fr;
  padding: 6px 12px 10px 12px;
}

.trend-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
}

.trend-pen-legend {
  display: flex;
  gap: 14px;
}

.pen-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.pen-line {
  width: 14px;
  height: 2px;
}

#trend-canvas {
  width: 100%;
  height: 100%;
  background: #0d1117;
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
}

/* Right Console (Tabs) */
.right-console {
  background: var(--bg-panel);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tab-nav {
  display: flex;
  background: var(--bg-panel-header);
  border-bottom: 1px solid var(--border-subtle);
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  padding: 10px 4px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--accent-blue);
  border-bottom-color: var(--accent-blue);
  background: rgba(88, 166, 255, 0.05);
}

.tab-content {
  flex: 1;
  padding: 14px;
  overflow-y: auto;
  display: none;
}

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

/* Section Cards */
.control-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 12px;
}

.card-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent-blue);
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.mode-btn-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 8px;
}

.btn-mode {
  background: #21262d;
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.btn-mode.active {
  background: rgba(46, 160, 67, 0.2);
  border-color: #3fb950;
  color: #3fb950;
}

/* Sliders */
.slider-group {
  margin-bottom: 10px;
}

.slider-label-row {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 11px;
  margin-bottom: 3px;
}

.slider-group input[type="range"] {
  width: 100%;
  accent-color: var(--accent-blue);
}

/* Action Buttons */
.btn-action {
  background: #21262d;
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-action:hover {
  border-color: var(--text-secondary);
  background: #30363d;
}

.btn-warning {
  border-color: rgba(210, 153, 34, 0.5);
  color: #e3b341;
}

.btn-warning:hover {
  background: rgba(210, 153, 34, 0.2);
}

.btn-cyber {
  border-color: rgba(188, 140, 255, 0.6);
  color: #d2a8ff;
}

.btn-cyber:hover {
  background: rgba(188, 140, 255, 0.15);
}

/* Modbus Registers Table */
.modbus-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 11px;
}

.modbus-table th {
  background: #21262d;
  color: var(--text-secondary);
  padding: 6px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

.modbus-table td {
  padding: 5px 8px;
  border-bottom: 1px solid rgba(48, 54, 61, 0.6);
}

.modbus-table tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.reg-val {
  color: var(--accent-cyan);
  font-weight: 600;
}

/* Structured Text Editor */
.st-editor {
  background: #0d1117;
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.5;
  color: #e6edf3;
  white-space: pre;
  overflow-x: auto;
}

.st-keyword { color: #ff7b72; font-weight: 700; }
.st-type { color: #79c0ff; }
.st-comment { color: #8b949e; font-style: italic; }
.st-val { color: #a5d6ff; }

/* Alarm List */
.alarm-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.alarm-item {
  background: #161b22;
  border: 1px solid var(--border-subtle);
  border-left: 4px solid var(--state-alarm);
  border-radius: 4px;
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.alarm-item.warning {
  border-left-color: var(--state-warning);
}

/* ==========================================================================
   ISA-101 Mobile & Smartphone Responsive Layout (< 960px)
   ========================================================================== */
@media (max-width: 960px) {
  body {
    overflow-y: auto !important;
    height: auto !important;
    min-height: 100vh;
  }

  .scada-layout {
    display: flex !important;
    flex-direction: column !important;
    height: auto !important;
    min-height: 100vh;
  }

  /* Header */
  .scada-header {
    flex-direction: column;
    align-items: flex-start;
    height: auto;
    padding: 8px 12px;
    gap: 8px;
  }

  .plant-identity {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px;
  }

  .alarm-banner {
    width: 100%;
    justify-content: space-between;
    font-size: 11px;
    padding: 6px 10px;
  }

  .header-right {
    width: 100%;
    display: flex;
    gap: 6px;
  }

  .header-right .btn-action {
    flex: 1;
    padding: 6px 2px;
    font-size: 10px;
    text-align: center;
  }

  .btn-estop {
    flex: 1.2;
    padding: 6px 4px;
    font-size: 10px;
    text-align: center;
  }

  /* Workspace Layout */
  .workspace-grid {
    display: flex !important;
    flex-direction: column !important;
    height: auto !important;
    overflow: visible !important;
  }

  .left-viewport {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    border-right: none !important;
    height: auto !important;
  }

  /* Process Mimic Canvas */
  .mimic-container {
    width: 100% !important;
    height: 370px !important;
    min-height: 340px;
  }

  /* Trend Chart */
  .trend-container {
    width: 100% !important;
    height: 170px !important;
  }

  .trend-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .trend-pen-legend {
    gap: 8px;
    font-size: 10px;
  }

  /* Right Console (Tabs) */
  .right-console {
    width: 100% !important;
    border-top: 1px solid var(--border-subtle);
    height: auto !important;
    overflow: visible !important;
  }

  .tab-nav {
    overflow-x: auto;
    white-space: nowrap;
  }

  .tab-btn {
    padding: 12px 10px;
    font-size: 11px;
  }

  .tab-content {
    overflow-y: visible !important;
    height: auto !important;
    padding: 10px 12px;
  }

  /* Modbus Table horizontal scrolling */
  #tab-modbus .control-card {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .modbus-table {
    min-width: 320px;
  }

  /* Touch controls */
  input[type="range"] {
    height: 26px;
    touch-action: pan-y;
  }

  .btn-mode {
    padding: 10px 4px;
    font-size: 11px;
  }

  .btn-action {
    padding: 8px 10px;
  }
}

@media (max-width: 480px) {
  .plant-title {
    font-size: 13px;
  }
  .isa-badge {
    font-size: 9px;
    padding: 1px 4px;
  }
  .mimic-container {
    height: 360px !important;
  }
}

@media (max-width: 900px) {
  html, body {
    margin: 0 !important;
    padding: 0 !important;
    width: 100vw !important;
    height: 100% !important; height: 100dvh !important;
    height: 100dvh !important;
    overflow: hidden !important;
  }
  .scada-layout {
    width: 100vw !important;
    height: 100% !important; height: 100dvh !important;
    height: 100dvh !important;
    position: relative !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
  }
  .scada-header {
    height: 42px !important;
    min-height: 42px !important;
    padding: 0 10px !important;
    flex-shrink: 0 !important;
  }
  .scada-header .header-right {
    display: none !important;
  }
  .scada-header .alarm-banner {
    display: none !important;
  }
  .workspace-grid {
    flex: 1 !important;
    position: relative !important;
    width: 100% !important;
    height: calc(100% - 42px) !important;
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
  }
  .left-viewport {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 4px !important;
  }
  .mimic-container {
    flex: 1 !important;
    min-height: 0 !important;
    position: relative !important;
    width: 100% !important;
  }
  .mimic-container canvas {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
  }
  .trend-container {
    display: none !important;
  }
}

/* ========================================================= */
/* Smart Mobile Full-Screen Canvas & Edge Collapsible Drawer  */
/* ========================================================= */

/* Glowing Yellow Spotlight (Zero Blur, Sharp & Clear) */
.tour-spotlight-active {
  position: relative !important;
  z-index: 9995 !important;
  outline: 3.5px solid #ffd600 !important;
  outline-offset: 3px !important;
  box-shadow: 0 0 0 3px #ffd600, 0 0 24px rgba(255, 214, 0, 0.95) !important;
  border-radius: 6px !important;
  animation: tourYellowPulse 1.2s infinite alternate ease-in-out !important;
}
@keyframes tourYellowPulse {
  0% { outline-color: #ffd600; box-shadow: 0 0 0 2px #ffd600, 0 0 12px rgba(255, 214, 0, 0.7); }
  100% { outline-color: #ffea00; box-shadow: 0 0 0 4px #ffea00, 0 0 28px rgba(255, 234, 0, 1); }
}

/* Crystal-Clear Interactive Tour Card */
.tour-card {
  position: fixed;
  z-index: 10000;
  background: rgba(9, 14, 26, 0.97) !important;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 2px solid #ffd600;
  border-radius: 14px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.95), 0 0 24px rgba(255, 214, 0, 0.35);
  color: #f1f5f9;
  display: none;
  flex-direction: column;
  padding: 10px 14px;
  gap: 8px;
  max-width: 460px;
  margin: 0 auto;
}
.tour-card.active {
  display: flex;
}

/* Position Tour Card at top on mobile so it never blocks the bottom drawer or center canvas */
@media (max-width: 900px) {
  .tour-card {
    top: 10px;
    left: 8px;
    right: 8px;
    max-width: 96%;
    padding: 8px 12px;
  }
}
@media (min-width: 901px) {
  .tour-card {
    bottom: 24px;
    right: 24px;
    width: 380px;
  }
}

.tour-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.tour-badge-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.tour-step-badge {
  background: linear-gradient(135deg, #f59e0b, #ffd600);
  color: #050811;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.tour-app-name {
  font-size: 0.72rem;
  font-weight: 700;
  color: #94a3b8;
}
.tour-btn-close {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #94a3b8;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}
.tour-btn-close:hover {
  color: #ffffff;
  border-color: #ffd600;
  background: rgba(255, 214, 0, 0.1);
}

.tour-card-body {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.tour-instruction-title {
  font-size: 0.86rem;
  font-weight: 800;
  color: #ffffff;
  line-height: 1.3;
}
.tour-detail-row {
  font-size: 0.73rem;
  line-height: 1.4;
  padding: 4px 8px;
  border-radius: 5px;
}
.tour-detail-happens {
  background: rgba(15, 23, 42, 0.85);
  border-left: 3px solid #ffd600;
  color: #e2e8f0;
}
.tour-detail-why {
  background: rgba(11, 17, 32, 0.85);
  border-left: 3px solid #38bdf8;
  color: #cbd5e1;
}

.tour-card-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 2px;
}
.tour-btn-prev {
  background: #1e293b;
  border: 1px solid #334155;
  color: #94a3b8;
  font-size: 0.74rem;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.tour-btn-prev:hover {
  color: #ffffff;
  background: #334155;
}
.tour-btn-next {
  background: linear-gradient(135deg, #ffd600, #f59e0b);
  border: none;
  color: #050811;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(255, 214, 0, 0.4);
  transition: transform 0.15s;
}
.tour-btn-next:hover {
  transform: translateY(-1px);
}

/* Floating Tour Launcher Button */
.btn-tour-launcher {
  position: fixed;
  bottom: 58px;
  right: 14px;
  z-index: 8990;
  background: linear-gradient(135deg, #f59e0b, #ffd600);
  color: #050811;
  border: 1px solid rgba(255, 255, 255, 0.4);
  padding: 7px 14px;
  border-radius: 50px;
  font-size: 0.76rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(255, 214, 0, 0.4), 0 2px 6px rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.2s;
}
.btn-tour-launcher:hover {
  transform: translateY(-2px);
}

/* Universal Collapsible Bottom Sheet Drawer for Controls */
@media (max-width: 900px) {
  .mobile-drawer-pane {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 9000 !important;
    max-height: 44vh !important;
    height: auto !important;
    background: rgba(8, 13, 24, 0.95) !important;
    backdrop-filter: blur(16px) !important;
    -webkit-backdrop-filter: blur(16px) !important;
    border-top: 2px solid #ffd600 !important;
    border-radius: 18px 18px 0 0 !important;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.9) !important;
    display: flex !important;
    flex-direction: column !important;
    transform: translateY(calc(100% - 44px)) !important;
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1) !important;
    margin: 0 !important;
  }
  .mobile-drawer-pane.drawer-expanded {
    transform: translateY(0) !important;
  }

  .mobile-drawer-header {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 10px 16px !important;
    height: 44px !important;
    min-height: 44px !important;
    background: rgba(14, 23, 42, 0.95) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 18px 18px 0 0 !important;
    cursor: pointer !important;
    user-select: none !important;
    flex-shrink: 0 !important;
  }
  .drawer-title-group {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
  }
  .drawer-badge {
    font-size: 0.82rem !important;
    font-weight: 800 !important;
    color: #ffd600 !important;
    letter-spacing: 0.5px !important;
  }
  .drawer-toggle-btn {
    background: #1e293b !important;
    border: 1px solid #334155 !important;
    color: #f1f5f9 !important;
    font-size: 0.72rem !important;
    font-weight: 800 !important;
    padding: 4px 10px !important;
    border-radius: 20px !important;
    display: flex !important;
    align-items: center !important;
    gap: 4px !important;
  }

  .mobile-drawer-body {
    flex: 1 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    padding: 12px 14px 48px !important;
  }

  
  /* Sleek Compact Drawer Accordion Cards */
  .mobile-drawer-body .card,
  .mobile-drawer-body .panel,
  .mobile-drawer-body .control-card {
    margin-bottom: 8px !important;
    border-radius: 10px !important;
    background: rgba(15, 23, 42, 0.7) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
  }
  .mobile-drawer-body .card-header,
  .mobile-drawer-body .panel-header {
    padding: 8px 12px !important;
    font-size: 0.76rem !important;
    cursor: pointer !important;
    user-select: none !important;
  }

  /* Mobile touch controls optimization */
  input[type=range] {
    height: 38px !important;
    min-height: 38px !important;
  }
  input[type=range]::-webkit-slider-thumb {
    width: 26px !important;
    height: 26px !important;
    border-radius: 50% !important;
    background: #ffd600 !important;
    border: 2px solid #ffffff !important;
    box-shadow: 0 0 10px rgba(255, 214, 0, 0.8) !important;
  }
  select, button {
    min-height: 40px !important;
  }
  .btn-tour-launcher {
    bottom: 52px !important;
    right: 10px !important;
    padding: 6px 12px !important;
    font-size: 0.72rem !important;
  }
}

/* Desktop layout rules */
@media (min-width: 901px) {
  .mobile-drawer-header {
    display: none !important;
  }
  .mobile-drawer-body {
    display: contents !important;
  }
}


/* Universal Mobile Drawer Accordions */
.accordion-arrow {
  font-size: 13px !important;
  color: #ffd600 !important;
  margin-left: auto !important;
  padding-left: 8px !important;
  display: inline-block !important;
  font-weight: 800 !important;
  transition: transform 0.2s ease !important;
}
.mobile-drawer-body .card-header,
.mobile-drawer-body .card-title,
.mobile-drawer-body .panel-header {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  cursor: pointer !important;
  user-select: none !important;
}


/* ========================================================= */
/* Floating Engineering HUD Overlay & Avionics Styles        */
/* ========================================================= */

.live-sticky-screen {
  position: relative !important;
  overflow: hidden !important;
}

.hud-overlay-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 20;
  overflow: hidden;
}

/* Top-Left HUD Controls */
.hud-top-left {
  position: absolute;
  top: 8px;
  left: 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  pointer-events: auto;
  z-index: 25;
}
.hud-pill-box {
  position: relative;
  width: 155px;
  background: rgba(11, 18, 32, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 7px;
  transition: all 0.2s ease;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}
.hud-pill-box:hover {
  border-color: rgba(0, 229, 255, 0.4);
}
.hud-pill-inner {
  display: flex;
  align-items: center;
  padding: 4px 7px;
  gap: 6px;
}
.hud-pill-icon {
  color: #94a3b8;
  flex-shrink: 0;
}
.hud-text-stack {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}
.hud-mini-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 7.5px;
  font-weight: 700;
  color: #64748b;
  letter-spacing: 0.4px;
  line-height: 1;
}
.hud-val-text {
  font-size: 9.5px;
  font-weight: 700;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}
.hud-caret {
  font-size: 9px;
  color: #64748b;
  margin-left: auto;
}
.hud-hidden-select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

/* Tag Pills Row */
.hud-tags-row {
  display: flex;
  align-items: center;
  gap: 5px;
}
.hud-tag-wrapper {
  position: relative;
}
.hud-tag-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(11, 18, 32, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 3.5px 7px;
  color: #94a3b8;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
}
.hud-tag-pill:hover {
  color: #f1f5f9;
  border-color: rgba(255, 255, 255, 0.25);
}
.hud-tag-pill.active {
  color: #00e5ff;
  border-color: rgba(0, 229, 255, 0.5);
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.25);
}
.hud-dot-active {
  color: #00e5ff;
  font-size: 8px;
  text-shadow: 0 0 6px #00e5ff;
}

/* Top-Right Floating Circular Buttons */
.hud-top-right {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  pointer-events: auto;
  z-index: 25;
}
.hud-circle-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(11, 18, 32, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #94a3b8;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}
.hud-circle-btn:hover, .hud-circle-btn:active {
  color: #00e5ff;
  border-color: rgba(0, 229, 255, 0.6);
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.35);
  transform: scale(1.05);
}

/* Floating Vertical Sliders */
.hud-vertical-rail {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 200px;
  background: rgba(11, 18, 32, 0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 8px 3px;
  pointer-events: auto;
  z-index: 22;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.6);
  transition: border-color 0.2s ease;
}
.hud-vertical-rail:hover {
  border-color: rgba(0, 229, 255, 0.35);
}
.hud-left-rail {
  left: 8px;
}
.hud-right-rail {
  right: 8px;
}
.hud-rail-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: #94a3b8;
}
.hud-rail-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 7.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #94a3b8;
}
.hud-rail-track-container {
  position: relative;
  width: 18px;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: none;
}
.hud-rail-track {
  position: absolute;
  width: 3.5px;
  height: 100%;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
  overflow: visible;
}
.hud-rail-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 0%;
  background: linear-gradient(to top, #2979ff, #00e5ff);
  border-radius: 3px;
  box-shadow: 0 0 6px rgba(0, 229, 255, 0.4);
}
.hud-rail-thumb {
  position: absolute;
  left: 50%;
  bottom: 0%;
  width: 13px;
  height: 13px;
  transform: translate(-50%, 50%);
  border-radius: 50%;
  background: #cbd5e1;
  border: 2px solid #0f172a;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.7);
  transition: background 0.15s ease, box-shadow 0.15s ease;
}
.hud-vertical-rail:hover .hud-rail-thumb,
.hud-rail-track-container.active .hud-rail-thumb {
  background: #00e5ff;
  box-shadow: 0 0 10px #00e5ff;
}
.hud-rail-range {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
.hud-rail-val-pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 8px;
  font-weight: 700;
  padding: 2px 4px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.06);
  color: #00e5ff;
  border: 1px solid rgba(255, 255, 255, 0.1);
  min-width: 22px;
  text-align: center;
}
.hud-rail-val-pill.is-paused {
  color: #ff9100;
  border-color: rgba(255, 145, 0, 0.3);
}
.hud-rail-val-pill.is-live {
  color: #00e5ff;
  border-color: rgba(0, 229, 255, 0.3);
}
.hud-rail-pause-btn {
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background: rgba(14, 23, 42, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #f1f5f9;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}
.hud-rail-pause-btn:hover {
  border-color: #00e5ff;
  color: #00e5ff;
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.3);
}

/* Bottom Controls Area */
.hud-bottom-area {
  position: absolute;
  bottom: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: auto;
  z-index: 25;
}
.hud-bottom-subrow {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  height: 36px;
}
.hud-aocs-trigger-pill {
  position: absolute;
  left: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 2px 8px;
  border-radius: 16px;
  background: rgba(11, 18, 32, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #f1f5f9;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  z-index: 2;
  max-width: 120px;
}
.hud-aocs-trigger-pill:hover, .hud-aocs-trigger-pill:active {
  border-color: rgba(0, 229, 255, 0.5);
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.3);
}
.aocs-trigger-icon {
  color: #00e5ff;
  font-size: 13px;
  flex-shrink: 0;
}
.aocs-trigger-text {
  display: flex;
  flex-direction: column;
  text-align: left;
  line-height: 1.1;
  min-width: 0;
}
.aocs-trigger-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 8px;
  font-weight: 800;
  color: #f1f5f9;
}
.aocs-trigger-sub {
  font-size: 6.5px;
  color: #64748b;
  letter-spacing: 0.2px;
  white-space: nowrap;
}
.aocs-trigger-chevron {
  color: #64748b;
  font-size: 11px;
  font-weight: 700;
  margin-left: auto;
}

/* Simulation Transport Cluster Centered */
.hud-sim-transport {
  position: absolute;
  left: 58%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  height: 32px;
  padding: 2px 4px;
  border-radius: 16px;
  background: rgba(11, 18, 32, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  z-index: 1;
}
.hud-transport-step {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}
.hud-transport-step:hover, .hud-transport-step:active {
  color: #f1f5f9;
  background: rgba(255, 255, 255, 0.08);
}
.hud-transport-pause {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 10px;
  border-radius: 13px;
  background: rgba(0, 229, 255, 0.12);
  border: 1.5px solid #00e5ff;
  color: #00e5ff;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.35);
  transition: all 0.2s ease;
}
.hud-transport-pause:hover, .hud-transport-pause:active {
  background: rgba(0, 229, 255, 0.22);
  box-shadow: 0 0 16px rgba(0, 229, 255, 0.55);
}
.hud-transport-pause.is-paused {
  background: rgba(255, 145, 0, 0.15);
  border-color: #ff9100;
  color: #ff9100;
  box-shadow: 0 0 12px rgba(255, 145, 0, 0.35);
}

/* Bottom Row: 4 Primary Mode Cards */
.hud-flight-modes-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 3px;
  width: 100%;
}
.hud-mode-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  padding: 4px 4px;
  height: 44px;
  border-radius: 7px;
  background: rgba(11, 18, 32, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
  min-width: 0;
  overflow: hidden;
}
.hud-mode-card:hover {
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(16, 26, 46, 0.9);
}
.hud-mode-card.active {
  background: rgba(0, 229, 255, 0.12) !important;
  border-color: #00e5ff !important;
  box-shadow: 0 0 14px rgba(0, 229, 255, 0.4) !important;
}
.mode-card-header {
  display: flex;
  align-items: center;
  gap: 3px;
  width: 100%;
}
.mode-card-icon {
  font-size: 9.5px;
  color: #94a3b8;
  flex-shrink: 0;
}
.hud-mode-card.active .mode-card-icon {
  color: #00e5ff;
}
.mode-card-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 7.2px;
  font-weight: 800;
  color: #f1f5f9;
  letter-spacing: 0.1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hud-mode-card.active .mode-card-title {
  color: #00e5ff;
}
.mode-card-sub {
  font-size: 6.5px;
  color: #64748b;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}
.hud-mode-card.active .mode-card-sub {
  color: #80f0ff;
}

/* Telemetry Drawer Slide-Over Panel */
.telemetry-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 9990;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.telemetry-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.telemetry-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(6, 11, 20, 0.98);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  position: sticky;
  top: 0;
  z-index: 10;
}
.drawer-header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}
.drawer-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 800;
  color: #00e5ff;
  letter-spacing: 0.5px;
}
.drawer-close-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #cbd5e1;
  padding: 4px 8px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}
.drawer-close-btn:hover {
  background: rgba(255, 23, 68, 0.2);
  border-color: #ff1744;
  color: #ff5252;
}

.telemetry-drawer-body {
  padding: 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

/* Avionics Dark Theme for ALL Drawer Elements (NEVER WHITE BUTTONS) */
.telemetry-drawer-body .tab-content,
.telemetry-drawer-body .card,
.telemetry-drawer-body .console-panel {
  background: rgba(11, 18, 32, 0.92) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  border-radius: 8px !important;
}
.telemetry-drawer-body .tab-header,
.telemetry-drawer-body .panel-header {
  background: rgba(15, 23, 42, 0.95) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
  padding: 8px 12px !important;
  font-family: 'JetBrains Mono', monospace !important;
  font-size: 10px !important;
  font-weight: 700 !important;
  color: #00e5ff !important;
}
.telemetry-drawer-body .btn,
.telemetry-drawer-body .btn-action,
.telemetry-drawer-body .mode-btn {
  background: rgba(15, 23, 42, 0.9) !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  color: #f1f5f9 !important;
  padding: 7px 12px !important;
  border-radius: 6px !important;
  font-family: 'JetBrains Mono', monospace !important;
  font-size: 9.5px !important;
  font-weight: 700 !important;
  cursor: pointer !important;
  transition: all 0.15s ease !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 6px !important;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4) !important;
}
.telemetry-drawer-body .btn:hover,
.telemetry-drawer-body .btn-action:hover,
.telemetry-drawer-body .mode-btn:hover {
  background: rgba(22, 36, 66, 0.95) !important;
  border-color: #00e5ff !important;
  color: #00e5ff !important;
}
.telemetry-drawer-body .btn.active,
.telemetry-drawer-body .btn-action.active,
.telemetry-drawer-body .mode-btn.active {
  background: rgba(0, 229, 255, 0.14) !important;
  border-color: #00e5ff !important;
  color: #00e5ff !important;
  box-shadow: 0 0 14px rgba(0, 229, 255, 0.35) !important;
}
.telemetry-drawer-body .btn-danger,
.telemetry-drawer-body #btn-estop {
  border-color: rgba(255, 23, 68, 0.4) !important;
  color: #ff5252 !important;
}
.telemetry-drawer-body .btn-danger:hover,
.telemetry-drawer-body #btn-estop:hover {
  background: rgba(255, 23, 68, 0.15) !important;
  border-color: #ff1744 !important;
  box-shadow: 0 0 10px rgba(255, 23, 68, 0.3) !important;
}

/* Immersive Fullscreen Mode */
body.immersive-fullscreen {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100% !important; height: 100dvh !important;
  height: 100dvh !important;
  z-index: 999999 !important;
  overflow: hidden !important;
  margin: 0 !important;
  padding: 0 !important;
  background: #02050b !important;
}
body.immersive-fullscreen .top-bar,
body.immersive-fullscreen .app-header {
  display: none !important;
}
body.immersive-fullscreen .app-layout {
  height: 100% !important;
  height: 100dvh !important;
  margin: 0 !important;
  padding: 0 !important;
}
body.immersive-fullscreen .live-sticky-screen {
  height: 100% !important;
  height: 100dvh !important;
}

/* Modal Overlay Styles */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-card {
  background: #0b1220;
  border: 1px solid rgba(0, 229, 255, 0.3);
  border-radius: 10px;
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  color: #00e5ff;
}
.modal-body {
  padding: 14px 16px;
  color: #cbd5e1;
  font-size: 11.5px;
  line-height: 1.6;
}
.modal-body h4 {
  color: #38bdf8;
  margin: 10px 0 4px 0;
  font-size: 12px;
}
.modal-body code {
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 4px;
  border-radius: 3px;
  color: #00e5ff;
  font-family: 'JetBrains Mono', monospace;
}

/* Responsive Mobile & Desktop Layout Rules */
@media (max-width: 900px) {
  html, body {
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important; height: 100dvh !important;
    height: 100dvh !important;
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
    position: relative !important;
    background: #02050b !important;
  }
  .top-bar, .app-header, .scada-header, header {
    display: none !important;
  }
  .app-layout {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    height: 100dvh !important;
    margin: 0 !important;
    padding: 0 !important;
    position: relative !important;
    overflow: hidden !important;
  }
  .left-workspace {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
  }
  .mimic-container, .live-sticky-screen {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    border: none !important;
    border-radius: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #02050b !important;
    overflow: hidden !important;
  }
  #process-canvas {
    width: 100% !important;
    height: 100% !important;
    display: block !important;
  }
  .trend-container {
    display: none !important;
  }

  .hud-overlay-layer {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    pointer-events: none !important;
  }
  
  /* Telemetry Drawer on Mobile (Slide-Over) */
  .telemetry-drawer {
    position: absolute !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 310px !important;
    max-width: 86vw !important;
    height: 100% !important;
    max-height: 100% !important;
    background: rgba(8, 14, 26, 0.96) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border-left: 1px solid rgba(0, 229, 255, 0.3) !important;
    box-shadow: -10px 0 35px rgba(0, 0, 0, 0.85) !important;
    z-index: 9995 !important;
    display: flex !important;
    flex-direction: column !important;
    transform: translateX(100%) !important;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1) !important;
    pointer-events: auto !important;
    margin: 0 !important;
  }
  .telemetry-drawer.open {
    transform: translateX(0) !important;
  }
  
  /* Remove old drawer action bar */
  .mobile-drawer-header,
  .mobile-drawer-pane {
    display: none !important;
  }
  .btn-tour-launcher {
    display: none !important;
  }
}

@media (min-width: 901px) {
  .hud-overlay-layer,
  .hud-vertical-rail,
  .hud-bottom-area,
  .telemetry-drawer-header,
  .telemetry-backdrop {
    display: none !important;
  }
  .telemetry-drawer {
    display: flex !important;
    position: static !important;
    transform: none !important;
    box-shadow: none !important;
    background: transparent !important;
    border: none !important;
  }
}

/* Clean Mobile HUD: Strictly hide desktop tour cards, launcher buttons, modal footers & headers */
@media (max-width: 900px) {
  .guide-modal-footer,
  .btn-guide-start,
  #tourCard,
  .tour-card,
  .tour-overlay,
  #btnTourLauncher,
  .btnTourLauncher,
  .tour-launcher-btn,
  .app-header,
  header.app-header,
  section.status-bar,
  footer {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }
}
