:root {
  --bg: #1b1d23;
  --panel: #23262e;
  --panel2: #2b2f39;
  --border: #393e4a;
  --text: #e8e9ed;
  --text-dim: #9aa0ad;
  --accent: #4fb8e8;
  --accent2: #e0a030;
  --green: #5fd56b;
  --red: #e6584f;
  font-family: 'Segoe UI', Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden; }
button { font-family: inherit; cursor: pointer; }

#app { display: flex; flex-direction: column; height: 100vh; }

/* ---------------- Top bar ---------------- */
#topbar {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); border-bottom: 1px solid var(--border);
  padding: 7px 12px; flex: 0 0 auto; z-index: 30;
}
#topbar .title { font-weight: 700; color: var(--accent2); margin-right: 6px; white-space: nowrap; font-size: 14px; }
#topbar .title small { color: var(--text-dim); font-weight: 400; margin-left: 6px; font-size: 11px; }
#topbar button, #topbar select {
  background: var(--panel2); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 10px; font-size: 13px;
}
#topbar button:hover { border-color: var(--accent); }
#topbar button.primary { background: var(--accent); color: #08222d; border-color: var(--accent); font-weight: 600; }
.spacer { flex: 1; }
.tb-select { padding: 6px 6px !important; font-size: 12px !important; }
.tb-zoom { display: flex; align-items: center; gap: 4px; background: var(--panel2); border: 1px solid var(--border); border-radius: 6px; padding: 2px; }
.tb-zoom button { background: transparent; border: none; padding: 4px 8px; border-radius: 4px; }
.tb-zoom button:hover { background: rgba(255,255,255,0.08); border-color: transparent; }
#zoomLabel { width: 40px; text-align: center; display: inline-block; font-size: 12px; color: var(--text-dim); }

/* ---------------- Action bar (contextual tools, below the top bar) ---------------- */
#actionbar {
  display: flex; align-items: center; gap: 6px;
  background: var(--panel); border-bottom: 1px solid var(--border);
  padding: 6px 12px; flex: 0 0 auto; z-index: 25;
}
#actionbar button {
  background: var(--panel2); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 10px; font-size: 12.5px;
}
#actionbar button:hover:not(:disabled) { border-color: var(--accent); }
#actionbar button.danger:hover:not(:disabled) { border-color: var(--red); color: var(--red); }
#actionbar button:disabled { opacity: 0.35; cursor: default; }
.tb-group { display: flex; align-items: center; gap: 6px; }
.tb-divider { width: 1px; height: 22px; background: var(--border); margin: 0 4px; flex: 0 0 auto; }
.tb-label { font-size: 11px; color: var(--text-dim); white-space: nowrap; margin-right: 2px; }
#selectionGroup { transition: opacity .15s; }
#selectionGroup.empty { opacity: 0.55; }
#selectionLabel { min-width: 92px; }

/* Wire-style segmented control */
.segmented { display: flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.segmented .seg-btn {
  background: var(--panel2); color: var(--text-dim); border: none; padding: 6px 10px;
  font-size: 12px; border-radius: 0; border-right: 1px solid var(--border);
}
.segmented .seg-btn:last-child { border-right: none; }
.segmented .seg-btn.active { background: var(--accent); color: #08222d; font-weight: 600; }
.color-dot { width: 24px; height: 24px; border-radius: 50%; padding: 0 !important; border: 2px solid var(--border) !important; }
.color-input { width: 24px; height: 24px; padding: 0; border: none; background: none; cursor: pointer; }

/* Dropdown menu (File) */
.dropdown { position: relative; }
.dropdown-toggle {
  background: var(--panel2); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 10px; font-size: 13px;
}
.dropdown-toggle:hover { border-color: var(--accent); }
.dropdown-toggle .chev { font-size: 10px; color: var(--text-dim); margin-left: 2px; }
.dropdown.open .dropdown-toggle { border-color: var(--accent); background: var(--panel); }
.dropdown-panel {
  display: none; position: absolute; top: calc(100% + 6px); left: 0; min-width: 210px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5); padding: 6px; z-index: 50;
}
.dropdown.open .dropdown-panel { display: block; }
.dropdown-item {
  display: flex; align-items: center; gap: 6px; width: 100%; text-align: left;
  background: transparent; border: none; color: var(--text); border-radius: 5px;
  padding: 8px 10px; font-size: 13px; cursor: pointer;
}
.dropdown-item:hover { background: var(--panel2); }
.dropdown-item.danger:hover { background: rgba(230,88,79,0.15); color: var(--red); }
.dropdown-sep { height: 1px; background: var(--border); margin: 4px 2px; }

/* ---------------- Layout ---------------- */
#main { flex: 1; display: flex; min-height: 0; }

/* ---------------- Palette (accordion) ---------------- */
#palette {
  width: 240px; background: var(--panel); border-right: 1px solid var(--border);
  overflow-y: auto; flex: 0 0 auto; display: flex; flex-direction: column;
}
#palette input.search {
  width: calc(100% - 16px); margin: 8px; padding: 7px 9px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--panel2); color: var(--text); font-size: 13px; flex: 0 0 auto;
}
.cat {
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.cat-header {
  display: flex; align-items: center; gap: 6px; width: 100%;
  padding: 9px 10px; font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-dim); font-weight: 700; background: transparent; border: none; cursor: pointer;
  text-align: left;
}
.cat-header:hover { color: var(--text); background: rgba(255,255,255,0.03); }
.cat-header .chev { font-size: 9px; transition: transform .15s; flex: 0 0 auto; color: var(--text-dim); }
.cat.collapsed .cat-header .chev { transform: rotate(-90deg); }
.cat-header .cat-count { margin-left: auto; font-size: 10px; color: var(--text-dim); font-weight: 400; }
.cat-items { overflow: hidden; }
.cat.collapsed .cat-items { display: none; }
.palette-item {
  display: flex; align-items: center; gap: 8px; margin: 2px 8px; padding: 7px 8px;
  border-radius: 6px; border: 1px solid transparent; font-size: 13px; user-select: none; cursor: pointer;
}
.palette-item:hover { background: var(--panel2); border-color: var(--border); }
.palette-item .swatch { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }
.palette-item .pname { flex: 1; }
.palette-item .pprice { font-size: 10px; color: var(--text-dim); font-family: monospace; flex: 0 0 auto; }
.palette-item .info-icon {
  width: 16px; height: 16px; border-radius: 50%; border: 1px solid var(--text-dim);
  color: var(--text-dim); font-size: 11px; display: flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
}
.palette-item .info-icon:hover { color: var(--accent); border-color: var(--accent); }

#costSummary {
  margin: 8px; padding: 10px 12px; background: var(--panel2); border: 1px solid var(--border);
  border-radius: 8px; font-size: 12px; cursor: pointer; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  transition: border-color .1s;
}
#costSummary:hover { border-color: var(--accent2); }
#costSummary .cost-mini-label { color: var(--text-dim); }
#costSummary .cost-mini-total { font-weight: 700; color: var(--green); font-family: monospace; }

/* ---------------- Canvas / workspace ---------------- */
#workspace-wrap { flex: 1; position: relative; overflow: auto; background: var(--bg); }
#workspace {
  position: relative; width: 4000px; height: 3000px;
  background-image:
    linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 40px 40px;
  transform-origin: 0 0;
}
#wireLayer { position: absolute; top: 0; left: 0; pointer-events: none; }
#wireLayer path.wire { pointer-events: stroke; cursor: pointer; }
#wireLayer path.wire:hover { filter: drop-shadow(0 0 3px #fff); }
#wireLayer path.wire.selected { stroke-dasharray: 6 4; }
#wireLayer path.tempwire { pointer-events: none; }
#regionLayer { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; }

/* ---------------- Node ---------------- */
.node {
  position: absolute; background: var(--panel2); border: 1px solid var(--border);
  border-radius: 9px; box-shadow: 0 2px 6px rgba(0,0,0,0.35), 0 8px 20px rgba(0,0,0,0.22);
  user-select: none; display: flex; flex-direction: column; height: auto;
  transition: box-shadow .12s ease, border-color .12s ease;
}
.node:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.4), 0 10px 26px rgba(0,0,0,0.3); }
.node.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(79,184,232,0.55), 0 2px 6px rgba(0,0,0,0.35), 0 8px 20px rgba(0,0,0,0.25);
}
.node.multi-selected {
  border-color: var(--accent2);
  box-shadow: 0 0 0 2px rgba(224,160,48,0.55), 0 2px 6px rgba(0,0,0,0.35), 0 8px 20px rgba(0,0,0,0.25);
}

/* Colored left accent bar — instant visual category ID without reading text,
   crucial for scanning a big build at a glance ("blue strip = a gate", etc).
   Rounded only on the left to match the node's own corner radius; NOTE:
   the node itself must NOT use overflow:hidden, since ports are
   intentionally positioned partially outside its box. */
.node-accent {
  position: absolute; left: 0; top: 0; bottom: 0; width: 5px;
  background: var(--accent-color, var(--accent)); z-index: 1;
  border-radius: 8px 0 0 8px;
}

.node-header {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 8px 7px 12px; cursor: grab;
  background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0));
  border-bottom: 1px solid rgba(255,255,255,0.06);
  border-radius: 8px 8px 0 0;
  font-size: 12.5px; font-weight: 600; letter-spacing: .01em;
}
.node-header:active { cursor: grabbing; }
.node-header .htitle {
  flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text);
}
.node-header .nbtn {
  width: 20px; height: 20px; border-radius: 5px; border: none; background: transparent;
  color: var(--text-dim); font-size: 13px; display: flex; align-items: center; justify-content: center;
  flex: 0 0 auto; transition: background .1s, color .1s;
}
.node-header .nbtn:hover { background: rgba(255,255,255,0.12); color: var(--text); }
.node-header .del-btn:hover { background: rgba(230,88,79,0.25); color: var(--red); }

.node-body {
  flex: 1; position: relative; padding: 12px 10px 20px 14px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px; min-height: 36px;
}

/* ---- Ports ----
   Inputs and outputs get distinct shapes/colors so signal direction reads at
   a glance in a dense diagram: inputs = cool blue-tinted squares on the left,
   outputs = warm amber-tinted squares on the right. An active (signal > 0)
   port always glows green regardless of direction. */
.port {
  position: absolute; width: 14px; height: 14px;
  border-radius: 3px; cursor: crosshair; z-index: 5;
  transition: transform .08s ease, box-shadow .08s ease;
}
.port.in { left: -7px; background: #1c2733; border: 2px solid #3a5a75; }
.port.out { right: -7px; background: #332a1c; border: 2px solid #7a5a2e; }
.port:hover { transform: scale(1.25); box-shadow: 0 0 0 4px rgba(79,184,232,0.18); }
.port.in:hover { border-color: var(--accent); }
.port.out:hover { border-color: var(--accent2); }
.port.active { background: var(--green); border-color: var(--green); box-shadow: 0 0 8px var(--green); }

.port-label {
  position: absolute; font-size: 9.5px; color: var(--text-dim); white-space: nowrap; pointer-events: none;
  font-weight: 600; letter-spacing: .02em; text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}
.port-badge {
  position: absolute; top: -7px; right: -7px; background: var(--accent2); color: #1a1200;
  font-size: 9px; font-weight: 700; border-radius: 50%; width: 14px; height: 14px;
  display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 6;
  box-shadow: 0 0 0 2px var(--panel2);
}

/* ---------------- Canvas / workspace ---------------- */

/* controls inside node body */
.ctrl-btn {
  padding: 8px 14px; border-radius: 6px; border: 1px solid var(--border); background: #3a3f4c;
  color: var(--text); font-size: 12px; font-weight: 700;
}
.ctrl-btn.active { background: var(--green); color: #06210a; border-color: var(--green); }
.ctrl-toggle {
  padding: 8px 14px; border-radius: 20px; border: 1px solid var(--border); background: #3a3f4c; color: var(--text-dim);
  font-size: 11px; font-weight: 700;
}
.ctrl-toggle.on { background: var(--green); color: #06210a; border-color: var(--green); }
.ctrl-slider { display: flex; flex-direction: column; align-items: center; width: 90%; gap: 2px; }
.ctrl-slider input[type=range] { width: 100%; }
.ctrl-slider .val { font-size: 11px; color: var(--accent2); font-weight: 700; }
.ctrl-select, .ctrl-number, .ctrl-text {
  width: 90%; background: #1d1f26; border: 1px solid var(--border); color: var(--text);
  border-radius: 5px; padding: 4px 6px; font-size: 12px;
}

/* Number Interface — redesigned to look like a deliberate constant-value source */
.ctrl-numiface { width: 94%; background: #1d1f26; border: 1px solid var(--border); border-radius: 8px; padding: 8px; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.numiface-label { font-size: 10px; letter-spacing: .08em; color: var(--accent2); font-weight: 700; }
.numiface-row { display: flex; align-items: center; gap: 6px; width: 100%; }
.numiface-step { width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--border); background: #3a3f4c; color: var(--text); font-weight: 700; flex: 0 0 auto; }
.numiface-step:hover { border-color: var(--accent); }
.numiface-input { flex: 1; min-width: 0; text-align: center; background: #06140a; color: var(--green); border: 1px solid #224; border-radius: 5px; padding: 5px 2px; font-family: 'Consolas', monospace; font-size: 16px; font-weight: 700; }

/* Donator */
.donator-box { width: 94%; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.donator-amount { font-size: 13px; font-weight: 700; color: var(--accent2); background: #1d1f26; border-radius: 6px; padding: 5px 8px; width: 100%; text-align: center; }

/* Interactor */
.interactor-box { display: flex; flex-direction: column; align-items: center; gap: 2px; }

/* Generic inline param editors (Delay seconds, Sustainer duration, channel #, message text, etc.) */
.param-field { width: 92%; display: flex; flex-direction: column; gap: 2px; }
.param-field label { font-size: 9px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .05em; }
.param-field input { width: 100%; background: #1d1f26; border: 1px solid var(--border); color: var(--text); border-radius: 5px; padding: 4px 6px; font-size: 12px; }
.param-field input:focus { border-color: var(--accent); outline: none; }
.ctrl-bits { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.bit-btn { width: 26px; height: 22px; border-radius: 4px; border: 1px solid var(--border); background: #1d1f26; color: var(--text-dim); font-size: 10px; font-weight: 700; }
.bit-btn.on { background: var(--accent2); color: #000; }
.lamp { width: 22px; height: 22px; border-radius: 50%; background: #1d1f26; border: 2px solid var(--border); }
.lamp.on { background: var(--green); border-color: var(--green); box-shadow: 0 0 10px var(--green); }
.value-readout { font-size: 18px; font-weight: 700; color: var(--green); font-family: 'Consolas', monospace; }
.display-screen {
  background: #06140a; color: #6dff7b; font-family: 'Consolas', monospace; font-size: 18px;
  border-radius: 4px; padding: 6px 8px; width: 90%; text-align: center; border: 1px solid #224;
  min-height: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.seg-digit { font-size: 36px; font-family: 'Consolas', monospace; color: #ff3b3b; text-shadow: 0 0 8px #ff3b3b; }
.seg-digit.off { color: #3a1212; text-shadow: none; }
.billboard { background: #06090f; color: #4fd1ff; font-weight: 700; padding: 8px; border-radius: 4px; width: 92%; text-align: center; font-size: 13px; letter-spacing: .05em; }
.billboard.off { color: #1c2733; }
.glass-pane { width: 90%; height: 30px; border-radius: 4px; border: 1px solid var(--border); background: rgba(150,200,255,0.08); transition: background .2s; }
.glass-pane.opaque { background: rgba(255,255,255,0.85); }
.lockpad { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.lockpad input { width: 80px; text-align: center; }
.commander-trigger { display: flex; flex-direction: column; gap: 4px; align-items: center; }

/* Logic gate equation display */
.gate-equation { font-family: 'Consolas', monospace; font-size: 15px; font-weight: 700; color: var(--accent); letter-spacing: .03em; }
.gate-live { font-family: 'Consolas', monospace; font-size: 10px; color: var(--text-dim); }

/* ---- Regions ---- */
.region {
  position: absolute; border-radius: 10px; border: 2px solid;
  pointer-events: none; /* children override this */
  box-sizing: border-box;
}
.region-header {
  display: flex; align-items: center; gap: 6px; padding: 5px 8px 4px;
  border-radius: 8px 8px 0 0; font-size: 12px; font-weight: 700;
  cursor: grab; pointer-events: auto; user-select: none;
}
.region-header input.region-label-edit {
  background: transparent; border: none; outline: none; color: inherit;
  font-size: 12px; font-weight: 700; width: 100%; cursor: text;
}
.region-resize {
  position: absolute; right: 0; bottom: 0; width: 18px; height: 18px;
  cursor: se-resize; pointer-events: auto;
  background: linear-gradient(135deg, transparent 50%, rgba(255,255,255,.25) 50%);
  border-radius: 0 0 8px 0;
}
.region-del {
  position: absolute; top: 4px; right: 6px; background: none; border: none;
  color: rgba(255,255,255,.5); font-size: 14px; cursor: pointer; pointer-events: auto;
  line-height: 1; padding: 0 2px;
}
.region-del:hover { color: #fff; }
.region.selected { outline: 2px dashed rgba(255,255,255,.6); outline-offset: 2px; }

/* ---- Wire anchor handles ---- */
.wire-anchor-handle {
  cursor: grab; transition: r .1s;
}
.wire-anchor-handle:hover { r: 8; }
.wire-anchor-handle:active { cursor: grabbing; }

/* ---- Wire path hit-area (invisible wider stroke for easier clicking) ---- */
path.wire-hitarea {
  pointer-events: stroke; fill: none; stroke: transparent; stroke-width: 14;
}

/* ---- Multi-select box ---- */
.marquee-box {
  position: absolute; border: 1.5px dashed var(--accent); background: rgba(79,184,232,.09);
  pointer-events: none; z-index: 50; border-radius: 3px;
}

/* ---- Node multi-select highlight ---- */
.node.multi-selected {
  border-color: var(--accent2);
  box-shadow: 0 0 0 2px rgba(224,160,48,.35), 0 3px 10px rgba(0,0,0,.4);
}

/* ---- Feedback modal ---- */
.feedback-stars { display: flex; gap: 6px; margin-bottom: 10px; }
.feedback-stars .star {
  font-size: 22px; cursor: pointer; color: var(--border); transition: color .1s;
  background: none; border: none; padding: 0;
}
.feedback-stars .star.active { color: var(--accent2); }
.feedback-status { font-size: 13px; margin-top: 8px; min-height: 20px; }
.feedback-status.ok { color: var(--green); }
.feedback-status.err { color: var(--red); }

/* ---- Region color swatches (in inspector) ---- */
.color-swatches { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.color-swatch {
  width: 24px; height: 24px; border-radius: 6px; border: 2px solid transparent;
  cursor: pointer;
}
.color-swatch.active { border-color: #fff; }

/* ---- Clipboard indicator ---- */
#clipboardIndicator {
  font-size: 11px; color: var(--text-dim); padding: 0 4px;
  display: none;
}


/* ---------------- Right panel ---------------- */
#inspector {
  width: 280px; background: var(--panel); border-left: 1px solid var(--border);
  padding: 12px; overflow-y: auto; flex: 0 0 auto;
}
#inspector h3 { margin: 0 0 8px; font-size: 14px; color: var(--accent2); }
#inspector .empty { color: var(--text-dim); font-size: 13px; }
.insp-row { margin-bottom: 10px; }
.insp-row label { display: block; font-size: 11px; color: var(--text-dim); margin-bottom: 3px; }
.insp-row input, .insp-row select { width: 100%; background: #1d1f26; border: 1px solid var(--border); color: var(--text); border-radius: 5px; padding: 5px 6px; }
.insp-note { font-size: 12px; color: var(--text-dim); line-height: 1.4; background: var(--panel2); border-radius: 6px; padding: 8px; margin-top: 10px; }
.insp-ports { font-size: 12px; margin-top: 10px; }
.insp-ports .prow { display: flex; justify-content: space-between; padding: 3px 0; border-bottom: 1px dashed var(--border); }
.insp-ports .pv { color: var(--green); font-family: monospace; }
.insp-delete { width: 100%; margin-top: 14px; background: var(--red); color: #fff; border: none; border-radius: 6px; padding: 8px; font-weight: 700; }

/* ---------------- Wire priority popup ---------------- */
#priorityPopup {
  position: absolute; background: var(--panel); border: 1px solid var(--accent); border-radius: 8px;
  padding: 8px; box-shadow: 0 6px 20px rgba(0,0,0,0.6); z-index: 100; width: 220px;
}
#priorityPopup h4 { margin: 0 0 6px; font-size: 12px; color: var(--accent2); }
#priorityPopup .priwire {
  display: flex; align-items: center; gap: 6px; padding: 5px 6px; margin-bottom: 4px; border-radius: 5px;
  background: var(--panel2); cursor: grab; font-size: 11px; border: 1px solid var(--border);
}
#priorityPopup .priwire .swatch { width: 12px; height: 12px; border-radius: 3px; }
#priorityPopup .priwire.top { border-color: var(--green); }
#priorityPopup .rank { width: 16px; text-align: center; color: var(--text-dim); font-weight: 700; }
#priorityPopup .close { float: right; cursor: pointer; color: var(--text-dim); }

/* ---------------- Tooltip ---------------- */
#tooltip {
  position: absolute; max-width: 260px; background: #11131a; border: 1px solid var(--accent);
  color: var(--text); font-size: 12px; padding: 8px 10px; border-radius: 6px; z-index: 200;
  line-height: 1.4; pointer-events: none; display: none;
}

/* ---------------- Modal ---------------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 300;
}
.modal {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 18px;
  width: 460px; max-height: 80vh; overflow-y: auto;
}
.modal h2 { margin-top: 0; color: var(--accent2); font-size: 16px; }
.modal textarea { width: 100%; height: 220px; background: #11131a; color: var(--text); border: 1px solid var(--border); border-radius: 6px; font-family: monospace; font-size: 12px; }
.modal .row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.modal button { background: var(--panel2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 7px 14px; }
.modal button.primary { background: var(--accent); color: #08222d; border-color: var(--accent); font-weight: 700; }

/* ---------------- Cost summary ---------------- */
.cost-table { max-height: 320px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; }
.cost-row { display: grid; grid-template-columns: 2fr 0.6fr 1fr 1fr; gap: 6px; align-items: center; padding: 6px 10px; font-size: 13px; border-bottom: 1px solid var(--border); }
.cost-row:last-child { border-bottom: none; }
.cost-row.cost-header { background: var(--panel2); font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }
.cost-qty { color: var(--text-dim); }
.cost-unit { display: flex; align-items: center; gap: 2px; }
.cost-price-input { width: 70px; background: #1d1f26; border: 1px solid var(--border); color: var(--text); border-radius: 5px; padding: 3px 5px; font-size: 12px; }
.cost-subtotal { font-weight: 700; color: var(--green); text-align: right; }
.cost-grand-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 10px; margin-top: 8px; background: var(--panel2); border-radius: 8px; font-size: 15px; }
.cost-grand-row #costTotal { font-weight: 800; color: var(--accent2); font-size: 18px; }

/* ---------------- Misc ---------------- */
#statusbar {
  flex: 0 0 auto; background: var(--panel); border-top: 1px solid var(--border); color: var(--text-dim);
  font-size: 11px; padding: 4px 10px; display: flex; gap: 16px; align-items: center;
}
#statusbar .spacer { flex: 1; }
#statusbar b { color: var(--accent2); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }

/* ---------------- LCD / Bulb light array ---------------- */
.light-array {
  display: flex; gap: 3px; padding: 4px; background: #0a0c10; border-radius: 6px;
  border: 1px solid #1e2230; flex-wrap: wrap; justify-content: center; max-width: 96%;
}
.light-cell {
  width: 14px; height: 14px; border-radius: 3px; background: #1a1d24;
  border: 1px solid #2a2e38; transition: background .05s;
}
.light-array.round .light-cell { border-radius: 50%; width: 16px; height: 16px; }
.light-cell.on { background: var(--green); border-color: var(--green); box-shadow: 0 0 5px var(--green); }

/* ---------------- Inspector price tag ---------------- */
.insp-price {
  font-size: 12px; color: var(--text-dim); background: var(--panel2); border-radius: 6px;
  padding: 6px 8px; margin-top: 8px; display: flex; align-items: center; gap: 5px;
}
.insp-price b { color: var(--accent2); }

/* ---------------- Speaker display ---------------- */
.speaker-msg {
  font-size: 12px; background: #06090f; color: #4fd1ff; border: 1px solid #1c2733;
  border-radius: 6px; padding: 5px 8px; width: 92%; text-align: center;
  min-height: 36px; display: flex; align-items: center; justify-content: center;
  word-break: break-word; line-height: 1.3;
}
.speaker-msg.flashing { color: #fff; border-color: var(--accent2); box-shadow: 0 0 8px var(--accent2); }
.speaker-msg.idle { color: #2a4055; font-style: italic; }
