:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --line: #e3e6ea;
  --line-strong: #cdd2d9;
  --text: #1c2430;
  --muted: #66707d;
  --accent: #2563eb;
  --accent-weak: #e8effd;
  --green: #137a4b;
  --green-weak: #e3f3ea;
  --red: #c0392b;
  --red-weak: #fbe9e7;
  --amber: #9a6a00;
  --amber-weak: #fbf0d8;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(20, 30, 45, 0.08), 0 1px 2px rgba(20, 30, 45, 0.04);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
a { color: inherit; text-decoration: none; }

.topbar {
  display: flex; align-items: center; gap: 24px;
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding: 0 20px; height: 56px; position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 9px; color: var(--text); white-space: nowrap; }
.brand .logo-truck { width: 34px; height: auto; flex: none; }
.brand-mark { color: var(--accent); font-size: 14px; }
.nav { display: flex; gap: 4px; }
.nav a { padding: 7px 14px; border-radius: 8px; color: var(--muted); font-weight: 500; }
.nav a:hover { background: var(--bg); color: var(--text); }
.nav a.active { background: var(--accent-weak); color: var(--accent); }
.nav-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 17px; height: 17px;
  padding: 0 4px; margin-left: 5px; border-radius: 9px; background: var(--red); color: #fff;
  font-size: 11px; font-weight: 700; vertical-align: 1px; }
.nav-badge:empty { display: none; }
.row-danger td { background: var(--red-weak); }
.trip-cont td { border-top: 1px dashed var(--line); }
.wear-alert { background: var(--red-weak); color: var(--red); font-weight: 600; border: 1px solid #f3c6bf; }

.container { max-width: 1240px; margin: 0 auto; padding: 22px 20px 80px; }

h1 { font-size: 22px; margin: 0 0 4px; font-weight: 600; }
h2 { font-size: 17px; margin: 0 0 12px; font-weight: 600; }
.sub { color: var(--muted); margin: 0 0 20px; }

.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }

/* кнопки */
.btn {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  padding: 9px 15px; border-radius: 8px; font-size: 14px; font-weight: 500; font-family: inherit;
}
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-sm { padding: 6px 10px; font-size: 13px; }

/* поиск */
.search { width: 100%; max-width: 520px; position: relative; }
.search input {
  width: 100%; padding: 13px 16px; font-size: 16px; border: 1px solid var(--line-strong);
  border-radius: var(--radius); background: var(--surface); font-family: inherit;
}
.search input:focus { outline: 2px solid var(--accent-weak); border-color: var(--accent); }

/* карточки ТС */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-top: 18px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); cursor: pointer; transition: border-color .12s;
}
.card:hover { border-color: var(--accent); }
.card .reg { font-size: 18px; font-weight: 600; letter-spacing: .3px; }
.card .meta { color: var(--muted); font-size: 13px; margin-top: 2px; }
.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500;
  padding: 3px 9px; border-radius: 20px; background: var(--bg); color: var(--muted);
}
.badge.ok { background: var(--green-weak); color: var(--green); }
.badge.warn { background: var(--amber-weak); color: var(--amber); }
.badge.danger { background: var(--red-weak); color: var(--red); }
.badge.tractor { background: var(--accent-weak); color: var(--accent); }
.badge.trailer { background: #f0ecfa; color: #6d4caa; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-pad { padding: 18px; }

/* плитки статистики на карточке ТС */
.ico { vertical-align: -3px; color: var(--muted); }
.muted { color: var(--muted); font-weight: 400; }
.stats { display: flex; gap: 14px; flex-wrap: wrap; margin: 16px 0 4px; }
.stat { flex: 1 1 200px; min-width: 180px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); }
.stat .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; font-weight: 500; display: flex; align-items: center; gap: 7px; }
.stat .value { font-size: 22px; font-weight: 600; margin-top: 6px; line-height: 1.2; }
.stat .value.sm { font-size: 18px; }
.stat .value .muted { font-size: .68em; }
.stat .value a { color: var(--accent); }
.stat .value a:hover { text-decoration: underline; }
.stat .meta { font-size: 13px; color: var(--muted); margin-top: 3px; }
.stat-btn { margin-top: 11px; }
.progress { height: 7px; background: var(--bg); border-radius: 6px; overflow: hidden; margin-top: 10px; }
.progress > span { display: block; height: 100%; border-radius: 6px; transition: width .2s; }
.tag-retread { display: inline-block; font-size: 11px; font-weight: 500; padding: 1px 7px; border-radius: 10px; background: var(--amber-weak); color: var(--amber); vertical-align: 1px; }
.grid tr.row-empty td { color: var(--muted); }
.grid tr.row-empty .pos-code { color: var(--text); }

/* карта колёс */
.wheelmap-wrap { display: flex; flex-direction: row; gap: 18px; flex-wrap: wrap; align-items: flex-start; }
.wheelmap { flex: 0 0 380px; width: 380px; max-width: 380px; }
.wheelmap svg { width: 100%; height: auto; }
.wheelmap svg { overflow: visible; }
.tire { cursor: pointer; }
.tire rect { fill: var(--green-weak); stroke: var(--green); stroke-width: 1.5; transition: fill .1s; filter: drop-shadow(0 1px 1.5px rgba(20, 30, 45, .12)); }
.tire:hover rect { fill: #c6e6d3; }
.tire.empty rect { fill: var(--red-weak); stroke: var(--red); stroke-dasharray: 4 3; }
.tire.empty:hover rect { fill: #f7d8d3; }
.tire.low rect { fill: var(--amber-weak); stroke: var(--amber); }
.tire text { font-size: 12px; font-weight: 600; fill: var(--text); pointer-events: none; }
.axle-line { stroke: var(--line-strong); stroke-width: 7; stroke-linecap: round; }
.hub { fill: #fff; stroke: var(--line-strong); stroke-width: 1.5; }
.hub-text { font-size: 12px; font-weight: 600; fill: var(--muted); }
.chassis { fill: #e3e7ec; }
.maplabel { font-size: 12px; fill: var(--muted); }
.deck { fill: #eceff3; stroke: var(--line); stroke-width: 1; }
.cab { fill: #e7edf4; stroke: var(--line-strong); stroke-width: 1.5; filter: drop-shadow(0 1px 2px rgba(20, 30, 45, .14)); }
.cab-glass { fill: #bccbdc; }
.cab-mirror { fill: #d7dee7; stroke: var(--line-strong); stroke-width: .75; }
.tread { stroke: rgba(20, 30, 45, .11); stroke-width: 2; stroke-linecap: round; }
.hub-ring { fill: none; stroke: var(--line); stroke-width: 1; }
.hitch-outer { fill: #fff; stroke: var(--muted); stroke-width: 2; }
.hitch-inner { fill: var(--line-strong); }
.train-label { font-size: 12px; font-weight: 500; fill: var(--accent); }
.train-trailer { opacity: .96; }
.train-trailer .tire { cursor: pointer; }

/* таблица позиций */
table.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
.grid th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.grid th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.grid th.sortable:hover { color: var(--text); }
.grid--sticky thead th { position: sticky; top: 56px; z-index: 5; background: var(--surface); box-shadow: inset 0 -1px 0 var(--line); }
.grid--positions { font-size: 14px; }
.grid--positions td, .grid--positions th { white-space: nowrap; padding: 8px 12px; }
.grid td { padding: 9px 10px; border-bottom: 1px solid var(--line); }
.grid tr:last-child td { border-bottom: none; }
.grid tr.clickable { cursor: pointer; }
.grid tr.clickable:hover { background: var(--bg); }
.grid .empty-cell { color: var(--red); font-weight: 500; }
.grid .plus { color: var(--muted); margin: 0 5px; font-weight: 500; }
.grid a.coupled { color: var(--accent); cursor: pointer; font-weight: 500; }
.grid a.coupled:hover { text-decoration: underline; }
.mono { font-variant-numeric: tabular-nums; }
.pos-code { font-weight: 600; }

/* формы / модалка */
.modal-bg {
  position: fixed; inset: 0; background: rgba(20, 28, 40, .45);
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 50; overflow: auto;
}
.modal {
  background: var(--surface); border-radius: 14px; width: 100%; max-width: 460px;
  box-shadow: 0 12px 40px rgba(20, 30, 45, .25); animation: pop .12s ease-out;
}
@keyframes pop { from { transform: translateY(6px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 18px 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; }

label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.input, select.input, textarea.input {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line-strong); border-radius: 8px;
  font-size: 14px; font-family: inherit; background: var(--surface); color: var(--text);
}
.input:focus { outline: 2px solid var(--accent-weak); border-color: var(--accent); }
.field-row { display: flex; gap: 12px; }
.field-row > * { flex: 1; }

.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.seg button { border: none; background: var(--surface); padding: 8px 12px; cursor: pointer; font-size: 13px; font-family: inherit; color: var(--muted); }
.seg button.on { background: var(--accent); color: #fff; }

.hint { font-size: 13px; color: var(--muted); }
.empty-state { text-align: center; color: var(--muted); padding: 50px 20px; }
.pill-list { display: flex; flex-wrap: wrap; gap: 6px; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 12px 0 12px 18px; border-left: 2px solid var(--line); position: relative; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 16px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.timeline .when { font-size: 12px; color: var(--muted); }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--text); color: #fff; padding: 11px 18px; border-radius: 8px; font-size: 14px; z-index: 80; box-shadow: var(--shadow); }

@media (max-width: 640px) {
  .nav a { padding: 7px 10px; }
  .container { padding: 16px 14px 80px; }
}
