:root {
  color-scheme: light;
  --ink: #18212B; --ink-2: #4A5663; --ink-3: #7A8591;
  --line: #D5DBE1; --bg: #F1F4F6; --paper: #FFFFFF;
  --sign: #1F5AA6; --sign-2: #E6EEF8;
  --late: #9A4600; --late-bg: #FFF0DC;
  --ok: #2B7349; --ok-bg: #E5F3EA; --bad: #B3261E; --bad-bg: #FBE9E7;
  --r: 6px; --tap: 44px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-bottom: 6rem; }
input, select, textarea, .btn { scroll-margin-bottom: 6rem; }
body { margin: 0; font: 16px/1.45 var(--font); color: var(--ink); background: var(--bg); font-variant-numeric: tabular-nums; }
a { color: var(--sign); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--sign); outline-offset: 2px; }
[hidden] { display: none !important; }
h1 { font-size: 1.35rem; line-height: 1.25; margin: 0 0 .25rem; font-weight: 650; }
h2 { font-size: 1.05rem; margin: 0; font-weight: 650; }
h3 { font-size: .95rem; margin: .75rem 0 .35rem; font-weight: 650; color: var(--ink-2); }
.muted { color: var(--ink-3); }
.small { font-size: .85rem; }
.pad { padding: 1rem; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.right { margin-left: auto; }
.money { white-space: nowrap; }
.neg { color: var(--bad); }
.pos { color: var(--ok); }

/* ---------- каркас: телефон — нижняя панель, компьютер — колонка слева ---------- */
.app { min-height: 100vh; min-height: 100dvh; }
.main { padding: .75rem .75rem calc(5.5rem + env(safe-area-inset-bottom)); max-width: 980px; margin: 0 auto; outline: none; }
.nav { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; display: flex; background: var(--paper); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); }
.nav a { flex: 1; min-height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; color: var(--ink-2); font-size: .72rem; }
.nav a .ico { font-size: 1.25rem; line-height: 1; }
.nav a.on { color: var(--sign); font-weight: 650; }
.nav a.plus .ico { background: var(--sign); color: #fff; border-radius: 50%; width: 34px; height: 34px; display: grid; place-items: center; }
.nav .wide { display: none; }
/* экранная клавиатура открыта: нижняя панель не должна подниматься над ней и закрывать поле */
@media (max-width: 899px) { body.kb .nav { display: none; } body.kb .main { padding-bottom: 1.5rem; } }
@media (min-width: 900px) {
  .app { display: grid; grid-template-columns: 220px 1fr; }
  .nav { position: sticky; top: 0; height: 100vh; flex-direction: column; border-top: 0; border-right: 1px solid var(--line); padding: 1rem .5rem; gap: 2px; }
  .nav a { flex: 0 0 auto; flex-direction: row; justify-content: flex-start; gap: .6rem; padding: 0 .75rem; font-size: .95rem; border-radius: var(--r); min-height: 42px; }
  .nav a.on { background: var(--sign-2); }
  .nav .wide { display: flex; }
  .nav .brand { font-weight: 700; padding: .25rem .75rem 1rem; color: var(--sign); }
  .main { padding: 1.5rem 2rem 3rem; }
}
.nav .brand { display: none; }
@media (max-width: 360px) { .nav a { font-size: .66rem; } }
@media (min-width: 900px) { .nav .brand { display: block; } }

.net { position: sticky; top: 0; z-index: 30; padding: .5rem 1rem; background: var(--late-bg); color: var(--late); font-size: .9rem; border-bottom: 1px solid #F0C990; }

/* ---------- блоки ---------- */
.block { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: .85rem; margin: 0 0 .75rem; }
.block > h2 { margin-bottom: .5rem; }
details.block > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: .5rem; min-height: 28px; font-weight: 650; }
details.block > summary::-webkit-details-marker { display: none; }
details.block > summary::after { content: "＋"; margin-left: auto; color: var(--ink-3); }
details.block[open] > summary::after { content: "－"; }
details.block[open] > summary { margin-bottom: .5rem; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-top: 1px solid var(--line); padding: .6rem 0; }
.list > li:first-child { border-top: 0; }
.item { display: flex; gap: .6rem; align-items: flex-start; text-decoration: none; color: inherit; }
.item .meta { color: var(--ink-3); font-size: .85rem; }
.kv { display: grid; grid-template-columns: minmax(110px, 40%) 1fr; gap: .25rem .75rem; margin: 0; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

/* «номерной знак» — название автомобиля */
.plate { display: inline-block; border: 1.5px solid var(--ink); border-radius: 4px; padding: 0 .4rem; font-weight: 650; background: #fff;
  letter-spacing: .01em; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }

.chip { display: inline-flex; align-items: center; gap: .25rem; padding: .1rem .5rem; border-radius: 999px; font-size: .8rem; background: var(--bg);
  border: 1px solid var(--line); color: var(--ink-2); white-space: nowrap; }
.chip.late { background: var(--late-bg); color: var(--late); border-color: #F0C990; }
.chip.ok { background: var(--ok-bg); color: var(--ok); border-color: #B8DCC6; }
.chip.bad { background: var(--bad-bg); color: var(--bad); border-color: #F2C0BA; }
.chip.blue { background: var(--sign-2); color: var(--sign); border-color: #BCD0EA; }

/* ---------- маршрут этапов: единственный выразительный элемент ---------- */
.route { display: flex; overflow-x: auto; gap: 0; padding: .4rem 0 .6rem; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.route::-webkit-scrollbar { display: none; }
.stop { position: relative; flex: 0 0 auto; padding: 1.15rem .55rem 0; font-size: .78rem; color: var(--ink-3); max-width: 9.5rem; text-align: center; }
.stop::before { content: ""; position: absolute; top: .45rem; left: 0; right: 0; height: 4px; background: var(--line); }
.stop:first-child::before { left: 50%; } .stop:last-child::before { right: 50%; }
.stop::after { content: ""; position: absolute; top: .2rem; left: calc(50% - 7px); width: 14px; height: 14px; border-radius: 50%; background: var(--paper); border: 3px solid var(--line); }
.stop.done { color: var(--ink-2); } .stop.done::before { background: var(--sign); } .stop.done::after { border-color: var(--sign); background: var(--sign); }
.stop.cur { color: var(--sign); font-weight: 700; } .stop.cur::before { background: linear-gradient(90deg, var(--sign) 50%, var(--line) 50%); }
.stop.cur::after { width: 20px; height: 20px; top: -.05rem; left: calc(50% - 10px); border-color: var(--sign); background: #fff; box-shadow: 0 0 0 4px var(--sign-2); }
.stop.end-lost.cur { color: var(--bad); } .stop.end-lost.cur::after { border-color: var(--bad); box-shadow: 0 0 0 4px var(--bad-bg); }
.stop .op { display: block; font-size: .68rem; color: var(--ink-3); font-weight: 400; }

/* следующее действие */
.next { border-left: 4px solid var(--sign); background: var(--paper); border-radius: 0 10px 10px 0; padding: .7rem .85rem; margin: 0 0 .75rem; border-top: 1px solid var(--line); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.next.late { border-left-color: var(--late); background: var(--late-bg); }
.next.none { border-left-color: var(--bad); background: var(--bad-bg); }

/* ---------- формы ---------- */
.field { margin: 0 0 .7rem; }
.field label, .field .lbl { display: block; font-size: .85rem; color: var(--ink-2); margin-bottom: .2rem; }
.field .req { color: var(--bad); }
.field .help { font-size: .8rem; color: var(--ink-3); margin-top: .2rem; }
.field .err { font-size: .82rem; color: var(--bad); margin-top: .2rem; }
input[type=text], input[type=tel], input[type=search], input[type=password], input[type=number], input[type=datetime-local], input[type=date], select, textarea {
  width: 100%; min-height: var(--tap); padding: .5rem .65rem; border: 1px solid #B9C2CB; border-radius: var(--r); background: #fff; font-size: 16px; }
textarea { min-height: 84px; resize: vertical; }
input[readonly], textarea[readonly], select:disabled { background: var(--bg); color: var(--ink-2); }
.check { display: flex; gap: .5rem; align-items: center; min-height: var(--tap); }
.check input { width: 22px; height: 22px; }
.multi { display: flex; flex-wrap: wrap; gap: .4rem; }
.multi label { display: inline-flex; align-items: center; gap: .35rem; padding: .35rem .65rem; border: 1px solid #B9C2CB; border-radius: 999px; min-height: 40px; background: #fff; }
.multi input { width: 18px; height: 18px; }
.grid2 { display: grid; grid-template-columns: 1fr; gap: 0 .75rem; }
@media (min-width: 600px) { .grid2 { grid-template-columns: 1fr 1fr; } }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; min-height: var(--tap); padding: .45rem .95rem; border-radius: var(--r);
  border: 1px solid #B9C2CB; background: #fff; color: var(--ink); text-decoration: none; cursor: pointer; font-weight: 550; }
.btn.primary { background: var(--sign); border-color: var(--sign); color: #fff; }
.btn.danger { color: var(--bad); border-color: #E3A7A1; }
.btn.small { min-height: 36px; padding: .25rem .65rem; font-size: .9rem; }
.btn[disabled], .btn.busy { opacity: .55; pointer-events: none; }
.btn.block { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .5rem; }

.tabs { display: flex; gap: .35rem; overflow-x: auto; margin: 0 0 .75rem; padding-bottom: 2px; scrollbar-width: none; }
.tabs a, .tabs button { flex: 0 0 auto; padding: .35rem .8rem; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  text-decoration: none; min-height: 38px; display: inline-flex; align-items: center; cursor: pointer; }
.tabs .on { background: var(--ink); color: #fff; border-color: var(--ink); }
/* Фильтры и вкладки на телефоне переносятся на новую строку: все видны сразу, без скрытой горизонтальной прокрутки */
.tabs { flex-wrap: wrap; overflow-x: visible; }
.tabs a, .tabs button, .tabs label { max-width: 100%; }
/* переключатель направления в новом обращении: выбранный вариант всегда контрастен */
.tabs.seg label { flex: 0 0 auto; display: inline-flex; align-items: center; gap: .35rem; padding: .35rem .8rem; min-height: 44px; border: 1px solid #B9C2CB; border-radius: 999px; background: #fff; color: var(--ink); cursor: pointer; }
.tabs.seg label.on, .tabs.seg label:has(input:checked) { background: var(--sign); border-color: var(--sign); color: #fff; font-weight: 650; }
.tabs.seg input { width: 18px; height: 18px; min-height: 0; margin: 0; accent-color: #fff; }
.tabs.seg label:focus-within { outline: 3px solid var(--sign); outline-offset: 2px; }

.thumb { width: 72px; height: 54px; flex: 0 0 72px; border-radius: 4px; background: var(--bg) center/cover no-repeat; border: 1px solid var(--line); display: grid; place-items: center; color: var(--ink-3); font-size: .7rem; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .5rem; }
.photos img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }

table.t { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.t th, table.t td { text-align: left; padding: .4rem .35rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t td.num, table.t th.num { text-align: right; }
.scroll-x { overflow-x: auto; }
/* узкий экран: таблицы финансов умещаются без бокового скролла (заголовки переносятся, плотнее отступы) */
@media (max-width: 480px) {
  table.t { font-size: .8rem; }
  table.t th, table.t td { padding: .35rem .2rem; overflow-wrap: anywhere; }
  table.t th { font-size: .72rem; line-height: 1.2; }
}

/* ---------- нижний лист (диалог) ---------- */
.sheet { position: fixed; inset: 0; z-index: 50; background: rgba(24, 33, 43, .45); display: flex; align-items: flex-end; justify-content: center; }
.sheet .panel { background: var(--paper); width: 100%; max-width: 640px; max-height: 92vh; max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain; border-radius: 14px 14px 0 0;
  padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom)); }
@media (min-width: 700px) { .sheet { align-items: center; } .sheet .panel { border-radius: 14px; } }
.sheet .panel header { display: flex; align-items: center; gap: .5rem; margin-bottom: .75rem; }
.sheet .panel header .x { margin-left: auto; }
@media (prefers-reduced-motion: no-preference) {
  .sheet .panel { animation: up .18s ease-out; }
  @keyframes up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
}

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(70px + env(safe-area-inset-bottom)); z-index: 60; max-width: 92vw;
  background: var(--ink); color: #fff; padding: .6rem 1rem; border-radius: 8px; font-size: .92rem; opacity: 0; pointer-events: none; transition: opacity .2s; }
.toast.show { opacity: 1; }
.toast.bad { background: var(--bad); }

.login { max-width: 380px; margin: 12vh auto 0; }
.login .mark { color: var(--sign); font-weight: 750; font-size: 1.4rem; margin-bottom: 1rem; }
.notice { padding: .6rem .75rem; border-radius: 8px; background: var(--sign-2); color: var(--ink); font-size: .9rem; margin: 0 0 .75rem; }
.notice.warn { background: var(--late-bg); color: var(--late); }
.notice.bad { background: var(--bad-bg); color: var(--bad); }
pre.code { white-space: pre-wrap; background: var(--bg); padding: .5rem; border-radius: 6px; font-size: .8rem; max-height: 50vh; overflow: auto; }
.hist { font-size: .85rem; }
.hist time { color: var(--ink-3); margin-right: .35rem; }

/* ---------- осмотры: карта кузова (SVG), легенда, детали, фото ---------- */
.bodymap { display: block; width: 100%; max-width: 460px; height: auto; margin: .25rem auto; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.bodymap .pz { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.bodymap .pz rect { stroke-width: 1.5; }
.bodymap .pz:focus { outline: none; }
.bodymap .pz:focus-visible rect, .bodymap .pz:hover rect { stroke: var(--sign); stroke-width: 3; }
.bodymap .zl { font: 600 10.5px var(--font); text-anchor: middle; fill: var(--ink); pointer-events: none; }
.bodymap .zh { font: 600 11px var(--font); text-anchor: middle; fill: var(--ink-3); }
.bodymap .zc { fill: var(--ink); }
.bodymap .zn { font: 700 10px var(--font); text-anchor: middle; fill: #fff; pointer-events: none; }
.bodymap .glass { fill: #DCE7F2; stroke: #B6C7D9; }
.st-unchecked rect, i.sw.st-unchecked { fill: url(#hatch); stroke: #A9B3BD; }
i.sw.st-unchecked { background: repeating-linear-gradient(45deg, #F1F3F5 0 3px, #C9D0D7 3px 5px); border-color: #A9B3BD; }
.st-ok rect { fill: #86CFA0; stroke: #2B7349; } i.sw.st-ok { background: #86CFA0; border-color: #2B7349; }
.st-paint rect { fill: #F4CE45; stroke: #8A6D00; } i.sw.st-paint { background: #F4CE45; border-color: #8A6D00; }
.st-putty rect { fill: #D9433A; stroke: #8E1B15; } i.sw.st-putty { background: #D9433A; border-color: #8E1B15; }
.bodymap .st-putty .zl { fill: #fff; }
i.sw { display: inline-block; width: 18px; height: 18px; border-radius: 4px; border: 1.5px solid; flex: 0 0 18px; vertical-align: middle; }
.legend { display: flex; flex-wrap: wrap; gap: .35rem .9rem; font-size: .85rem; margin: .25rem 0 .5rem; }
.legend span { display: inline-flex; align-items: center; gap: .35rem; }
.states { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .4rem; }
.states .stp { min-width: 0; overflow-wrap: anywhere; display: flex; align-items: center; gap: .45rem; min-height: var(--tap); padding: .35rem .6rem; border: 1.5px solid #B9C2CB; border-radius: var(--r); background: #fff; cursor: pointer; }
.states .stp input { width: 18px; height: 18px; margin: 0; }
.states .stp:has(input:checked) { border-color: var(--sign); box-shadow: 0 0 0 3px var(--sign-2); font-weight: 650; }
.partlist .pl { display: flex; align-items: center; gap: .6rem; width: 100%; min-height: var(--tap); background: none; border: 0; padding: .2rem 0; text-align: left; cursor: pointer; }
.vinrow { display: flex; gap: .5rem; flex-wrap: wrap; }
.vinrow input { flex: 1 1 12rem; min-width: 0; font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .03em; }
.vinbox { border: 1px solid var(--line); border-radius: 8px; padding: .6rem; margin-top: .5rem; background: var(--bg); }
.vinbox .list > li { padding: .25rem 0; }
.photos .ph { padding: 0; border: 0; background: none; cursor: zoom-in; }
.lightbox { position: fixed; inset: 0; z-index: 70; background: rgba(10, 14, 18, .94); color: #fff; display: flex; flex-direction: column; padding: calc(.5rem + env(safe-area-inset-top)) .5rem calc(.5rem + env(safe-area-inset-bottom)); }
.lightbox .lb-top { display: flex; align-items: flex-start; gap: .5rem; justify-content: space-between; font-size: .9rem; padding: .25rem .25rem .5rem; }
.lightbox img { flex: 1 1 auto; min-height: 0; width: 100%; object-fit: contain; }
.lightbox .lb-nav { display: flex; justify-content: space-between; gap: .5rem; padding-top: .5rem; }
.lightbox .btn { background: rgba(255, 255, 255, .92); }
