:root {
  --bg: #e9ebef;
  --topbar: #00a651;
  --menu: #b9ebcf;
  --menu-active: #00a651;
  --track: #000000;
  --node-red: #f98d82;
  --node-green: #5cc286;
  --node-ring: #d7d7d7;
  --panel: rgba(255, 255, 255, 0.72);
  --text-main: #f4fff8;
  --text-dark: #304252;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(1150px 500px at 70% -40%, #f5f7fb, var(--bg));
  font-family: "Trebuchet MS", Verdana, sans-serif;
  color: var(--text-dark);
  overflow: hidden;
}

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  height: 74px;
  background: var(--topbar);
  box-shadow: 0 2px 7px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px 0 0;
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  gap: 18px;
  color: var(--text-main);
  letter-spacing: 0.22em;
  font-size: clamp(24px, 2.2vw, 42px);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.28);
  white-space: nowrap;
}

.title-row {
  display: flex;
  align-items: baseline;
  gap: 14px;
}

#page-title {
  line-height: 1;
}

.active-measurement-banner {
  font-size: 13px;
  letter-spacing: 0.05em;
  color: #ffe066;
  margin-top: 2px;
  font-weight: 600;
}

.logo {
  width: 130px;
  height: 66px;
  border-radius: 0 0 22px 0;
  border: 3px solid #d0d0d0;
  border-top: 0;
  border-left: 0;
  object-fit: cover;
}

.clock {
  color: var(--text-main);
  font-size: clamp(20px, 2vw, 45px);
  letter-spacing: 0.04em;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
  font-weight: 700;
  min-width: 340px;
  text-align: right;
  padding-right: 18px;
}

.layout {
  position: fixed;
  inset: 74px 0 0 0;
  display: flex;
}

.left-rail {
  width: 104px;
  background: transparent;
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 20;
}

.menu-btn {
  appearance: none;
  width: 100%;
  height: 104px;
  background: var(--menu);
  border-top-right-radius: 10px;
  border-bottom-right-radius: 10px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(0, 140, 68, 0.28);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}

.menu-btn.active {
  background: var(--menu-active);
  border-color: rgba(0, 118, 57, 0.85);
}

.menu-btn:focus-visible {
  outline: 2px solid #e7f2ff;
  outline-offset: -2px;
}

.menu-btn svg {
  width: 57px;
  height: 57px;
  color: #07a24f;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.98;
}

.menu-btn.active svg {
  color: #d8f7e6;
}

.canvas {
  flex: 1;
  position: relative;
  display: grid;
  place-items: center;
  padding: 28px 24px 24px;
}

.view {
  display: none;
  width: min(1120px, calc(100vw - 160px));
  height: min(560px, calc(100vh - 170px));
  min-height: 350px;
  position: relative;
}

.view.active {
  display: block;
}

.machine {
  width: 100%;
  height: 100%;
  position: relative;
}

.machine-bg {
  border-radius: 14px;
  overflow: hidden;
  background: linear-gradient(145deg, #d7dde6, #edf1f6);
  border: 1px solid rgba(36, 52, 68, 0.14);
  box-shadow: 0 10px 28px rgba(25, 39, 52, 0.18);
}

.conveyor-bg-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: contrast(1.02) saturate(0.98);
}

.node-overlay {
  position: absolute;
  inset: 0;
}

.hud {
  position: absolute;
  right: 16px;
  bottom: 16px;
  background: var(--panel);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  padding: 12px 14px;
  width: 320px;
  backdrop-filter: blur(2px);
  box-shadow: 0 8px 22px rgba(30, 40, 54, 0.15);
  font-size: 28px;
}

.hud-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 8px;
  line-height: 1.4;
  margin: 2px 0;
}

.hud-row .k {
  opacity: 0.64;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.08em;
}

.hud-row .v {
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.measurement-controls {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.measurement-toggle {
  border: 1px solid rgba(0, 0, 0, 0.18);
  background: #e8f6ec;
  color: #1d7f3d;
  border-radius: 9px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.measurement-toggle.stop {
  background: #fff0f0;
  color: #a13838;
}

.measurement-toggle:disabled {
  cursor: wait;
  opacity: 0.7;
}

.measurement-state {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #5c6a77;
}

.v.state-on { color: #be2b2b; }
.v.state-off { color: #1d8842; }

.node-dot {
  position: absolute;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: background 160ms ease, box-shadow 160ms ease, transform 100ms linear;
  background: var(--node-red);
  box-shadow: 0 0 0 6px rgba(249, 141, 130, 0.3), 0 8px 18px rgba(40, 20, 20, 0.3);
  z-index: 3;
}

/* LED-synced flashing states on spider circles */
.node-dot.led-disconnected {
  background: var(--node-red);
  box-shadow: 0 0 0 6px rgba(249, 141, 130, 0.3), 0 8px 18px rgba(40, 20, 20, 0.3);
  animation: blink-slow-red 2s ease-in-out infinite;
}

.node-dot.led-connected-idle {
  background: var(--node-green);
  box-shadow: 0 0 0 6px rgba(92, 194, 134, 0.3), 0 8px 18px rgba(20, 40, 30, 0.3);
  animation: blink-slow-green 2s ease-in-out infinite;
}

.node-dot.led-collecting {
  background: var(--node-green);
  box-shadow: 0 0 0 6px rgba(92, 194, 134, 0.3), 0 8px 18px rgba(20, 40, 30, 0.3);
  animation: blink-fast-green 0.4s ease-in-out infinite;
}

@keyframes blink-slow-red {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

@keyframes blink-slow-green {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

@keyframes blink-fast-green {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}

.node-1 { left: 13.4%; top: 36.4%; }
.node-2 { left: 39.4%; top: 22.9%; }
.node-3 { left: 70%; top: 12.9%; }
.node-4 { left: 29.6%; top: 54.3%; }
.node-5 { left: 61.1%; top: 39.6%; }
.node-6 { left: 80.8%; top: 32.9%; }

.spider-debug-wrap {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.spider-debug {
  position: absolute;
  min-width: 165px;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(0, 0, 0, 0.18);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
  font-size: 22px;
  line-height: 1.28;
}

.spider-debug.connected {
  border-color: rgba(45, 150, 80, 0.48);
}

.spider-debug.disconnected {
  border-color: rgba(181, 51, 51, 0.42);
}

.spider-debug-title {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

.spider-debug-line {
  color: #2d3e4d;
  white-space: nowrap;
}

.spider-card-led {
  position: absolute;
  bottom: 8px;
  right: 8px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #aaa;
  transition: background 160ms ease, box-shadow 160ms ease;
}

.spider-card-led.led-disconnected {
  background: var(--node-red);
  box-shadow: 0 0 0 3px rgba(249, 141, 130, 0.3);
  animation: blink-slow-red 2s ease-in-out infinite;
}

.spider-card-led.led-connected-idle {
  background: var(--node-green);
  box-shadow: 0 0 0 3px rgba(92, 194, 134, 0.3);
  animation: blink-slow-green 2s ease-in-out infinite;
}

.spider-card-led.led-collecting {
  background: var(--node-green);
  box-shadow: 0 0 0 3px rgba(92, 194, 134, 0.3);
  animation: blink-fast-green 0.4s ease-in-out infinite;
}

.spider-1 { left: 36px; top: 66px; }
.spider-2 { left: 296px; top: 18px; }
.spider-3 { left: 618px; top: 4px; }
.spider-4 { left: 186px; top: 258px; }
.spider-5 { left: 520px; top: 178px; }
.spider-6 { left: 842px; top: 122px; }

.log-list {
  flex: 1;
  min-height: 0;
  display: grid;
  gap: 4px;
  overflow-y: auto;
  padding-right: 4px;
  align-content: start;
}

#view-logs {
  display: none;
  flex-direction: column;
  padding: 14px;
  gap: 10px;
}

#view-logs.view.active {
  display: flex;
}

.log-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.3;
  border: 1px solid rgba(0,0,0,0.06);
  background: rgba(255,255,255,0.6);
  min-width: 0;
}

.log-ts {
  color: #5c6a77;
  font-family: "Consolas","Courier New",monospace;
  font-size: 11px;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 150px;
}

.log-src {
  font-weight: 700;
  font-size: 11px;
  flex-shrink: 0;
  min-width: 60px;
}

.log-spider {
  color: #718096;
  font-size: 11px;
  flex-shrink: 0;
}

.log-msg {
  color: #1f2b36;
  word-break: break-all;
  flex: 1;
  min-width: 100px;
}

.log-error { border-left: 4px solid #e53e3e; background: rgba(229,62,62,0.06); }
.log-warn  { border-left: 4px solid #dd9a00; background: rgba(221,154,0,0.07); }
.log-info  { border-left: 4px solid #3182ce; background: rgba(49,130,206,0.06); }
.log-debug { border-left: 4px solid #999; background: rgba(0,0,0,0.03); }

.lora-signal-bars {
  font-family: monospace;
  letter-spacing: 1px;
  color: #2f855a;
  white-space: nowrap;
  flex-shrink: 0;
}

.lora-snr-badge {
  background: rgba(49,130,206,0.12);
  color: #2b6cb0;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.log-type-dropdown {
  position: relative;
  flex-shrink: 0;
}

.log-type-menu {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 100;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  min-width: 140px;
}

.log-type-menu label {
  display: block;
  padding: 4px 2px;
  cursor: pointer;
  font-size: 12px;
}

.log-type-menu label:hover {
  background: #f0f0f0;
}

.log-filter-input {
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  flex: 1;
  min-width: 120px;
}

.logs-empty {
  text-align: center;
  padding: 24px;
  color: #66717b;
  font-size: 14px;
}

.logs-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.log-filter-input {
  flex: 1;
  min-width: 120px;
  border: 1px solid rgba(0,0,0,0.16);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 13px;
  background: #fff;
}

.log-action-btn {
  border: 1px solid rgba(0,0,0,0.16);
  background: #fff;
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.log-clear {
  background: #fff3f3;
  color: #a13838;
  border-color: rgba(161,56,56,0.3);
}

.panel {
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(16, 26, 36, 0.14);
  backdrop-filter: blur(2px);
  padding: 14px;
  font-size: 16px;
}

.panel-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.62;
  margin-bottom: 8px;
}

.signal-wrap {
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 10px;
}

.signal-screen {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 28px;
  align-content: center;
}

.signal-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 44px;
  align-items: stretch;
  padding: 40px 70px 0;
}

.signal-card {
  background: #efefef;
  border-radius: 32px;
  box-shadow: 0 8px 20px rgba(20, 28, 35, 0.12);
  min-height: 340px;
  display: grid;
  place-items: center;
  align-content: center;
  padding: 30px 24px;
}


.signal-strength-card {
  align-content: center;
}

.signal-card-title {
  font-size: clamp(28px, 3vw, 56px);
  line-height: 1;
  color: #1d242c;
  margin-bottom: 26px;
  letter-spacing: 0.02em;
}

.signal-db {
  font-size: clamp(64px, 8vw, 138px);
  line-height: 1;
  color: #000;
  font-weight: 500;
}

.signal-snr-title {
  font-size: clamp(20px, 2.4vw, 50px);
  line-height: 1.1;
  color: #0f141a;
  margin-top: 12px;
}

.signal-snr-value {
  font-size: clamp(64px, 8vw, 138px);
  line-height: 1;
  color: #000;
  font-weight: 500;
}

.quality-bars {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 18px;
  height: 148px;
  margin-top: 8px;
}

.quality-bar {
  width: 46px;
  border-radius: 9px;
  opacity: 0.28;
  background: linear-gradient(90deg, #6de565, #62e95c);
  transition: opacity 140ms ease;
}

.quality-bar.active {
  opacity: 1;
}

.quality-bar.b1 { height: 58px; }
.quality-bar.b2 { height: 88px; }
.quality-bar.b3 { height: 116px; }
.quality-bar.b4 { height: 146px; }
.quality-bar.b5 { height: 182px; }

.signal-payload {
  text-align: center;
  font-size: clamp(28px, 2.7vw, 56px);
  color: #8f9499;
  letter-spacing: 0.03em;
  margin-bottom: 6px;
}

.signal-connection {
  text-align: center;
  font-size: clamp(20px, 2vw, 36px);
  letter-spacing: 0.02em;
  margin-bottom: 16px;
  font-weight: 600;
}

.signal-connection.connected {
  color: #07a24f;
}

.signal-connection.disconnected {
  color: #d9534f;
}

.signal-payload-time {
  text-align: center;
  font-size: clamp(12px, 1.2vw, 16px);
  color: #aaa;
  margin-top: -10px;
  margin-bottom: 18px;
}

.signal-chart {
  width: 100%;
  height: 100%;
  min-height: 220px;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(46, 160, 221, 0.08), rgba(46, 160, 221, 0));
}

.signal-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
}

.energy-grid {
  height: 100%;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  align-content: start;
}

.actions-screen {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  grid-template-rows: minmax(0, min-content) 1fr;
  gap: 12px;
}

.actions-card-available {
  grid-column: 1;
  grid-row: 1 / span 2;
  min-height: 0;
}

.actions-card-active {
  grid-column: 2;
  grid-row: 1;
}

.actions-card-logs {
  grid-column: 2;
  grid-row: 2;
}

.actions-card {
  background: #efefef;
  border-radius: 24px;
  box-shadow: 0 8px 20px rgba(20, 28, 35, 0.1);
  padding: 18px 20px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  gap: 14px;
}

.actions-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.actions-head-column {
  flex-direction: column;
  align-items: stretch;
}

.action-pickers {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.picker-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #5f6f7d;
  font-weight: 700;
}

.picker-select {
  border: 1px solid rgba(0, 0, 0, 0.16);
  border-radius: 9px;
  min-height: 42px;
  padding: 0 10px;
  font-size: 14px;
  font-weight: 700;
  background: #fff;
  color: #23313f;
}

.play-action-btn {
  border: 1px solid rgba(0, 0, 0, 0.18);
  background: #dcf7e5;
  color: #1b8142;
  border-radius: 10px;
  min-height: 42px;
  padding: 0 14px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.play-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: center;
}

.connected-spiders {
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: 10px;
  min-height: 42px;
  display: grid;
  align-items: center;
  padding: 0 10px;
  background: rgba(255, 255, 255, 0.78);
  color: #2d3f4f;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.play-action-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.selected-action-meta {
  font-size: 13px;
  color: #394b5a;
  font-weight: 700;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.65);
  padding: 9px 10px;
}

.actions-title {
  margin: 0;
  font-size: clamp(24px, 2.6vw, 52px);
  font-weight: 500;
  text-align: center;
  letter-spacing: 0.04em;
  color: #1f252c;
}

.add-action-btn {
  border: 1px solid rgba(0, 0, 0, 0.16);
  background: #ffffff;
  border-radius: 10px;
  min-height: 42px;
  padding: 0 14px;
  font-size: clamp(14px, 1.2vw, 22px);
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.actions-buttons {
  display: grid;
  gap: 12px;
  margin-top: 8px;
  align-content: start;
  min-height: 0;
  overflow-y: auto;
  padding-right: 6px;
}

.custom-panel {
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  padding: 10px;
  display: grid;
  gap: 8px;
}

.custom-panel-head {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #4f5f6e;
  font-weight: 700;
}

.custom-form {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  gap: 8px;
  align-items: center;
}

.custom-input {
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 8px;
  min-height: 38px;
  padding: 0 10px;
  font-size: 13px;
}

.custom-list {
  display: grid;
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
}

.custom-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  background: #f7f7f7;
  min-height: 36px;
  padding: 0 8px;
}

.custom-row-text {
  font-size: 13px;
  color: #2d3e4d;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.custom-row-del {
  border: 1px solid rgba(0, 0, 0, 0.14);
  background: #fff4f4;
  color: #a53f3f;
  border-radius: 7px;
  min-height: 28px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.actions-empty {
  padding: 8px 4px;
  color: #66717b;
  font-size: clamp(14px, 1.3vw, 22px);
}

.action-available-row {
  display: grid;
  grid-template-columns: 1fr 48px 48px;
  align-items: stretch;
  border-radius: 10px;
  overflow: hidden;
  min-height: 74px;
}

.action-available-main {
  border: 0;
  background: transparent;
  text-align: center;
  font-size: clamp(22px, 2.1vw, 44px);
  letter-spacing: 0.16em;
  color: #222b33;
  cursor: pointer;
}

.action-available-row.a { background: #81aeda; }
.action-available-row.b { background: #8ebc9d; }
.action-available-row.c { background: #cdb394; }
.action-available-row.d { background: #d59bb7; }

.action-available-row .action-icon {
  border-left: 1px solid rgba(0, 0, 0, 0.12);
  background: rgba(255, 255, 255, 0.56);
}

.action-type {
  border: 0;
  border-radius: 10px;
  min-height: 74px;
  font-size: clamp(22px, 2.1vw, 44px);
  letter-spacing: 0.16em;
  color: #222b33;
  cursor: pointer;
}

.action-type.a { background: #81aeda; }
.action-type.b { background: #8ebc9d; }
.action-type.c { background: #cdb394; }
.action-type.d { background: #d59bb7; }

.action-log-list {
  display: grid;
  gap: 6px;
  align-content: start;
  min-height: 0;
  overflow-y: auto;
  padding-right: 6px;
}

.action-log-row {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  align-items: center;
  border: 1px solid #d8d8d8;
  border-radius: 10px;
  background: #f4f4f4;
  min-height: 62px;
  overflow: hidden;
}

.action-log-badge {
  height: 100%;
  display: grid;
  place-items: center;
  font-size: 48px;
  font-weight: 500;
  color: #26435f;
}

.action-log-badge.a,
.action-log-badge.c,
.action-log-badge.d {
  background: #82b2df;
}

.action-log-badge.b {
  background: #8ebc9d;
  color: #1f4d2c;
}

.action-log-time {
  padding: 0 12px;
  font-size: clamp(14px, 1.3vw, 20px);
  letter-spacing: 0.03em;
  color: #454f59;
}

.action-log-name {
  padding: 0 12px;
  font-size: clamp(12px, 1.2vw, 16px);
  font-weight: 700;
  color: #26435f;
  letter-spacing: 0.05em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.action-log-status {
  padding: 0 12px;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: #2e3f50;
  font-weight: 700;
  text-transform: uppercase;
}

.active-action-box {
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 12px;
  background: #f7f7f7;
  padding: 10px;
  display: grid;
  gap: 8px;
}

.active-action-row {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 8px;
  align-items: center;
}

.active-action-row .k {
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: #63717e;
}

.active-action-row .v {
  font-size: 15px;
  font-weight: 700;
  color: #1f2b36;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stop-action-btn {
  border: 1px solid rgba(0, 0, 0, 0.18);
  background: #fff3f3;
  color: #a13838;
  border-radius: 8px;
  min-height: 36px;
  padding: 0 12px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.stop-action-btn:disabled {
  background: #e8e8e8;
  color: #aaa;
  border-color: #ccc;
  cursor: not-allowed;
  opacity: 0.7;
}

.action-icon {
  height: 100%;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 34px;
  line-height: 1;
}

.action-icon.edit {
  color: #5eaef0;
}

.action-icon.delete {
  color: #e07474;
}

.metric {
  background: rgba(255, 255, 255, 0.8);
  border-radius: 10px;
  padding: 12px;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.metric .k {
  font-size: 11px;
  opacity: 0.6;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.metric .v {
  margin-top: 8px;
  font-size: 34px;
  font-weight: 700;
  line-height: 1;
}

.settings-grid {
  display: grid;
  gap: 12px;
  align-content: start;
}

.setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(0, 0, 0, 0.08);
  font-weight: 700;
}

.setting input[type="range"] {
  width: 240px;
  max-width: 52vw;
}

.config-editor {
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.84);
  padding: 10px;
}

.config-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.config-editor-actions {
  display: flex;
  gap: 8px;
}

.config-editor-actions button {
  border: 1px solid rgba(0, 0, 0, 0.16);
  background: #ffffff;
  border-radius: 8px;
  padding: 5px 10px;
  cursor: pointer;
  font-weight: 700;
}

#config-text {
  width: 100%;
  min-height: 220px;
  resize: vertical;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.16);
  padding: 10px;
  font-family: "Consolas", "Courier New", monospace;
  font-size: 13px;
  line-height: 1.4;
  background: #fcfcfc;
}

#lora-config-text {
  width: 100%;
  min-height: 220px;
  resize: vertical;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.16);
  padding: 10px;
  font-family: "Consolas", "Courier New", monospace;
  font-size: 13px;
  line-height: 1.4;
  background: #fcfcfc;
}

#lora-device-picker {
  border: 1px solid rgba(0, 0, 0, 0.16);
  border-radius: 8px;
  min-height: 34px;
  padding: 0 8px;
  font-size: 14px;
  font-weight: 700;
  color: #23313f;
  background: #fff;
}

.config-status {
  margin-top: 7px;
  font-size: 12px;
  color: #5d6873;
}

@media (max-width: 920px) {
  body { overflow: auto; }
  .topbar { height: 62px; }
  .logo {
    width: 96px;
    height: 56px;
  }
  .brand {
    font-size: 20px;
    gap: 12px;
    letter-spacing: 0.16em;
  }
  .clock {
    min-width: 205px;
    font-size: 17px;
    padding-right: 8px;
  }
  .layout {
    inset: 62px 0 0 0;
    flex-direction: column;
  }
  .left-rail {
    width: 100%;
    padding: 6px;
    flex-direction: row;
    justify-content: space-between;
  }
  .menu-btn {
    width: calc(25% - 4px);
    height: 70px;
    border-radius: 8px;
  }
  .menu-btn svg {
    width: 38px;
    height: 38px;
  }
  .canvas {
    padding: 10px 6px 16px;
  }
  .view {
    width: min(760px, calc(100vw - 12px));
    height: min(500px, calc(100vh - 180px));
  }
  .hud {
    width: min(96%, 430px);
    right: 2%;
  }
  .signal-stats,
  .energy-grid {
    grid-template-columns: 1fr;
  }

  .actions-screen {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto minmax(0, 1fr);
    gap: 14px;
  }

  .actions-card-available,
  .actions-card-active,
  .actions-card-logs {
    grid-column: 1;
    grid-row: auto;
  }

  .action-log-row {
    grid-template-columns: 52px 1fr auto;
    min-height: 52px;
  }

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

  .custom-form {
    grid-template-columns: 1fr;
  }

  .play-row {
    grid-template-columns: 1fr;
  }

  .action-log-badge {
    font-size: 32px;
  }

  .action-type {
    min-height: 54px;
    letter-spacing: 0.08em;
    font-size: 28px;
  }

  .action-available-row {
    grid-template-columns: 1fr 40px 40px;
    min-height: 54px;
  }

  .action-available-main {
    letter-spacing: 0.08em;
    font-size: 28px;
  }

  .signal-cards {
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 12px;
  }

  .signal-card {
    min-height: 340px;
    border-radius: 18px;
    padding: 18px;
  }

  .signal-strength-card {
    align-content: center;
  }

  .signal-card-title {
    font-size: 40px;
    margin-bottom: 14px;
  }

  .signal-snr-title {
    font-size: 30px;
    margin-top: 6px;
  }

  .signal-snr-value {
    font-size: 64px;
  }

  .quality-bars {
    height: 96px;
    gap: 10px;
  }

  .quality-bar {
    width: 24px;
    border-radius: 7px;
  }

  .quality-bar.b1 { height: 40px; }
  .quality-bar.b2 { height: 58px; }
  .quality-bar.b3 { height: 72px; }
  .quality-bar.b4 { height: 84px; }
  .quality-bar.b5 { height: 98px; }

  .signal-payload {
    font-size: 30px;
  }

  .spider-debug-wrap {
    display: none;
  }
}

/* ── Frequency analyser / Pulse tab ─────────────────────────────────── */
.pulse-screen {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 12px;
}

.pulse-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.pulse-spider-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pulse-label {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-dark);
}

.pulse-spider-select {
  appearance: none;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text-dark);
  cursor: pointer;
}

.pulse-spider-indicator {
  font-size: 13px;
  color: #555;
  font-style: italic;
}

.pulse-data-display {
  flex: 1;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  padding: 12px;
  font-family: "Courier New", Courier, monospace;
  font-size: 12px;
  white-space: pre;
  overflow: auto;
  line-height: 1.5;
  color: var(--text-dark);
  min-height: 100px;
}
