﻿* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #fafafa;
  color: #222;
  overflow: hidden;
}
header {
  padding: 10px 20px;
  background: #1a1a1a;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
header h1 { margin: 0; font-size: 15px; font-weight: 500; }
header .sub { font-size: 11px; color: #aaa; margin-top: 2px; }

.layout {
  display: grid;
  grid-template-columns: 220px 1fr 320px;
  height: calc(100vh - 50px);
}

/* ---- Palett ---- */
.palette { background: #f0f0f0; border-right: 1px solid #ddd; padding: 12px; overflow-y: auto; }
.palette h2 {
  margin: 0 0 8px 0; font-size: 10px; color: #555;
  text-transform: uppercase; letter-spacing: 1px;
}
.palette-hint { font-size: 11px; color: #777; margin-bottom: 10px; line-height: 1.4; }
.palette-item {
  padding: 7px 10px; border: 1px solid #ddd; background: #fff;
  margin-bottom: 3px; cursor: pointer; border-radius: 3px;
  font-size: 12px; transition: all 0.1s;
}
.palette-item.active {
  background: #e3f2fd; border-color: #1565c0; color: #1565c0;
}
.palette-item:hover { background: #f8f8f8; border-color: #bbb; }
.palette-item.armed {
  border-color: #c00; background: #fff0f0;
  box-shadow: 0 0 0 1px #c00;
}
.palette-item .pal-type {
  font-size: 9px; color: #888; text-transform: uppercase;
  letter-spacing: 0.5px; margin-top: 2px;
}
.palette-group-label {
  font-size: 9px; color: #888; text-transform: uppercase; letter-spacing: 1px;
  margin: 10px 0 4px 0; padding-bottom: 3px; border-bottom: 1px solid #ddd;
  cursor: pointer; user-select: none; display: flex; align-items: center; gap: 4px;
}
.palette-group-label:hover { color: #555; border-bottom-color: #bbb; }
.palette-group-label.collapsed { color: #bbb; border-bottom-color: #eee; }
.palette-group-label:first-child { margin-top: 0; }
.pal-chevron { font-size: 7px; flex-shrink: 0; opacity: 0.7; }
.pal-signal {
  display: inline-block; font-size: 8px; padding: 1px 4px; border-radius: 2px;
  vertical-align: middle; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px;
}
.pal-signal.analog  { background: #e8f4e8; color: #2e7d32; }
.pal-signal.digital { background: #e8eaf6; color: #1a237e; }
.sensor-signal-badge {
  display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 3px; font-weight: 600;
}
.sensor-signal-badge.analog  { background: #e8f4e8; color: #2e7d32; }
.sensor-signal-badge.digital { background: #e8eaf6; color: #1a237e; }

/* ---- Canvas ---- */
.canvas-wrap { overflow: auto; background: #fff; position: relative; }
.canvas-wrap.armed { cursor: crosshair; }
.canvas-wrap.wire-mode { cursor: crosshair; }
.canvas-wrap.pan-mode { cursor: grab; }
.canvas-wrap.pan-mode.panning { cursor: grabbing; }
.canvas-wrap.select-mode { cursor: crosshair; }
.canvas-wrap svg { display: block; width: 100%; height: 100%; }
.toolbar {
  position: absolute; top: 10px; left: 10px;
  background: rgba(255,255,255,0.95); border: 1px solid #ddd;
  border-radius: 3px; padding: 6px; display: flex; gap: 4px; z-index: 10;
  flex-wrap: wrap; max-width: calc(100% - 20px);
}
.toolbar button {
  border: 1px solid #ccc; background: #fff; padding: 5px 10px;
  cursor: pointer; font-size: 11px; border-radius: 2px;
}
.toolbar select {
  border: 1px solid #ccc; background: #fff; padding: 4px 6px;
  font-size: 11px; border-radius: 2px; max-width: 180px;
}
.toolbar .select-group {
  display: flex; align-items: center; gap: 4px;
  font-size: 10px; color: #555; padding: 0 4px;
}
.toolbar button:hover { background: #f0f0f0; }
.toolbar button:disabled { opacity: 0.4; cursor: not-allowed; }
.toolbar button.active {
  background: #c00; color: #fff; border-color: #900;
}
.toolbar label {
  display: flex; align-items: center; gap: 4px;
  font-size: 11px; padding: 0 6px; cursor: pointer;
}

/* ---- Info-panel ---- */
.panel { background: #f5f5f5; border-left: 1px solid #ddd; padding: 14px; overflow-y: auto; font-size: 13px; }
.panel h2 {
  margin: 0 0 10px 0; font-size: 10px; color: #555;
  text-transform: uppercase; letter-spacing: 1px;
}
.info-card {
  background: #fff; border: 1px solid #ddd; border-radius: 4px;
  padding: 12px; margin-bottom: 10px;
}
.info-card .row { margin-bottom: 8px; }
.info-card .label {
  font-size: 10px; color: #888; text-transform: uppercase;
  letter-spacing: 0.5px; margin-bottom: 2px;
}
.info-card .value { font-size: 13px; }
.info-card input[type="text"] {
  width: 100%; padding: 4px 6px; border: 1px solid #ccc;
  border-radius: 3px; font-size: 13px; font-family: inherit;
}
.info-card .pin-id {
  display: inline-block; background: #1a1a1a; color: #fff;
  padding: 2px 8px; border-radius: 3px;
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px;
}
.info-card .desc {
  font-size: 11px; color: #555; line-height: 1.5;
  background: #f9f9f9; padding: 8px; border-radius: 3px;
  border-left: 3px solid #c00;
}
.terminal-list { list-style: none; padding: 0; margin: 0; font-size: 11px; }
.terminal-list li {
  padding: 3px 6px; background: #f8f8f8; border-radius: 2px;
  margin-bottom: 2px; font-family: ui-monospace, Menlo, Consolas, monospace;
}
.side-buttons {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px;
}
.side-buttons button {
  padding: 6px 4px; border: 1px solid #ccc; background: #fff;
  cursor: pointer; font-size: 11px; border-radius: 3px;
}
.side-buttons button.active {
  background: #1a1a1a; color: #fff; border-color: #1a1a1a;
}
.side-buttons button:hover:not(.active) { background: #f0f0f0; }

.color-swatch-grid {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px;
}
.color-swatch {
  aspect-ratio: 1;
  border: 2px solid #ccc;
  border-radius: 3px;
  cursor: pointer;
  position: relative;
}
.color-swatch.active {
  border-color: #1a1a1a;
  box-shadow: 0 0 0 2px #fff inset;
}
.color-swatch .swatch-label {
  position: absolute; bottom: -16px; left: 0; right: 0;
  text-align: center; font-size: 9px; color: #555;
}

.endpoint-pill {
  display: inline-block;
  padding: 3px 8px;
  background: #e8e8e8;
  border-radius: 3px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 11px;
  margin-right: 4px;
}

.btn-danger {
  background: #c00; color: #fff; border: 1px solid #900;
  padding: 6px 12px; border-radius: 3px; cursor: pointer;
  font-size: 12px; width: 100%;
}
.btn-danger:hover { background: #900; }
.empty { color: #888; font-style: italic; font-size: 12px; }
.note {
  margin-top: 12px; padding: 8px;
  background: #fff8e6; border: 1px solid #f0d878; border-radius: 3px;
  font-size: 10px; color: #6b5500; line-height: 1.5;
}
.wire-mode-banner {
  background: #c00; color: #fff; padding: 8px 12px;
  text-align: center; font-size: 12px; font-weight: 500;
  margin-bottom: 10px; border-radius: 3px;
}

/* ---- SVG ---- */
.grid-line { stroke: #e8e8e8; stroke-width: 0.5; pointer-events: none; }
.selection-box {
  fill: rgba(198, 0, 0, 0.08);
  stroke: #c00;
  stroke-width: 1;
  stroke-dasharray: 4,3;
  pointer-events: none;
}
.ecu-box { fill: #fff; stroke: #1a1a1a; stroke-width: 1.5; }
.pin-line { stroke: #444; stroke-width: 1; fill: none; }
.pin-line.selected { stroke: #c00; stroke-width: 2; }
.pin-line.wire-armed { stroke: #c00; stroke-width: 2.5; }
.pin-label { font-size: 10px; fill: #222; }
.pin-label.selected { fill: #c00; font-weight: 600; }
.pin-label.wire-armed { fill: #c00; font-weight: 700; }
.pin-id-label {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 9px; fill: #888;
}
.pin-id-label.selected { fill: #c00; font-weight: 600; }
.pin-id-label.wire-armed { fill: #c00; font-weight: 700; }
.pin-hit { fill: transparent; cursor: pointer; }
.canvas-wrap.wire-mode .pin-hit { cursor: crosshair; }
.ecu-title { font-size: 14px; font-weight: 600; fill: #1a1a1a; }
.ecu-sub {
  font-size: 10px; fill: #888;
  text-transform: uppercase; letter-spacing: 1px;
}
.group-label {
  font-size: 9px; fill: #999;
  text-transform: uppercase; letter-spacing: 1px;
}

.component { cursor: move; }
.canvas-wrap.wire-mode .component { cursor: crosshair; }
.comp-body {
  fill: #fff; stroke: #333; stroke-width: 1.2;
}
.comp-body.selected { stroke: #c00; stroke-width: 2; }
.comp-label {
  font-size: 10px; fill: #222; pointer-events: none; text-anchor: middle;
}
.comp-sublabel {
  font-size: 7px; fill: #888; pointer-events: none;
  text-anchor: middle; text-transform: uppercase; letter-spacing: 0.3px;
}
.terminal {
  fill: #fff; stroke: #333; stroke-width: 1; cursor: crosshair;
}
.terminal:hover { fill: #ffe0a0; }
.terminal.wire-armed { fill: #c00; stroke: #900; stroke-width: 1.5; }
.terminal-name {
  font-size: 8px; fill: #555; pointer-events: none;
}

.wire {
  fill: none;
  cursor: pointer;
}
.wire:hover { stroke-width: 3.5 !important; }
.wire.selected { stroke-width: 3.5 !important; }
.wire-ghost {
  fill: none;
  stroke-dasharray: 4,3;
  pointer-events: none;
}
.wire-label-bg {
  fill: rgba(255,255,255,0.85);
  pointer-events: none;
}
.wire-label-text {
  font-size: 9px;
  fill: #333;
  pointer-events: none;
  text-anchor: middle;
}
.wire-handle {
  fill: #fff;
  stroke: #c00;
  stroke-width: 1.5;
  cursor: move;
}
.wire-handle:hover { fill: #ffe0a0; }
.wire-plus {
  fill: #fff;
  stroke: #888;
  stroke-width: 1;
  cursor: pointer;
  opacity: 0.55;
}
.wire-plus:hover { opacity: 1; fill: #c00; stroke: #c00; }
.wire-plus-text {
  font-size: 11px;
  font-weight: 600;
  fill: #888;
  text-anchor: middle;
  pointer-events: none;
  opacity: 0.55;
}
.wire-plus-group:hover .wire-plus-text { fill: #fff; opacity: 1; }

/* ---- Eksportmodal ---- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal-box {
  background: #fff; border-radius: 5px; box-shadow: 0 8px 32px rgba(0,0,0,0.22);
  width: 480px; max-width: calc(100vw - 40px); font-size: 13px;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 12px; border-bottom: 1px solid #ddd;
}
.modal-title { font-size: 14px; font-weight: 600; }
.modal-close {
  background: none; border: none; font-size: 16px; cursor: pointer;
  color: #777; line-height: 1; padding: 2px 4px;
}
.modal-close:hover { color: #c00; }
.modal-section { padding: 12px 16px; border-bottom: 1px solid #f0f0f0; }
.modal-label { font-size: 10px; color: #888; text-transform: uppercase; letter-spacing: 0.7px; margin-bottom: 8px; }
.modal-row { display: flex; gap: 8px; }
.modal-check { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.size-btn {
  flex: 1; padding: 7px 10px; border: 1px solid #ccc; background: #f8f8f8;
  border-radius: 3px; cursor: pointer; font-size: 12px; text-align: center;
}
.size-btn:hover { background: #f0f0f0; border-color: #bbb; }
.size-btn.active { border-color: #1a1a1a; background: #1a1a1a; color: #fff; }
.tb-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.tb-grid label {
  display: flex; flex-direction: column; gap: 3px;
  font-size: 10px; color: #888; text-transform: uppercase; letter-spacing: 0.5px;
}
.tb-grid label input {
  padding: 5px 7px; border: 1px solid #ccc; border-radius: 3px;
  font-size: 12px; font-family: inherit; color: #222; margin-top: 1px;
}
.tb-full { grid-column: 1 / -1; }
.modal-footer {
  padding: 12px 16px; display: flex; gap: 8px; justify-content: flex-end;
}
.btn-primary {
  padding: 7px 18px; background: #1a1a1a; color: #fff;
  border: none; border-radius: 3px; cursor: pointer; font-size: 12px;
}
.btn-primary:hover { background: #333; }
.btn-secondary {
  padding: 7px 14px; background: #f0f0f0; color: #222;
  border: 1px solid #ccc; border-radius: 3px; cursor: pointer; font-size: 12px;
}
.btn-secondary:hover { background: #e0e0e0; }

/* ---- Utskriftsramme-overlay (SVG-elementer) ---- */
.print-area-border {
  fill: none; stroke: #0055cc; stroke-width: 1.2;
  stroke-dasharray: 8,4; pointer-events: none;
}
.print-tb-line {
  fill: none; stroke: #0055cc; stroke-width: 0.8; pointer-events: none;
}
.print-area-label {
  font-size: 9px; fill: #0055cc; pointer-events: none;
}



/* Wire thickness buttons */
.thickness-btn.active { background: #1a1a1a !important; color: #fff !important; border-color: #1a1a1a !important; }


/* ===== HEADER NAV ===== */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 20px;
  min-height: 50px;
}
.header-left { display: flex; flex-direction: column; }
.header-nav { display: flex; gap: 6px; align-items: center; }
.nav-btn {
  padding: 5px 14px; border: 1px solid #555; background: transparent;
  color: #ccc; font-size: 12px; border-radius: 3px; cursor: pointer;
  transition: all 0.1s;
}
.nav-btn:hover { background: #333; color: #fff; border-color: #888; }
.nav-btn.active { background: #c00; color: #fff; border-color: #900; }
.nav-action-btn { border-color: #2e7d32; color: #90EE90; }
.nav-action-btn:hover { background: #2e7d32; color: #fff; border-color: #1b5e20; }
.nav-divider { width: 1px; height: 20px; background: #444; margin: 0 4px; }

/* ===== START SCREEN ===== */
#start-screen {
  height: calc(100vh - 50px);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: #fafafa; overflow-y: auto; padding: 40px 20px;
}
.start-hero { text-align: center; margin-bottom: 36px; }
.start-title { font-size: 28px; font-weight: 600; color: #1a1a1a; margin-bottom: 8px; }
.start-sub { font-size: 14px; color: #666; }
.start-cards { display: flex; gap: 24px; flex-wrap: wrap; justify-content: center; margin-bottom: 32px; }
.start-card {
  width: 280px; background: #fff; border: 1.5px solid #ddd;
  border-radius: 8px; padding: 24px; cursor: pointer;
  transition: all 0.15s; display: flex; flex-direction: column;
}
.start-card:hover { border-color: #c00; box-shadow: 0 4px 16px rgba(0,0,0,0.10); transform: translateY(-2px); }
.start-card-icon { height: 70px; display: flex; align-items: center; justify-content: center; margin-bottom: 16px; }
.start-card-icon svg { width: 80px; height: 60px; }
.start-card-title { font-size: 17px; font-weight: 600; color: #1a1a1a; margin-bottom: 8px; }
.start-card-desc { font-size: 12px; color: #666; line-height: 1.5; flex: 1; margin-bottom: 16px; }
.start-card-btn { font-size: 12px; font-weight: 600; color: #c00; }
.start-card:hover .start-card-btn { text-decoration: underline; }
.start-actions { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.start-load-btn {
  padding: 8px 24px; border: 1px solid #ccc; background: #fff;
  border-radius: 4px; cursor: pointer; font-size: 13px; color: #444;
}
.start-load-btn:hover { background: #f0f0f0; border-color: #bbb; }
.start-note { font-size: 11px; color: #888; }

/* ===== LAYOUT VIEW ===== */
#layout-view { height: calc(100vh - 50px); }
.layout-palette { width: 220px; }
#layout-canvas-wrap { overflow: hidden; background: #fff; position: relative; }
#layout-canvas-wrap svg { display: block; width: 100%; height: 100%; }

/* ===== LAYOUT SVG ELEMENTS ===== */
.layout-node-junction {
  fill: #1a1a1a; cursor: move;
}
.layout-node-junction.selected { fill: #c00; }
.layout-node-junction.connect-armed { fill: #c00; cursor: crosshair; }
.layout-node-label {
  font-size: 11px; font-weight: 600; fill: #1a1a1a;
  text-anchor: middle; pointer-events: none;
}
.layout-node-junction.selected + .layout-node-label { fill: #c00; }
.layout-node-connector-body {
  fill: #fff; stroke: #333; stroke-width: 1.5; cursor: move;
}
.layout-node-connector-body.selected { stroke: #c00; stroke-width: 2; }
.layout-node-connector-label {
  font-size: 9px; fill: #222; text-anchor: middle; pointer-events: none;
}
.layout-node-ecu-body {
  fill: #f8f8f8; stroke: #1a1a1a; stroke-width: 1.5; cursor: move;
}
.layout-node-ecu-label {
  font-size: 9px; font-weight: 600; fill: #1a1a1a; text-anchor: middle; pointer-events: none;
}
.layout-branch {
  fill: none; stroke: #444; cursor: pointer;
}
.layout-branch:hover { stroke: #c00; }
.layout-branch.selected { stroke: #c00; }
.layout-branch-hit {
  fill: none; stroke: transparent; stroke-width: 10; cursor: pointer;
}
.layout-branch-label {
  font-size: 9px; fill: #333; text-anchor: middle; pointer-events: none;
}
.layout-branch-badge {
  font-size: 7px; font-weight: 700; fill: #fff; text-anchor: middle; pointer-events: none;
}
.layout-branch-badge-bg {
  fill: #555; rx: 2; pointer-events: none;
}
.layout-ghost-line {
  fill: none; stroke: #c00; stroke-dasharray: 6,4;
  stroke-width: 2; pointer-events: none;
}
.layout-connector-icon { pointer-events: none; }

/* ===== CONNECTOR LIBRARY IN PALETTE ===== */
.conn-lib-filter {
  width: 100%; font-size: 10px; margin-bottom: 5px;
  padding: 3px 4px; border: 1px solid #ccc; border-radius: 3px; background: #fff;
}
.conn-lib-section-header {
  font-size: 9px; font-weight: 700; color: #666; text-transform: uppercase;
  letter-spacing: 0.6px; margin: 8px 0 3px; padding: 0 2px;
}
.conn-lib-item {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 6px; border: 1px solid #ddd; background: #fff;
  margin-bottom: 3px; border-radius: 3px; cursor: pointer; font-size: 11px;
  transition: background 0.1s;
}
.conn-lib-item:hover { background: #f0f4ff; border-color: #90b0e0; }
.conn-lib-item.active { background: #e3f2fd; border-color: #1565c0; }
.conn-lib-item svg { flex-shrink: 0; }
.conn-lib-name { font-size: 10px; color: #333; font-weight: 500; }
.conn-lib-brand { font-size: 8px; color: #888; }
.conn-lib-part { font-size: 8px; color: #aaa; margin-top: 1px; }
/* ===== LAYOUT COMPONENT LIST ===== */
.layout-comp-item {
  display: flex; flex-direction: column; gap: 1px;
  padding: 4px 7px; border: 1px solid #ddd; background: #fff;
  margin-bottom: 3px; border-radius: 3px; cursor: pointer; font-size: 11px;
  transition: background 0.1s;
}
.layout-comp-item:hover { background: #f0f4ff; border-color: #90b0e0; }
.layout-comp-item.active { background: #e3f2fd; border-color: #1565c0; }
.layout-comp-item.placed { opacity: 0.55; }
.layout-comp-name { font-size: 10px; color: #333; font-weight: 500; }
.layout-comp-type { font-size: 8px; color: #888; text-transform: uppercase; letter-spacing: 0.4px; }
.layout-comp-empty { font-size: 10px; color: #aaa; padding: 4px 2px; font-style: italic; }

/* ---- Registry view ---- */
.registry-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 4px;
  overflow: hidden;
}
.reg-th {
  background: #1a1a1a;
  color: #fff;
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.reg-row:nth-child(even) { background: #fafafa; }
.reg-row:hover { background: #f0f4ff; }
.reg-td {
  padding: 10px 14px;
  vertical-align: middle;
  border-bottom: 1px solid #eee;
}
.reg-td-icon { width: 80px; text-align: center; }
.reg-td-comp { min-width: 120px; }
.reg-td-conn { min-width: 200px; }
.reg-td-pins { width: 80px; text-align: center; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11px; color: #555; }
.reg-td-notes { min-width: 200px; }
.reg-comp-name { font-weight: 600; font-size: 13px; color: #1a1a1a; }
.reg-comp-type { font-size: 10px; color: #888; text-transform: uppercase; letter-spacing: 0.3px; margin-top: 2px; }
.reg-conn-select { width: 100%; padding: 5px 8px; font-size: 12px; border: 1px solid #ccc; border-radius: 3px; background: #fff; }
.reg-conn-label { font-size: 11px; color: #555; margin-top: 4px; }
.reg-part-ref { font-size: 10px; color: #aaa; font-family: ui-monospace, Menlo, Consolas, monospace; margin-top: 2px; }
.reg-notes-input { width: 100%; padding: 5px 8px; font-size: 12px; border: 1px solid #ddd; border-radius: 3px; background: #fff; font-family: inherit; }
.reg-notes-input:focus { border-color: #1565c0; outline: none; }
.reg-no-icon { width: 64px; height: 64px; border: 1px dashed #ccc; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 20px; color: #bbb; margin: 0 auto; }

/* Start screen 3-card layout */
.start-cards { flex-wrap: wrap; }
