/* ============================================================
   OT HMI PORTFOLIO — STYLES
   2005-era Windows XP Embedded industrial workstation
   ============================================================ */

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #D4D0C8;
  font-family: Tahoma, "MS Sans Serif", Arial, sans-serif;
  font-size: 11px;
  color: #000;
  cursor: default;
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: grayscale;
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  cursor: default;
}

/* ============================================================
   BEVELED BORDER PRIMITIVES
   ============================================================ */
.raised {
  border-top: 1px solid #FFFFFF;
  border-left: 1px solid #FFFFFF;
  border-bottom: 1px solid #808080;
  border-right: 1px solid #808080;
}
.raised-2 {
  border-top: 2px solid;
  border-left: 2px solid;
  border-bottom: 2px solid;
  border-right: 2px solid;
  border-top-color: #FFFFFF;
  border-left-color: #FFFFFF;
  border-bottom-color: #404040;
  border-right-color: #404040;
  box-shadow: inset 1px 1px 0 #DFDFDF, inset -1px -1px 0 #808080;
}
.sunken {
  border-top: 1px solid #808080;
  border-left: 1px solid #808080;
  border-bottom: 1px solid #FFFFFF;
  border-right: 1px solid #FFFFFF;
  background: #B8B4AC;
}
.sunken-2 {
  border-top: 2px solid;
  border-left: 2px solid;
  border-bottom: 2px solid;
  border-right: 2px solid;
  border-top-color: #404040;
  border-left-color: #404040;
  border-bottom-color: #FFFFFF;
  border-right-color: #FFFFFF;
  box-shadow: inset 1px 1px 0 #808080, inset -1px -1px 0 #DFDFDF;
}

/* SCADA wrapper — transparent pass-through during normal use,
   gets clip-path + elevated z-index during the boot wipe */
#scada-wrapper {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none; /* children handle their own events */
}
#scada-wrapper > * {
  pointer-events: auto;
}

/* ============================================================
   TOP TITLE BAR
   ============================================================ */
#title-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 36px;
  background: #003366;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  font-family: Tahoma, sans-serif;
  font-weight: bold;
  font-size: 11px;
  padding: 0 8px;
  gap: 0;
  z-index: 100;
  border-bottom: 1px solid #000;
  user-select: none;
}
.tb-cell {
  padding: 0 12px;
  height: 100%;
  display: flex;
  align-items: center;
  border-right: 1px solid #1A4D80;
  border-left: 1px solid #00264D;
  white-space: nowrap;
}
.tb-cell:first-child { border-left: none; }
.tb-cell:last-child { border-right: none; }
.tb-logo {
  width: 22px; height: 22px;
  display: inline-block;
  margin-right: 8px;
  flex-shrink: 0;
}
.tb-title { flex: 1; font-size: 12px; letter-spacing: 0.5px; }
.tb-alarm {
  font-family: "Courier New", monospace;
  font-weight: bold;
  background: #CC0000;
  color: #FFFFFF;
}
.tb-alarm.has-alarm {
  animation: alarmPulse 0.7s steps(1) infinite;
}
@keyframes alarmPulse {
  0%, 50% { background: #CC0000; }
  51%, 100% { background: #990000; }
}
.tb-time, .tb-date {
  font-family: "Courier New", monospace;
  font-weight: bold;
  letter-spacing: 1px;
}

/* ============================================================
   ALARM BANNER
   ============================================================ */
#alarm-banner {
  position: fixed;
  top: 36px; left: 0; right: 0;
  height: 0;
  overflow: hidden;
  background: #FFAA00;
  color: #000;
  font-family: "Courier New", monospace;
  font-size: 10px;
  font-weight: bold;
  display: flex;
  align-items: center;
  padding: 0 8px;
  gap: 12px;
  z-index: 99;
  border-bottom: 1px solid #806000;
  transition: height 0.1s;
}
#alarm-banner.active {
  height: 22px;
}
#alarm-banner.flashing {
  animation: bannerFlash 0.4s steps(1) 3;
}
@keyframes bannerFlash {
  0%, 50% { background: #FFAA00; }
  51%, 100% { background: #FFD580; }
}
#alarm-banner .alm-icon { font-size: 12px; }
#alarm-banner .alm-sep { color: #806000; }
#alarm-banner .alm-ack {
  margin-left: auto;
  padding: 1px 10px;
  background: #C8C4BC;
  font-family: Tahoma, sans-serif;
  font-size: 10px;
  font-weight: bold;
}

/* ============================================================
   BOTTOM STATUS BAR
   ============================================================ */
#status-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 24px;
  background: #C8C4BC;
  border-top: 1px solid #FFFFFF;
  display: flex;
  align-items: center;
  font-family: "Courier New", monospace;
  font-size: 10px;
  z-index: 100;
  user-select: none;
}
.sb-cell {
  height: 100%;
  display: flex;
  align-items: center;
  padding: 0 10px;
  border-left: 1px solid #FFFFFF;
  border-right: 1px solid #808080;
}
.sb-cell:first-child { border-left: none; }
.sb-cell:last-child { border-right: none; flex: 1; }
.sb-led {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #00AA00;
  margin-right: 5px;
  box-shadow: 0 0 2px #00FF00;
}

/* ============================================================
   MAIN CANVAS — PROCESS DIAGRAM
   ============================================================ */
#main-canvas {
  position: fixed;
  top: 36px; left: 0; right: 0; bottom: 24px;
  background-color: #D4D0C8;
  background-image:
    radial-gradient(circle, #B8B4AC 1px, transparent 1px);
  background-size: 20px 20px;
  background-position: 0 0;
  overflow: hidden;
  cursor: grab;
}
#main-canvas.dragging { cursor: grabbing; }
#pid-viewport {
  position: absolute;
  top: 0; left: 0;
  transform-origin: 0 0;
  will-change: transform;
}
#pid-svg {
  width: 1400px;
  height: 760px;
  display: block;
}

/* ── Zoom bar ── */
#zoom-bar {
  position: absolute;
  bottom: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  gap: 5px;
  background: #D4D0C8;
  border: 1px solid;
  border-color: #DFDFDF #808080 #808080 #DFDFDF;
  padding: 3px 6px 3px 5px;
  z-index: 10;
  user-select: none;
}
#zoom-bar .zb-btn {
  font-family: 'Courier New', monospace;
  font-size: 9px;
  font-weight: bold;
  background: #D4D0C8;
  border: 1px solid;
  border-color: #DFDFDF #808080 #808080 #DFDFDF;
  padding: 1px 5px;
  cursor: default;
  color: #000;
}
#zoom-bar .zb-btn:active {
  border-color: #808080 #DFDFDF #DFDFDF #808080;
}
#zoom-slider {
  width: 90px;
  height: 12px;
  cursor: default;
  accent-color: #005A9E;
}
#zoom-pct {
  font-family: 'Courier New', monospace;
  font-size: 9px;
  font-weight: bold;
  color: #000080;
  min-width: 36px;
  text-align: right;
}

/* SVG equipment styling */
.equipment {
  cursor: pointer;
}
.equipment .eq-fill { fill: #C8C4BC; stroke: #404040; stroke-width: 1.5; }
.equipment .eq-fill-light { fill: #DFDBD3; stroke: #404040; stroke-width: 1.5; }
.equipment .eq-line { stroke: #404040; stroke-width: 1.5; fill: none; }
.equipment .eq-thin { stroke: #404040; stroke-width: 1; fill: none; }
.equipment .eq-label {
  font-family: "Courier New", monospace;
  font-size: 13px;
  font-weight: bold;
  fill: #FFFFFF;
  text-anchor: middle;
  pointer-events: none;
}
.equipment .eq-sublabel {
  font-family: Tahoma, sans-serif;
  font-size: 11px;
  fill: #FFFFFF;
  text-anchor: middle;
  pointer-events: none;
}
.equipment .eq-label-bg {
  fill: #CC0000;
  stroke: #800000;
  stroke-width: 1;
  pointer-events: none;
}
.equipment:hover .eq-hover-target,
.equipment.hovered .eq-hover-target {
  stroke: #005A9E;
  stroke-width: 2;
}
#eq-PLC401:hover .eq-hover-target,
#eq-SW501:hover .eq-hover-target {
  stroke: #CC0000;
}

/* Pipes */
.pipe {
  stroke: #4A4A4A;
  stroke-width: 2;
  fill: none;
}
.pipe-flow {
  stroke: #005A9E;
  stroke-width: 2;
  fill: none;
  stroke-dasharray: 8 4;
  animation: flowDash 1.2s linear infinite;
}
.pipe-flow.pressure {
  stroke: #CC0000;
}
@keyframes flowDash {
  to { stroke-dashoffset: -12; }
}
.pipe-junction { fill: #4A4A4A; }
.pipe-arrow { fill: #4A4A4A; }

/* Instrument bubbles */
.inst-bubble circle {
  fill: #FFFFFF;
  stroke: #4A4A4A;
  stroke-width: 1.2;
}
.inst-bubble text {
  font-family: "Courier New", monospace;
  font-size: 9px;
  font-weight: bold;
  fill: #000080;
  text-anchor: middle;
  pointer-events: none;
}
.inst-bubble line { stroke: #4A4A4A; stroke-width: 1; }

/* Reactor pulse */
@keyframes reactorPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.65; }
}
#eq-R201 .reactor-outline {
  animation: reactorPulse 4s ease-in-out infinite;
}

/* PLC blinking LED */
@keyframes ledBlink {
  0%, 49% { fill: #00DD00; }
  50%, 100% { fill: #003300; }
}
.plc-led {
  animation: ledBlink 1s steps(1) infinite;
}

/* ============================================================
   TOOLTIP
   ============================================================ */
#tooltip {
  position: fixed;
  display: none;
  background: #003366;
  color: #FFFFFF;
  font-family: "Courier New", monospace;
  font-size: 10px;
  padding: 4px 8px;
  pointer-events: none;
  z-index: 500;
  white-space: pre;
  line-height: 1.45;
  border-top: 1px solid #4080C0;
  border-left: 1px solid #4080C0;
  border-bottom: 1px solid #001A33;
  border-right: 1px solid #001A33;
}
#tooltip .tt-key { color: #80C0FF; }

/* ============================================================
   FACEPLATE MODAL
   ============================================================ */
#faceplate-overlay {
  position: fixed;
  top: 36px; left: 0; right: 0; bottom: 24px;
  z-index: 800;
  pointer-events: none;
}
#faceplate-overlay.active { pointer-events: auto; }
#faceplate-overlay .fp-clickaway {
  position: absolute;
  inset: 0;
}
.faceplate {
  position: absolute;
  width: 720px;
  background: #D4D0C8;
  font-family: Tahoma, sans-serif;
  font-size: 11px;
  display: none;
  flex-direction: column;
  max-height: calc(100vh - 80px);
  outline: 2px solid #000000;
  box-shadow: 4px 4px 0px #505050;
}
.faceplate.open { display: flex; }
.fp-titlebar {
  height: 22px;
  background: linear-gradient(to bottom, #0A4480 0%, #003366 100%);
  color: #FFFFFF;
  font-family: Tahoma, sans-serif;
  font-weight: bold;
  font-size: 11px;
  display: flex;
  align-items: center;
  padding: 0 4px 0 6px;
  cursor: move;
  user-select: none;
  flex-shrink: 0;
  border-bottom: 2px solid #CC0000;
}
.fp-titlebar .fp-title { flex: 1; letter-spacing: 0.3px; }
.fp-titlebar .fp-x {
  width: 18px; height: 18px;
  background: #C8C4BC;
  color: #000;
  font-family: "Marlett", "Courier New", monospace;
  font-size: 10px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  border-top: 1px solid #FFFFFF;
  border-left: 1px solid #FFFFFF;
  border-bottom: 1px solid #404040;
  border-right: 1px solid #404040;
  padding: 0;
  line-height: 1;
}
.fp-titlebar .fp-x:active {
  border-top: 1px solid #404040;
  border-left: 1px solid #404040;
  border-bottom: 1px solid #FFFFFF;
  border-right: 1px solid #FFFFFF;
}
.fp-body {
  padding: 8px 8px 4px 8px;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  background: #D4D0C8;
}
.fp-body::-webkit-scrollbar { width: 16px; }
.fp-body::-webkit-scrollbar-track {
  background: #C8C4BC;
  border-left: 1px solid #808080;
}
.fp-body::-webkit-scrollbar-thumb {
  background: #C8C4BC;
  border-top: 1px solid #FFFFFF;
  border-left: 1px solid #FFFFFF;
  border-bottom: 1px solid #404040;
  border-right: 1px solid #404040;
}
.fp-footer {
  display: flex;
  gap: 4px;
  padding: 6px 8px;
  border-top: 1px solid #808080;
  background: #D4D0C8;
  flex-shrink: 0;
}
.fp-footer .spacer { flex: 1; }

/* Group box (fieldset) */
.gbox {
  position: relative;
  margin: 12px 0 8px 0;
  padding: 10px 8px 8px 8px;
  border-top: 1px solid #808080;
  border-left: 1px solid #808080;
  border-bottom: 1px solid #FFFFFF;
  border-right: 1px solid #FFFFFF;
}
.gbox-title {
  position: absolute;
  top: -7px;
  left: 8px;
  background: #D4D0C8;
  padding: 0 4px;
  font-family: Tahoma, sans-serif;
  font-size: 11px;
  font-weight: bold;
  color: #000080;
}

/* Readout field row */
.rd-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 6px;
  margin-bottom: 4px;
  align-items: center;
}
.rd-label {
  font-family: Tahoma, sans-serif;
  font-size: 11px;
  font-weight: bold;
  color: #1A1A1A;
  text-align: right;
  padding-right: 4px;
}
.rd-value {
  background: #FFFFFF;
  border-top: 1px solid #808080;
  border-left: 1px solid #808080;
  border-bottom: 1px solid #DFDFDF;
  border-right: 1px solid #DFDFDF;
  font-family: "Courier New", monospace;
  font-size: 12px;
  font-weight: bold;
  color: #000080;
  padding: 3px 6px;
  height: 22px;
  display: flex;
  align-items: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rd-value.status-ok { color: #008800; }
.rd-value.status-warn { color: #B86A00; }

/* HMI pushbutton */
.btn {
  background: #C8C4BC;
  border-top: 1px solid #FFFFFF;
  border-left: 1px solid #FFFFFF;
  border-bottom: 1px solid #404040;
  border-right: 1px solid #404040;
  box-shadow: inset 1px 1px 0 #DFDFDF, inset -1px -1px 0 #808080;
  padding: 3px 14px;
  font-family: Tahoma, sans-serif;
  font-size: 11px;
  font-weight: bold;
  color: #000;
  min-width: 64px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  user-select: none;
}
.btn:active, .btn.pressed {
  border-top: 1px solid #404040;
  border-left: 1px solid #404040;
  border-bottom: 1px solid #FFFFFF;
  border-right: 1px solid #FFFFFF;
  box-shadow: inset 1px 1px 0 #808080, inset -1px -1px 0 #DFDFDF;
  padding: 4px 13px 2px 15px;
}
.btn.btn-sm { padding: 1px 8px; min-width: 0; font-size: 10px; }
.btn.btn-sm:active { padding: 2px 7px 0 9px; }

/* Sunken text area / notepad */
.notepad {
  background: #FFFFFF;
  border-top: 1px solid #808080;
  border-left: 1px solid #808080;
  border-bottom: 1px solid #DFDFDF;
  border-right: 1px solid #DFDFDF;
  padding: 6px 8px;
  font-family: Tahoma, sans-serif;
  font-size: 11px;
  color: #000;
  line-height: 1.5;
  max-height: 110px;
  overflow-y: auto;
}

/* HMI table */
.hmi-table {
  width: 100%;
  background: #FFFFFF;
  border-top: 1px solid #808080;
  border-left: 1px solid #808080;
  border-bottom: 1px solid #DFDFDF;
  border-right: 1px solid #DFDFDF;
  border-collapse: collapse;
  font-family: "Courier New", monospace;
  font-size: 11px;
}
.hmi-table thead th {
  background: #C8C4BC;
  border-top: 1px solid #FFFFFF;
  border-left: 1px solid #FFFFFF;
  border-bottom: 1px solid #808080;
  border-right: 1px solid #808080;
  padding: 3px 6px;
  text-align: left;
  font-weight: bold;
  font-family: Tahoma, sans-serif;
  font-size: 10px;
  color: #000080;
}
.hmi-table tbody td {
  padding: 4px 6px;
  border-bottom: 1px dotted #808080;
  vertical-align: top;
  color: #000080;
}
.hmi-table tbody tr {
  cursor: default;
}
.hmi-table tbody tr.expandable { cursor: pointer; }
.hmi-table tbody tr.expandable:hover { background: #E8E4DC; }
.hmi-table tbody tr.expanded { background: #E0DCD4; }
.hmi-table .led {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
  border: 1px solid #404040;
}
.hmi-table .led.green { background: #00AA00; box-shadow: 0 0 2px #00FF00; }
.hmi-table .led.blue { background: #005A9E; box-shadow: 0 0 2px #00AAFF; }
.hmi-table .led.amber { background: #FFAA00; box-shadow: 0 0 2px #FFCC00; }
.hmi-table tr.detail-row td {
  background: #F4F0E8;
  font-family: Tahoma, sans-serif;
  font-size: 11px;
  color: #000;
  padding: 8px 12px 10px 24px;
  border-bottom: 1px solid #808080;
}
.hmi-table tr.detail-row ul { margin: 0; padding-left: 16px; }
.hmi-table tr.detail-row li { margin-bottom: 2px; }
.hmi-table tr.detail-row .alarm-detail {
  font-family: "Courier New", monospace;
  color: #1A1A1A;
}

/* Batch record card (Projects) */
.batch-card {
  background: #FFFFFF;
  border-top: 1px solid #808080;
  border-left: 1px solid #808080;
  border-bottom: 1px solid #DFDFDF;
  border-right: 1px solid #DFDFDF;
  margin-bottom: 8px;
  padding: 8px 10px;
}
.batch-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: "Courier New", monospace;
  font-size: 10px;
  color: #000080;
  border-bottom: 1px dotted #808080;
  padding-bottom: 4px;
  margin-bottom: 6px;
}
.batch-head .batch-status.complete { color: #008800; font-weight: bold; }
.batch-head .batch-status.progress { color: #B86A00; font-weight: bold; }
.batch-name {
  font-family: Tahoma, sans-serif;
  font-weight: bold;
  font-size: 13px;
  color: #000;
  margin-bottom: 4px;
}
.batch-row {
  font-family: "Courier New", monospace;
  font-size: 10px;
  color: #1A1A1A;
  margin-bottom: 4px;
}
.batch-row .lbl { color: #000080; font-weight: bold; }
.batch-desc {
  font-family: Tahoma, sans-serif;
  font-size: 11px;
  color: #000;
  background: #F4F0E8;
  padding: 4px 6px;
  border: 1px solid #C8C4BC;
  margin: 4px 0;
  line-height: 1.4;
}
.batch-actions {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}

/* Level indicator (Cert validity bar) */
.level-bar {
  width: 100%;
  height: 14px;
  background: #FFFFFF;
  border-top: 1px solid #808080;
  border-left: 1px solid #808080;
  border-bottom: 1px solid #DFDFDF;
  border-right: 1px solid #DFDFDF;
  position: relative;
  overflow: hidden;
}
.level-bar .level-fill {
  height: 100%;
  background: repeating-linear-gradient(90deg, #00AA00 0 6px, #008800 6px 8px);
  transition: width 0.4s;
}
.level-bar.amber .level-fill {
  background: repeating-linear-gradient(90deg, #FFAA00 0 6px, #CC8800 6px 8px);
}
.level-bar .level-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Courier New", monospace;
  font-size: 9px;
  font-weight: bold;
  color: #000;
  text-shadow: 0 0 2px #FFF;
}

/* I/O Module rows (Skills) */
.io-module {
  background: #C8C4BC;
  border-top: 1px solid #FFFFFF;
  border-left: 1px solid #FFFFFF;
  border-bottom: 1px solid #808080;
  border-right: 1px solid #808080;
  margin-bottom: 6px;
}
.io-module-head {
  display: flex;
  align-items: center;
  padding: 4px 8px;
  font-family: Tahoma, sans-serif;
  font-weight: bold;
  font-size: 11px;
  color: #000080;
  border-bottom: 1px solid #808080;
  background: linear-gradient(to bottom, #DFDBD3, #C8C4BC);
}
.io-module-head .io-led {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #00AA00;
  margin-right: 8px;
  border: 1px solid #404040;
  box-shadow: 0 0 3px #00FF00;
}
.io-module-head .io-slot {
  font-family: "Courier New", monospace;
  font-size: 10px;
  color: #1A1A1A;
  margin-left: auto;
}
.io-channels {
  background: #FFFFFF;
  padding: 4px 8px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2px 12px;
}
.io-channel {
  display: grid;
  grid-template-columns: 14px 1fr 50px;
  align-items: center;
  font-family: "Courier New", monospace;
  font-size: 11px;
  padding: 1px 0;
}
.io-channel .ch-box {
  width: 10px; height: 10px;
  border-top: 1px solid #808080;
  border-left: 1px solid #808080;
  border-bottom: 1px solid #DFDFDF;
  border-right: 1px solid #DFDFDF;
  background: #FFFFFF;
}
.io-channel.proficient .ch-box { background: #000080; }
.io-channel .ch-name { color: #000; padding-left: 4px; }
.io-channel .ch-val {
  font-family: "Courier New", monospace;
  font-size: 10px;
  color: #000080;
  text-align: right;
  background: #F0F0F0;
  border-top: 1px solid #808080;
  border-left: 1px solid #808080;
  border-bottom: 1px solid #DFDFDF;
  border-right: 1px solid #DFDFDF;
  padding: 0 3px;
}

/* Signal status row (Contact) */
.signal-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 0;
  font-family: "Courier New", monospace;
  font-size: 11px;
  border-bottom: 1px dotted #808080;
}
.signal-row:last-child { border-bottom: none; }
.signal-row .sig-name { font-weight: bold; color: #000080; }
.signal-row .sig-status {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #008800;
  font-weight: bold;
}
.signal-row .sig-led {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #00AA00;
  box-shadow: 0 0 3px #00FF00;
}

/* ============================================================
   MOBILE — FIELD DEVICE
   ============================================================ */
#mobile-shell { display: none; }

@media (max-width: 1023px) {
  #title-bar, #status-bar, #main-canvas, #faceplate-overlay { display: none; }
  #mobile-shell { display: flex; }
}
@media (min-width: 1024px) {
  #mobile-shell { display: none !important; }
}

#mobile-shell {
  position: fixed;
  inset: 0;
  flex-direction: column;
  background: #1A1A1A;
  padding: 0;
}

.fd-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #D4D0C8;
  border-top: 3px solid #003366;
  overflow: hidden;
}

/* ── Top bar ── */
.fd-topbar {
  height: 52px;
  min-height: 52px;
  background: #003366;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  font-family: Tahoma, sans-serif;
  font-weight: bold;
  font-size: 13px;
  padding: 0 10px;
  gap: 10px;
  flex-shrink: 0;
  border-bottom: 2px solid #001A33;
}
.fd-menu-btn {
  background: transparent;
  color: #80C0FF;
  border: 1px solid #4080C0;
  font-family: "Courier New", monospace;
  font-size: 11px;
  font-weight: bold;
  padding: 8px 12px;
  letter-spacing: 0.5px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(128,192,255,0.2);
}
.fd-menu-btn:active { background: rgba(128,192,255,0.15); }
.fd-title {
  flex: 1;
  font-family: "Courier New", monospace;
  font-size: 12px;
  letter-spacing: 0.5px;
  text-align: center;
}
.fd-batt {
  font-family: "Courier New", monospace;
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.fd-batt-bar {
  width: 40px;
  height: 14px;
  background: #001A33;
  border: 1px solid #80A0C0;
  display: flex;
  gap: 1px;
  padding: 2px;
}
.fd-batt-bar i { flex: 1; background: #00FF00; }
.fd-batt-bar i.empty { background: transparent; }

/* ── Breadcrumb ── */
.fd-breadcrumb {
  height: 32px;
  background: #B8B4AC;
  border-top: 1px solid #FFFFFF;
  border-bottom: 1px solid #808080;
  font-family: "Courier New", monospace;
  font-size: 11px;
  color: #1A1A1A;
  display: flex;
  align-items: center;
  padding: 0 12px;
  flex-shrink: 0;
}
.fd-breadcrumb .crumb-cur { color: #000080; font-weight: bold; }

/* ── Scrollable body ── */
.fd-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: #D4D0C8;
}
.fd-body::-webkit-scrollbar { width: 0; }

/* ── Minimap (collapsible) ── */
.fd-minimap {
  background: #FFFFFF;
  border-bottom: 1px solid #808080;
}
.fd-minimap-title {
  font-family: "Courier New", monospace;
  font-size: 10px;
  font-weight: bold;
  color: #FFFFFF;
  background: #003366;
  letter-spacing: 0.5px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(128,192,255,0.15);
  user-select: none;
}
.fd-minimap-title::after {
  content: '▾';
  font-size: 13px;
  transition: transform 0.2s;
}
.fd-minimap.collapsed .fd-minimap-title::after { transform: rotate(-90deg); }
.fd-minimap-body { padding: 6px 8px 8px; }
.fd-minimap.collapsed .fd-minimap-body { display: none; }
.fd-minimap svg {
  width: 100%;
  height: 80px;
  display: block;
  background-color: #D4D0C8;
  background-image: radial-gradient(circle, #B8B4AC 0.5px, transparent 0.5px);
  background-size: 10px 10px;
}

/* ── Tag list ── */
.fd-list { display: flex; flex-direction: column; }
.fd-tag-row {
  min-height: 72px;
  display: grid;
  grid-template-columns: 30px 1fr auto;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid #808080;
  background: #D4D0C8;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(0,0,0,0.05);
}
.fd-tag-row:nth-child(even) { background: #C8C4BC; }
.fd-tag-row .fd-tag-led {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #00AA00;
  border: 1px solid #404040;
  box-shadow: 0 0 5px #00FF00;
}
.fd-tag-info { display: flex; flex-direction: column; gap: 2px; }
.fd-tag-id {
  font-family: "Courier New", monospace;
  font-weight: bold;
  font-size: 15px;
  color: #000080;
  letter-spacing: 0.5px;
}
.fd-tag-desc {
  font-family: Tahoma, sans-serif;
  font-size: 13px;
  color: #000;
}
.fd-tag-section {
  font-family: "Courier New", monospace;
  font-size: 10px;
  color: #4A4A4A;
  letter-spacing: 0.5px;
}
.fd-open-btn {
  min-height: 44px;
  min-width: 70px;
  background: #C8C4BC;
  border-top: 2px solid #FFFFFF;
  border-left: 2px solid #FFFFFF;
  border-bottom: 2px solid #404040;
  border-right: 2px solid #404040;
  font-family: "Courier New", monospace;
  font-weight: bold;
  font-size: 12px;
  padding: 8px 14px;
  color: #000080;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(0,0,0,0.1);
}
.fd-open-btn:active {
  border-top: 2px solid #404040;
  border-left: 2px solid #404040;
  border-bottom: 2px solid #FFFFFF;
  border-right: 2px solid #FFFFFF;
}

/* ── Detail screen ── */
.fd-detail {
  display: none;
  flex-direction: column;   /* JS sets display:flex → becomes a column stack */
  padding: 0;
}

/* Full-width sticky header inside detail */
.fd-detail-header {
  background: #003366;
  color: #FFFFFF;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  font-weight: bold;
  letter-spacing: 0.5px;
  padding: 10px 14px;
  flex-shrink: 0;
  border-bottom: 2px solid #001A33;
}

/* Scrollable content area */
#fd-detail-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
}

/* ── Function key bar ── */
.fd-fkeys {
  height: 60px;
  display: flex;
  background: #808080;
  border-top: 2px solid #C8C4BC;
  flex-shrink: 0;
}
.fd-fkey {
  flex: 1;
  background: #C8C4BC;
  border-top: 2px solid #FFFFFF;
  border-left: 1px solid #FFFFFF;
  border-bottom: 2px solid #404040;
  border-right: 1px solid #404040;
  font-family: "Courier New", monospace;
  font-size: 11px;
  font-weight: bold;
  color: #000;
  margin: 4px 2px;
  padding: 0 4px;
  letter-spacing: 0.5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(0,0,0,0.1);
}
.fd-fkey:active, .fd-fkey.pressed {
  border-top: 2px solid #404040;
  border-left: 1px solid #404040;
  border-bottom: 2px solid #FFFFFF;
  border-right: 1px solid #FFFFFF;
}
.fd-fkey .fk-num {
  display: block;
  font-size: 9px;
  color: #000080;
}
.fd-fkey:disabled { color: #A0A0A0; opacity: 0.5; }

/* ── Mobile alarm banner ── */
#mobile-alarm-banner {
  height: 0;
  overflow: hidden;
  background: #FFAA00;
  color: #000;
  font-family: "Courier New", monospace;
  font-size: 11px;
  font-weight: bold;
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 10px;
  flex-shrink: 0;
  border-bottom: 1px solid #806000;
  transition: height 0.15s;
}
#mobile-alarm-banner.active { height: 38px; }
#mobile-alarm-banner.flashing { animation: bannerFlash 0.4s steps(1) 3; }
#mobile-alarm-banner .alm-ack {
  margin-left: auto;
  padding: 7px 14px;
  background: #C8C4BC;
  font-family: Tahoma, sans-serif;
  font-size: 11px;
  font-weight: bold;
  border-top: 1px solid #FFFFFF;
  border-left: 1px solid #FFFFFF;
  border-bottom: 1px solid #404040;
  border-right: 1px solid #404040;
  touch-action: manipulation;
}

/* ── Mobile overrides for shared components rendered inside fd-detail ── */
@media (max-width: 1023px) {
  /* Hide desktop scrollbar */
  .fp-body::-webkit-scrollbar { width: 0; }

  /* ── Tabs: full-width, finger-friendly ── */
  .fp-tabs {
    padding: 0;
    gap: 0;
    border-bottom: 2px solid #808080;
    flex-shrink: 0;
  }
  .fp-tab {
    flex: 1;
    text-align: center;
    padding: 13px 4px;
    font-size: 12px;
    bottom: 0;
    border-right: 1px solid #808080;
  }
  .fp-tab:last-child { border-right: none; }
  .fp-tab.active {
    border-bottom: 3px solid #003366;
    background: #D4D0C8;
    color: #000080;
  }

  /* ── Tab panes get their own padding (container has none) ── */
  .fp-tab-pane { padding: 10px; }

  /* ── Tables: horizontal scroll so columns don't break layout ── */
  .fp-tab-pane .hmi-table,
  .fp-tab-pane table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    max-width: 100%;
  }
  /* Let detail rows inside the table wrap normally */
  .fp-tab-pane .alarm-detail,
  .fp-tab-pane .detail-row td {
    white-space: normal;
  }

  /* ── Group boxes ── */
  .gbox { margin: 16px 0 8px; padding: 14px 10px 10px; }
  .gbox-title { font-size: 10px; }

  /* ── Readout rows: stack label above value on narrow screens ── */
  .rd-row {
    grid-template-columns: 1fr;
    gap: 2px;
    margin-bottom: 8px;
  }
  .rd-label { text-align: left; font-size: 11px; }
  .rd-value { font-size: 14px; height: auto; min-height: 36px; padding: 7px 10px; white-space: normal; }

  /* ── Buttons ── */
  .btn { min-height: 44px; font-size: 12px; padding: 10px 18px; touch-action: manipulation; }

  /* ── Control widgets ── */
  .ctrl-btn-start, .ctrl-btn-stop {
    min-height: 52px; font-size: 14px; padding: 14px 28px;
    touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  }
  .ctrl-mode-group { flex-wrap: wrap; gap: 6px; }
  .ctrl-mode-btn {
    min-height: 44px; min-width: 72px; font-size: 12px; padding: 10px 14px;
    touch-action: manipulation;
  }
  .ctrl-port-row {
    display: flex; flex-wrap: wrap; gap: 8px;
    align-items: center; padding: 10px 0;
    border-bottom: 1px solid #C0C0C0;
  }
  .ctrl-port-label { flex: 0 0 60px; font-size: 12px; }
  .ctrl-port-status { flex: 1; }
  .ctrl-rv-row { grid-template-columns: 110px 1fr; margin-bottom: 8px; }
  .ctrl-rv-label { font-size: 12px; }
  .ctrl-readout { font-size: 16px; padding: 6px; }
  .ctrl-sp-row { grid-template-columns: 100px 1fr 60px; gap: 6px; margin-bottom: 10px; }
  input[type="range"].ctrl-slider { height: 36px; }
  .notepad { font-size: 13px; line-height: 1.7; padding: 10px; }

  /* ── Photo pane ── */
  .photo-reveal-img { width: 150px; height: 150px; }
  .photo-id-tag { width: 154px; }
  .photo-pane { padding: 14px 10px 10px; }
}

/* ============================================================
   BOOT SEQUENCE OVERLAY  — matches HMI theme
   ============================================================ */
#boot-overlay {
  position: fixed;
  inset: 0;
  background-color: #D4D0C8;
  background-image: radial-gradient(circle, #B8B4AC 1px, transparent 1px);
  background-size: 20px 20px;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}
#boot-screen {
  width: 680px;
  max-width: 95vw;
  background: #D4D0C8;
  border-top: 2px solid #FFFFFF;
  border-left: 2px solid #FFFFFF;
  border-bottom: 2px solid #404040;
  border-right: 2px solid #404040;
  box-shadow: inset 1px 1px 0 #DFDFDF, inset -1px -1px 0 #808080, 4px 4px 0 #505050;
  display: flex;
  flex-direction: column;
}
#boot-header {
  height: 22px;
  background: linear-gradient(to bottom, #0A4480 0%, #003366 100%);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  padding: 0 6px;
  gap: 8px;
  border-bottom: 2px solid #CC0000;
  font-family: Tahoma, sans-serif;
  font-weight: bold;
  font-size: 11px;
  flex-shrink: 0;
  user-select: none;
}
#boot-logo {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
#boot-title {
  font-size: 11px;
  letter-spacing: 0.3px;
}
#boot-separator-top {
  border-top: 1px solid #808080;
  border-bottom: 1px solid #FFFFFF;
  height: 2px;
  margin: 6px 8px 2px;
  flex-shrink: 0;
}
#boot-separator-bot {
  border-top: 1px solid #808080;
  border-bottom: 1px solid #FFFFFF;
  height: 2px;
  margin: 2px 8px 0;
  flex-shrink: 0;
}
#boot-log {
  margin: 0;
  padding: 4px 12px 6px;
  font-family: "Courier New", monospace;
  font-size: 11px;
  color: #1A1A1A;
  white-space: pre-wrap;
  background: #FFFFFF;
  border-top: 1px solid #808080;
  border-left: 1px solid #808080;
  border-bottom: 1px solid #DFDFDF;
  border-right: 1px solid #DFDFDF;
  margin: 0 8px 4px;
}
#boot-ready {
  margin: 0 8px 8px;
  padding: 4px 12px 6px;
  font-family: "Courier New", monospace;
  font-size: 11px;
  font-weight: bold;
  color: #000080;
  white-space: pre-wrap;
  background: #E8F4E8;
  border-top: 1px solid #808080;
  border-left: 1px solid #808080;
  border-bottom: 1px solid #DFDFDF;
  border-right: 1px solid #DFDFDF;
}
.boot-line {
  line-height: 1.6;
  color: #1A1A1A;
}
.boot-line .bl-ok {
  color: #008800;
  font-weight: bold;
}
#boot-progress-wrap {
  padding: 0 8px 4px;
  flex-shrink: 0;
}
#boot-progress-label {
  font-family: Tahoma, sans-serif;
  font-size: 11px;
  font-weight: bold;
  color: #000080;
  margin-bottom: 4px;
  letter-spacing: 0.5px;
}
#boot-progressbar {
  height: 18px;
  background: #FFFFFF;
  border-top: 1px solid #808080;
  border-left: 1px solid #808080;
  border-bottom: 1px solid #DFDFDF;
  border-right: 1px solid #DFDFDF;
  position: relative;
  overflow: hidden;
}
#boot-progress-fill {
  height: 100%;
  width: 0%;
  background: repeating-linear-gradient(90deg, #00AA00 0 6px, #008800 6px 8px);
  transition: width 0.05s linear;
}
#boot-progress-pct {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Courier New", monospace;
  font-size: 10px;
  font-weight: bold;
  color: #000080;
  text-shadow: 0 0 2px #FFF;
  pointer-events: none;
}

/* ============================================================
   FACEPLATE TAB BAR
   ============================================================ */
.fp-tabs {
  display: flex;
  background: #B8B4AC;
  border-bottom: 2px solid #808080;
  padding: 4px 6px 0;
  gap: 2px;
  flex-shrink: 0;
  user-select: none;
}
.fp-tab {
  padding: 3px 18px;
  background: #C8C4BC;
  border-top: 1px solid #FFFFFF;
  border-left: 1px solid #FFFFFF;
  border-bottom: none;
  border-right: 1px solid #808080;
  font-family: Tahoma, sans-serif;
  font-size: 11px;
  font-weight: bold;
  color: #000;
  cursor: default;
  position: relative;
  bottom: -1px;
}
.fp-tab.active {
  background: #D4D0C8;
  border-bottom: 2px solid #D4D0C8;
  z-index: 1;
  color: #000080;
}
.fp-tab:not(.active):hover {
  background: #D0CCC4;
}

/* ============================================================
   CONTROL WIDGET STYLES
   ============================================================ */

/* Start / Stop pushbuttons */
.ctrl-btn-start {
  background: #003300;
  color: #00EE00;
  border-top: 1px solid #006600;
  border-left: 1px solid #006600;
  border-bottom: 1px solid #001100;
  border-right: 1px solid #001100;
  font-family: Tahoma, sans-serif;
  font-size: 11px;
  font-weight: bold;
  padding: 4px 18px;
  min-width: 88px;
  letter-spacing: 0.5px;
}
.ctrl-btn-start:active {
  border-top: 1px solid #001100;
  border-left: 1px solid #001100;
  border-bottom: 1px solid #006600;
  border-right: 1px solid #006600;
  padding: 5px 17px 3px 19px;
}
.ctrl-btn-stop {
  background: #330000;
  color: #FF4444;
  border-top: 1px solid #880000;
  border-left: 1px solid #880000;
  border-bottom: 1px solid #110000;
  border-right: 1px solid #110000;
  font-family: Tahoma, sans-serif;
  font-size: 11px;
  font-weight: bold;
  padding: 4px 18px;
  min-width: 88px;
  letter-spacing: 0.5px;
}
.ctrl-btn-stop:active {
  border-top: 1px solid #110000;
  border-left: 1px solid #110000;
  border-bottom: 1px solid #880000;
  border-right: 1px solid #880000;
  padding: 5px 17px 3px 19px;
}

/* Mode selector group */
.ctrl-mode-group {
  display: flex;
  gap: 0;
}
.ctrl-mode-btn {
  background: #C8C4BC;
  border: 1px solid #808080;
  font-family: "Courier New", monospace;
  font-size: 10px;
  font-weight: bold;
  padding: 3px 14px;
  color: #1A1A1A;
  cursor: default;
  letter-spacing: 0.5px;
}
.ctrl-mode-btn + .ctrl-mode-btn { border-left: none; }
.ctrl-mode-btn.active {
  background: #003366;
  color: #FFFFFF;
  border-color: #001A33;
}
.ctrl-mode-btn:not(.active):hover { background: #D4D0C8; }

/* Port / transmitter toggle rows */
.ctrl-port-row {
  display: grid;
  grid-template-columns: 80px 60px 1fr 80px;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px dotted #808080;
  font-family: "Courier New", monospace;
  font-size: 11px;
}
.ctrl-port-row:last-child { border-bottom: none; }
.ctrl-port-label { color: #000080; font-weight: bold; }
.ctrl-port-status { display: flex; align-items: center; gap: 5px; }

/* Large status LED */
.ctrl-led {
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 1px solid #404040;
  vertical-align: middle;
  flex-shrink: 0;
}
.ctrl-led.green { background: #00CC00; box-shadow: 0 0 4px #00FF00; }
.ctrl-led.red   { background: #CC0000; box-shadow: 0 0 4px #FF4444; }
.ctrl-led.amber { background: #FFAA00; box-shadow: 0 0 4px #FFCC44; }
.ctrl-led.dark  { background: #1A1A1A; box-shadow: none; }

/* Green-on-black readout display */
.ctrl-readout {
  display: inline-block;
  background: #001400;
  border: 1px solid #004400;
  color: #00EE00;
  font-family: "Courier New", monospace;
  font-size: 12px;
  font-weight: bold;
  padding: 2px 8px;
  min-width: 72px;
  text-align: right;
}

/* Setpoint row: label | slider | value */
.ctrl-sp-row {
  display: grid;
  grid-template-columns: 110px 1fr 70px;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-family: "Courier New", monospace;
  font-size: 11px;
  color: #000080;
  font-weight: bold;
}
input[type="range"].ctrl-slider {
  width: 100%;
  height: 14px;
  cursor: default;
  accent-color: #005A9E;
}

/* Readout row in controls */
.ctrl-rv-row {
  display: grid;
  grid-template-columns: 130px 1fr auto;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-family: "Courier New", monospace;
  font-size: 11px;
}
.ctrl-rv-label { color: #000080; font-weight: bold; }
.ctrl-rv-status { font-size: 10px; font-weight: bold; color: #008800; }

/* ============================================================
   PHOTO REVEAL PANE
   ============================================================ */
.photo-pane {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 10px 8px;
  gap: 8px;
}
.photo-caption {
  font-family: 'Courier New', monospace;
  font-size: 9px;
  font-weight: bold;
  letter-spacing: 0.5px;
  text-align: center;
  padding: 4px 10px;
  background: #003366;
  color: #80C0FF;
  width: 100%;
}
.photo-reveal-wrap {
  position: relative;
  display: inline-block;
  border: 2px solid;
  border-color: #808080 #DFDFDF #DFDFDF #808080;
}
.photo-reveal-img {
  display: block;
  width: 180px;
  height: 180px;
  object-fit: cover;
  object-position: top center;
}
.photo-reveal-canvas {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
}
.photo-id-tag {
  width: 184px;
  background: #E8F0FF;
  border: 1px solid #003366;
  padding: 5px 8px;
}
.photo-id-row {
  display: flex;
  justify-content: space-between;
  font-family: 'Courier New', monospace;
  font-size: 9px;
  color: #003366;
  font-weight: bold;
  margin-bottom: 2px;
}
.photo-id-row:last-child { margin-bottom: 0; }
