:root {
  --bg: #0e1116;
  --panel: #161b22;
  --panel2: #1c222c;
  --border: #2b323d;
  --text: #e6edf3;
  --muted: #9aa7b4;
  --accent: #4aa3ff;
  --green: #2ecc40;
  --amber: #f0ad4e;
  --red: #e74c3c;
  --blue: #5dade2;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 20px;
  background: linear-gradient(180deg, #1a212c, #11161d);
  border-bottom: 1px solid var(--border);
}

.brand h1 { margin: 0; font-size: 20px; }
.brand .accent { color: var(--accent); }
.subtitle { margin: 4px 0 0; color: var(--muted); font-size: 12px; }

.controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sep { width: 1px; height: 24px; background: var(--border); margin: 0 4px; }

.btn {
  background: var(--accent);
  color: #06121f;
  border: none;
  border-radius: 6px;
  padding: 8px 12px;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }
.btn-sec { background: var(--panel2); color: var(--text); border: 1px solid var(--border); }
.btn-sec.active { background: var(--amber); color: #1a1207; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.dat-pack-hint {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
}
.dat-pack-status {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}
.dat-pack-status.ok { color: var(--green); }
.dat-pack-status.warn { color: var(--amber); }
.dat-pack-status.err { color: var(--red); }

.dropzone {
  margin: 14px 20px;
  padding: 14px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
  background: var(--panel);
  font-size: 13px;
}
.dropzone.drag { border-color: var(--accent); color: var(--text); }
.dropzone code { color: var(--accent); }

.status { margin: 0 20px 10px; color: var(--muted); font-size: 13px; }

.panel-spectrum { margin-bottom: 8px; }
.panel-spectrum h2 { margin-bottom: 4px; }
.spectrum-hint {
  margin: 0 0 8px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.35;
}
.spectrum-hint code { color: var(--accent); font-size: 10px; }
.spectrum-combine {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  margin: 0 0 8px;
  font-size: 11px;
  color: var(--muted);
}
.spectrum-combine-label { font-weight: 600; color: var(--text); }
.spectrum-combine-default { color: var(--accent); font-size: 11px; }
.spectrum-combine-note {
  flex: 1 1 100%;
  font-size: 10px;
  color: var(--muted);
  font-style: italic;
}
.spectrum-combine-opt {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  user-select: none;
}
.spectrum-combine-opt input { margin: 0; cursor: pointer; }
.spectrum-combine-opt input:disabled { cursor: default; opacity: 0.85; }
.spectrum-host {
  background: #050608;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  min-height: 170px;
}
.spectrum-canvas {
  display: block;
  width: 100%;
  height: 170px;
}

.panel {
  margin: 12px 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}
.panel h2 { margin: 0 0 10px; font-size: 15px; color: var(--text); }
.panel.is-off { display: none !important; }

/* Tandem: kolumna pilot + odbiornik (bez przewijania miedzy sekcjami) */
.sim-pairs-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}
@media (max-width: 1200px) {
  .sim-pairs-row { grid-template-columns: 1fr; }
}
.sim-pair {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.sim-pair-rx {
  border-top: 2px solid var(--green);
  padding-top: 4px;
}
.sim-pair-rx .device.rx {
  border-top-width: 2px;
}
.sim-pair-rx .relay-schematic-host {
  max-height: min(42vh, 420px);
  overflow: auto;
  overflow-x: auto;
}
.sim-pair-rx .lamp-grid {
  max-height: 120px;
  overflow-y: auto;
}
.sim-pair-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 2px;
}
.sim-pair-label-rx { color: #6fcf97; }
body.layout-tandem .frame-details > summary,
body.layout-tandem .role-map-block { font-size: 11px; }

.dev-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.dev-row.dev-row-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1100px) { .dev-row { grid-template-columns: 1fr; } }

.device {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
}
.device.tx { border-top: 3px solid var(--amber); }
.device.rx { border-top: 3px solid var(--green); }

.device-head { display: flex; align-items: center; justify-content: space-between; }
.device-title { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.dev-sub { color: var(--muted); font-size: 11px; margin: 4px 0; word-break: break-word; }
.dev-ui-hint { font-size: 10px; color: var(--accent); margin: 0 0 6px; line-height: 1.3; }
.dev-sub.small { font-size: 10px; }
.dev-empty { color: var(--muted); font-style: italic; padding: 14px 4px; }

.mod-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 5px; font-weight: 700; font-size: 12px;
  background: #2a3542; color: var(--text);
}
.mod-A { background: #355c7d; }
.mod-B { background: #6c5b7b; }
.mod-BS { background: #7a5f45; color: #f0e6d8; }

.mod-AZ { background: #4a6f8a; color: #e8f0f6; }

/* Zakladki A / Az w jednej karcie nadajnika A (tandem + zapas) */
.device.tx.tx-a-tabbed { min-width: 0; }
.tx-a-tabs {
  display: flex;
  gap: 4px;
  margin: 0 0 8px;
  padding: 0 2px;
  border-bottom: 1px solid var(--border);
}
.tx-a-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 5px 6px 7px;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 4px 4px 0 0;
}
.tx-a-tab:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.tx-a-tab.active {
  color: var(--text);
  border-bottom-color: var(--amber);
  background: rgba(230, 162, 60, 0.08);
}
.tx-a-tab[data-letter="az"].active { border-bottom-color: #5a8aa8; background: rgba(74, 111, 138, 0.15); }
.tx-a-tab-label { font-weight: 700; }
.tx-a-tab-hint {
  font-size: 10px;
  font-weight: 500;
  color: var(--muted);
  text-transform: lowercase;
}
.tx-a-tab.active .tx-a-tab-hint { color: var(--text); opacity: 0.75; }
.tx-a-panels { min-width: 0; }
.tx-a-panel { display: none; }
.tx-a-panel.active { display: block; }

/* Zakladki B / Bz w jednej karcie nadajnika B */
.device.tx.tx-b-tabbed { min-width: 0; }
.tx-b-tabs {
  display: flex;
  gap: 4px;
  margin: 0 0 8px;
  padding: 0 2px;
  border-bottom: 1px solid var(--border);
}
.tx-b-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 5px 6px 7px;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 4px 4px 0 0;
}
.tx-b-tab:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.tx-b-tab.active {
  color: var(--text);
  border-bottom-color: var(--amber);
  background: rgba(230, 162, 60, 0.08);
}
.tx-b-tab[data-letter="bs"].active { border-bottom-color: #9a7b4f; background: rgba(154, 123, 79, 0.12); }
.tx-b-tab-label { font-weight: 700; }
.tx-b-tab-hint {
  font-size: 10px;
  font-weight: 500;
  color: var(--muted);
  text-transform: lowercase;
}
.tx-b-tab.active .tx-b-tab-hint { color: var(--text); opacity: 0.75; }
.conn-led-tab { width: 8px; height: 8px; flex-shrink: 0; }
.tx-b-panels { min-width: 0; }
.tx-b-panel { display: none; }
.tx-b-panel.active { display: block; }

.conn-led {
  width: 12px; height: 12px; border-radius: 50%;
  background: #444; border: 1px solid #222;
}
.conn-led.on { background: var(--green); box-shadow: 0 0 6px var(--green); }

.power {
  display: block; width: 100%; margin: 6px 0; background: var(--panel);
  color: var(--text); border: 1px solid var(--border);
}
.power.on { background: var(--green); color: #06210b; border-color: var(--green); }

.rf-label { font-weight: 600; font-size: 13px; margin: 4px 0; color: var(--blue); }

.device.rx.jammed { border-top-color: var(--red); }
.rx-jam-wrap {
  min-height: 3.4em;
  margin: 4px 0;
  display: flex;
  align-items: stretch;
}
.rx-jam {
  flex: 1;
  padding: 6px 8px; border-radius: 6px;
  background: rgba(231, 76, 60, 0.15); border: 1px solid var(--red);
  color: var(--red); font-weight: 600; font-size: 12px; line-height: 1.3;
  box-sizing: border-box;
}
.rx-jam.is-off {
  visibility: hidden;
  border-color: transparent;
  background: transparent;
  animation: none;
  pointer-events: none;
}
.rx-jam.active { animation: jamBlink 0.8s ease-in-out infinite; }
.rx-jam.warn {
  background: rgba(243, 156, 18, 0.15); border-color: var(--orange, #f39c12);
  color: var(--orange, #f39c12);
}
.rx-jam.warn.active { animation: warnBlink 1.2s ease-in-out infinite; }

.roles-panel-details { margin: 0; }
.roles-panel-details summary { cursor: pointer; font-weight: 600; }
.role-map-hint { font-size: 12px; color: var(--muted, #888); margin: 6px 0; line-height: 1.35; }
.role-map-block { margin: 6px 0; font-size: 12px; }
.role-map-block summary { cursor: pointer; font-weight: 600; color: var(--blue); }
.role-map-tbl { width: 100%; border-collapse: collapse; margin-top: 4px; font-size: 12px; }
.role-map-tbl th, .role-map-tbl td { border: 1px solid var(--border); padding: 3px 5px; text-align: left; }
.role-map-tbl th { background: var(--panel); }
.role-map-inp { width: 5.5em; padding: 2px 4px; border-radius: 4px; border: 1px solid var(--border); background: var(--panel); color: var(--text); }
.role-map-tab { color: var(--muted, #888); }
.role-num-row { display: flex; align-items: center; gap: 6px; margin: 3px 0; font-size: 13px; }
.role-num-nr { font-weight: 600; min-width: 4.5em; }
@keyframes jamBlink {
  0%, 100% { background: rgba(231, 76, 60, 0.15); }
  50% { background: rgba(231, 76, 60, 0.35); }
}
@keyframes warnBlink {
  0%, 100% { background: rgba(243, 156, 18, 0.12); }
  50% { background: rgba(243, 156, 18, 0.28); }
}

.rotary { display: flex; align-items: center; gap: 6px; margin: 6px 0; flex-wrap: wrap; }
.rotary.num-sel-row .ns-offset-lbl { font-size: 12px; color: var(--muted, #888); margin-left: 4px; }
.rotary .ns-offset-inp {
  width: 3.2em; padding: 4px 6px; border-radius: 5px;
  background: var(--panel); color: var(--text); border: 1px solid var(--border);
}
.rotary select {
  background: var(--panel); color: var(--text); border: 1px solid var(--border);
  border-radius: 5px; padding: 4px 6px;
}
.rotary select.rotary-select-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); border: 0;
}
.rotary-dial-wrap {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  margin: 0;
}
.rotary-dial-outer {
  position: relative; width: 158px; height: 158px; flex-shrink: 0;
}
.rotary-dial-outer.disabled { opacity: 0.55; pointer-events: none; filter: grayscale(0.35);
}
.rotary-dial-svg {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 0;
}
.rotary-leader {
  stroke: #6a7380; stroke-width: 0.55; vector-effect: non-scaling-stroke;
}
.rotary-leader.active { stroke: #1a1a1a; stroke-width: 0.85; }
.rotary-dial {
  position: absolute; left: 50%; top: 50%;
  width: 76px; height: 76px; margin: -38px 0 0 -38px;
  border-radius: 50%;
  background: #b8bcc6;
  border: 2px solid #1a1a1a;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
  cursor: grab; touch-action: none; user-select: none; z-index: 2;
}
.rotary-dial.dragging { cursor: grabbing; }
.rotary-dial.disabled { pointer-events: none; cursor: not-allowed; }
.rotary-dial:focus { outline: 2px solid var(--accent); outline-offset: 3px; }
.rotary-dial-handle {
  position: absolute; left: 50%; top: 50%;
  width: 32px; height: 9px; margin: -4.5px 0 0 -3px;
  transform-origin: 4px 50%;
  background: #eceef2;
  border: 2px solid #111;
  border-radius: 5px;
  transition: transform 0.12s ease-out;
  pointer-events: none; z-index: 3;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}
.rotary-dial-notch {
  position: absolute; right: 3px; top: 50%; width: 5px; height: 5px;
  margin-top: -2.5px; border: 1.5px solid #111; border-radius: 1px;
  background: transparent; box-sizing: border-box;
}
.rotary-pos-hit {
  position: absolute; width: 36px; height: 18px; padding: 0; border: none;
  background: transparent; transform: translate(-50%, -50%);
  cursor: pointer; z-index: 4; border-radius: 4px;
}
.rotary-pos-hit:hover + .rotary-pos-lbl,
.rotary-pos-lbl:hover { color: #fff; }
.rotary-pos-lbl {
  position: absolute; font-size: 12px; font-weight: 700; color: #d8dee6;
  transform: translate(-50%, -50%);
  pointer-events: none; white-space: nowrap; text-align: center;
  font-family: Consolas, "Segoe UI", sans-serif;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
  z-index: 5; letter-spacing: 0.02em;
}
.rotary-pos-lbl.active {
  color: #111; font-size: 13px;
  background: #eceef2; padding: 1px 5px; border-radius: 3px;
  border: 1.5px solid #111;
  text-shadow: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}
.rotary-dial-caption {
  font-size: 13px; font-weight: 700; color: var(--muted); text-align: center;
  max-width: 170px; line-height: 1.25;
}
.rotary-dial-caption.active { color: var(--text); }

.tx-control-row {
  display: flex; align-items: flex-start; gap: 10px; margin: 8px 0;
  flex-wrap: wrap;
}
.tx-control-row-stack {
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.tx-control-row-stack .tx-btn-panel {
  width: 100%;
  max-width: 220px;
}
.tx-control-row-stack .tx-dial-col {
  margin-top: 2px;
}
.tx-controls-below {
  width: 100%;
  min-width: 0;
  margin: 4px 0 8px;
}
.tx-controls-below .tx-joy-row {
  margin-top: 0;
}
.tx-controls-below .tx-winch-col {
  margin-top: 6px;
}
.tx-dial-col { flex: 0 0 auto; min-width: 0; }
.tx-dial-label {
  font-size: 13px; font-weight: 600; color: var(--muted); text-align: center; margin-bottom: 2px;
}
.tx-offset-row {
  display: flex; align-items: center; justify-content: center; gap: 4px;
  margin-top: 2px; font-size: 11px;
}
.tx-offset-row .ns-offset-inp { width: 2.8em; padding: 2px 4px; }
.tx-btn-panel {
  display: flex; flex-direction: column; gap: 6px; flex: 1 1 auto; min-width: 0;
}
.tx-btn-panel-solo { max-width: 148px; margin: 8px 0; }
.tx-btn-grid { display: flex; flex-direction: column; gap: 4px; }
.tx-btn-row { display: flex; gap: 4px; }
.tx-btn-row .tx-mbtn { flex: 1 1 0; min-width: 0; }
.tx-winch-col {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  margin-top: 2px; padding-top: 4px; border-top: 1px solid var(--border);
}
.tx-winch-col .rotary-dial-outer { width: 118px; height: 118px; }
.tx-winch-col .rotary-dial {
  width: 56px; height: 56px; margin: -28px 0 0 -28px;
}
.tx-winch-col .rotary-dial-handle { width: 26px; height: 8px; margin: -4px 0 0 -3px; }
.tx-winch-col .rotary-pos-hit { width: 30px; height: 16px; }
.tx-winch-col .rotary-pos-lbl { font-size: 9px; }
.tx-winch-col .rotary-pos-lbl.active { font-size: 10px; }
.tx-bistab-col {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  margin-top: 2px; padding-top: 4px; border-top: 1px solid var(--border);
}
.tx-joy-row {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
  align-items: flex-end;
  margin-top: 4px; padding-top: 6px; border-top: 1px solid var(--border);
  width: 100%;
  box-sizing: border-box;
}
.tx-joy-row .tx-bistab-col {
  border-top: none;
  margin-top: 0;
  padding-top: 0;
  flex: 0 0 auto;
  align-self: flex-end;
  padding-bottom: 4px;
}
.tx-joy-row .tx-winch-col {
  border-top: none;
  margin-top: 0;
  padding-top: 0;
  flex: 0 0 auto;
  align-self: flex-end;
  padding-bottom: 4px;
}
.tx-joy-row .tx-winch-col .dev-sub.small {
  max-width: 80px;
  text-align: center;
  line-height: 1.15;
  font-size: 9px;
}
.tx-joy-row .tx-bistab-col .dev-sub.small {
  max-width: 72px;
  text-align: center;
  line-height: 1.15;
  font-size: 9px;
}
.tx-joy-col { flex: 0 0 auto; }
.joy-wrap {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.joy-title { font-size: 10px; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.joy-pad {
  position: relative; border-radius: 50%;
  background: radial-gradient(circle at 50% 45%, #2e3848 0%, #1a2030 70%);
  border: 2px solid #4a5568;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.5);
  touch-action: none; user-select: none; cursor: crosshair;
}
.joy-wrap-1d .joy-pad { border-radius: 12px; }
.joy-rings { position: absolute; inset: 0; pointer-events: none; }
.joy-ring {
  position: absolute; left: 50%; top: 50%; border: 1px dashed #4a6080;
  border-radius: 50%; transform: translate(-50%, -50%); opacity: 0.55;
}
.joy-ring-1 { width: 38%; height: 38%; }
.joy-ring-2 { width: 62%; height: 62%; }
.joy-ring-3 { width: 86%; height: 86%; }
.joy-cross { position: absolute; inset: 0; pointer-events: none; }
.joy-axis { position: absolute; background: #3d4d66; }
.joy-axis-h { left: 8%; right: 8%; top: 50%; height: 1px; margin-top: -1px; }
.joy-axis-v { top: 8%; bottom: 8%; left: 50%; width: 1px; margin-left: -1px; }
.joy-track-1d {
  position: absolute; left: 50%; top: 10%; bottom: 10%; width: 4px; margin-left: -2px;
  background: #3d4d66; border-radius: 2px; pointer-events: none;
}
.joy-knob {
  position: absolute; width: 22px; height: 22px; margin: -11px 0 0 -11px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #f0f4fa 0%, #9aa8bc 100%);
  border: 2px solid #111; box-shadow: 0 2px 5px rgba(0,0,0,0.55);
  pointer-events: none; transition: left 0.04s, top 0.04s;
}
.joy-pad[data-step="1"] .joy-knob { box-shadow: 0 0 6px var(--green); }
.joy-pad[data-step="2"] .joy-knob { box-shadow: 0 0 8px #f0c040; }
.joy-pad[data-step="3"] .joy-knob { box-shadow: 0 0 10px var(--accent); }
.joy-axis-labels { position: absolute; inset: 0; pointer-events: none; font-size: 9px; font-weight: 700; color: #7a8ea8; }
.joy-lbl { position: absolute; }
.joy-lbl-n { top: 2px; left: 50%; transform: translateX(-50%); }
.joy-lbl-s { bottom: 2px; left: 50%; transform: translateX(-50%); }
.joy-lbl-w { left: 4px; top: 50%; transform: translateY(-50%); }
.joy-lbl-e { right: 4px; top: 50%; transform: translateY(-50%); }
.joy-hint { text-align: center; max-width: 150px; line-height: 1.2; }
.lever-host { display: flex; justify-content: center; }
.lever-switch { user-select: none; touch-action: none; }
.lever-track {
  position: relative; width: 44px; height: 96px;
  background: linear-gradient(180deg, #2a3140 0%, #1a1f28 100%);
  border: 2px solid #4a5568; border-radius: 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  padding: 6px 0; cursor: pointer;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.45);
}
.lever-lbl {
  font-size: 10px; font-weight: 700; color: #8899aa;
  pointer-events: none; line-height: 1;
}
.lever-switch.pressed .lever-lbl-off { color: #556; }
.lever-switch.pressed .lever-lbl-on { color: #f0d878; }
.lever-knob {
  width: 28px; height: 22px; border-radius: 4px;
  background: linear-gradient(180deg, #e8ecf2 0%, #b8c0cc 100%);
  border: 2px solid #111;
  box-shadow: 0 2px 4px rgba(0,0,0,0.5);
  transition: transform 0.12s ease-out;
  pointer-events: none;
}
.lever-switch.pressed .lever-knob {
  transform: translateY(14px);
  background: linear-gradient(180deg, #ffe566 0%, #d4a820 100%);
}
.tx-mbtn {
  padding: 5px 4px; font-size: 10px;
}

/* Kompaktowe piktogramy mechanizmów: G/D, L/P, T/P — „G, 2st” */
.tx-btn-row-mech {
  justify-content: center;
  gap: 6px;
  padding: 1px 0;
}
.tx-dg-picto {
  flex: 0 0 auto;
  width: 56px;
  height: 40px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  line-height: 0;
}
.tx-dg-svg {
  width: 56px;
  height: 40px;
  display: block;
  pointer-events: none;
}
.tx-dg-face {
  fill: #243042;
  stroke: var(--border);
  stroke-width: 1.5;
}
.tx-dg-letter {
  fill: #e8eef6;
  font-size: 14px;
  font-weight: 700;
  font-family: system-ui, sans-serif;
}
.tx-dg-2st {
  fill: rgba(160, 180, 200, 0.7);
  font-size: 8px;
  font-weight: 700;
  font-family: system-ui, sans-serif;
}
.tx-dg-chev {
  fill: none;
  stroke: rgba(160, 180, 200, 0.55);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tx-dg-picto.pressed .tx-dg-face {
  fill: var(--accent);
  stroke: #7ec8e8;
}
.tx-dg-picto.pressed .tx-dg-letter { fill: #06121f; }
.tx-dg-picto.pressed .tx-dg-2st { fill: rgba(6, 18, 31, 0.55); }
.tx-dg-picto.pressed .tx-dg-chev { stroke: rgba(6, 18, 31, 0.5); }
.tx-dg-picto.gear2 .tx-dg-face {
  fill: #e8a820;
  stroke: #f0c040;
}
.tx-dg-picto.gear2 .tx-dg-letter { fill: #1a1200; }
.tx-dg-picto.gear2 .tx-dg-2st { fill: #1a1200; }
.tx-dg-picto.gear2 .tx-dg-chev { stroke: #1a1200; }

.rotary.num-sel-row { align-items: flex-start; }
.rotary.num-sel-row > label:first-child { margin-top: 88px; }

.btn-stop {
  display: block; width: 100%; margin: 6px 0;
  background: #5a2230; color: #ffd7df; border: 1px solid #7a2b3c;
}
.btn-stop.active { background: var(--red); color: #2a0508; }

.btn-bar { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.mbtn {
  flex: 1 1 auto; min-width: 56px; padding: 8px 6px;
  background: #243042; color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; cursor: pointer; user-select: none; font-size: 12px;
}
.mbtn:active { background: var(--accent); color: #06121f; }

.io-block { margin-top: 8px; }
.io-details { margin-top: 8px; }
.io-details > summary { cursor: pointer; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.io-details-body { margin-top: 4px; }
.rx-editor-host { margin-top: 8px; }
.io-label { font-size: 11px; color: var(--muted); margin-bottom: 4px; }

.lamp-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.lamp-cell { display: flex; flex-direction: column; align-items: center; gap: 2px; max-width: 52px; }

/* Widok przekaznikow — wymienne: siatka kropek LUB schemat SVG (nigdy oba) */
.rx-status-block {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}
.rx-status-block .rf-label { margin: 0 0 4px; }
.rx-status-block .rx-jam-wrap { margin: 0 0 4px; }
.rx-status-block .dev-sub.small { margin: 0; }
body.relay-view-schematic .lamp-grid { display: none !important; }
body.relay-view-schematic .relay-schematic-host:not(:empty) { display: block; }
body.relay-view-grid .relay-schematic-host,
body:not(.relay-view-schematic) .relay-schematic-host { display: none !important; }
.lamp {
  width: 20px; height: 20px; border-radius: 50%;
  background: #3a3a3a; border: 1px solid #222;
}
.lamp.on { background: var(--green); box-shadow: 0 0 6px var(--green); }
.lamp-name { font-size: 8px; color: var(--muted); text-align: center; line-height: 1.15; word-break: break-word; }

.panel-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 8px 16px; margin-bottom: 8px;
}
.panel-head h2 { margin: 0; }
.relay-view-toggle {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--muted); cursor: pointer; user-select: none;
}
.relay-view-toggle input { cursor: pointer; }
.relay-view-toggle.is-disabled { opacity: 0.45; cursor: not-allowed; }

.relay-schematic { margin-top: 4px; }
.relay-board { margin-bottom: 10px; }
.relay-board-title {
  font-size: 10px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 4px;
}
.relay-board-row {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.relay-slot {
  flex: 0 0 auto;
}
.relay-slot-empty { opacity: 0.4; }
.relay-slot-cut { opacity: 0.28; }
.relay-slot-cut .relay-frame-empty { stroke-dasharray: 4 3; stroke: #4a5060; }
.relay-symbol-svg { display: block; }
.relay-frame {
  fill: #1a1d22; stroke: #5a6270; stroke-width: 1;
}
.relay-frame-on { stroke: #8a95a8; }
.relay-frame-empty { fill: #14161a; stroke: #3a3f48; stroke-dasharray: 3 2; }
.relay-id {
  fill: #e8eaed; font-size: 11px; font-weight: 700;
  font-family: system-ui, sans-serif;
}
.relay-id-sim {
  fill: #7a8494; font-size: 8px; font-weight: 400;
  font-family: system-ui, sans-serif;
}
.relay-id-dim { fill: #6a7080; }
.relay-func {
  fill: #8a909c; font-size: 7px; font-family: system-ui, sans-serif;
}
.relay-line {
  stroke: #8a95a8; stroke-width: 1.5; fill: none;
  stroke-linecap: round; stroke-linejoin: round;
}
.relay-coil-path {
  stroke: #8a95a8; stroke-width: 1.5; fill: none;
  stroke-linecap: round; stroke-linejoin: round;
}
.relay-arm { stroke-width: 2; fill: none; stroke-linecap: round; }
.relay-arm-off { stroke: #6a7380; }
.relay-arm-on { stroke: #6a7380; }
.relay-arm-active { stroke: #e8c840 !important; }
.relay-dot { fill: #2a3038; stroke: #6a7380; stroke-width: 1; }
.relay-dot-nc { fill: #2a3038; }
.relay-dot-active { fill: #e8c840; stroke: #c8a820; }
.relay-led { stroke: #444; stroke-width: 0.8; }
.relay-led-off { fill: #2a2d32; }
.relay-led-on.relay-led-red { fill: #e22; stroke: #a11; filter: drop-shadow(0 0 4px #e44); }
.relay-led-on.relay-led-green { fill: #3d4; stroke: #2a3; filter: drop-shadow(0 0 4px #4e6); }
.relay-slot.is-on .relay-frame { stroke: #9aa8bc; }

.vbit-grid { display: grid; grid-template-columns: repeat(22, 1fr); gap: 2px; }
.vbit {
  width: 100%; aspect-ratio: 1 / 1; min-width: 7px;
  background: #333; border: 1px solid #444; border-radius: 2px;
}
.vbit.on { background: var(--blue); border-color: var(--blue); }

.frame-wrap { margin-top: 8px; }
.frame-bits { display: grid; grid-template-columns: repeat(16, 1fr); gap: 2px; }
.frame-bit {
  font-size: 8px; text-align: center; padding: 3px 0;
  background: #2a2f38; border: 1px solid var(--border); border-radius: 3px; color: var(--muted);
}
.frame-bit.on { background: var(--amber); color: #1a1207; border-color: var(--amber); font-weight: 700; }

.rx-frame {
  margin-top: 8px; font-family: Consolas, monospace; font-size: 11px;
  color: var(--muted); word-break: break-all;
}

/* Edytor konfiguracji TX/RX + eksport .dat */
.cfg-editor, .rx-cfg-editor {
  margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border);
}
.cfg-editor-details > summary.cfg-editor-summary {
  cursor: pointer; font-size: 12px; font-weight: 600; color: var(--muted);
  user-select: none; list-style: none;
}
.cfg-editor-details > summary.cfg-editor-summary::-webkit-details-marker { display: none; }
.cfg-editor-details > summary.cfg-editor-summary::before {
  content: '▸ '; display: inline-block; width: 1em; color: var(--accent);
}
.cfg-editor-details[open] > summary.cfg-editor-summary::before { content: '▾ '; }
.cfg-editor-details > summary.cfg-editor-summary:hover { color: var(--text); }
.cfg-editor-body { margin-top: 8px; }
.cfg-tools { margin-top: 6px; }
.cfg-btns, .cfg-dat-btns, .rx-cfg-btns {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}
.cfg-btns .btn, .cfg-dat-btns .btn, .rx-cfg-btns .btn { font-size: 12px; padding: 6px 10px; }
.btn-tiny { font-size: 10px !important; padding: 3px 8px !important; }
.cfg-src, .rx-cfg-src {
  width: 100%; min-height: 100px; max-height: 220px; resize: vertical;
  font-family: Consolas, "Courier New", monospace; font-size: 11px; line-height: 1.35;
  background: #0d1117; color: #c9d1d9; border: 1px solid var(--border); border-radius: 5px;
  padding: 8px; tab-size: 4;
}
.rx-cfg-editor .cfg-src { min-height: 140px; max-height: 280px; border-radius: 0 5px 5px 5px; }
.cfg-src.hidden, .rx-cfg-src.hidden { display: none; }
.cfg-msg, .rx-cfg-msg {
  font-size: 11px; margin-top: 4px; min-height: 1.2em; color: var(--muted);
}
.cfg-msg.ok, .rx-cfg-msg.ok { color: var(--green); }
.cfg-msg.err, .rx-cfg-msg.err { color: var(--red); }
.cfg-dat-hex { margin-top: 6px; }
.cfg-dat-hex summary {
  cursor: pointer; font-size: 11px; color: var(--muted); user-select: none;
}
.cfg-dat-hex summary:hover { color: var(--text); }
.cfg-dat-hex-dump {
  margin: 6px 0 4px; padding: 8px;
  font-family: Consolas, "Courier New", monospace; font-size: 10px; line-height: 1.45;
  background: #0d1117; color: #8b949e; border: 1px solid var(--border); border-radius: 5px;
  max-height: 200px; overflow: auto; white-space: pre-wrap; word-break: break-all;
}
.cfg-dat-hex-dump.err { color: var(--red); }
.cfg-folder-hint {
  font-size: 10px; color: var(--muted); margin-bottom: 4px; word-break: break-all;
}

.rx-cfg-tabs { display: flex; gap: 4px; margin-bottom: 4px; }
.rx-cfg-tab {
  padding: 4px 10px; font-size: 11px; cursor: pointer;
  background: var(--panel); color: var(--muted); border: 1px solid var(--border);
  border-radius: 5px 5px 0 0;
}
.rx-cfg-tab.active { background: var(--panel2); color: var(--text); border-bottom-color: var(--panel2); }

/* legacy aliases (rx-cfg-*) */
.rx-cfg-editor {
  margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border);
}
.rx-cfg-src {
  width: 100%; min-height: 140px; max-height: 280px; resize: vertical;
  font-family: Consolas, "Courier New", monospace; font-size: 11px; line-height: 1.35;
  background: #0d1117; color: #c9d1d9; border: 1px solid var(--border); border-radius: 0 5px 5px 5px;
  padding: 8px; tab-size: 4;
}
.rx-cfg-src.hidden { display: none; }
.rx-cfg-btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.rx-cfg-btns .btn { font-size: 12px; padding: 6px 10px; }
.rx-cfg-msg { font-size: 11px; margin-top: 4px; min-height: 1.2em; color: var(--muted); }
.rx-cfg-msg.ok { color: var(--green); }
.rx-cfg-msg.err { color: var(--red); }

.tx-quick-actions {
  display: flex; flex-direction: column; gap: 6px; margin: 8px 0;
}
.tx-quick-actions .rfid-btn,
.tx-quick-actions .btn-stop {
  display: block; width: 100%; margin: 0;
}
.tx-quick-actions .rfid-status { font-size: 11px; color: var(--muted); margin-top: -2px; }
.tx-quick-actions .rfid-status.ok { color: var(--blue); font-weight: 600; }

.rx-pwr-btn { margin: 6px 0 8px; width: 100%; }

.rfid-block {
  margin: 8px 0; padding: 8px; border-radius: 6px;
  background: rgba(93, 173, 226, 0.08); border: 1px solid rgba(93, 173, 226, 0.35);
}
.rfid-btn {
  display: block; width: 100%; margin: 4px 0;
  background: #243042; color: var(--text); border: 1px solid var(--border);
}
.rfid-btn.on { background: #2a5a8a; border-color: var(--blue); color: #e8f4ff; }
.rfid-status { font-size: 11px; color: var(--muted); }
.rfid-status.ok { color: var(--blue); font-weight: 600; }

.foot {
  margin: 16px 20px; padding-top: 10px; border-top: 1px solid var(--border);
  color: var(--muted); font-size: 12px;
}

/* --- Panel wgrywania (.dat -> urzadzenie przez BLE/USB) --- */
.panel-flash h2 { margin: 0 0 6px; font-size: 17px; }
.flash-panel-hint {
  margin: 0 0 12px; font-size: 12px; color: var(--muted); line-height: 1.45;
}
.flash-panel-host {
  background: var(--panel2); border: 1px solid var(--border); border-radius: 8px;
  padding: 14px 16px;
}
.flash-alert { padding: 8px 10px; border-radius: 6px; font-size: 12px; line-height: 1.4; }
.flash-alert.err { background: rgba(231, 76, 60, 0.12); border: 1px solid rgba(231, 76, 60, 0.4); color: #ffb4ab; }
.flash-alert.warn { background: rgba(240, 173, 78, 0.12); border: 1px solid rgba(240, 173, 78, 0.4); color: #f0ad4e; }
.flash-file { margin-bottom: 12px; }
.flash-info {
  display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 0;
  font-size: 12px;
}
.flash-info dt { color: var(--muted); }
.flash-info dd { margin: 0; font-family: Consolas, "Courier New", monospace; }
.flash-config { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.flash-field { display: flex; flex-direction: column; gap: 4px; flex: 1 1 180px; }
.flash-field-wide { flex: 2 1 320px; }
.flash-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.flash-select {
  background: var(--panel); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; padding: 7px 8px; font-size: 13px;
}
.flash-select:disabled { opacity: 0.55; }
.flash-conn-status {
  font-size: 12px; color: var(--muted); margin: 4px 0 8px;
  padding: 6px 8px; border-radius: 6px; background: rgba(0, 0, 0, 0.15);
}
.flash-conn-status.ok { color: var(--green); border: 1px solid rgba(46, 204, 64, 0.35); }
.flash-version-row {
  display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; font-size: 12px;
}
.flash-version-info {
  font-family: Consolas, "Courier New", monospace; color: var(--accent);
}
.flash-action-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.flash-action-btns .btn-flash { background: #2a5a8a; border-color: var(--accent); color: #e8f4ff; }
.flash-action-btns .btn-flash:hover { background: #35699c; }
.flash-action-btns .btn:disabled { opacity: 0.5; }
.flash-progress-wrap {
  height: 10px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 6px; overflow: hidden;
}
.flash-progress-bar { height: 100%; width: 0%; background: linear-gradient(90deg, #2a5a8a, var(--accent)); transition: width 0.25s; }
.flash-progress-text { margin: 8px 0 0; font-size: 12px; color: var(--muted); min-height: 1.3em; }
.flash-progress-text.ok { color: var(--green); font-weight: 600; }
.flash-progress-text.err { color: var(--red); font-weight: 600; }
.flash-progress-text.warn { color: var(--amber); }
.flash-log-det { margin-top: 10px; }
.flash-log-det summary { cursor: pointer; font-size: 12px; color: var(--muted); }
.flash-log {
  margin: 6px 0 0; max-height: 220px; overflow: auto; white-space: pre-wrap; word-break: break-all;
  font-family: Consolas, "Courier New", monospace; font-size: 11px; line-height: 1.4;
  background: #0d1117; color: #c9d1d9; border: 1px solid var(--border); border-radius: 6px; padding: 8px;
}

/* ---------- Logowanie ---------- */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 10, 14, 0.92);
  backdrop-filter: blur(4px);
}
.auth-card {
  width: min(400px, 92vw);
  padding: 28px 24px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}
.auth-card h2 { margin: 0 0 8px; font-size: 20px; }
.auth-hint { margin: 0 0 18px; color: var(--muted); font-size: 13px; }
.auth-form label {
  display: block;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--muted);
}
.auth-form input {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 9px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
.auth-submit { width: 100%; margin-top: 4px; }
.auth-error { color: var(--red); font-size: 13px; margin: 0 0 8px; }
body.auth-locked > *:not(.auth-overlay) { pointer-events: none; user-select: none; }
.auth-userbar {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-right: 8px;
}
.auth-user-label {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.auth-logout { font-size: 12px; padding: 6px 10px; }

/* ---------- Panel konfiguracji klienta (www) ---------- */
.client-config-host {
  display: block;
  width: 100%;
  flex-basis: 100%;
  margin-top: 4px;
  padding: 10px 12px;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.client-config-title {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}
.client-config-title:not(:first-child) { margin-top: 14px; }
.client-config-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.client-config-btn { font-size: 12px; padding: 6px 10px; }
.client-config-hint { margin: 0; font-size: 12px; color: var(--muted); }
.client-config-hint.warn { color: var(--amber); }

.client-config-search-wrap { margin-top: 4px; }
.client-config-search-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.client-config-search-input {
  display: block;
  width: 100%;
  max-width: 280px;
  margin-top: 4px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.client-config-search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent);
}
.client-config-search-hint { margin: 8px 0 0; }
.client-config-search-results {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 10px;
  max-height: 240px;
  overflow-y: auto;
}
.client-config-search-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  width: 100%;
  text-align: left;
  font-size: 12px;
  padding: 7px 10px;
}
.client-config-search-num {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  min-width: 4.5em;
}
.client-config-search-label-txt { color: var(--muted); flex: 1; }

