:root {
  color-scheme: dark;
  --bg: #0b0e12;
  --panel: #12171d;
  --panel-2: #182028;
  --line: #2a333e;
  --text: #edf2f7;
  --muted: #8e9aa8;
  --accent: #ef4d23;
  --accent-soft: rgba(239, 77, 35, .14);
  --blue: #58a6ff;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { overflow: hidden; }
button, input, select { font: inherit; }
button { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, .viewport:focus-visible { outline: 2px solid #ff7957; outline-offset: 2px; }
.hidden { display: none !important; }
.topbar { height: 66px; display: flex; align-items: center; gap: 22px; padding: 0 24px; border-bottom: 1px solid var(--line); background: #0d1217; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.brand-mark { width: 34px; height: 37px; display: grid; place-items: center; background: var(--accent); clip-path: polygon(0 0,100% 0,82% 100%,0 100%); font-size: 23px; font-weight: 800; font-style: italic; }
.brand strong { display: block; font-size: 15px; letter-spacing: .11em; }
.brand small { display: block; margin-top: 1px; color: var(--muted); font-size: 9px; letter-spacing: .08em; text-transform: uppercase; }
.topbar-stats { margin-left: auto; color: var(--muted); font-size: 12px; }
.home-button, .icon-button { border: 1px solid var(--line); border-radius: 6px; background: var(--panel-2); cursor: pointer; padding: 7px 12px; font-size: 12px; }
.home-button:hover, .icon-button:hover { background: #25303a; }
.mobile-menu { display: none; font-size: 20px; }
.app-layout { display: grid; grid-template-columns: 350px minmax(0,1fr); height: calc(100vh - 66px); }
.sidebar-backdrop { display: none; }
.sidebar { min-width: 0; min-height: 0; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: var(--panel); z-index: 20; }
.sidebar-top { flex: 0 0 auto; padding: 14px 14px 10px; border-bottom: 1px solid var(--line); }
.nav-tabs { display: grid; grid-template-columns: repeat(3,1fr); gap: 5px; margin-bottom: 13px; }
.nav-tab { padding: 9px 4px; border: 1px solid transparent; border-radius: 5px; background: transparent; color: var(--muted); cursor: pointer; font-size: 12px; }
.nav-tab:hover { background: var(--panel-2); color: var(--text); }
.nav-tab.active { border-color: #3a4550; background: #222b34; color: var(--text); }
.search-box { position: relative; display: block; }
.search-box span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.search-box input { width: 100%; height: 39px; padding: 0 38px 0 12px; border: 1px solid var(--line); border-radius: 6px; background: #0e141a; color: var(--text); font-size: 12px; }
.search-box input::placeholder { color: #6e7a87; }
.search-box kbd { position: absolute; right: 10px; top: 9px; padding: 1px 5px; border: 1px solid #3a444e; border-radius: 3px; color: #788694; font: 11px Consolas,monospace; }
.filters { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 7px; margin-top: 8px; }
.filters select { min-width: 0; height: 33px; padding: 0 6px; border: 1px solid var(--line); border-radius: 5px; background: #11181f; color: #b4c0cc; font-size: 10px; }
.result-count { min-height: 17px; margin-top: 9px; color: var(--muted); font-size: 10px; }
.navigation-list { flex: 1 1 0; min-height: 0; max-height: 100%; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; padding: 8px; }
.nav-item { width: 100%; display: block; padding: 11px 10px; border: 1px solid transparent; border-radius: 6px; background: transparent; text-align: left; cursor: pointer; }
.nav-item:hover { background: var(--panel-2); }
.nav-item.active { border-color: #3b4651; background: #202a33; }
.nav-item-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; font-size: 12px; font-weight: 600; line-height: 1.35; }
.nav-item-meta { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; color: var(--muted); font: 10px Consolas,monospace; }
.badge { display: inline-block; padding: 2px 5px; border-radius: 3px; background: #28323c; color: #b9c5d0; font: 9px Consolas,monospace; white-space: nowrap; }
.badge.mode { background: var(--accent-soft); color: #ff896c; }
.badge.views { background: #20334a; color: #93c5fd; }
.tree-item { margin: 2px 0; }
.tree-button { display: flex; align-items: center; gap: 7px; width: 100%; padding: 9px 8px; border: 0; border-radius: 5px; background: transparent; text-align: left; cursor: pointer; font-size: 12px; }
.tree-button:hover { background: var(--panel-2); }
.tree-arrow { width: 12px; color: #7d8a97; transition: transform .12s; }
.tree-button.expanded .tree-arrow { transform: rotate(90deg); }
.tree-children { margin-left: 13px; padding-left: 8px; border-left: 1px solid #2c3741; }
.brand-logo { width: 24px; height: 24px; flex: 0 0 24px; object-fit: contain; }
.tree-model { padding: 7px 5px 4px; color: #d1d9e1; font-size: 11px; font-weight: 600; }
.tree-version { margin-left: 7px; padding-left: 7px; border-left: 1px solid #27333d; }
.tree-version-name { padding: 5px 0; color: var(--muted); font-size: 10px; }
.engine-card { margin: 5px 0; padding: 8px; border: 1px solid #28333e; border-radius: 5px; background: #141c23; }
.engine-title { color: #c7d1da; font-size: 11px; line-height: 1.4; }
.engine-meta { margin: 4px 0 7px; color: var(--muted); font-size: 9px; }
.ecu-modes { display: flex; flex-wrap: wrap; gap: 4px; }
.ecu-mode { padding: 4px 6px; border: 1px solid #354452; border-radius: 4px; background: #1c2934; cursor: pointer; font: 9px Consolas,monospace; }
.ecu-mode:hover { border-color: var(--accent); }
.pagination { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 4px; }
.pagination button { padding: 5px 9px; border: 1px solid var(--line); border-radius: 4px; background: var(--panel-2); cursor: pointer; font-size: 10px; }
.pagination button:disabled { opacity: .4; cursor: default; }
.pagination span { color: var(--muted); font-size: 10px; }
.empty-state { padding: 30px 15px; color: var(--muted); text-align: center; font-size: 12px; line-height: 1.6; }
.main-content { min-width: 0; overflow-y: auto; }
.welcome { max-width: 1280px; margin: 0 auto; padding: 52px 38px; }
.eyebrow { margin: 0 0 9px; color: var(--accent); font-size: 11px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }
.welcome h1 { max-width: 720px; margin: 0; font-size: clamp(32px,4vw,52px); line-height: 1.06; letter-spacing: -.035em; }
.welcome-copy > p:not(.eyebrow) { max-width: 720px; margin: 18px 0 0; color: var(--muted); font-size: 15px; line-height: 1.65; }
.welcome-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 25px; }
.primary-button, .secondary-button { padding: 11px 17px; border-radius: 6px; cursor: pointer; font-size: 12px; font-weight: 600; }
.primary-button { border: 1px solid var(--accent); background: var(--accent); }
.primary-button:hover { background: #ff6137; }
.secondary-button { border: 1px solid #35404b; background: var(--panel-2); }
.secondary-button:hover { background: #25313c; }
.welcome-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; margin-top: 42px; }
.stat-card { padding: 18px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.stat-value { font-size: 26px; font-weight: 700; }
.stat-label { margin-top: 4px; color: var(--muted); font-size: 11px; }
.recent-section { margin-top: 40px; }
.recent-section h2 { margin: 0 0 12px; font-size: 14px; }
.recent-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(230px,1fr)); gap: 10px; }
.recent-card { padding: 13px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); text-align: left; cursor: pointer; }
.recent-card:hover { background: var(--panel-2); }
.recent-card strong { display: block; font-size: 12px; line-height: 1.4; }
.recent-card small { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; }
.manual-page { padding: 20px 22px 28px; }
.manual-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.manual-title { min-width: 0; }
.manual-breadcrumbs { margin-bottom: 6px; color: var(--muted); font-size: 10px; }
.manual-title h1 { margin: 0; font-size: 25px; line-height: 1.2; letter-spacing: -.02em; }
.manual-subtitle { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.header-actions { display: flex; flex: 0 0 auto; gap: 8px; }
.header-actions .secondary-button { padding: 8px 12px; font-size: 11px; }
.favorite-button { flex: 0 0 auto; padding: 8px 12px; border: 1px solid #3a4650; border-radius: 6px; background: var(--panel-2); cursor: pointer; font-size: 11px; }
.favorite-button.active { border-color: #c9902f; color: #ffd788; }
.manual-workspace { display: grid; grid-template-columns: minmax(0,1fr) 300px; gap: 14px; align-items: start; }
.viewer-card { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: #0e141a; }
.viewer-toolbar { min-height: 61px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 13px; border-bottom: 1px solid var(--line); }
.view-tabs { display: flex; flex-wrap: wrap; gap: 5px; }
.view-tab { padding: 7px 9px; border: 1px solid transparent; border-radius: 5px; background: transparent; color: var(--muted); cursor: pointer; font-size: 10px; }
.view-tab.active { border-color: #3b4854; background: #22303b; color: var(--text); }
.view-tab:hover { color: var(--text); }
.zoom-controls { display: flex; flex: 0 0 auto; align-items: center; border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
.zoom-controls button { width: 30px; height: 29px; border: 0; background: #19222a; cursor: pointer; }
.zoom-controls button:hover { background: #2b3945; }
.zoom-controls output { width: 48px; color: var(--muted); font: 10px Consolas,monospace; text-align: center; }
.viewport { position: relative; height: min(68vh,730px); min-height: 440px; overflow: hidden; background-color: #0a0f14; background-image: linear-gradient(rgba(255,255,255,.018) 1px,transparent 1px),linear-gradient(90deg,rgba(255,255,255,.018) 1px,transparent 1px); background-size: 24px 24px; cursor: grab; touch-action: none; user-select: none; }
.viewport.dragging { cursor: grabbing; }
.scene { position: absolute; left: 50%; top: 50%; transform-origin: center; will-change: transform; }
.scene > img { display: block; width: 100%; height: 100%; pointer-events: none; }
.svg-container { position: absolute; inset: 0; }
.svg-container > svg { display: block; width: 100%; height: 100%; }
.pin-target { cursor: pointer; outline: none; transform-box: fill-box; transform-origin: center; }
.pin-target rect, .pin-target path, .pin-target circle, .pin-target ellipse, .pin-target polygon { fill: var(--pin-color); fill-opacity: 1; stroke: var(--pin-color); stroke-width: .25; }
.pin-target:hover, .pin-target.active, .pin-target:focus-visible { filter: drop-shadow(0 0 .45px var(--pin-color)); opacity: 1; }
.pin-target.active { scale: 1.18; }
.pin-target.active rect, .pin-target.active path, .pin-target.active circle, .pin-target.active ellipse, .pin-target.active polygon { stroke-width: .6; }
.signal-card { position: absolute; left: 0; top: 0; z-index: 8; width: min(230px,calc(100% - 24px)); padding: 12px 13px; border: 1px solid rgba(255,255,255,.17); border-radius: 8px; background: rgba(12,18,24,.88); box-shadow: 0 8px 24px rgba(0,0,0,.28); backdrop-filter: blur(12px); pointer-events: auto; }
.signal-card-close { position: absolute; right: 3px; top: 3px; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 5px; background: transparent; color: #aab6c1; cursor: pointer; font: 20px/24px Arial,sans-serif; }
.signal-card-close:hover { background: rgba(255,255,255,.09); color: #fff; }
.signal-card-head { display: flex; align-items: center; gap: 8px; padding: 0 20px 10px 0; border-bottom: 1px solid rgba(255,255,255,.1); }
.signal-card-head i { flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; background: var(--pin-color); box-shadow: 0 0 8px var(--pin-color); }
.signal-card-head strong { overflow: hidden; color: #f3f6f8; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.signal-card-pin { margin-left: auto; color: #b5c0ca; font: 11px Consolas,monospace; }
.signal-card-grid { display: grid; grid-template-columns: auto 1fr; gap: 7px 12px; margin-top: 10px; font-size: 10px; }
.signal-card-grid span { color: #8e9aa7; }
.signal-card-grid b { color: #d5dde4; font-weight: 500; text-align: right; }
.markers, .overlays { position: absolute; inset: 0; pointer-events: none; }
.marker { position: absolute; width: 18px; min-width: 18px; height: 18px; padding: 0; transform-origin: 0 100%; border: 1.5px solid #fff; border-radius: 50% 50% 50% 0; background: var(--pin-color); box-shadow: 0 1px 4px rgba(0,0,0,.55); color: #fff; pointer-events: auto; cursor: pointer; font: 0 Consolas,monospace; }
.marker::before { content: attr(data-label); display: block; color: #fff; font: 7px Consolas,monospace; line-height: 13px; text-align: center; text-shadow: 0 1px 2px #000; transform: rotate(45deg); }
.marker:hover { z-index: 3; border-color: #fff; box-shadow: 0 0 0 2px #fff,0 2px 7px #000; }
.marker.active { z-index: 3; scale: 1.18; border-width: 2px; box-shadow: 0 0 0 2px var(--pin-color),0 2px 7px #000; }
.marker.warning { border-radius: 3px; }
.overlay-image { position: absolute; pointer-events: none; }
.viewport-hint { position: absolute; left: 50%; bottom: 13px; transform: translateX(-50%); padding: 6px 11px; border: 1px solid #303b45; border-radius: 15px; background: rgba(10,15,20,.87); color: #8e9aa7; font-size: 9px; white-space: nowrap; pointer-events: none; }
.viewport-message { position: absolute; inset: 0; display: grid; place-items: center; padding: 30px; background: #0b1117; color: var(--muted); text-align: center; }
.viewer-status { min-height: 35px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 13px; border-top: 1px solid var(--line); color: var(--muted); font-size: 9px; }
.pin-panel { overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.pin-list { max-height: 44vh; overflow-y: auto; padding: 7px; }
.pin-list-title { padding: 11px 10px 8px; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.pin-item { width: 100%; display: grid; grid-template-columns: 4px 1fr; gap: 10px; padding: 10px 9px; border: 1px solid transparent; border-radius: 6px; background: transparent; text-align: left; cursor: pointer; }
.pin-item:hover { background: var(--panel-2); }
.pin-item.active { border-color: #3b4853; background: #202b35; }
.pin-color { width: 4px; min-height: 32px; border: 1px solid rgba(255,255,255,.18); border-radius: 2px; background: var(--pin-color); }
.pin-name { display: block; font-size: 11px; font-weight: 600; }
.pin-meta { display: block; margin-top: 3px; color: var(--muted); font: 9px Consolas,monospace; }
.pin-details { padding: 15px; border-top: 1px solid var(--line); }
.pin-details h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 13px; font-size: 19px; }
.pin-details h3 i { width: 11px; height: 11px; border-radius: 50%; background: var(--pin-color); }
.details-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 8px; margin: 0; }
.details-grid dt { margin-bottom: 4px; color: var(--muted); font-size: 9px; }
.details-grid dd { margin: 0; font: 10px Consolas,monospace; }
.details-comment { margin: 14px 0 0; color: #c1cbd5; font-size: 11px; line-height: 1.5; }
.protocol-panel { margin-top: 14px; padding: 18px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.protocol-panel h2 { margin: 0 0 12px; font-size: 15px; }
.protocol-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.protocol-table th, .protocol-table td { padding: 9px 7px; border-bottom: 1px solid var(--line); text-align: left; }
.protocol-table th { color: var(--muted); font-size: 9px; text-transform: uppercase; }
.safety-note { margin-top: 14px; color: #8794a0; font-size: 10px; line-height: 1.5; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 100; max-width: 420px; padding: 13px 16px; border: 1px solid #604137; border-radius: 7px; background: #2b1c19; color: #ffd9cf; box-shadow: 0 12px 30px rgba(0,0,0,.35); font-size: 12px; }
.loading-screen { position: fixed; inset: 66px 0 0 350px; z-index: 50; display: grid; place-content: center; justify-items: center; background: var(--bg); color: var(--muted); }
.loader { width: 34px; height: 34px; border: 3px solid #29333e; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f2f5f7;
  --panel: #ffffff;
  --panel-2: #edf1f4;
  --line: #d2dbe3;
  --text: #18222d;
  --muted: #647384;
  --accent: #d94820;
  --accent-soft: rgba(217,72,32,.11);
  --blue: #246fb8;
}
[data-theme="light"] .topbar { background: #fff; }
[data-theme="light"] .brand-mark, [data-theme="light"] .primary-button { color: #fff; }
[data-theme="light"] .home-button:hover, [data-theme="light"] .icon-button:hover { background: #dfe6ec; }
[data-theme="light"] .nav-tab.active { border-color: #bac7d2; background: #e4ebf1; }
[data-theme="light"] .search-box input { background: #f7f9fb; }
[data-theme="light"] .search-box input::placeholder { color: #7b8996; }
[data-theme="light"] .search-box kbd { border-color: #c6d0d9; color: #687786; }
[data-theme="light"] .filters select { background: #f7f9fb; color: #465666; }
[data-theme="light"] .nav-item.active { border-color: #b9c7d3; background: #e4ebf1; }
[data-theme="light"] .badge { background: #e3eaf0; color: #4b5b6a; }
[data-theme="light"] .badge.mode { color: #b73d1d; }
[data-theme="light"] .badge.views { background: #dceaf7; color: #286497; }
[data-theme="light"] .tree-children, [data-theme="light"] .tree-version { border-color: #d2dce4; }
[data-theme="light"] .tree-model, [data-theme="light"] .engine-title { color: #354453; }
[data-theme="light"] .engine-card { border-color: #d2dce4; background: #f5f7f9; }
[data-theme="light"] .ecu-mode { border-color: #c3d0dc; background: #e9eff4; }
[data-theme="light"] .secondary-button { border-color: #c6d1da; }
[data-theme="light"] .secondary-button:hover { background: #dfe7ed; }
[data-theme="light"] .favorite-button { border-color: #c3ced8; }
[data-theme="light"] .favorite-button.active { border-color: #b17c22; color: #89600f; }
[data-theme="light"] .viewer-card { background: #fff; }
[data-theme="light"] .view-tab.active { border-color: #bac9d5; background: #e5edf3; }
[data-theme="light"] .zoom-controls button { background: #edf1f5; }
[data-theme="light"] .zoom-controls button:hover { background: #dce4eb; }
[data-theme="light"] .viewport { background-color: #e5eaee; background-image: linear-gradient(rgba(20,35,45,.045) 1px,transparent 1px),linear-gradient(90deg,rgba(20,35,45,.045) 1px,transparent 1px); }
[data-theme="light"] .viewport-hint { border-color: #bdc8d1; background: rgba(255,255,255,.88); color: #58697a; }
[data-theme="light"] .viewport-message { background: #edf1f4; }
[data-theme="light"] .pin-item.active { border-color: #b8c6d2; background: #e4ebf1; }
[data-theme="light"] .details-comment { color: #455666; }
@media (max-width: 480px) {
  [data-theme="light"] .topbar-stats, :root:not([data-theme="light"]) .topbar-stats { display: none; }
}
@media (max-width: 1100px) {
  .app-layout { grid-template-columns: 300px minmax(0,1fr); }
  .manual-workspace { grid-template-columns: minmax(0,1fr) 260px; }
  .loading-screen { left: 300px; }
}
@media (max-width: 820px) {
  body { overflow: auto; }
  .topbar { height: 58px; padding: 0 13px; gap: 11px; }
  .mobile-menu { display: block; }
  .home-button { display: none; }
  .topbar-stats { font-size: 10px; }
  .app-layout { display: block; height: calc(100vh - 58px); }
  .sidebar { position: fixed; left: 0; top: 58px; bottom: 0; width: min(88vw,340px); transform: translateX(-105%); transition: transform .18s; box-shadow: 18px 0 45px rgba(0,0,0,.35); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; inset: 58px 0 0; z-index: 15; display: none; background: rgba(0,0,0,.55); }
  .sidebar.open + .sidebar-backdrop { display: block; }
  .main-content { height: calc(100vh - 58px); }
  .welcome { padding: 32px 18px; }
  .welcome-grid { grid-template-columns: 1fr; margin-top: 30px; }
  .manual-page { padding: 14px 10px 22px; }
  .manual-header { gap: 10px; }
  .manual-title h1 { font-size: 21px; }
  .manual-workspace { display: block; }
  .pin-panel { margin-top: 12px; }
  .pin-list { max-height: none; }
  .viewport { min-height: 400px; height: 56vh; }
  .loading-screen { inset: 58px 0 0; }
}
@media (max-width: 480px) {
  .brand small { display: none; }
  .brand strong { font-size: 12px; }
  .topbar-stats { max-width: 120px; text-align: right; }
  .welcome h1 { font-size: 34px; }
  .manual-header { display: block; }
  .favorite-button { margin-top: 10px; }
  .viewer-toolbar { align-items: flex-start; }
  .zoom-controls output { width: 40px; }
  .viewport { min-height: 350px; }
  .viewport-hint { font-size: 8px; }
}
