:root {
  --bg: #14171c;
  --bg2: #1b2027;
  --bg3: #232a33;
  --line: #2e3742;
  --text: #e8edf3;
  --muted: #93a1b1;
  --dim: #6b7889;
  --acc: #5aa9ff;
  --acc2: #3d7fd6;
  --ok: #57c78a;
  --warn: #e5b34c;
  --bad: #e57171;
  --def: #b48ce8;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--acc); text-decoration: none; }
a:hover { text-decoration: underline; }
button {
  font: inherit; color: inherit; background: var(--bg3);
  border: 1px solid var(--line); border-radius: 6px; cursor: pointer;
  padding: 4px 10px;
}
button:hover { border-color: var(--acc2); }
button:focus-visible, input:focus-visible, a:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--acc); outline-offset: 1px;
}
input[type="search"] {
  width: 100%; padding: 7px 10px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--bg2); color: var(--text);
}
::selection { background: var(--acc2); color: #fff; }

/* ---------- layout ---------- */
#app { display: flex; min-height: 100vh; }
aside {
  width: 330px; min-width: 280px; flex: 0 0 auto;
  border-right: 1px solid var(--line);
  background: var(--bg2);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow: hidden;
}
aside .side-head { padding: 12px 14px 8px; border-bottom: 1px solid var(--line); }
aside .side-head h2 { margin: 0 0 8px; font-size: 15px; letter-spacing: .3px; }
main { flex: 1; min-width: 0; padding: 18px 22px 90px; max-width: 1500px; }

/* ---------- truck list ---------- */
#trucklist { overflow-y: auto; flex: 1; padding: 8px 10px 20px; }
.tl-group { margin-top: 10px; }
.tl-group h3 {
  margin: 0 0 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .8px;
  color: var(--dim); padding: 0 4px;
}
.tl-item {
  display: flex; gap: 8px; align-items: baseline; width: 100%;
  text-align: left; background: none; border: 1px solid transparent;
  border-radius: 6px; padding: 5px 8px; margin: 1px 0;
}
.tl-item:hover { background: var(--bg3); border-color: var(--line); }
.tl-item.selected { background: var(--bg3); border-color: var(--acc2); }
.tl-item.focused { outline: 2px solid var(--acc); outline-offset: -2px; }
.tl-item .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-item .dlc { font-size: 10px; color: var(--dim); font-family: var(--mono); }

/* ---------- truck head ---------- */
.truck-head { margin-bottom: 6px; }
.truck-head h1 { margin: 0 0 2px; font-size: 24px; }
.truck-head .en { font-size: 16px; color: var(--muted); font-weight: 400; margin-left: 8px; }
.truck-head .desc { color: var(--muted); max-width: 900px; margin: 6px 0 0; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 2px; }
.badge {
  display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 20px;
  background: var(--bg3); border: 1px solid var(--line); color: var(--muted);
}
.badge.acc { color: var(--acc); border-color: var(--acc2); }
.badge.warn { color: var(--warn); border-color: var(--warn); }
.badge.def { color: var(--def); border-color: var(--def); }
.badge.ok { color: var(--ok); border-color: var(--ok); }

/* ---------- TOC ---------- */
.toc { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 4px; position: sticky; top: 0; background: var(--bg); padding: 8px 0; z-index: 5; }
.toc a {
  font-size: 12px; padding: 4px 10px; border-radius: 20px;
  background: var(--bg3); border: 1px solid var(--line); color: var(--muted);
}
.toc a:hover { color: var(--acc); border-color: var(--acc2); text-decoration: none; }

/* ---------- sections & tables ---------- */
section.sec { margin: 26px 0; scroll-margin-top: 60px; }
section.sec > h2 {
  font-size: 18px; margin: 0 0 4px; padding-bottom: 4px; border-bottom: 1px solid var(--line);
}
section.sec .sec-note { color: var(--muted); font-size: 12px; margin: 4px 0 8px; }
.subsec { margin: 14px 0 4px; }
.subsec h3 { font-size: 14px; margin: 0 0 4px; color: var(--muted); }
table.rt { border-collapse: collapse; width: 100%; margin: 6px 0 10px; }
table.rt th, table.rt td {
  border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top;
}
table.rt th {
  font-size: 12px; color: var(--muted); text-transform: none; letter-spacing: .2px;
  background: var(--bg2); position: static; user-select: none;
}
table.rt th .thb {
  background: none; border: 0; padding: 0; margin: 0;
  color: inherit; font: inherit; cursor: pointer; width: 100%;
  text-align: inherit; text-transform: none; letter-spacing: inherit;
  border-radius: 4px;
}
table.rt th .thb:hover { color: var(--acc); }
table.rt th.num .thb { text-align: right; }
table.rt th .arrow { color: var(--acc); margin-left: 3px; }
table.rt th.cbh { width: 28px; padding-left: 4px; padding-right: 2px; }
table.rt th.dth { width: 70px; color: var(--dim); }
table.rt td.num, table.rt th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.rt tbody tr:hover { background: rgba(90,169,255,.05); }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.lang { display: flex; align-items: center; gap: 6px; margin: 0 0 8px; }
.lang .lang-btn { padding: 2px 10px; font-size: 12px; font-weight: 700; }
.lang .lang-btn[aria-pressed="true"] { border-color: var(--acc); color: var(--acc); background: var(--bg3); }
.lang .lang-hint { font-size: 11px; color: var(--dim); }
td .nm { font-weight: 600; }
/* имя + метки одной строкой (flex-wrap: при тесной ширине метки переносятся); */
/* альтернативное имя (.nm-en) — отдельной строкой ниже */
td .nm-main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 6px; }
td .nm-en { display: block; font-size: 11px; color: var(--dim); font-weight: 400; }
td .id { font-family: var(--mono); font-size: 11px; color: var(--dim); }
/* длинные XML-пути и идентификаторы в details — переносим, не вылазим */
.det-body p, .det-body .id, .meta, .cmp-table th .id, .truck-head .desc { overflow-wrap: anywhere; }
/* реальный горизонтальный скролл таблиц: страница не расширяется (мобильная ширина);
   position:relative — positioned ancestor для абсолютных .sr-only в th,
   чтобы скрытые лейблы не «вылезали» за контейнер и не расширяли documentElement */
.tscroll { position: relative; overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; }
.val-ok { color: var(--ok); }
.val-warn { color: var(--warn); }
.val-bad { color: var(--bad); }
/* ячейка «Размер»: размеры одной (набор, шина); выделенные требуют подвеску
   (видимая подсказка при наведении и при фокусе с клавиатуры, см. #tooltip) */
td .sz { display: inline-block; white-space: nowrap; }
td .sz-warn {
  background: rgba(229,179,76,.16); color: var(--warn);
  border-radius: 4px; padding: 0 4px; cursor: help;
}
td .sz-bad {
  background: rgba(229,113,113,.18); color: var(--bad);
  border-radius: 4px; padding: 0 4px; cursor: help;
}
/* видимый tooltip: fixed, чтобы не обрезался overflow-x контейнера .tscroll;
   pointer-events:none — не перескакивает курсор и не гасит собственный hover */
#tooltip {
  position: fixed; z-index: 40; display: none; max-width: 440px;
  background: var(--bg3); border: 1px solid var(--warn); color: var(--text);
  padding: 8px 10px; border-radius: 8px; font-size: 12.5px; line-height: 1.4;
  box-shadow: 0 6px 18px rgba(0,0,0,.45); pointer-events: none;
}
#tooltip.bad { border-color: var(--bad); }
.empty { color: var(--dim); font-style: italic; padding: 8px 2px; }

/* раскрытие подробностей: кнопка в служебной ячейке + строка на всю ширину таблицы */
.dt-btn, .detbtn {
  background: none; border: 1px solid var(--line); border-radius: 50%;
  color: var(--acc); cursor: pointer; width: 22px; height: 22px;
  line-height: 1; padding: 0; font-size: 12px;
}
.detbtn:hover { border-color: var(--acc2); }
.detbtn[aria-expanded="true"] { border-color: var(--acc); background: var(--bg3); }
td.dth-cell { width: 34px; text-align: center; }
tr.det-row td {
  background: var(--bg2); border-bottom: 1px solid var(--line);
  padding: 10px 14px;
}
.det-body { font-size: 12.5px; }
.det-body dl { display: grid; grid-template-columns: max-content 1fr; column-gap: 14px; row-gap: 2px; margin: 0 0 8px; }
.det-body dt { color: var(--dim); }
.det-body dd { margin: 0; }
.det-body p { margin: 6px 0 0; color: var(--muted); }
/* метки в ячейке имени — отдельная строка под именем (стабильно) */
td .nm-badges { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }

/* compare bar */
#cmpbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--bg3); border-top: 1px solid var(--acc2);
  display: flex; gap: 10px; align-items: center; padding: 8px 16px;
}
#cmpbar .lbl { font-size: 13px; color: var(--muted); }
#cmpbar .items { flex: 1; display: flex; flex-wrap: wrap; gap: 6px; }
#cmpbar .chip {
  font-size: 12px; background: var(--bg2); border: 1px solid var(--line);
  padding: 2px 8px; border-radius: 12px;
}
#toast {
  position: fixed; bottom: 64px; left: 50%; transform: translateX(-50%);
  background: var(--bg3); border: 1px solid var(--warn); color: var(--warn);
  padding: 8px 14px; border-radius: 8px; z-index: 30; display: none; font-size: 13px;
}

/* compare view */
.cmp-table td, .cmp-table th { padding: 7px 10px; }
.cmp-table td.dif, .cmp-table th.dif { background: rgba(229,179,76,.10); }
.cmp-table td.dif { box-shadow: inset 3px 0 0 var(--warn); }
.cmp-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.crumb { font-size: 13px; color: var(--muted); }

/* catalog */

/* meta footer */
.meta { color: var(--dim); font-size: 11.5px; margin-top: 40px; border-top: 1px solid var(--line); padding-top: 10px; }

/* responsive */
@media (max-width: 900px) {
  #app { flex-direction: column; }
  aside { width: 100%; height: auto; position: static; max-height: 46vh; }
  main { padding: 14px 12px 90px; }
  table.rt th { position: static; }
  .toc { position: static; }
}
