/* AutoCat витрина — светлая тема, тёмно-синий + оранжевый акцент (пилот aleksparts) */
:root {
  --ink: #1c2733;
  --muted: #5b6b7b;
  --line: #dde5ec;
  --bg: #f4f6f9;
  --card: #ffffff;
  --primary: #173a5e;
  --primary-ink: #ffffff;
  --accent: #f39c12;
  --accent-ink: #4a2e00;
  --ok: #1e7e46;
  --err: #b02a37;
  --radius: 10px;
}
* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  line-height: 1.5; min-height: 100vh; display: flex; flex-direction: column;
}
.container { width: min(1120px, 94vw); margin: 0 auto; flex: 1 0 auto; padding-bottom: 3rem; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Шапка */
.topbar {
  background: var(--primary); color: var(--primary-ink);
  padding: .65rem 0; margin-bottom: 1.5rem;
}
.topbar .container { display: flex; align-items: center; justify-content: space-between; width: min(1120px, 94vw); }
.brand { color: inherit; text-decoration: none; font-weight: 700; font-size: 1.35rem; letter-spacing: .3px; }
.brand-accent { color: var(--accent); }
.brand-sub { font-size: .78rem; font-weight: 400; opacity: .75; margin-left: .6rem; }
.topbar-right { display: flex; gap: 1rem; align-items: center; }

/* Герой поиска */
.hero { text-align: center; padding: 2.5rem 0 1.5rem; }
.hero h1 { font-size: clamp(1.6rem, 4vw, 2.3rem); margin: 0 0 .4rem; }
.hero-sub { color: var(--muted); margin: 0 0 1.4rem; }
.vin-form { display: flex; gap: .6rem; max-width: 640px; margin: 0 auto; }
.vin-form input {
  flex: 1; font-size: 1.15rem; padding: .8rem 1rem;
  border: 2px solid var(--line); border-radius: var(--radius);
  text-transform: uppercase; letter-spacing: 1px;
}
.vin-form input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(23,58,94,.15); }
.hint { color: var(--muted); font-size: .85rem; }
#vin-hint { margin-top: .6rem; }

.btn {
  display: inline-block; border: 0; cursor: pointer; text-decoration: none;
  border-radius: var(--radius); padding: .8rem 1.6rem; font-size: 1.05rem; font-weight: 600;
  background: var(--accent); color: var(--accent-ink);
}
.btn:hover { filter: brightness(.96); }
.btn-primary { background: var(--accent); }
.btn-sm { padding: .35rem .8rem; font-size: .85rem; border-radius: 8px; background: var(--primary); color: #fff; }

/* Уведомления */
.alert { border-radius: var(--radius); padding: .8rem 1.1rem; margin: 1rem 0; }
.alert-ok { background: #e8f6ee; color: var(--ok); }
.alert-err { background: #fdecee; color: var(--err); border: 1px solid #f2c4c9; }

/* Как это работает */
.how { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .8rem; margin: 2rem 0; }
.how-step {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .9rem 1rem; display: flex; gap: .7rem; align-items: center; font-size: .95rem;
}
.how-num {
  background: var(--primary); color: #fff; width: 1.7rem; height: 1.7rem; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex: 0 0 auto;
}

/* Паспорт машины */
.car-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.2rem 1.4rem; display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}
.car-card h1 { margin: 0 0 .5rem; font-size: 1.4rem; }
.car-specs { display: flex; gap: 1.6rem; margin: 0; flex-wrap: wrap; }
.car-specs div { display: flex; flex-direction: column; }
.car-specs dt { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.car-specs dd { margin: 0; font-weight: 600; }
.car-vin { text-align: right; align-self: center; }
.car-vin-label { display: block; font-size: .75rem; color: var(--muted); }
.car-vin-value { font-family: Consolas, monospace; font-size: 1.05rem; letter-spacing: 1.5px; }

/* Дерево узлов */
.tree-title { margin: 1.6rem 0 .2rem; font-size: 1.15rem; }
.tree-cat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin: .6rem 0; }
.tree-cat > summary {
  cursor: pointer; padding: .75rem 1rem; font-weight: 600; user-select: none; list-style: none;
}
.tree-cat > summary::-webkit-details-marker { display: none; }
.tree-cat > summary::before { content: "▸"; display: inline-block; margin-right: .5rem; color: var(--muted); transition: transform .15s; }
.tree-cat[open] > summary::before { transform: rotate(90deg); }
.tree-count { color: var(--muted); font-weight: 400; font-size: .85rem; margin-left: .4rem; }
.tree-list { list-style: none; margin: 0; padding: 0 1rem .8rem 1.6rem; columns: 2; column-gap: 2rem; }
.tree-list-sub { padding-left: 1rem; }
.tree-list li { break-inside: avoid; margin: .15rem 0; }
.tree-list a { color: var(--ink); text-decoration: none; }
.tree-list a:hover { color: var(--accent); text-decoration: underline; }
.tree-sub summary { cursor: pointer; color: var(--muted); font-size: .82rem; }

/* Узел: схема + таблица */
.group-title { font-size: 1.3rem; margin: .2rem 0 1rem; }
.breadcrumbs { color: var(--muted); font-size: .88rem; margin-bottom: .8rem; }
.breadcrumbs a { color: var(--primary); text-decoration: none; }
.breadcrumbs a:hover { text-decoration: underline; }

.schema-block { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.45fr); gap: 1.2rem; align-items: start; }
.schema-figure {
  position: relative; margin: 0; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .6rem; position: sticky; top: 1rem;
}
.schema-figure img { width: 100%; height: auto; display: block; border-radius: 6px; }
/* Выноска = кликабельная зона точно ПОВЕРХ номера на чертеже.
   Координаты elcats (MapPoint) — это левый-ВЕРХНИЙ угол текстового бокса номера
   (номера у elcats 4–6 знаков, бокс ~39×11), поэтому якорь — угол, без центровки:
   рамка охватывает номер, как маркер. */
.hotspot {
  position: absolute;
  width: 54px; height: 19px; border-radius: 9px;
  margin-left: -7px; margin-top: -4px;
  border: 2px solid transparent; background: transparent;
  cursor: pointer; padding: 0; font-size: 0; line-height: 0;
  transition: border-color .12s, background .12s, box-shadow .12s;
}
.hotspot:hover, .hotspot.is-active {
  background: rgba(255,196,0,.10);
  border-color: #ff9d00;
  box-shadow: 0 0 0 3px rgba(255,255,255,.85), 0 0 0 6px rgba(255,157,0,.30), 0 0 16px 5px rgba(255,157,0,.45);
}

.parts-table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; }
.parts-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.parts-table th {
  text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .4px;
  color: var(--muted); padding: .7rem .8rem; border-bottom: 2px solid var(--line);
  position: sticky; top: 0; background: var(--card);
}
.parts-table td { padding: .55rem .8rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.parts-table tr.is-active td { background: #fff7e6; }
.parts-table tr:hover td { background: #f2f6fb; }
.cell-pos { font-weight: 700; color: var(--primary); width: 2.6rem; }
.cell-oem { font-family: Consolas, monospace; white-space: nowrap; }
.cell-qty { width: 3.5rem; }
.stock-unknown { color: var(--muted); font-style: italic; font-size: .85rem; }

/* Футер */
.footer {
  flex-shrink: 0; background: var(--card); border-top: 1px solid var(--line);
  color: var(--muted); font-size: .8rem; padding: .8rem 0; text-align: center;
}

/* Мобилка */
@media (max-width: 860px) {
  .schema-block { grid-template-columns: 1fr; }
  .schema-figure { position: static; }
  .tree-list { columns: 1; }
  .vin-form { flex-direction: column; }
  .vin-form .btn { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* === Каноническое дерево (Laximo/Armtek) + двухпанельный макет === */
.cat-layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 1.4rem; align-items: start; }
.cat-side {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  position: sticky; top: .8rem; max-height: calc(100vh - 6rem); overflow: auto;
}
.cat-side-head {
  padding: .6rem .9rem; font-weight: 700; color: var(--primary);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--card);
}
.cat-content { min-width: 0; }
.cat-placeholder {
  background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius);
  padding: 2.2rem 1.6rem; color: var(--muted);
}
.cat-placeholder h2 { margin: 0 0 .4rem; font-size: 1.15rem; color: var(--ink); }

/* Дерево */
.cat-tree { padding: .45rem .45rem .9rem; font-size: .86rem; }
[x-cloak] { display: none !important; }
.ct-list { list-style: none; margin: 0; padding: 0; }
.ct-list .ct-list { padding-left: .95rem; }
.ct-row {
  display: flex; align-items: baseline; gap: .3rem; width: 100%;
  background: none; border: 0; text-align: left; cursor: pointer;
  padding: .18rem .35rem; border-radius: 6px; color: var(--ink);
  font-size: inherit; font-family: inherit; line-height: 1.35;
}
.ct-row:hover { background: #eef3f8; }
a.ct-row { text-decoration: none; display: flex; }
.ct-bucket-row { font-weight: 700; color: var(--primary); }
.ct-marker { flex: 0 0 1em; position: relative; font-weight: 400; }
.ct-marker::before { content: "+"; display: inline-block; width: 1em; text-align: center; color: var(--muted); }
.is-open > .ct-row .ct-marker::before, .ct-row.is-open .ct-marker::before { content: "−"; }
a.ct-row .ct-marker::before { content: "·"; }
.ct-label { min-width: 0; overflow-wrap: anywhere; }
.ct-children { padding-left: .55rem; border-left: 1px dotted var(--line); margin-left: .5rem; }
.ct-branch-row { font-weight: 600; }
.ct-leaf.is-active { background: #fdf3dd; color: var(--accent-ink); font-weight: 700; }
.ct-leaf.is-active .ct-label { color: var(--accent-ink); }
.is-active-path > .ct-bucket-row { color: var(--accent); }

.schema-caption { margin-top: .45rem; font-size: .85rem; color: var(--muted); }

@media (max-width: 860px) {
  .cat-layout { grid-template-columns: 1fr; }
  .cat-side { position: static; max-height: none; }
}

.parts-table { font-size: .82rem; }
.parts-table .cell-oem { white-space: nowrap; font-variant-numeric: tabular-nums; }
.parts-table th, .parts-table td { padding: .45rem .5rem; }
.parts-table .btn-sm { padding: .25rem .6rem; font-size: .78rem; }

/* Клик-увеличение схемы */
.schema-img { cursor: zoom-in; }
.schema-figure { position: relative; }
.lightbox {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(9, 14, 20, .93);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .6rem; padding: 1rem; cursor: zoom-out;
}
.lightbox img { max-width: 96vw; max-height: 92vh; width: auto; height: auto; background: #fff; }
.lightbox-hint { color: rgba(255,255,255,.75); font-size: .82rem; }

/* Дерево прижато к левому краю (как у референса) — больше места схеме */
.cat-layout { grid-template-columns: 250px minmax(0, 1fr); }
.cat-side { border-radius: 8px; }
.cat-side-head { font-size: .85rem; padding: .45rem .7rem; }
.cat-tree { font-size: .8rem; padding: .3rem .3rem .7rem; }
.ct-row { padding: .1rem .3rem; }

/* Схема: панорама + масштаб */
.schema-viewport {
  position: relative; overflow: hidden; height: min(72vh, 640px);
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  cursor: grab; touch-action: none;
}
.schema-viewport:active { cursor: grabbing; }
.schema-canvas { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.schema-canvas img { display: block; user-select: none; }
.schema-toolbar {
  position: absolute; top: .5rem; right: .5rem; z-index: 5;
  display: flex; align-items: center; gap: .3rem;
  background: rgba(255,255,255,.95); border: 1px solid var(--line); border-radius: 8px;
  padding: .15rem .35rem;
}
.schema-toolbar button {
  border: 0; background: none; cursor: pointer; font-size: 1rem; line-height: 1;
  width: 1.8rem; height: 1.6rem; border-radius: 6px; color: var(--primary);
}
.schema-toolbar button:hover { background: #eef3f8; }
.schema-zoom { font-size: .78rem; color: var(--muted); min-width: 3em; text-align: center; }
.schema-figure:fullscreen { background: #fff; padding: .5rem; }
.schema-figure:fullscreen .schema-viewport { height: 94vh; }
@media (max-width: 860px) { .cat-layout { grid-template-columns: 1fr; } }

/* === ЭКРАН УЗЛА v2 — один экран: дерево слева | схема в центре | детали справа ===
   Требование Александра: всё видно и умещается на одном экране, схема целиком,
   зум/перемещение, выноски подсвечиваются вместе со строками деталей. */
body.grp-page { overflow: hidden; height: 100vh; }
body.grp-page .topbar { margin-bottom: .5rem; padding: .4rem 0; }
body.grp-page .container { width: 100%; max-width: none; padding: 0 .7rem; flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
body.grp-page .footer { display: none; }

.grp-screen {
  flex: 1 1 auto; min-height: 0;
  display: grid;
  /* Резерв до применения Alpine: 5 треков (дерево | ручка | схема | ручка | детали) */
  grid-template-columns: 250px 8px minmax(0, 1fr) 8px minmax(360px, 26vw);
  grid-template-rows: minmax(0, 1fr);
  gap: .7rem;
}

/* Колонки с собственной прокруткой */
.grp-tree, .grp-parts {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  overflow: auto; min-height: 0;
}
.grp-tree .cat-side-head { position: sticky; top: 0; z-index: 2; background: var(--card); }

/* Центр: заголовок + схема на всю оставшуюся высоту */
.grp-center { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.grp-head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0 .1rem .4rem;
}
.grp-head .breadcrumbs { margin: 0; font-size: .76rem; }
.grp-title { font-size: 1.05rem; margin: .05rem 0 0; line-height: 1.25; }
.schema-toolbar { flex-shrink: 0; position: static; }

.grp-stage {
  flex: 1 1 auto; min-height: 0; position: relative; overflow: hidden;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  cursor: grab; touch-action: none;
}
.grp-stage:active { cursor: grabbing; }
.grp-hint { font-size: .74rem; color: var(--muted); text-align: center; padding-top: .3rem; flex-shrink: 0; }
.grp-empty {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--muted); padding: 2rem; text-align: center;
}
.grp-stage .schema-canvas img { max-width: none; }

/* Разделители колонок: тянуть мышью — ширина дерева/деталей (схема забирает остаток) */
.grp-grip { cursor: col-resize; position: relative; z-index: 5; border-radius: 4px; }
.grp-grip::before {
  content: ''; position: absolute; left: 3px; top: 12%; bottom: 12%; width: 2px;
  background: var(--line); border-radius: 2px; transition: background .15s, width .15s;
}
.grp-grip:hover::before, .grp-grip:active::before { background: var(--accent); width: 3px; left: 2.5px; }
body.is-col-resize { user-select: none; cursor: col-resize; }
body.is-col-resize .grp-screen { pointer-events: none; }
body.is-col-resize .grp-screen .grp-grip { pointer-events: auto; }

/* Закреплённая выноска — кольцо пульсирует, чтобы взгляд цеплялся */
.hotspot.is-active { animation: hs-pulse 1.2s ease-in-out infinite; }
@keyframes hs-pulse {
  50% { box-shadow: 0 0 0 3px rgba(255,255,255,.85), 0 0 0 8px rgba(255,157,0,.40), 0 0 22px 8px rgba(255,157,0,.55); }
}

/* Детали справа */
.grp-parts { display: flex; flex-direction: column; overflow: hidden; }
.parts-head {
  flex-shrink: 0; font-weight: 700; color: var(--primary); font-size: .88rem;
  padding: .5rem .8rem; border-bottom: 1px solid var(--line); background: #f6f9fc;
}
.parts-count { color: var(--muted); font-weight: 400; font-size: .78rem; margin-left: .3rem; }
.parts-scroll { flex: 1 1 auto; overflow: auto; min-height: 0; }
.grp-parts .parts-table { font-size: .84rem; }
.grp-parts .parts-table th { font-size: .7rem; padding: .45rem .55rem; }
.grp-parts .parts-table td { padding: .4rem .55rem; }
.grp-parts .cell-oem { font-size: .78rem; color: var(--muted); }
.grp-parts .parts-table tr.is-active td { background: #fff3d6; }
.grp-parts .parts-table tr:hover td { background: #f2f6fb; }

/* Узкий экран: колонки складываются в поток, страница снова прокручивается */
@media (max-width: 1000px) {
  body.grp-page { overflow: auto; height: auto; }
  body.grp-page .container { flex: none; }
  .grp-screen { display: flex; flex-direction: column; height: auto; }
  .grp-center { order: 1; }
  .grp-stage { flex: none; height: 58vh; }
  .grp-parts { order: 2; max-height: 52vh; }
  .grp-tree { order: 3; max-height: 44vh; }
}

/* ===== Очередь «VIN с сайта»: статус-страница ===== */
.queue-page { max-width: 720px; margin: 1.5rem auto; }
.queue-card {
  background: #fff; border: 1px solid #e3e9f2; border-radius: var(--radius);
  padding: 1.2rem 1.4rem; margin-top: 1rem; box-shadow: 0 1px 3px rgba(23,58,94,.06);
}
.queue-wait { border-left: 4px solid var(--accent); }
.queue-ok { border-left: 4px solid var(--ok); }
.queue-err { border-left: 4px solid var(--err); }
.queue-status-line { display: flex; align-items: center; gap: .6rem; font-size: 1.02rem; }
.queue-hint { color: var(--muted); font-size: .88rem; margin: .6rem 0 0; }
.queue-spinner {
  width: 16px; height: 16px; flex: none; border-radius: 50%;
  border: 2px solid #d8e2ef; border-top-color: var(--accent);
  animation: queue-spin 1s linear infinite;
}
@keyframes queue-spin { to { transform: rotate(360deg); } }
.queue-options {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: .35rem .9rem; margin: .8rem 0; max-height: 420px; overflow: auto;
}
.queue-option {
  display: flex; align-items: center; gap: .5rem; padding: .45rem .6rem;
  border: 1px solid #e3e9f2; border-radius: 8px; cursor: pointer; font-size: .9rem;
}
.queue-option:hover { background: #f2f6fb; }
.queue-search { display: flex; gap: .5rem; margin-bottom: .4rem; }
.queue-search input[type="search"] {
  flex: 1; padding: .5rem .7rem; border: 1px solid #d8e2ef; border-radius: 8px; font-size: .95rem;
}
@media (prefers-reduced-motion: reduce) { .queue-spinner { animation: none; } }
