:root {
  color-scheme: dark;
  --bg: #101317;
  --card: #1a1f26;
  --card-2: #232a33;
  --rail: #0a0d11;
  --ink: #eef1f5;
  --muted: #9aa5b3;
  --line: #2f3844;
  --accent: #ff7a1a;
  --accent-2: #ffad33;
  --ok: #3ccf74;
  --warn: #ffb84d;
  --danger: #ff7070;
  --blue: #6db3ff;
  --rail-width: 68px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 16px/1.4 -apple-system, "Segoe UI", Roboto, Arial, sans-serif; min-height: 100vh; }
h1, h2, h3, p { margin: 0; }
h2 { font-size: 16px; }

/* Каркас: меню сбоку всегда на экране */
.shell { min-height: 100vh; padding-left: calc(var(--rail-width) + env(safe-area-inset-left)); }
.rail {
  position: fixed; left: 0; top: 0; bottom: 0; z-index: 10;
  width: calc(var(--rail-width) + env(safe-area-inset-left));
  padding: calc(env(safe-area-inset-top) + 10px) 0 calc(env(safe-area-inset-bottom) + 8px) env(safe-area-inset-left);
  background: var(--rail); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: stretch; gap: 3px; overflow-y: auto;
}
.brand { width: 42px; height: 42px; margin: 0 auto 8px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(145deg, var(--accent-2), var(--accent)); color: #17110a; font-weight: 800; font-size: 15px; letter-spacing: -.5px; }
.rail button {
  border: 0; background: none; color: var(--muted); font: inherit; font-size: 10.5px; line-height: 1.15; cursor: pointer;
  padding: 9px 1px 8px; display: flex; flex-direction: column; align-items: center; gap: 4px; position: relative;
}
.rail button svg { width: 23px; height: 23px; }
.rail button.on { color: var(--accent-2); font-weight: 600; }
.rail button.on::before { content: ""; position: absolute; left: 0; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.rail .spacer { flex: 1; min-height: 8px; }

.main { max-width: 680px; margin: 0 auto; padding-bottom: calc(env(safe-area-inset-bottom) + 24px); }
.top {
  padding: calc(env(safe-area-inset-top) + 13px) 14px 11px; display: flex; align-items: center; gap: 8px;
  position: sticky; top: 0; z-index: 5; background: rgba(16, 19, 23, .92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.top h1 { font-size: 20px; font-weight: 750; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top button { background: none; border: 0; color: var(--ink); font: inherit; padding: 4px 6px; cursor: pointer; }
.top .back { font-size: 22px; line-height: 1; padding: 2px 8px 4px 0; }
.top button.bell { font-weight: 700; white-space: nowrap; color: var(--accent-2); }

.page { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 13px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.muted { color: var(--muted); font-size: 14px; }
.row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.row .grow { flex: 1; min-width: 0; }

/* Экран входа */
.auth { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; gap: 22px; padding: 24px 18px; max-width: 420px; margin: 0 auto; }
.auth .brand { width: 62px; height: 62px; border-radius: 18px; font-size: 22px; margin: 0; }
.auth h1 { font-size: 27px; line-height: 1.15; }

/* Кнопки */
button.btn, a.btn {
  display: block; width: 100%; border: 0; border-radius: 11px; padding: 14px; font-family: inherit; font-weight: 650; font-size: 16px; line-height: 1.2;
  text-align: center; cursor: pointer; background: var(--card-2); color: var(--ink); text-decoration: none;
}
button.btn.accent { background: linear-gradient(135deg, var(--accent-2), var(--accent)); color: #17110a; }
button.btn.ok { background: var(--ok); color: #06210f; }
button.btn.plain { background: none; border: 1px solid var(--line); }
button.btn.danger { background: none; color: var(--danger); font-weight: 500; }
button.btn.big { padding: 19px 14px; font-size: 18px; display: flex; align-items: center; justify-content: center; gap: 10px; box-shadow: 0 8px 24px rgba(255, 122, 26, .25); }
button.btn.big svg { width: 24px; height: 24px; flex: none; }
button.btn.pay-btn { width: auto; flex: none; padding: 12px 16px; background: var(--ok); color: #06210f; }
button:disabled { opacity: .5; }
button.small { border: 0; background: var(--card-2); border-radius: 8px; padding: 9px 11px; font-family: inherit; font-weight: 600; font-size: 14px; color: var(--ink); cursor: pointer; }
button.icon { border: 0; background: none; font-size: 18px; color: var(--muted); padding: 6px; cursor: pointer; flex: none; }
button.link { border: 0; background: none; color: var(--blue); font: inherit; padding: 4px; cursor: pointer; }

input, select, textarea {
  width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: 10px; padding: 12px; font: inherit; background: var(--bg); color: var(--ink);
}
input::placeholder, textarea::placeholder { color: #6e7886; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 14px; color: var(--muted); min-width: 0; }
.price { width: 88px; flex: none; text-align: right; padding: 9px 8px; }

.chips { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips button { flex: none; border: 1px solid var(--line); background: var(--card); border-radius: 18px; padding: 7px 12px; font: inherit; font-size: 14px; color: var(--ink); cursor: pointer; }
.chips button.on { background: var(--accent); border-color: var(--accent); color: #17110a; font-weight: 650; }

.switch { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 3px; }
.switch button { flex: 1; border: 0; background: none; border-radius: 9px; padding: 10px 6px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.switch button.on { background: var(--card-2); color: var(--accent-2); }

/* Российский номер */
.ru-plate {
  display: inline-flex; align-items: stretch; background: #fff; color: #111; border: 2px solid #111; border-radius: 6px;
  outline: 1px solid #8a93a0; font-weight: 800; line-height: 1; white-space: nowrap; max-width: 100%; font-size: 17px;
}
.ru-plate .num { padding: 5px 7px; letter-spacing: .3px; display: flex; align-items: center; }
.ru-plate .reg { border-left: 2px solid #111; padding: 2px 5px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: .78em; }
.ru-plate .reg i { font-style: normal; font-size: .44em; font-weight: 700; display: flex; align-items: center; gap: 2px; margin-top: 1px; }
.ru-plate .reg u { width: 10px; height: 6px; background: linear-gradient(#fff 33%, #1f4fbf 33% 66%, #d52b1e 66%); outline: .5px solid #999; }
.ru-plate.big { font-size: 27px; border-width: 3px; }
.ru-plate.big .reg { border-left-width: 3px; }
.ru-plate.empty { background: var(--card-2); color: var(--muted); border-color: var(--line); outline: 0; font-weight: 600; }
.ru-plate.empty .num { font-size: 14px; }

/* Списки машин */
.car {
  display: flex; gap: 11px; align-items: stretch; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 8px;
  width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; position: relative; overflow: hidden;
}
.car::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--line); }
.car.draft::before { background: var(--blue); }
.car.submitted::before { background: var(--warn); }
.car.approved::before { background: var(--ok); }
.car img { width: 78px; min-height: 86px; align-self: stretch; object-fit: cover; border-radius: 9px; background: var(--card-2); flex: none; margin-left: 3px; }
.car .info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.car .info .muted { font-size: 13px; }
.car .info .row { width: 100%; justify-content: space-between; }
.status { display: inline-block; font-size: 12px; font-weight: 650; padding: 2px 8px; border-radius: 10px; background: var(--card-2); white-space: nowrap; }
.status.draft { background: rgba(109, 179, 255, .16); color: var(--blue); }
.status.submitted { background: rgba(255, 184, 77, .16); color: var(--warn); }
.status.approved { background: rgba(60, 207, 116, .15); color: var(--ok); }

/* Карточка */
.photo { width: 100%; max-height: 280px; object-fit: cover; border-radius: 10px; display: block; background: var(--card-2); cursor: zoom-in; }
.photo.full { max-height: none; object-fit: contain; cursor: zoom-out; }
.plate-view { display: flex; justify-content: center; padding: 3px 0; }
.plate-input { font-size: 24px; font-weight: 800; letter-spacing: 1px; text-align: center; text-transform: uppercase; background: #fff; color: #111; border: 3px solid #111; outline: 1px solid #8a93a0; padding: 9px 4px; }
.plate-input::placeholder { color: #777; font-size: 18px; font-weight: 600; letter-spacing: 0; text-transform: none; }
.dates { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: baseline; background: var(--bg); border-radius: 10px; padding: 9px 11px; }
.dates b { text-align: right; font-size: 15px; font-variant-numeric: tabular-nums; }
.notice { background: rgba(255, 184, 77, .12); color: var(--warn); border-radius: 10px; padding: 10px 12px; font-size: 15px; }
.item { display: flex; gap: 8px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.item:first-of-type { border-top: 0; }
.item .name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.total { display: flex; justify-content: space-between; gap: 10px; font-size: 19px; font-weight: 750; padding-top: 9px; border-top: 2px solid var(--line); }
.total.head { border-top: 0; padding-top: 0; }
.total span:last-child { color: var(--accent-2); }
.pay { display: flex; gap: 8px; align-items: center; width: 100%; background: none; border: 0; border-top: 1px solid var(--line); padding: 9px 0; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.pay .name { flex: 1; min-width: 0; overflow-wrap: anywhere; }

/* История автомобиля */
.timeline { display: flex; flex-direction: column; }
.stop { display: block; width: 100%; background: none; border: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; padding: 0 0 16px 22px; position: relative; }
.stop::before { content: ""; position: absolute; left: 5px; top: 7px; width: 11px; height: 11px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px rgba(255, 122, 26, .2); }
.stop::after { content: ""; position: absolute; left: 10px; top: 20px; bottom: -6px; width: 1px; background: var(--line); }
.stop:last-child { padding-bottom: 2px; }
.stop:last-child::after { display: none; }
.stop .row { justify-content: space-between; }
.stop p { margin-top: 3px; }

/* Выбор работ */
.sheet-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg); width: 100%; max-width: 680px; height: 88vh; border-radius: 16px 16px 0 0; display: flex; flex-direction: column; }
.sheet header { padding: 14px 16px 8px; display: flex; flex-direction: column; gap: 10px; }
.sheet .list { flex: 1; overflow-y: auto; padding: 0 16px 12px; -webkit-overflow-scrolling: touch; }
.sheet footer { padding: 10px 16px calc(env(safe-area-inset-bottom) + 12px); display: flex; flex-direction: column; gap: 8px; }
details.panel summary { cursor: pointer; font-weight: 650; list-style-position: inside; }
details.panel summary .muted { font-weight: 400; margin-left: 4px; }
.cat { font-size: 13px; font-weight: 700; color: var(--accent-2); margin: 13px 0 5px; text-transform: uppercase; letter-spacing: .4px; }
.pick { display: flex; width: 100%; gap: 10px; justify-content: space-between; background: var(--card); border: 0; border-bottom: 1px solid var(--line); padding: 13px 12px; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.pick.added { background: rgba(60, 207, 116, .18); }
.pick span:last-child { flex: none; color: var(--muted); }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.stat { background: var(--bg); border-radius: 11px; padding: 11px; min-width: 0; }
.stat b { display: block; font-size: 20px; overflow-wrap: anywhere; }
.salary { gap: 2px; }
.salary b { font-size: 26px; color: var(--accent-2); }
.notify { border-color: var(--accent); }
.notify .link { text-align: left; }
.qr svg { display: block; margin: 0 auto; max-width: 230px; height: auto; width: 100%; background: #fff; border-radius: 10px; padding: 8px; }

#toast { position: fixed; left: calc(var(--rail-width) + 12px); right: 12px; bottom: calc(env(safe-area-inset-bottom) + 18px); max-width: 560px; margin: 0 auto; background: var(--ink); color: #14171c; font-weight: 600; padding: 12px 14px; border-radius: 11px; z-index: 40; text-align: center; box-shadow: 0 8px 24px rgba(0, 0, 0, .45); }
#busy { position: fixed; inset: 0; background: rgba(0, 0, 0, .72); color: #fff; z-index: 30; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; font-size: 18px; }
[hidden] { display: none !important; }
.spinner { width: 46px; height: 46px; border: 5px solid rgba(255, 255, 255, .25); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.stack { display: flex; flex-direction: column; gap: 9px; }
.stock-row { display: flex; gap: 9px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); }
.stock-row:first-of-type { border-top: 0; }
.stock-row .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; overflow-wrap: anywhere; }
.article { color: var(--accent-2); font-size: 15px; letter-spacing: .2px; }
.stock-numbers { flex: none; text-align: right; display: flex; flex-direction: column; gap: 2px; }
.offer { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); }
.offer:first-of-type { border-top: 0; }
.offer .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; overflow-wrap: anywhere; }
.offer-price { font-size: 17px; color: var(--ink); white-space: nowrap; }
.error-text { color: var(--danger); font-size: 13px; }
.cars, .split, .split-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.brand-name { display: none; }
.brand-row { display: flex; align-items: center; }

/* Компьютер: подписанное меню и несколько колонок */
@media (min-width: 900px) {
  :root { --rail-width: 216px; }
  .rail { padding: 16px 10px; gap: 4px; }
  .brand-row { gap: 11px; padding: 0 8px; margin-bottom: 14px; }
  .brand { margin: 0; flex: none; }
  .brand-name { display: block; font-weight: 750; font-size: 16px; line-height: 1.15; }
  .brand-name small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }
  .rail button { flex-direction: row; gap: 12px; font-size: 15px; padding: 11px 12px; border-radius: 10px; justify-content: flex-start; text-align: left; }
  .rail button:hover { background: var(--card); color: var(--ink); }
  .rail button.on { background: var(--card); }
  .rail button.on::before { display: none; }
  .main { max-width: 1240px; padding: 0 12px 28px; }
  .top { padding-top: 16px; padding-bottom: 12px; }
  .top h1 { font-size: 24px; }
  .cars { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }
  .split { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); align-items: start; }
  .photo { max-height: 420px; }
  .stats { grid-template-columns: repeat(4, 1fr); }
  button.btn.big { max-width: 420px; }
  .sheet-bg { align-items: center; }
  .sheet { height: 80vh; max-height: 760px; border-radius: 16px; }
  button:hover { filter: brightness(1.08); }
  #toast { left: calc(var(--rail-width) + 20px); }
}

@media (max-width: 350px) {
  :root { --rail-width: 60px; }
  .rail button { font-size: 9.5px; }
  .page { padding: 11px; }
  .ru-plate.big { font-size: 23px; }
}
