/* «Мой гараж» — оформление: гибрид.
   Каркас: фиксированная шапка + боковое меню + панели (как в макете P).
   Язык: тёмная панель, синий акцент, тонкие рамки, плотные таблицы,
   моноширинные цифры (как в варианте 3 «Бортовой журнал»).
   Только CSS-переменные, без inline-стилей — совместимо со строгим CSP. */

:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --ink: #10131a;
  --ink-soft: #344054;
  --muted: #667085;
  --line: #e4e7ec;
  --line-soft: #eef0f4;
  --accent: #1d4ed8;
  --accent-dark: #1a3fb0;
  --accent-soft: #eaf0ff;
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --ok: #0f8a5f;
  --ok-soft: #ecfdf3;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;
  --radius: 6px;
  --radius-sm: 3px;
  --nav-h: 56px;
  --side-w: 232px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 13.5px/1.45 "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Шапка ---------- */
.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 1030;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  background: #10131a;
  color: #fff;
  border-bottom: 1px solid #1b202b;
}
.menu-btn {
  display: none;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid #262d3a;
  border-radius: var(--radius-sm);
  background: transparent;
  color: #c3cbd8;
  cursor: pointer;
}
.menu-btn svg { width: 15px; height: 15px; }
.menu-btn:hover { background: #1a1f2b; color: #fff; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 13.5px;
  letter-spacing: .01em;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, .18);
  flex: none;
}

.search { position: relative; flex: 1 1 auto; max-width: 620px; margin: 0 auto; }
.search-icon {
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: #8f9aab;
  pointer-events: none;
}
.search input {
  width: 100%;
  height: 30px;
  padding: 0 10px 0 29px;
  border: 1px solid #262d3a;
  border-radius: var(--radius-sm);
  background: #171c26;
  color: #e8ecf3;
  font: inherit;
  font-size: 12.5px;
}
.search input::placeholder { color: #7e8a9c; }
.search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(29, 78, 216, .25);
}

.top-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.user {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 8px 3px 3px;
  border-radius: var(--radius-sm);
  color: #e8ecf3;
  font-size: 12.5px;
}
.avatar {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
}
.top-links { display: flex; align-items: center; gap: 4px; font-size: 12.5px; }
.top-links a { color: #b9c2d2; padding: 4px 7px; border-radius: var(--radius-sm); }
.top-links a:hover { background: rgba(255, 255, 255, .08); color: #fff; text-decoration: none; }

/* ---------- Боковое меню ---------- */
.sidebar {
  position: fixed;
  top: var(--nav-h);
  bottom: 0;
  left: 0;
  z-index: 1020;
  width: var(--side-w);
  padding: 8px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.side-nav { list-style: none; margin: 0; padding: 0; }
.side-nav a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}
.side-nav a svg { width: 14px; height: 14px; flex: none; opacity: .75; }
.side-nav a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.side-nav a.active {
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--accent);
}
.side-nav a.active svg { opacity: 1; }
.side-nav .badge { margin-left: auto; }
.side-heading {
  margin: 10px 0 4px;
  padding: 7px 10px 6px;
  border-bottom: 1px solid var(--line);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .11em;
  text-transform: uppercase;
  color: var(--muted);
}
.side-nav + .side-heading { margin-top: 14px; }
.side-foot {
  margin-top: auto;
  padding: 10px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}
.side-foot .sep { margin: 0 6px; }

/* ---------- Контент ---------- */
main {
  margin-left: var(--side-w);
  padding: calc(var(--nav-h) + 16px) 20px 40px;
  min-height: 100vh;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.crumb {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .11em;
  text-transform: uppercase;
  color: var(--muted);
}
.page-head h1 {
  margin: 3px 0 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -.015em;
}
.page-head .sub { margin: 3px 0 0; font-size: 12.5px; color: var(--muted); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Метрики ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.stat {
  padding: 11px 13px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
}
.stat-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}
.stat-value {
  margin-top: 5px;
  font-family: var(--mono);
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.stat-foot { margin-top: 3px; font-size: 12px; color: var(--muted); }
.stat.warn { border-left-color: var(--danger); }
.stat.warn .stat-value { color: var(--danger); }

/* ---------- Панели ---------- */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2 {
  margin: 0;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .11em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.panel-head .tag, .panel-head .panel-link, .panel-head .badge { margin-left: auto; }
.panel-link { font-size: 12px; }
.panel-foot {
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 11.5px;
  color: var(--muted);
}

/* ---------- Полосы категорий ---------- */
.catlist { list-style: none; margin: 0; padding: 0; }
.catlist li { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); }
.catlist li:last-child { border-bottom: none; }
.cat-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 5px;
  font-size: 12.5px;
  color: var(--ink-soft);
}
.cat-row .num { color: var(--ink); font-weight: 700; font-family: var(--mono); font-size: 12px; }
.progress { height: 6px; background: var(--line-soft); border-radius: 2px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--accent); border-radius: 2px; }

.w-5 { width: 5%; } .w-10 { width: 10%; } .w-15 { width: 15%; } .w-20 { width: 20%; }
.w-25 { width: 25%; } .w-30 { width: 30%; } .w-35 { width: 35%; } .w-40 { width: 40%; }
.w-45 { width: 45%; } .w-50 { width: 50%; } .w-55 { width: 55%; } .w-60 { width: 60%; }
.w-65 { width: 65%; } .w-70 { width: 70%; } .w-75 { width: 75%; } .w-80 { width: 80%; }
.w-85 { width: 85%; } .w-90 { width: 90%; } .w-95 { width: 95%; } .w-100 { width: 100%; }

/* ---------- Тулбар фильтров ---------- */
.toolbar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 10px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
.field { display: flex; flex-direction: column; gap: 3px; }
.field.grow { flex: 1 1 180px; }
.field label {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}
.field-actions { display: flex; gap: 6px; margin-left: auto; }

select, input[type="date"], input[type="text"], input[type="password"],
input[type="search"], input[type="file"], textarea {
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 12.5px;
}
textarea { height: auto; padding: 6px 8px; line-height: 1.4; }
input[type="file"] { height: auto; padding: 4px 6px; background: var(--surface-2); }
select:hover, input:hover, textarea:hover { border-color: #cfd5e0; }
select:focus, input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(29, 78, 216, .18);
}

/* ---------- Таблицы ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 7px 10px; text-align: left; font-size: 13px; }
thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
tbody td { border-bottom: 1px solid var(--line-soft); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #f5f7ff; }
th.num, td.num {
  text-align: right;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
thead th.num { font-family: inherit; font-size: 10px; }
td.num.strong, .strong { font-weight: 700; }
td.nowrap { white-space: nowrap; }
td.date { font-family: var(--mono); font-size: 11.5px; color: var(--muted); white-space: nowrap; }
td.comment {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink-soft);
}
.cell-sub { font-size: 11px; color: var(--muted); }
.actions-col { width: 64px; text-align: right; white-space: nowrap; }
td.actions-col .icon-btn + .icon-btn { margin-left: 2px; }
tfoot td {
  background: var(--surface-2);
  border-top: 1px solid var(--line);
  border-bottom: none;
  font-weight: 700;
  white-space: nowrap;
}
.link { color: var(--ink); font-weight: 600; }
.link:hover { color: var(--accent); }

/* ---------- Кнопки, теги, иконки ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--accent-dark); text-decoration: none; }
.btn.ghost { background: #fff; border-color: var(--line); color: var(--ink-soft); }
.btn.ghost:hover { background: var(--surface-2); border-color: #cfd5e0; }
.btn.danger { background: #fff; border-color: #f0c9c4; color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.small { padding: 4px 9px; font-size: 12px; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn svg { width: 13px; height: 13px; }
.icon-btn:hover { background: var(--accent-soft); color: var(--accent-dark); border-color: #d8e2ff; }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); border-color: #f5cfca; }

button.link {
  background: none;
  border: none;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
button.link:hover { background: var(--danger-soft); color: var(--danger); }

.tag {
  display: inline-block;
  padding: 1px 7px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 11.5px;
  white-space: nowrap;
}
.tag.danger { background: var(--danger-soft); border-color: #f5cfca; color: var(--danger); }
.tag.ok { background: var(--ok-soft); border-color: #abefc6; color: #085d3a; }

.badge {
  padding: 0 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.6;
}
.badge.danger { background: var(--danger-soft); border-color: #f5cfca; color: var(--danger); }

/* ---------- Сообщения ---------- */
.msg, .error {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin-bottom: 12px;
  border: 1px solid;
  border-left-width: 3px;
  border-radius: 4px;
  font-size: 13px;
}
.msg { background: var(--ok-soft); border-color: #abefc6; color: #085d3a; }
.msg svg { width: 14px; height: 14px; flex: none; }
.error { background: var(--danger-soft); border-color: #fecdca; color: #912018; }

/* ---------- Списки ---------- */
.list-group { list-style: none; margin: 0; padding: 0; }
.list-group-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
}
.list-group-item:last-child { border-bottom: none; }
.list-group-item.overdue {
  background: var(--danger-soft);
  box-shadow: inset 3px 0 0 var(--danger);
}
.list-group-item .tag, .list-group-item .badge { margin-left: auto; }
.li-main { min-width: 0; }
.li-title { font-size: 13px; font-weight: 600; }
.li-sub { font-size: 11.5px; color: var(--muted); }

/* ---------- Формы ---------- */
.edit-form { padding: 12px; }
.edit-form .form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.edit-form .form-grid .full { grid-column: 1 / -1; }
.edit-form label { display: block; font-size: 12.5px; color: var(--ink-soft); }
.edit-form label > span.hint { display: block; margin-top: 3px; font-size: 11.5px; color: var(--muted); }
.edit-form input[type="text"], .edit-form input[type="password"],
.edit-form select, .edit-form textarea { width: 100%; margin-top: 4px; }
.form-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}
.panel > .form-actions { border-radius: 0 0 var(--radius) var(--radius); }

/* Раскрывающийся блок «добавить» внутри панели */
.add-block { border-top: 1px solid var(--line); background: var(--surface-2); }
.add-block summary {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  list-style: none;
}
.add-block summary::-webkit-details-marker { display: none; }
.add-block summary:hover { color: var(--accent); }
.add-block .edit-form { background: var(--surface); border-top: 1px solid var(--line); }

code, kbd {
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 12px;
}

.photos { display: flex; flex-wrap: wrap; gap: 10px; padding: 0 12px 12px; }
.photo { width: 120px; }
.photo img {
  display: block;
  width: 120px;
  height: 90px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.photo form { margin-top: 4px; text-align: center; }

/* ---------- Мелочи ---------- */
.muted { font-size: 12px; color: var(--muted); }
.inline { display: inline; }
.sep { color: var(--line); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: 2px; }

/* ---------- Страница входа ---------- */
body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: #10131a;
}
.login-form {
  width: 340px;
  padding: 22px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 60px -30px rgba(0, 0, 0, .6);
}
.login-form h1 {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.01em;
}
.login-form .brand-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}
.login-form label { display: block; margin-bottom: 12px; font-size: 12.5px; color: var(--ink-soft); }
.login-form input {
  display: block;
  width: 100%;
  height: 34px;
  margin-top: 4px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 13px;
}
.login-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(29, 78, 216, .18);
}
.login-form button {
  width: 100%;
  height: 36px;
  margin-top: 4px;
  border: 0;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.login-form button:hover { background: var(--accent-dark); }
.login-form .error { margin-bottom: 12px; }

/* ---------- Адаптив ---------- */
@media (max-width: 1180px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
  .sidebar { display: none; }
  main { margin-left: 0; padding-left: 12px; padding-right: 12px; }
  .menu-btn { display: grid; }
  body.nav-open .sidebar {
    display: flex;
    width: 264px;
    box-shadow: 0 20px 50px -20px rgba(0, 0, 0, .5);
    z-index: 1040;
  }
  .two-col { grid-template-columns: 1fr; }
  .edit-form .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .topbar { gap: 8px; padding: 0 10px; }
  .brand-title { display: none; }
  .search { max-width: none; }
  .uname { display: none; }
  .stats { grid-template-columns: 1fr; gap: 8px; }
  .page-head h1 { font-size: 18px; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1 1 auto; justify-content: center; }
  .field { flex: 1 1 45%; }
  .field.grow { flex: 1 1 100%; }
  .field-actions { margin-left: 0; width: 100%; }
  .field-actions .btn { flex: 1 1 auto; justify-content: center; }
  th, td { padding: 6px 8px; font-size: 12.5px; }
  td.comment { max-width: 110px; }
  .edit-form .form-actions { flex-wrap: wrap; }
}
