:root {
  --bg: #f4f5f7; --card: #ffffff; --text: #1a1d21; --muted: #6b7280;
  --line: #e5e7eb; --accent: #2563eb; --accent2: #0ea5e9;
  --green: #16a34a; --red: #dc2626; --amber: #d97706;
  --chip: #eef2f7; --shadow: 0 1px 3px rgba(0,0,0,.08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101318; --card: #1a1f27; --text: #e8eaed; --muted: #9aa3af;
    --line: #2a3038; --accent: #4f8cff; --accent2: #38bdf8;
    --green: #34d399; --red: #f87171; --amber: #fbbf24;
    --chip: #232a33; --shadow: 0 1px 3px rgba(0,0,0,.4);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent; }
a { color: var(--accent); text-decoration: none; }
button { font: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; width: 100%; }
textarea { min-height: 110px; resize: vertical; }
input:focus, textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }

#app { max-width: 860px; margin: 0 auto; padding: 10px 10px 76px; }

/* верхняя панель */
.topbar { display: flex; align-items: center; gap: 8px; padding: 6px 2px 10px; }
.topbar h1 { font-size: 19px; margin: 0; flex: 1; }
.topbar .sub { color: var(--muted); font-size: 12px; }

/* нижняя навигация */
.nav { position: fixed; bottom: 0; left: 0; right: 0; display: flex; z-index: 20;
  background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.nav button { flex: 1; background: none; border: none; color: var(--muted);
  padding: 9px 0 7px; font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.nav button .ico { font-size: 20px; line-height: 1; }
.nav button.on { color: var(--accent); font-weight: 600; }

/* чипы-фильтры */
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button { white-space: nowrap; border: 1px solid var(--line); background: var(--card);
  color: var(--text); border-radius: 999px; padding: 6px 13px; font-size: 13px; }
.chips button.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.search { margin-bottom: 10px; }

/* карточки машин */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.car-card { background: var(--card); border-radius: 14px; box-shadow: var(--shadow);
  overflow: hidden; cursor: pointer; border: 1px solid var(--line); }
.car-card .ph { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; background: var(--chip); }
.car-card .noph { width: 100%; aspect-ratio: 4/3; display: flex; align-items: center;
  justify-content: center; font-size: 42px; background: var(--chip); color: var(--muted); }
.car-card .body { padding: 10px 12px 12px; }
.car-card .name { font-weight: 650; font-size: 14.5px; margin-bottom: 5px; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; }
.badge { font-size: 11.5px; background: var(--chip); border-radius: 6px; padding: 2px 7px; color: var(--muted); }
.badge.g { color: var(--green); } .badge.r { color: var(--red); } .badge.a { color: var(--amber); }
.badge.b { color: var(--accent); }
.car-card .fin { margin-top: 6px; font-size: 13px; color: var(--muted); }
.car-card .fin b { color: var(--text); }

.summary { background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 14px; margin-bottom: 10px; font-size: 13.5px; color: var(--muted);
  display: flex; flex-wrap: wrap; gap: 6px 18px; }
.summary b { color: var(--text); }

/* страница машины */
.backrow { display: flex; align-items: center; gap: 10px; margin: 2px 0 8px; }
.backrow button { background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 7px 13px; color: var(--text); }
.backrow h2 { font-size: 17px; margin: 0; flex: 1; }
.vinline { color: var(--muted); font-size: 12px; margin-bottom: 8px; user-select: all; }

.gallery { position: relative; border-radius: 14px; overflow: hidden; background: var(--chip); margin-bottom: 8px; }
.gallery img.main { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; }
.gallery .cnt { position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.55);
  color: #fff; font-size: 12px; border-radius: 8px; padding: 2px 8px; }
.thumbs { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 8px; }
.thumbs img { width: 72px; height: 54px; object-fit: cover; border-radius: 8px; flex: none;
  border: 2px solid transparent; cursor: pointer; }
.thumbs img.on { border-color: var(--accent); }
.thumbs img.sel { border-color: var(--green); }

.tabs { display: flex; gap: 4px; overflow-x: auto; margin-bottom: 10px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { white-space: nowrap; border: none; background: none; color: var(--muted);
  padding: 8px 11px; border-bottom: 2px solid transparent; font-size: 14px; }
.tabs button.on { color: var(--accent); border-color: var(--accent); font-weight: 600; }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px; margin-bottom: 10px; }
.panel h3 { margin: 0 0 10px; font-size: 14px; color: var(--muted); text-transform: uppercase;
  letter-spacing: .4px; }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0;
  border-bottom: 1px dashed var(--line); font-size: 14.5px; }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 600; text-align: right; }
.kv .v.g { color: var(--green); } .kv .v.r { color: var(--red); }

.btnrow { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.btn { background: var(--accent); color: #fff; border: none; border-radius: 10px;
  padding: 9px 15px; font-weight: 600;
  transition: transform .08s ease, filter .08s ease; }
.btn.sec { background: var(--chip); color: var(--text); }
.btn.warn { background: var(--red); }
.btn.ok { background: var(--green); }
.btn:disabled { opacity: .55; }
/* явный отклик нажатия: кнопка «проседает» под пальцем */
.btn:active, .chips button:active, .nav button:active, .backrow button:active {
  transform: scale(.94); filter: brightness(.82); }
.btn.busy { position: relative; pointer-events: none; opacity: .75; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn.busy::after { content: ''; display: inline-block; width: 13px; height: 13px;
  margin-left: 8px; vertical-align: -2px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent;
  animation: spin .7s linear infinite; }

/* чек-лист */
.check { display: flex; align-items: center; gap: 10px; padding: 9px 2px;
  border-bottom: 1px dashed var(--line); }
.check:last-child { border-bottom: none; }
.check input[type=checkbox] { width: 21px; height: 21px; flex: none; accent-color: var(--green); }
.check .t { flex: 1; }
.check.done .t { color: var(--muted); text-decoration: line-through; }
.check .who { font-size: 11px; color: var(--muted); }
.check .del { background: none; border: none; color: var(--muted); font-size: 16px; }
.addrow { display: flex; gap: 8px; margin-top: 10px; }

/* журнал */
.jrow { padding: 8px 2px; border-bottom: 1px dashed var(--line); font-size: 14px; }
.jrow:last-child { border-bottom: none; }
.jrow .meta { font-size: 11.5px; color: var(--muted); margin-bottom: 1px; }

/* расходы */
.exp { display: flex; gap: 10px; padding: 6px 2px; border-bottom: 1px dashed var(--line); font-size: 13.5px; }
.exp:last-child { border-bottom: none; }
.exp .d { color: var(--muted); flex: none; width: 74px; }
.exp .s { font-weight: 600; flex: none; width: 70px; text-align: right; }
.exp .c { flex: 1; color: var(--muted); }

/* формы-модалки */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 40;
  display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--card); border-radius: 18px 18px 0 0; width: 100%; max-width: 560px;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); max-height: 88vh; overflow-y: auto; }
.modal h3 { margin: 0 0 12px; }
.modal label { display: block; font-size: 12.5px; color: var(--muted); margin: 10px 0 4px; }

/* просмотр фото */
.viewer { position: fixed; inset: 0; background: rgba(0,0,0,.93); z-index: 50;
  display: flex; align-items: center; justify-content: center; }
.viewer img { max-width: 100vw; max-height: 100vh; object-fit: contain; }
.viewer .x { position: absolute; top: 12px; right: 14px; font-size: 26px; color: #fff;
  background: none; border: none; }
.viewer .pn { position: absolute; top: 50%; transform: translateY(-50%); font-size: 30px;
  color: #fff; background: rgba(0,0,0,.3); border: none; padding: 14px 10px; border-radius: 10px; }
.viewer .prev { left: 6px; } .viewer .next { right: 6px; }
.viewer .cap { position: absolute; bottom: 14px; left: 0; right: 0; text-align: center;
  color: #ccc; font-size: 13px; }

/* фото-грид */
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(105px, 1fr)); gap: 6px; }
.pgrid .pw { position: relative; }
.pgrid img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 9px;
  cursor: pointer; border: 2px solid transparent; display: block; }
.pgrid img.sel { border-color: var(--green); }
.pgrid .tag { position: absolute; left: 4px; top: 4px; font-size: 10px; background: rgba(0,0,0,.55);
  color: #fff; padding: 1px 5px; border-radius: 5px; }
.pgrid .rm { position: absolute; right: 3px; top: 3px; background: rgba(0,0,0,.55); color: #fff;
  border: none; border-radius: 6px; font-size: 12px; padding: 1px 6px; }

/* логин */
.login { max-width: 360px; margin: 14vh auto 0; }
.login .panel { padding: 22px; }
.login h2 { margin: 0 0 4px; }
.login .hint { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.err { color: var(--red); font-size: 13.5px; margin-top: 8px; min-height: 18px; }

/* тудушки */
.todo-car { margin-bottom: 4px; }
.todo-car .nm { font-weight: 650; }
.todo-car .days { color: var(--muted); font-size: 12.5px; }
.todo-car ul { margin: 4px 0 10px; padding-left: 22px; color: var(--muted); }

/* пользователи */
.usr { padding: 10px 2px; border-bottom: 1px dashed var(--line); }
.usr:last-child { border-bottom: none; }
.usr .l { font-weight: 650; }
.usr .meta { font-size: 12.5px; color: var(--muted); }
.passbox { background: var(--chip); border-radius: 10px; padding: 10px 12px; margin-top: 10px;
  font-family: ui-monospace, monospace; user-select: all; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mt { margin-top: 10px; }
pre.notes { white-space: pre-wrap; font: 13px/1.5 ui-monospace, monospace; background: var(--chip);
  border-radius: 10px; padding: 10px; margin: 0; max-height: 300px; overflow-y: auto; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 84px; background: var(--text);
  color: var(--bg); border-radius: 10px; padding: 9px 16px; font-size: 14px; z-index: 60;
  box-shadow: var(--shadow); }
