:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --line: #e3e6ea;
  --text: #1c2024;
  --muted: #6b7480;
  --accent: #2f6fed;
  --accent-soft: #e8f0fe;
  --new: #0f9d58;
  --new-soft: #e6f5ec;
  --gone: #c5372c;
  --gone-soft: #fdeceb;
  --warn: #b8730a;
  --warn-soft: #fdf3e2;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

/* Анимация нажатия на каждой кнопке — обязательный минимум обратной связи. */
button {
  font: inherit;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
}
button:active { transform: scale(0.95); }

.wrap { max-width: 1440px; margin: 0 auto; padding: 16px; }

header.top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 16px;
  margin-bottom: 14px;
}
header.top h1 { font-size: 20px; margin: 0; font-weight: 650; }
header.top .meta { color: var(--muted); font-size: 13px; }

.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tabs button {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 7px 14px;
  color: var(--muted);
  font-weight: 550;
}
.tabs button:hover { background: #eceff3; }
.tabs button.active { background: var(--accent-soft); color: var(--accent); }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}
.controls input[type="search"], .controls select {
  font: inherit;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}
.controls input[type="search"] { min-width: 230px; flex: 1 1 230px; }
.controls .spacer { flex: 1 1 auto; }
.controls .count { color: var(--muted); white-space: nowrap; }

.btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 7px 12px;
  color: var(--text);
}
.btn:hover { background: #f2f4f7; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #2760d4; }
.btn.on { background: var(--accent-soft); border-color: #bcd2fb; color: var(--accent); }

.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #fafbfc;
  border-bottom: 1px solid var(--line);
  text-align: left;
  padding: 9px 10px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
thead th:hover { background: #f0f2f5; }
thead th .arrow { color: var(--accent); margin-left: 3px; }
tbody td { border-bottom: 1px solid #f0f2f4; padding: 7px 10px; vertical-align: middle; }
tbody tr:hover td { background: #fbfcfd; }
td.num, td.n { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
td.model { font-weight: 550; }
td.nowrap { white-space: nowrap; }

tr.is-new td { background: var(--new-soft); }
tr.is-new:hover td { background: #daf0e3; }
tr.is-gone td { background: var(--gone-soft); color: #8a3229; }
tr.is-gone:hover td { background: #fbdfdc; }

.badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge.new { background: var(--new); color: #fff; }
.badge.gone { background: var(--gone); color: #fff; }
.badge.ren { background: var(--warn-soft); color: var(--warn); border: 1px solid #f0d9ae; }

select.prep {
  font: inherit;
  font-size: 12px;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  max-width: 150px;
}
select.prep.saving { opacity: 0.5; }

.more { padding: 14px; text-align: center; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

.notice {
  margin-bottom: 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--warn-soft);
  border: 1px solid #f0d9ae;
  color: #7a4d06;
}

/* Журнал изменений */
.log { padding: 4px 0; }
.log .day { padding: 12px 14px 4px; font-weight: 650; border-top: 1px solid var(--line); }
.log .day:first-child { border-top: 0; }
.log .row { display: flex; gap: 10px; align-items: baseline; padding: 5px 14px; }
.log .row .what { flex: 1; }
.log .row .was { color: var(--muted); font-size: 12px; }

/* Тост — единая точка обратной связи для всех запросов */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: #23282e;
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.22);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 50;
  max-width: 90vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-error { background: #a52a1f; }
.toast-success { background: #0f7a45; }

/* Годы отдельной колонкой видны только на широком экране; на телефоне они
   уходят второй строкой под поколение, чтобы влезла «Подготовка» — это главное
   действие на телефоне, ради него не должно быть горизонтального скролла. */
.yr-sm { display: none; }

@media (max-width: 720px) {
  .wrap { padding: 10px; }
  .controls input[type="search"] { min-width: 100%; }
  td.hide-sm, th.hide-sm { display: none; }
  .yr-sm { display: block; color: var(--muted); font-size: 11px; white-space: nowrap; }
  tbody td { padding: 7px 6px; }
  thead th { padding: 9px 6px; }
  select.prep { max-width: 110px; }
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171a;
    --card: #1c2025;
    --line: #2c3238;
    --text: #e7eaee;
    --muted: #949ca6;
    --accent: #6f9dff;
    --accent-soft: #23304a;
    --new-soft: #17351f;
    --gone-soft: #3a1f1c;
    --warn-soft: #3a2e15;
  }
  :root:not([data-theme="light"]) thead th { background: #20262c; }
  :root:not([data-theme="light"]) tbody tr:hover td { background: #22272d; }
  :root:not([data-theme="light"]) .btn { background: #232930; }
  :root:not([data-theme="light"]) .controls input, :root:not([data-theme="light"]) .controls select,
  :root:not([data-theme="light"]) select.prep { background: #232930; color: var(--text); }
}
