html, body {
  overflow-x: hidden;
}

:root {
  color-scheme: light;
  /* ── Design-Tokens (Pi-aligned) ─────────────────── */
  --bg:           #f4f6f9;
  --surface:      #ffffff;
  --surface2:     #f0f2f5;
  --ink:          #1a2332;
  --ink2:         #5a6a7d;
  --line:         #dde3eb;
  --accent:       #1469a8;
  --accent-hover: #0b426d;
  --ok:           #22c55e;
  --warn:         #f59e0b;
  --err:          #ef4444;
  --offline:      #aab4bd;
  --shadow:       0 2px 8px rgba(0,0,0,.08);
  --shadow-md:    0 12px 30px rgba(23,33,43,.12);
  --radius:       12px;
  --radius-sm:    8px;
  /* backward-compat aliases */
  --panel:        var(--surface);
  --panel-soft:   var(--surface2);
  --muted:        var(--ink2);
  --success:      var(--ok);
  --fault:        var(--err);
  --accent-dark:  var(--accent-hover);
  --accent-soft:  #e6f2fb;
  --shadow-sm:    var(--shadow);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
}

html.graph-open,
body.graph-open {
  overflow: hidden;
  height: 100%;
}

.console-page {
  min-height: 100vh;
  background: var(--bg);
}

.app-chrome {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  box-sizing: border-box;
  min-height: 60px;
  padding: 0 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
  font-size: 13px;
  position: sticky;
  top: 0;
  z-index: 25;
}
.app-chrome::before {
  display: none;
}

.brand-row,
.user-row {
  display: flex;
  align-items: center;
  gap: 9px;
}

.brand-home {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.brand-home:hover,
.brand-home:focus-visible {
  background: var(--accent-soft);
  border-color: rgba(20, 105, 168, 0.38);
  outline: none;
}

.brand-logo {
  display: block;
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.app-version {
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface2);
  color: var(--ink2);
  font-size: 11px;
  font-weight: 500;
}

.expert-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border: 1px solid #f0c4c8;
  border-radius: 999px;
  background: #fff6f6;
  color: #9f1f2d;
  font-size: 12px;
  font-weight: 800;
  user-select: none;
}

.expert-toggle input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
}

.expert-toggle i {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 20px;
  border-radius: 999px;
  background: #d8e2ea;
  box-shadow: inset 0 0 0 1px rgba(23, 33, 43, 0.12);
}

.expert-toggle i::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform 0.16s ease;
}

.expert-toggle input:checked + i {
  background: #b4232f;
}

.expert-toggle input:checked + i::after {
  transform: translateX(18px);
}

body.expert-mode-enabled .expert-toggle {
  background: #fff0f1;
  border-color: #b4232f;
  box-shadow: 0 0 0 3px rgba(180, 35, 47, 0.12);
}

h1, h2, h3, p {
  margin: 0;
}

h1 {
  font-size: 20px;
  font-weight: 600;
}

h2 {
  font-size: 22px;
  font-weight: 500;
}

h3 {
  font-size: 16px;
}

.vehicle-strip {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 72px;
  padding: 12px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.vehicle-icon {
  width: 42px;
  height: 42px;
  position: relative;
  border-radius: 7px;
  background: #e3e7ea;
  border: 1px solid #b8c0c7;
}

.vehicle-icon span,
.vehicle-icon::before,
.vehicle-icon::after {
  content: "";
  position: absolute;
  background: #20272d;
}

.vehicle-icon span {
  width: 26px;
  height: 11px;
  left: 8px;
  top: 17px;
  border-radius: 3px;
}

.vehicle-icon::before,
.vehicle-icon::after {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  top: 26px;
}

.vehicle-icon::before {
  left: 10px;
}

.vehicle-icon::after {
  right: 10px;
}

.vehicle-topology-button {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

.vehicle-topology-button:hover,
.vehicle-topology-button:focus-visible {
  border-color: #8aa9c4;
  background: var(--accent-soft);
  outline: none;
}

.vehicle-topology-button img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.vehicle-title p,
.user-row span {
  color: var(--muted);
  font-size: 12px;
}

.vin-mode-control {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.vin-mode-control select {
  min-width: 132px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.vin-decode-box {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  margin-top: 8px;
  font-size: 12px;
}

.vin-decode-box strong {
  color: var(--ink);
}

.vin-decode-box dl {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  width: 100%;
  margin: 0;
}

.vin-decode-box div {
  display: flex;
  gap: 4px;
}

.vin-decode-box dt {
  color: var(--muted);
}

.vin-decode-box dd {
  margin: 0;
  color: var(--ink);
  font-weight: 600;
}

.vin-check {
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--muted);
}

.vin-check.ok {
  border-color: rgba(31, 143, 95, 0.28);
  background: rgba(31, 143, 95, 0.1);
  color: #14613e;
}

.vin-check.warn {
  border-color: rgba(230, 0, 18, 0.28);
  background: rgba(230, 0, 18, 0.1);
  color: #b00010;
}

.voltage-box {
  display: grid;
  gap: 4px;
  justify-items: end;
  color: var(--ink);
  font-size: 12px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-soft);
}

.start-screen {
  min-height: calc(100vh - 64px);
  padding: 28px 18px;
}

.start-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  max-width: 1180px;
  margin: 0 auto 18px;
  padding: 0 2px 12px;
  border-bottom: 1px solid var(--line);
}

.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  max-width: 1180px;
  margin: 0 auto;
}

.device-card {
  position: relative;
  display: grid;
  grid-template-columns: 6px 1fr;
  gap: 4px 12px;
  min-height: 140px;
  width: 100%;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  box-shadow: var(--shadow);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
  cursor: pointer;
}

.device-card.locked {
  opacity: 0.62;
  cursor: not-allowed;
}

.device-lock {
  color: #991b1b;
  font-weight: 800;
}

.device-card:hover,
.device-card:focus-visible {
  transform: translateY(-2px);
  background: var(--surface);
  border-color: rgba(20, 105, 168, 0.34);
  box-shadow: var(--shadow-md);
  outline: none;
}

.device-card strong,
.device-card span:not(.device-status),
.device-card small,
.device-card em,
.device-card p,
.device-card div {
  grid-column: 2;
}

.device-card strong {
  font-size: 17px;
}

.device-card span:not(.device-status),
.device-card small,
.device-card em,
.device-firmware {
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
}

.device-card p {
  margin: 0;
}

.device-update {
  width: fit-content;
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.device-update.current {
  background: #e8f6ef;
  color: #1c6b41;
}

.device-update.available {
  background: #fff4cc;
  color: #7a5700;
}

.device-update.running {
  background: #fee2e2;
  color: #9b1c1c;
}

.device-update.failed {
  background: #f3d7d7;
  color: #8b1d1d;
}

.device-card div {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 8px;
  color: #3c4952;
  font-size: 12px;
}

.device-actions {
  justify-content: flex-start;
}

.update-button {
  margin-top: 0;
}

.device-status {
  grid-column: 1;
  grid-row: 1 / span 8;
  width: 6px;
  min-height: 100%;
  border-radius: 3px;
  background: var(--offline);
}

.device-status.online {
  background: var(--ok);
  box-shadow: 0 0 6px var(--ok);
}

.device-status.recent {
  background: var(--warn);
}

.device-status.fault {
  background: var(--err);
}

.device-empty,
.topology-empty {
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--muted);
  text-align: center;
}

.menu-wrap {
  position: relative;
}

.menu-button {
  width: auto;
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  font-size: 12px;
}

.menu-button:hover {
  background: var(--surface2);
}

.top-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 20;
  min-width: 170px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.top-menu button,
.top-menu a {
  display: block;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
}

.top-menu button:hover,
.top-menu a:hover {
  background: var(--surface2);
  color: var(--ink);
}

.download-link {
  color: var(--accent-dark);
  font-weight: 700;
  text-decoration: none;
}

.download-link:hover {
  text-decoration: underline;
}

.diagnostic-shell {
  width: 100%;
  min-height: calc(100vh - 146px);
}

.action-header {
  padding: 18px 22px 0;
  background: transparent;
  border-bottom: 0;
}

.tabs {
  display: flex;
  gap: 0;
  margin-top: 10px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: 0 0 auto;
  min-width: 72px;
  padding: 10px 14px;
  border: none;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: none;
  color: var(--ink2);
  font-size: 13px;
  font-weight: 500;
  box-shadow: none;
  white-space: nowrap;
  margin-bottom: -1px;
  transition: color .2s, border-color .2s;
  cursor: pointer;
}

.tab:hover {
  background: none;
  color: var(--ink);
}

.tab.active {
  background: none;
  border-bottom-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.work-area {
  position: relative;
  min-height: calc(100vh - 174px);
  background: transparent;
  border-top: 0;
}

.legend-panel {
  position: static;
  z-index: 2;
  padding: 8px 22px 0;
  color: #5e6a72;
  font-size: 12px;
}

.legend-items {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 5px;
  border-radius: 2px;
  vertical-align: -1px;
}

.legend-dot.online {
  background: var(--accent);
}

.legend-dot.fault {
  background: var(--fault);
}

.legend-dot.offline {
  background: var(--offline);
}

.view {
  display: none;
}

.active-view {
  display: block;
}

/* ── Topology split layout ──────────────────────────────────────────── */
.topology-split {
  display: grid;
  grid-template-columns: 1fr 280px;
  height: calc(100vh - 214px);
  min-height: 470px;
  overflow: hidden;
}

.network-canvas {
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-x pan-y;
  border-right: 1px solid var(--line);
}

/* ── ECU list panel ─────────────────────────────────────────────────── */
.ecu-list-panel {
  height: 100%;
  overflow-y: auto;
  background: var(--panel);
  display: flex;
  flex-direction: column;
}

.ecu-list-empty {
  padding: 24px 16px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.ecu-list-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.ecu-list-table thead th {
  padding: 8px 10px 6px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 1;
}

.ecu-list-table thead th:nth-child(3),
.ecu-list-table thead th:nth-child(4) {
  text-align: center;
}

.ecu-row {
  cursor: pointer;
  border-bottom: 1px solid var(--line);
  transition: background 100ms;
}

.ecu-row:hover {
  background: var(--accent-soft);
}

.ecu-status-cell {
  width: 28px;
  padding: 10px 4px 10px 10px;
}

.ecu-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--offline);
}

.ecu-dot.online  { background: var(--online); }
.ecu-dot.fault   { background: var(--fault); }
.ecu-dot.offline { background: var(--offline); }

.ecu-name-cell {
  padding: 8px 6px;
}

.ecu-name-cell strong {
  display: block;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
}

.ecu-addr {
  font-size: 11px;
  color: var(--muted);
  font-family: monospace;
}

.ecu-dtc-cell,
.ecu-live-cell {
  width: 44px;
  text-align: center;
  padding: 8px 6px;
}

.dtc-badge {
  display: inline-block;
  background: var(--fault);
  color: white;
  font-size: 11px;
  font-weight: 700;
  border-radius: 10px;
  padding: 1px 7px;
  min-width: 20px;
}

.live-badge {
  display: inline-block;
  background: var(--accent);
  color: white;
  font-size: 11px;
  font-weight: 700;
  border-radius: 10px;
  padding: 1px 7px;
  min-width: 20px;
}

.no-dtc, .no-live {
  color: var(--muted);
  font-size: 13px;
}

.ecu-row.fault .ecu-name-cell strong {
  color: var(--fault);
}

@media (max-width: 760px) {
  .topology-split {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
  }
  .network-canvas {
    border-right: none;
    border-bottom: 1px solid var(--line);
    min-height: 280px;
    max-height: 55vh;
  }
  .ecu-list-panel {
    max-height: 45vh;
  }
}

.network-svg {
  min-width: 100%;
  min-height: 100%;
  display: block;
}

.canvas-bg {
  fill: transparent;
}

.bus-line {
  stroke: #256f9a;
  stroke-width: 5;
  fill: none;
  stroke-linecap: round;
}

.connector {
  stroke-width: 3;
  stroke-linecap: round;
}

.connector.online,
.connector.fault {
  stroke: #256f9a;
}

.connector.fault {
  stroke: #e60012;
}

.connector.offline {
  stroke: #9fa6ab;
}

.module rect {
  stroke-width: 2;
}

.module text {
  fill: white;
  text-anchor: middle;
  pointer-events: none;
}

.module .module-id {
  font-size: 16px;
  font-weight: 800;
}

.module .module-name {
  font-size: 10px;
  font-weight: 600;
  opacity: 0.92;
}

.obd-node rect {
  fill: #111827;
  stroke: #475569;
  stroke-width: 2;
}

.obd-node text {
  fill: #e5eef8;
  font-size: 12px;
  text-anchor: middle;
  font-weight: 700;
  pointer-events: none;
}

.obd-node .obd-title {
  fill: #ffffff;
  font-size: 17px;
  font-weight: 800;
}

.module {
  cursor: pointer;
}

.module:focus rect {
  stroke: #0b2538;
  stroke-width: 4;
}

.module.online rect {
  fill: var(--accent);
  stroke: #164d7d;
}

.module.fault rect {
  fill: var(--fault);
  stroke: #a4000d;
}

.module.offline rect {
  fill: var(--offline);
  stroke: #8f969b;
}

.module.stale rect {
  stroke-dasharray: 1.2 0.9;
  opacity: 0.72;
}

.dtc-view,
.placeholder-view,
.learning-view,
.pi-diag-view,
.admin-view {
  padding: 34px 22px 22px;
}

.pi-diag-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 16px;
}
.pi-diag-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 16px;
}
.pi-diag-card h4 {
  margin: 0 0 10px;
  font-size: .85rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink2);
}
.pi-diag-wide {
  grid-column: 1 / -1;
}
.pi-diag-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}
.pi-diag-table td {
  padding: 4px 8px 4px 0;
  vertical-align: top;
}
.pi-diag-table td:first-child {
  color: var(--ink2);
  white-space: nowrap;
  width: 120px;
}
.pi-diag-pre {
  margin: 8px 0 0;
  padding: 8px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  font-size: .75rem;
  overflow-x: auto;
  white-space: pre;
}
.log-block {
  max-height: 320px;
  overflow-y: auto;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-family: monospace;
  font-size: .75rem;
}
.log-line {
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
}
.log-line.log-err  { color: var(--err); }
.log-line.log-warn { color: var(--warn); }
.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: .78rem;
  font-weight: 600;
}
.status-badge.ok   { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.status-badge.warn { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }
.status-badge.err  { background: color-mix(in srgb, var(--err) 15%, transparent); color: var(--err); }

.can-watchdog-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.can-watchdog-table th { background: var(--bg2); padding: 5px 8px; text-align: left; font-size: 11px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.can-watchdog-table td { padding: 4px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.can-evt-row { cursor: pointer; }
.can-evt-row:hover { background: var(--bg2); }
.can-evt-detail td { font-size: 11px; }

.ecu-detail {
  width: 100%;
  min-height: calc(100vh - 174px);
  margin: 0;
  padding: 8px 22px 22px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.ecu-detail-head {
  display: flex;
  justify-content: flex-end;
  align-items: start;
  gap: 12px;
  padding: 8px 0 12px;
  border-bottom: 1px solid var(--line);
}

.ecu-detail-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.ecu-actions {
  display: flex;
  gap: 8px;
  margin: 12px 0 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.ecu-action {
  width: auto;
  min-width: 88px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  color: var(--ink2);
  font-size: 12px;
  font-weight: 500;
  transition: background .15s, color .15s;
}

.ecu-action:hover {
  background: var(--surface2);
  color: var(--ink);
}

.ecu-action.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.ecu-panel {
  display: none;
}

.active-ecu-panel {
  display: block;
}

.ecu-panel[data-ecu-content="data"] {
  width: 100%;
}

.ecu-panel h3 {
  margin-bottom: 8px;
}

.ecu-panel p {
  color: var(--muted);
  font-size: 14px;
}

.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.toolbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

th, td {
  border-bottom: 1px solid var(--line);
  padding: 11px 10px;
  text-align: left;
  font-size: 13px;
}

th {
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

tr:last-child td {
  border-bottom: 0;
}

.empty {
  color: var(--muted);
  text-align: center;
}

.raw-drawer {
  border-top: 1px solid var(--line);
  background: var(--panel-soft);
  padding: 10px 16px 20px;
}

.settings-panel {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: start center;
  padding: 72px 18px 24px;
  background: rgba(23, 33, 43, 0.32);
  backdrop-filter: blur(4px);
}

.settings-card {
  width: min(1040px, 100%);
  max-height: calc(100vh - 96px);
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

#settingsPanel {
  inset: 72px 0 0;
  z-index: 30;
  display: block;
  height: calc(100dvh - 72px);
  padding: 0;
  background: var(--bg);
  backdrop-filter: none;
  overflow: hidden;
}

.settings-full-card {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  width: 100%;
  height: 100%;
  min-height: 0;
  max-height: none;
  overflow: hidden;
  padding: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.settings-sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--surface2);
  overflow: hidden;
}

.settings-sidebar-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.settings-sidebar-head h3 {
  margin: 0;
}

.settings-nav {
  display: grid;
  gap: 4px;
  padding: 8px;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

.nav-group-label {
  padding: 14px 8px 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
  user-select: none;
}

.nav-group-label:first-child {
  padding-top: 8px;
}

.settings-nav button {
  display: block;
  width: 100%;
  box-sizing: border-box;
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background 120ms, color 120ms;
}

.settings-nav button:hover {
  background: var(--accent-soft);
}

.settings-nav button.active {
  border-color: transparent;
  border-left-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.settings-overview-grid button {
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.settings-overview-grid button:hover {
  background: var(--accent-soft);
}

.settings-content {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 18px;
  overscroll-behavior: contain;
}

.settings-page {
  display: none;
}

.settings-page.active-settings-page {
  display: block;
}

.settings-overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
}

.settings-overview-grid button {
  min-height: 58px;
  border-color: var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.settings-dynamic-page > .settings-card {
  width: 100%;
  max-height: none;
  overflow: visible;
  padding: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.settings-dynamic-page > .settings-card > .settings-head .icon-button {
  display: none;
}

.settings-shortcuts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 12px 0 18px;
}

.settings-shortcuts button {
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-soft);
  color: var(--ink);
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.settings-shortcuts button:hover {
  border-color: var(--accent);
  background: var(--surface);
}

.qr-card {
  width: min(430px, 100%);
}

.flash-card {
  width: min(620px, 100%);
}

.server-update-card {
  width: min(1120px, 100%);
}

.server-update-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin: 12px 0 18px;
}

.server-update-status {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-soft);
}

.server-update-status span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.server-update-status strong {
  font-size: 16px;
}

.server-update-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #edf2f7;
  color: var(--ink);
  font-size: 14px;
}

.server-update-pill.running,
.server-update-pill.checking {
  background: #fff4d8;
  color: #7a4b00;
}

.server-update-pill.success,
.server-update-pill.up_to_date {
  background: #dff7ea;
  color: #16623a;
}

.server-update-pill.update_available {
  background: #e1ecff;
  color: #174a95;
}

.server-update-pill.error {
  background: #ffe1e1;
  color: #9b1c1c;
}

.server-update-log {
  min-height: 180px;
  max-height: 300px;
  overflow: auto;
  margin: 10px 0 18px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #111827;
  color: #d1fae5;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.flash-body {
  display: grid;
  gap: 14px;
}

.web-flash-box {
  min-height: 92px;
  display: grid;
  align-items: center;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-soft);
}

.qr-code-box {
  display: grid;
  place-items: center;
  min-height: 250px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.qr-code-box svg {
  width: min(260px, 100%);
  height: auto;
}

.qr-payload {
  max-height: 120px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.managed-device-list {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.managed-device {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.managed-device > div:first-child {
  display: grid;
  gap: 3px;
}

.managed-device span,
.managed-device small {
  color: var(--muted);
}

.managed-device.offline {
  background: #f8fafc;
}

.managed-device-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.share-device-box {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.inline-form {
  margin-bottom: 12px;
}

.offline-card {
  opacity: 0.78;
}

#graphPanel {
  padding: 0;
  place-items: stretch;
  overflow: hidden;
}

.settings-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.settings-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.changelog-card {
  width: min(760px, 100%);
}

.history-card {
  width: min(980px, 100%);
}

.history-vehicle-list {
  display: grid;
  gap: 12px;
}

.history-vehicle-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.history-vehicle-card:hover,
.history-vehicle-card:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(20, 105, 168, 0.12);
  outline: none;
}

.history-vehicle-head {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: flex-start;
}

.history-vehicle-head h4 {
  margin: 0;
  font-size: 16px;
}

.history-vehicle-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.history-source {
  flex: 0 0 auto;
  padding: 4px 8px;
  border: 1px solid #cfd9e2;
  border-radius: 999px;
  color: #43505a;
  font-size: 11px;
  background: #f6f9fb;
}

.history-equipment {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px 14px;
  margin: 12px 0 0;
}

.history-equipment div {
  min-width: 0;
}

.history-equipment dt {
  color: var(--muted);
  font-size: 11px;
}

.history-equipment dd {
  margin: 2px 0 0;
  color: var(--ink);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.history-detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.history-detail-title {
  font-weight: 600;
  font-size: 15px;
  color: var(--ink);
}

.history-detail-section {
  margin-bottom: 24px;
}

.history-detail-section h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
}

.history-detail-dl {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px 14px;
}

.history-detail-dl div {
  min-width: 0;
}

.history-detail-dl dt {
  color: var(--muted);
  font-size: 11px;
}

.history-detail-dl dd {
  margin: 2px 0 0;
  color: var(--ink);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.history-detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.history-detail-table th {
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  color: var(--muted);
  padding: 4px 10px 6px 0;
  border-bottom: 1px solid var(--line);
}

.history-detail-table td {
  padding: 7px 10px 7px 0;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  color: var(--ink);
}

.history-detail-table td.num {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.history-detail-table tr:last-child td {
  border-bottom: none;
}


.data-source-card {
  width: min(820px, 100%);
}

.data-source-list {
  display: grid;
  gap: 10px;
}

.data-source-item {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.data-source-item > span {
  display: inline-grid;
  place-items: center;
  min-height: 28px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.data-source-item.green > span {
  background: rgba(31, 143, 95, 0.12);
  color: #14613e;
}

.data-source-item.yellow > span {
  background: rgba(181, 128, 0, 0.14);
  color: #755100;
}

.data-source-item.red > span {
  background: rgba(230, 0, 18, 0.12);
  color: #b00010;
}

.data-source-item p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.changelog-content {
  display: grid;
  gap: 14px;
}

.changelog-entry {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.changelog-entry h4 {
  margin: 0 0 10px;
  font-size: 15px;
}

.changelog-entry h4 span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.changelog-entry ul {
  margin: 0;
  padding-left: 20px;
}

.changelog-entry li {
  margin: 6px 0;
  color: var(--ink);
  font-size: 13px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 10px;
  background: var(--panel-soft);
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
}

.icon-button:hover {
  background: var(--accent-soft);
}

.raw-drawer summary {
  cursor: pointer;
  color: #3d4a53;
  font-weight: 700;
  font-size: 13px;
}

pre {
  overflow: auto;
  max-height: 300px;
  padding: 14px;
  background: #111827;
  color: #d1fae5;
  border-radius: 6px;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.login-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  width: min(390px, calc(100% - 32px));
  padding: 28px;
  box-shadow: var(--shadow-md);
}

.login-logo {
  display: block;
  width: 112px;
  max-width: 48%;
  height: auto;
  margin: 0 auto 14px;
}

.login-panel h1 {
  text-align: center;
  margin-bottom: 20px;
}

.login-panel label {
  display: block;
  margin-bottom: 14px;
  color: var(--ink2);
  font-size: 14px;
}

.login-panel input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font: inherit;
  background: var(--surface);
  color: var(--ink);
}

.login-panel input:focus {
  border-color: rgba(20, 105, 168, 0.55);
  box-shadow: 0 0 0 3px rgba(20, 105, 168, 0.14);
  outline: none;
}

button {
  width: auto;
  padding: 9px 18px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: white;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 150ms ease, opacity 150ms ease;
}

button:hover {
  background: var(--accent-hover);
}

button:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.login-panel button {
  width: 100%;
  padding: 11px;
  font-size: 15px;
  font-weight: 700;
  border-radius: var(--radius-sm);
}

.small-button,
.danger-button,
.secondary-button {
  width: auto;
  padding: 8px 12px;
  font-size: 12px;
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--surface2);
  color: var(--ink);
}

.secondary-button:hover {
  background: var(--line);
}

.danger-button {
  background: var(--err);
}

.danger-button:hover {
  opacity: .88;
  background: var(--err);
}

.dtc-status {
  display: inline-flex;
  align-items: center;
  min-width: 78px;
  justify-content: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.dtc-status.active {
  background: #fee2e2;
  color: #991b1b;
}

.dtc-status.sporadic {
  background: #fef3c7;
  color: #92400e;
}

.dtc-status.stored {
  background: #e0f2fe;
  color: #075985;
}

.ecu-dtc-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.dtc-card {
  display: grid;
  grid-template-columns: minmax(70px, 110px) minmax(90px, 140px) 1fr;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.dtc-card strong {
  font-size: 16px;
}

.dtc-card span:last-child {
  color: var(--muted);
}

.actuator-grid {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.actuator-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 14px;
  align-items: center;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.actuator-row:hover {
  border-color: rgba(35, 106, 166, 0.35);
  box-shadow: 0 10px 24px rgba(31, 50, 70, 0.12);
}

.actuator-row:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.actuator-row strong,
.actuator-row span {
  display: block;
}

.actuator-row span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.actuator-state {
  justify-self: end;
  min-width: 86px;
  padding: 6px 10px;
  border-radius: 999px;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
}

.actuator-state.running {
  background: rgba(180, 35, 47, 0.12);
  color: #b4232f;
}

.actuator-state.stopped {
  background: rgba(102, 120, 138, 0.12);
  color: var(--muted);
}

.actuator-detail {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.actuator-detail-head {
  display: grid;
  gap: 4px;
}

.actuator-detail-head h4 {
  margin: 0;
  font-size: 22px;
}

.actuator-detail-head p,
.actuator-safety-note {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.expert-warning-inline {
  padding: 10px 12px;
  border: 1px solid #f0c4c8;
  border-radius: 12px;
  background: #fff6f6;
  color: #9f1f2d;
  font-size: 13px;
  font-weight: 700;
}

.actuator-timer {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fbfd;
}

.actuator-timer-head,
.actuator-scale {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.actuator-timer-head span,
.actuator-scale span {
  color: var(--muted);
  font-size: 13px;
}

.actuator-timer-head strong {
  color: var(--text);
}

.actuator-progress {
  position: relative;
  flex: 1;
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #dbe5ec;
}

.actuator-progress i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #236aa6, #b4232f);
  transition: width 0.25s ease;
}

.actuator-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.actuator-actions button {
  width: auto;
}

.recording-active {
  background: #b4232f;
  box-shadow: 0 0 0 3px rgba(180, 35, 47, 0.16);
}

.recording-active:hover {
  background: #8f1d28;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(260px, 380px) minmax(260px, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}

.token-form,
.new-token-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.token-form h3,
.new-token-box h3 {
  margin-bottom: 10px;
}

.new-token-box p {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.new-token-box code {
  display: block;
  overflow-wrap: anywhere;
  padding: 10px;
  background: #111827;
  color: #d1fae5;
  border-radius: 4px;
}

.token-value {
  display: block;
  max-width: 340px;
  overflow-wrap: anywhere;
  padding: 6px;
  background: #111827;
  color: #d1fae5;
  border-radius: 4px;
}

.token-note {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.copy-button {
  width: auto;
  margin-top: 6px;
  padding: 6px 8px;
  font-size: 12px;
}

.live-grid {
  display: block;
}

.record-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 10px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.record-toolbar span {
  color: var(--muted);
  font-size: 13px;
}

.live-table strong {
  font-size: 17px;
}

.live-table {
  border: 0;
  border-spacing: 0 8px;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.live-table th {
  background: transparent;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.live-table td {
  border-bottom: 0;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: inset 0 1px 0 rgba(215, 224, 231, 0.72), inset 0 -1px 0 rgba(215, 224, 231, 0.72);
}

.live-table td:first-child {
  border-radius: 12px 0 0 12px;
  box-shadow: inset 1px 0 0 rgba(215, 224, 231, 0.72), inset 0 1px 0 rgba(215, 224, 231, 0.72), inset 0 -1px 0 rgba(215, 224, 231, 0.72);
}

.live-table td:last-child {
  border-radius: 0 12px 12px 0;
  box-shadow: inset -1px 0 0 rgba(215, 224, 231, 0.72), inset 0 1px 0 rgba(215, 224, 231, 0.72), inset 0 -1px 0 rgba(215, 224, 231, 0.72);
}

.live-table tr.live-stale td {
  background: rgba(246, 248, 250, 0.78);
  color: #6f7d89;
}

.live-table tr.live-stale strong {
  color: #596977;
}

.learning-table {
  table-layout: fixed;
}

.learning-table th:nth-child(1),
.learning-table td:nth-child(1) {
  width: 160px;
}

.learning-table th:nth-child(7),
.learning-table td:nth-child(7),
.learning-table th:nth-child(8),
.learning-table td:nth-child(8),
.learning-table th:nth-child(9),
.learning-table td:nth-child(9) {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  word-break: break-all;
}

.raw-cell {
  color: var(--ink);
}

.byte-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.byte-cell span {
  display: inline-flex;
  min-width: 24px;
  justify-content: center;
  padding: 2px 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7fafc;
  color: var(--ink);
}

.learning-test-panel {
  display: grid;
  gap: 12px;
  margin: 12px 0 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.78);
}

.learning-test-head {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
}

.learning-test-head h4 {
  margin: 0 0 4px;
}

.learning-live-status {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.learning-live-status span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.learning-live-status .learning-state {
  color: #ffffff;
  border-color: transparent;
}

.learning-live-status .learning-state.active {
  background: #0f8f5f;
}

.learning-live-status .learning-state.idle {
  background: #718096;
}

.learning-test-head p,
.learning-step-detail p {
  margin: 0;
  color: var(--muted);
}

.learning-test-grid {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
  gap: 12px;
}

.learning-step-list {
  max-height: 360px;
  overflow: auto;
  display: grid;
  gap: 8px;
  padding-right: 2px;
}

.learning-step-list button {
  display: grid;
  gap: 3px;
  min-height: 54px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-soft);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.learning-step-list button.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.learning-step-list button span {
  color: var(--muted);
  font-size: 12px;
}

.learning-step-detail {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 10px;
}

.learning-step-detail textarea {
  width: 100%;
  resize: vertical;
}

.learning-test-analysis {
  display: grid;
  gap: 8px;
}

.learning-analysis-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.learning-analysis-summary span {
  display: inline-flex;
  padding: 5px 9px;
  border-radius: 999px;
  background: #eef5ff;
  color: #214f86;
  font-size: 12px;
  font-weight: 800;
}

.learning-analysis-summary.live span:first-child {
  background: #0f8f5f;
  color: #ffffff;
}

.learning-analysis-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
}

.learning-analysis-list article {
  display: grid;
  gap: 4px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.learning-analysis-list span,
.learning-analysis-list small {
  color: var(--muted);
}

.learning-candidates {
  margin: 10px 0 14px;
}

.learning-candidate-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 8px;
}

.learning-candidate-head span,
.learning-candidate small {
  color: var(--muted);
}

.learning-candidate-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
}

.learning-candidate {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
}

.learning-candidate div {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.learning-candidate p {
  margin: 6px 0;
  color: var(--text);
}

.quality-pill {
  display: inline-flex;
  padding: 3px 7px;
  border-radius: 999px;
  background: #fff7ed;
  color: #9a4b00;
  font-size: 0.78rem;
  font-weight: 800;
}

.sort-button {
  width: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  text-align: left;
}

.sort-button:hover {
  background: transparent;
  color: var(--accent-dark);
}

.record-cell {
  text-align: center;
}

.record-checkbox {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.live-empty {
  padding: 24px;
  background: transparent;
  border: 0;
  border-radius: 12px;
}

.graph-panel {
  margin-top: 14px;
  padding: 12px 0 0;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.graph-panel canvas {
  display: block;
  width: 100%;
  height: 280px;
  border: 1px solid #d6dee5;
  border-radius: 10px;
  background: var(--surface);
}

.graph-card {
  width: 100%;
  height: 100dvh;
  min-height: 100vh;
  max-height: none;
  overflow: hidden;
  border-radius: 0;
  border: 0;
  display: grid;
  grid-template-rows: auto minmax(260px, 1fr) auto minmax(110px, 28vh);
}

.graph-card canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  cursor: crosshair;
  touch-action: manipulation;
}

.graph-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.graph-scrubber {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.graph-scrubber label {
  margin: 0;
}

.graph-scrubber input {
  margin-top: 8px;
  padding: 0;
}

.graph-values {
  display: grid;
  align-content: start;
  gap: 6px;
  margin-top: 12px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
  padding-bottom: 10px;
}

.graph-value-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) minmax(90px, auto);
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.78);
}

.graph-value-row input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.graph-value-row span {
  color: var(--muted);
  font-size: 12px;
}

.graph-value-row strong {
  font-size: 16px;
  text-align: right;
}

@media (max-width: 760px) {
  .app-chrome {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
    height: auto;
    padding: 8px 12px;
  }

  .brand-row,
  .user-row {
    justify-content: space-between;
    width: 100%;
    flex-wrap: wrap;
  }

  .brand-row strong {
    flex: 1;
    min-width: 160px;
  }

  .app-version {
    margin-left: 50px;
  }

  .vehicle-strip {
    grid-template-columns: 56px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    min-height: auto;
    padding: 10px 12px;
  }

  .vehicle-title h1 {
    font-size: 16px;
    overflow-wrap: anywhere;
  }

  .vehicle-title p {
    line-height: 1.35;
    overflow-wrap: anywhere;
  }

  .voltage-box {
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-items: start;
    width: 100%;
  }

  .history-vehicle-head {
    flex-direction: column;
  }

  .action-header {
    padding: 10px 10px 0;
  }

  .tabs {
    overflow-x: auto;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
  }

  .tab {
    flex: 0 0 auto;
    min-width: max-content;
  }

  .work-area {
    min-height: calc(100vh - 220px);
  }

  .legend-panel {
    position: static;
    padding: 10px 12px 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
  }

  .legend-items {
    flex-wrap: wrap;
  }

  .network-canvas {
    width: 100%;
    height: calc(100vh - 250px);
    min-height: 360px;
    margin: 8px auto 0;
  }

  .ecu-detail,
  .dtc-view,
  .placeholder-view,
  .admin-view {
    padding: 16px 10px;
  }

  .ecu-detail {
    width: 100%;
    min-height: calc(100vh - 220px);
    border-left: 0;
    border-right: 0;
    padding: 10px 12px 18px;
  }

  .ecu-detail-head {
    align-items: stretch;
    flex-direction: column;
  }

  .record-toolbar,
  .table-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .learning-test-grid {
    grid-template-columns: 1fr;
  }

  .learning-step-list {
    grid-auto-flow: column;
    grid-auto-columns: minmax(210px, 75vw);
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }

  .toolbar-actions {
    justify-content: stretch;
  }

  .toolbar-actions .small-button {
    width: 100%;
  }

  .record-toolbar .small-button,
  .record-toolbar .secondary-button {
    width: 100%;
  }

  .live-grid {
    overflow-x: auto;
  }

  .live-table {
    min-width: 620px;
  }

  .graph-panel {
    padding: 8px;
  }

  .graph-panel canvas {
    height: 220px;
  }

  .settings-panel {
    padding: 54px 8px 12px;
  }

  #settingsPanel {
    inset: 116px 0 0;
    height: calc(100dvh - 116px);
    padding: 0;
  }

  .settings-full-card {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .settings-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: 148px;
  }

  .settings-sidebar-head {
    padding: 10px 12px;
  }

  .settings-nav {
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    max-width: 100vw;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px 10px 10px;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
  }

  .settings-nav button {
    min-width: max-content;
    white-space: nowrap;
  }

  .nav-group-label {
    display: none;
  }

  .settings-content {
    padding: 12px;
  }

  .settings-card {
    max-height: calc(100vh - 70px);
    padding: 12px;
  }

  .settings-full-card {
    max-height: none;
    padding: 0;
  }

  .settings-card table,
  .dtc-view table,
  .admin-view table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  .top-menu {
    right: auto;
    left: 0;
  }

  .admin-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  #settingsPanel {
    inset: 104px 0 0;
    height: calc(100dvh - 104px);
  }

  .settings-sidebar {
    max-height: 136px;
  }

  .settings-sidebar-head {
    align-items: center;
  }

  .vehicle-topology-button {
    width: 48px;
    height: 48px;
  }

  .start-head {
    align-items: stretch;
    flex-direction: column;
  }

  .device-grid {
    grid-template-columns: 1fr;
  }
}

/* ── PID-Wert-Verbesserungen ─────────────────────────────────────────── */
.value-suspect {
  color: var(--color-warning, #d97706);
  cursor: help;
  text-decoration: underline dotted;
}

.live-suspect td {
  opacity: 0.7;
}

.pid-label-with-desc {
  cursor: help;
  white-space: nowrap;
}

.pid-desc-icon {
  font-size: 0.7em;
  opacity: 0.5;
  vertical-align: super;
}

.pid-bar {
  width: 100%;
  height: 3px;
  background: var(--color-border, #e5e7eb);
  border-radius: 2px;
  margin-top: 2px;
}

.pid-bar-fill {
  height: 100%;
  background: var(--color-primary, #2563eb);
  border-radius: 2px;
  min-width: 1px;
}

/* ── Odometer-Badge im Fahrzeugkopf ──────────────────────────────────── */
.odometer-badge {
  font-size: 0.85em;
  color: var(--color-text-muted, #6b7280);
  background: var(--color-surface, #f3f4f6);
  border-radius: 4px;
  padding: 1px 6px;
  border: 1px solid var(--color-border, #e5e7eb);
}

.odometer-badge::before {
  content: '🛣️ ';
}

/* ── Community-PID-Datenbank ─────────────────────────────────────────── */
.pid-db-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.pid-db-controls input[type="search"] {
  flex: 1 1 200px;
  padding: 6px 10px;
  border: 1px solid var(--color-border, #d1d5db);
  border-radius: 6px;
  font-size: 0.9em;
  background: var(--color-surface, #fff);
  color: var(--ink);
}
.pid-db-controls select {
  flex: 0 1 200px;
  padding: 6px 8px;
  border: 1px solid var(--color-border, #d1d5db);
  border-radius: 6px;
  font-size: 0.9em;
  background: var(--color-surface, #fff);
  color: var(--ink);
}
.pid-db-table-wrap {
  overflow-x: auto;
}
.pid-db-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82em;
}
.pid-db-table th {
  background: var(--color-surface, #f3f4f6);
  text-align: left;
  padding: 6px 8px;
  border-bottom: 2px solid var(--color-border, #e5e7eb);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
.pid-db-table td {
  padding: 5px 8px;
  border-bottom: 1px solid var(--color-border, #e5e7eb);
  vertical-align: top;
  word-break: break-word;
}
.pid-db-table tr:hover td { background: var(--color-hover, #f0f4ff); }
.pid-db-table .col-model  { color: var(--color-primary, #2563eb); font-weight: 500; }
.pid-db-table .col-pid    { font-family: monospace; font-size: 0.9em; }
.pid-db-table .col-eq     { font-family: monospace; font-size: 0.78em; color: #555; max-width: 180px; word-break: break-all; }
.pid-db-table .col-range  { font-size: 0.85em; color: var(--color-text-muted, #6b7280); }
.pid-db-pager {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  justify-content: center;
  font-size: 0.88em;
}

/* ── Community-PID Stats Bar ─────────────────────────────────────────── */
.pid-db-stats {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.pid-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--color-surface, #f3f4f6);
  border: 1px solid var(--color-border, #e5e7eb);
  border-radius: 10px;
  padding: 8px 18px;
  min-width: 90px;
}
.pid-stat-val {
  font-size: 1.45em;
  font-weight: 800;
  color: var(--color-primary, #2563eb);
  line-height: 1.1;
}
.pid-stat-lbl {
  font-size: 0.72em;
  color: var(--color-text-muted, #6b7280);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.col-mfr {
  font-size: 0.78em;
  font-weight: 700;
  color: var(--color-text-muted, #6b7280);
  white-space: nowrap;
}

/* ── Topology SVG redesign ───────────────────────────────────────────── */
.topo-svg {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 12px;
}
.topo-node {
  cursor: pointer;
  transition: opacity 0.15s;
}
.topo-node:hover rect, .topo-node:focus rect {
  filter: brightness(1.15);
  outline: none;
}
.topo-gateway {
  pointer-events: none;
}

/* ── DTC Category Colors ─────────────────────────────────────────────── */
.dtc-table { width: 100%; border-collapse: collapse; }
.dtc-table td, .dtc-table th { padding: 6px 8px; border-bottom: 1px solid var(--border, #dde3ea); }
.dtc-ecu-header td { background: var(--bg, #eef3f7); font-size: 0.82em; padding: 4px 8px; }
.dtc-ecu-badge { font-weight: 700; color: var(--ink, #17212b); background: var(--card-bg, #fff); border-radius: 4px; padding: 1px 6px; font-size: 0.85em; border: 1px solid var(--border, #dde3ea); }
.dtc-code { font-size: 1.05em; letter-spacing: 0.04em; }
.dtc-cat-p { color: #dc2626; }
.dtc-cat-c { color: #d97706; }
.dtc-cat-b { color: #2563eb; }
.dtc-cat-u { color: #7c3aed; }
.dtc-desc-cell { max-width: 280px; }
.dtc-id-cell code, .dtc-raw-cell code { font-size: 0.78em; color: var(--muted, #667887); }
.dtc-ecu-cell { font-size: 0.82em; color: var(--muted, #667887); }

/* ── ECU List improvements ───────────────────────────────────────────── */
.ecu-active-count { font-weight: 400; color: var(--muted, #667887); font-size: 0.8em; margin-left: 4px; }
.ecu-stale { opacity: 0.5; }
.ecu-stale .ecu-name-cell strong { color: var(--muted, #667887); }
.ecu-stale-mark { color: var(--muted, #667887); margin-left: 3px; font-size: 0.9em; }
.ecu-stale-toggle-row td { padding: 6px 8px; text-align: center; }
.ecu-stale-toggle { background: none; border: 1px solid var(--border, #dde3ea); border-radius: 6px; padding: 3px 10px; font-size: 0.8em; cursor: pointer; color: var(--muted, #667887); }
.ecu-stale-toggle:hover { background: var(--bg, #eef3f7); color: var(--ink, #17212b); }

/* ── Live Values improvements ────────────────────────────────────────── */
.live-filter-input { font-size: 0.85em; padding: 3px 8px; border: 1px solid var(--border, #dde3ea); border-radius: 6px; background: var(--card-bg, #fff); color: var(--ink, #17212b); width: 160px; }
.live-ecu-header td { background: var(--bg, #eef3f7); padding: 4px 8px; }
.live-ecu-badge { font-size: 0.82em; font-weight: 700; color: var(--ink, #17212b); background: var(--card-bg, #fff); border-radius: 4px; padding: 1px 6px; border: 1px solid var(--border, #dde3ea); }
.live-ecu-col { font-size: 0.78em; color: var(--muted, #667887); }
.value-warn { color: #d97706; }

/* ── Dark Mode ───────────────────────────────────────────────────────── */

/* CSS variable overrides – Pi-aligned dark palette */
html[data-theme="dark"] {
  color-scheme: dark;
  background: #0f1520;
  --bg:           #0f1520;
  --surface:      #1a2535;
  --surface2:     #131d2b;
  --ink:          #e8eef5;
  --ink2:         #8a9bb0;
  --line:         #2a3a50;
  --accent:       #3b9fe8;
  --accent-hover: #2b82d4;
  --ok:           #34d399;
  --warn:         #fbbf24;
  --err:          #f87171;
  --offline:      #556470;
  --shadow:       0 2px 8px rgba(0,0,0,.4);
  --shadow-md:    0 12px 30px rgba(0,0,0,.6);
  /* aliases auto-resolve via :root definitions */
  --accent-dark:  var(--accent-hover);
  --accent-soft:  #0d2535;
  --shadow-sm:    var(--shadow);
}

/* Translucent / gradient backgrounds */
html[data-theme="dark"] .console-page {
  background: var(--bg);
}
html[data-theme="dark"] .app-chrome {
  background: var(--surface);
  border-bottom-color: var(--line);
}
html[data-theme="dark"] .vehicle-strip {
  background: var(--surface);
  border-bottom-color: var(--line);
}
html[data-theme="dark"] .login-page {
  background: var(--bg);
}
html[data-theme="dark"] .login-panel {
  background: var(--surface);
  border-color: var(--line);
}

/* Panels / cards with hardcoded #ffffff */
html[data-theme="dark"] .device-card,
html[data-theme="dark"] .device-empty,
html[data-theme="dark"] .topology-empty,
html[data-theme="dark"] .tab,
html[data-theme="dark"] .menu-button,
html[data-theme="dark"] .top-menu,
html[data-theme="dark"] .brand-home,
html[data-theme="dark"] .vehicle-topology-button,
html[data-theme="dark"] .settings-card,
html[data-theme="dark"] .changelog-entry,
html[data-theme="dark"] .history-vehicle-card,
html[data-theme="dark"] .managed-device,
html[data-theme="dark"] .token-form,
html[data-theme="dark"] .new-token-box,
html[data-theme="dark"] .actuator-row,
html[data-theme="dark"] .actuator-detail,
html[data-theme="dark"] .dtc-card,
html[data-theme="dark"] .data-source-item,
html[data-theme="dark"] .ecu-action,
html[data-theme="dark"] .qr-code-box,
html[data-theme="dark"] table,
html[data-theme="dark"] .learning-analysis-list article,
html[data-theme="dark"] .settings-overview-grid button {
  background: var(--panel);
}
html[data-theme="dark"] .device-card:hover,
html[data-theme="dark"] .device-card:focus-visible {
  background: var(--panel);
  border-color: rgba(43,130,212,0.5);
}
html[data-theme="dark"] .settings-sidebar {
  background: var(--panel-soft);
}
html[data-theme="dark"] .managed-device.offline {
  background: var(--panel-soft);
}
html[data-theme="dark"] .web-flash-box,
html[data-theme="dark"] .server-update-status,
html[data-theme="dark"] .actuator-timer {
  background: var(--panel-soft);
}
html[data-theme="dark"] .icon-button {
  background: var(--panel-soft);
  color: var(--ink);
}
html[data-theme="dark"] .icon-button:hover { background: var(--accent-soft); }

/* Interactive controls */
html[data-theme="dark"] .login-panel input:not([type="checkbox"]):not([type="radio"]),
html[data-theme="dark"] textarea,
html[data-theme="dark"] select,
html[data-theme="dark"] .vin-mode-control select,
html[data-theme="dark"] .settings-card input:not([type="checkbox"]):not([type="radio"]) {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}
html[data-theme="dark"] .login-panel input:not([type="checkbox"]):not([type="radio"]):focus,
html[data-theme="dark"] textarea:focus,
html[data-theme="dark"] .settings-card input:not([type="checkbox"]):not([type="radio"]):focus {
  border-color: rgba(59,159,232,0.55);
  box-shadow: 0 0 0 3px rgba(59,159,232,0.18);
}
html[data-theme="dark"] .secondary-button {
  background: var(--panel);
  color: var(--ink);
  border-color: var(--line);
}
html[data-theme="dark"] .secondary-button:hover { background: var(--accent-soft); }
html[data-theme="dark"] .ecu-action { color: var(--ink); }
html[data-theme="dark"] .ecu-action:hover { background: var(--accent-soft); }
html[data-theme="dark"] .top-menu button,
html[data-theme="dark"] .top-menu a { color: var(--ink); }
html[data-theme="dark"] .top-menu button:hover,
html[data-theme="dark"] .top-menu a:hover { background: var(--accent-soft); color: var(--accent); }
html[data-theme="dark"] .menu-button:hover { background: var(--accent-soft); }
html[data-theme="dark"] .brand-home:hover,
html[data-theme="dark"] .brand-home:focus-visible { background: var(--accent-soft); }
html[data-theme="dark"] .vehicle-topology-button:hover { background: var(--accent-soft); }

/* Live table rows */
html[data-theme="dark"] .live-table td {
  background: rgba(27,37,53,0.85);
  box-shadow: inset 0 1px 0 var(--line), inset 0 -1px 0 var(--line);
}
html[data-theme="dark"] .live-table td:first-child {
  box-shadow: inset 1px 0 0 var(--line), inset 0 1px 0 var(--line), inset 0 -1px 0 var(--line);
}
html[data-theme="dark"] .live-table td:last-child {
  box-shadow: inset -1px 0 0 var(--line), inset 0 1px 0 var(--line), inset 0 -1px 0 var(--line);
}
html[data-theme="dark"] .live-table tr.live-stale td {
  background: rgba(21,30,40,0.85);
  color: var(--muted);
}
html[data-theme="dark"] .graph-panel canvas,
html[data-theme="dark"] .graph-card canvas {
  background: var(--panel);
  border-color: var(--line);
}
html[data-theme="dark"] .graph-value-row { background: rgba(27,37,53,0.85); }
html[data-theme="dark"] .learning-test-panel,
html[data-theme="dark"] .learning-candidate { background: rgba(27,37,53,0.85); }
html[data-theme="dark"] .learning-live-status span {
  background: var(--panel);
  border-color: var(--line);
}

/* Text colors */
html[data-theme="dark"] .changelog-entry li,
html[data-theme="dark"] .top-menu button,
html[data-theme="dark"] .top-menu a,
html[data-theme="dark"] .settings-shortcuts button { color: var(--ink); }
html[data-theme="dark"] .vin-decode-box dd { color: var(--ink); }
html[data-theme="dark"] .device-card div { color: var(--muted); }
html[data-theme="dark"] .raw-cell { color: var(--muted); }
html[data-theme="dark"] .raw-drawer summary { color: var(--muted); }
html[data-theme="dark"] .raw-drawer { background: var(--panel-soft); }

/* Misc */
html[data-theme="dark"] .byte-cell span {
  background: var(--panel-soft);
  border-color: var(--line);
  color: var(--ink);
}
html[data-theme="dark"] .history-source {
  background: var(--panel-soft);
  border-color: var(--line);
  color: var(--muted);
}
html[data-theme="dark"] .voltage-box {
  color: var(--ink);
  background: var(--panel-soft);
}
html[data-theme="dark"] .settings-shortcuts button:hover { background: var(--panel); }
html[data-theme="dark"] .settings-overview-grid button:hover { background: var(--accent-soft); }
html[data-theme="dark"] .live-filter-input,
html[data-theme="dark"] .pid-db-controls input,
html[data-theme="dark"] .pid-db-controls select {
  background: var(--panel);
  color: var(--ink);
  border-color: var(--line);
}
html[data-theme="dark"] .pid-stat {
  background: var(--panel-soft);
  border-color: var(--line);
}
html[data-theme="dark"] .pid-db-table tr:hover td { background: var(--accent-soft); }
html[data-theme="dark"] .dtc-ecu-badge,
html[data-theme="dark"] .live-ecu-badge {
  background: var(--panel);
  border-color: var(--line);
  color: var(--ink);
}
html[data-theme="dark"] .dtc-ecu-header td,
html[data-theme="dark"] .live-ecu-header td { background: var(--panel-soft); }
html[data-theme="dark"] .ecu-stale-toggle { border-color: var(--line); color: var(--muted); }
html[data-theme="dark"] .ecu-stale-toggle:hover { background: var(--panel-soft); color: var(--ink); }
html[data-theme="dark"] #settingsPanel { background: var(--bg); }

/* Expert toggle */
html[data-theme="dark"] .expert-toggle {
  background: #1d1014;
  border-color: #6e2030;
  color: #c45070;
}
html[data-theme="dark"] body.expert-mode-enabled .expert-toggle {
  background: #1d1014;
  border-color: #8f1d28;
  box-shadow: 0 0 0 3px rgba(180,35,47,0.2);
}

/* Color chips – adapt for dark bg */
html[data-theme="dark"] .device-update.current   { background: #0d2e18; color: #2ea055; }
html[data-theme="dark"] .device-update.available { background: #2a2100; color: #d4a017; }
html[data-theme="dark"] .device-update.running   { background: #2d0e0e; color: #e84040; }
html[data-theme="dark"] .device-update.failed    { background: #2d0e0e; color: #c04040; }
html[data-theme="dark"] .dtc-status.active   { background: #2d0e0e; color: #e84040; }
html[data-theme="dark"] .dtc-status.sporadic { background: #2a1d00; color: #d4a017; }
html[data-theme="dark"] .dtc-status.stored   { background: #0d1f35; color: #5faadd; }
html[data-theme="dark"] .server-update-pill             { background: var(--panel-soft); color: var(--ink); }
html[data-theme="dark"] .server-update-pill.running,
html[data-theme="dark"] .server-update-pill.checking    { background: #2a1d00; color: #d4a017; }
html[data-theme="dark"] .server-update-pill.success,
html[data-theme="dark"] .server-update-pill.up_to_date  { background: #0d2e18; color: #2ea055; }
html[data-theme="dark"] .server-update-pill.update_available { background: #0d1f35; color: #5faadd; }
html[data-theme="dark"] .server-update-pill.error        { background: #2d0e0e; color: #e84040; }
html[data-theme="dark"] .vin-check { border-color: var(--line); background: var(--panel-soft); color: var(--muted); }
html[data-theme="dark"] .vin-check.ok { border-color: rgba(46,160,85,0.35); background: rgba(46,160,85,0.12); color: #2ea055; }
html[data-theme="dark"] .vin-check.warn { border-color: rgba(232,64,64,0.35); background: rgba(232,64,64,0.12); color: #e84040; }
html[data-theme="dark"] .learning-analysis-summary span { background: #0d1f35; color: #5faadd; }
html[data-theme="dark"] .quality-pill { background: #2a1500; color: #d4830a; }
html[data-theme="dark"] .app-version { background: var(--panel-soft); border-color: var(--line); color: var(--muted); }
