/* Кабінет «Петрович». Палітра й ритм — як у панелі Aero Connect (dark v2),
   акцент — фірмовий червоний з орнаменту (#DA2128). */
:root {
  color-scheme: dark;
  --bg: #0b0f14;
  --bg-soft: #0f151c;
  --panel: #10161e;
  --panel-strong: #151d27;
  --line: rgba(150, 164, 184, .14);
  --line-strong: rgba(150, 164, 184, .28);
  --text: #eef3f8;
  --muted: #93a1b2;
  --faint: #66748a;
  --accent: #da2128;
  --accent-hover: #ec3a41;
  --accent-ink: #fff;
  --accent-quiet: rgba(218, 33, 40, .14);
  --accent-line: rgba(218, 33, 40, .42);
  --good: #66c49a;
  --good-quiet: rgba(102, 196, 154, .13);
  --warn: #d6b463;
  --warn-quiet: rgba(214, 180, 99, .13);
  --bad: #f0787e;
  --bad-quiet: rgba(224, 111, 117, .14);
  --hover: rgba(255, 255, 255, .045);
  --mono: "Geist Mono", "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
  --sans: "Geist", "Satoshi", "Avenir Next", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f5f7;
  --bg-soft: #ffffff;
  --panel: #ffffff;
  --panel-strong: #f0f2f5;
  --line: rgba(16, 24, 32, .1);
  --line-strong: rgba(16, 24, 32, .2);
  --text: #101820;
  --muted: #556274;
  --faint: #7d8898;
  --accent: #c81d24;
  --accent-hover: #da2128;
  --accent-quiet: rgba(218, 33, 40, .08);
  --accent-line: rgba(218, 33, 40, .35);
  --good: #1f8a5b;
  --good-quiet: rgba(31, 138, 91, .1);
  --warn: #946c00;
  --warn-quiet: rgba(214, 160, 20, .14);
  --bad: #c2262d;
  --bad-quiet: rgba(194, 38, 45, .09);
  --hover: rgba(16, 24, 32, .045);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-width: 320px; background: var(--bg); color: var(--text);
  font-family: var(--sans); font-size: 13px; line-height: 1.45;
  font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1, h2 { margin: 0; text-wrap: balance; }
h1 { font-size: clamp(20px, 2vw, 26px); line-height: 1.15; font-weight: 700; letter-spacing: -.015em; }
h2 { font-size: 14px; font-weight: 650; }
p { margin: 0; }
small { font-size: 11.5px; color: var(--muted); }
code { font-family: var(--mono); background: var(--panel-strong); padding: 2px 6px; border-radius: 5px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12px; }
.nw { white-space: nowrap; }
.r { text-align: right; }
.c { text-align: center; }
.push { margin-left: auto; }
.ic { width: 15px; height: 15px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ── каркас ── */
.layout { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 18px;
  padding: 14px 12px 12px; background: var(--bg-soft); border-right: 1px solid var(--line); overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 4px; }
.brand img { border-radius: 10px; }
.brand span { display: grid; line-height: 1.2; }
.brand b { font-size: 15px; letter-spacing: -.01em; }
.brand small { color: var(--faint); }
.nav { display: grid; gap: 4px; }
.nav a {
  display: flex; align-items: center; gap: 10px; min-height: 34px; padding: 0 9px; border-radius: 7px;
  color: var(--muted); transition: background .15s ease, color .15s ease;
}
.nav a:hover { background: var(--hover); color: var(--text); }
.nav a.on { background: var(--panel-strong); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.nav .ic { width: 17px; height: 17px; }
.side-foot { margin-top: auto; display: flex; align-items: center; gap: 6px; padding-top: 12px; border-top: 1px solid var(--line); }
.side-foot .who { display: grid; min-width: 0; flex: 1; line-height: 1.25; }
.side-foot .who b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.side-foot form { display: contents; }
.side-foot .mark { opacity: .9; }
.main { padding: 20px 24px 40px; min-width: 0; }

.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.back { display: inline-block; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.back:hover { color: var(--text); }

/* ── кнопки ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px;
  border: 1px solid var(--line-strong); border-radius: 7px; background: var(--hover); color: var(--text);
  font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.btn:hover { background: var(--panel-strong); border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--hover); }
.btn.danger { color: var(--bad); border-color: var(--accent-line); background: transparent; }
.btn.danger:hover { background: var(--bad-quiet); }
.btn.sm { height: 26px; padding: 0 8px; font-size: 11.5px; }
.btn.big { height: 44px; padding: 0 22px; font-size: 14px; border-radius: 9px; }
.btn.icon-only { padding: 0; width: 26px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── панелі, статистика ── */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 14px; }
.panel.flush { padding: 0; overflow: hidden; }
.panel-title { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; display: grid; gap: 3px; }
.stat span { color: var(--muted); font-size: 11.5px; }
.stat b { font-size: 21px; font-weight: 650; letter-spacing: -.02em; }
.stat.bad { border-color: var(--accent-line); background: linear-gradient(var(--bad-quiet), var(--bad-quiet)), var(--panel); }
.stat.bad b { color: var(--bad); }
.stat.good b { color: var(--good); }

.note { display: flex; gap: 9px; align-items: flex-start; padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; border: 1px solid var(--line); }
.note .ic { margin-top: 1px; }
.note.warn { background: var(--warn-quiet); border-color: transparent; color: var(--warn); }
.note.warn span, .note.bad span { color: var(--text); }
.note.bad { background: var(--bad-quiet); border-color: var(--accent-line); color: var(--bad); }
.flash { padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; background: var(--good-quiet); border: 1px solid transparent; transition: opacity .4s ease; }
.flash.warn { background: var(--warn-quiet); }
.flash.hide { opacity: 0; }

/* ── фільтри ── */
.filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.chips { display: flex; gap: 4px; flex-wrap: wrap; margin-right: 6px; }
.chip { height: 30px; padding: 0 11px; display: inline-flex; align-items: center; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); font-size: 12px; font-weight: 600; }
.chip:hover { color: var(--text); border-color: var(--line-strong); }
.chip.on { background: var(--accent-quiet); border-color: var(--accent-line); color: var(--text); }

/* ── поля ── */
.field { display: grid; gap: 5px; min-width: 0; }
.field > span { color: var(--muted); font-size: 11.5px; font-weight: 600; }
.field.inline { display: flex; align-items: center; gap: 6px; }
input, select, textarea {
  width: 100%; height: 32px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 7px;
  background: var(--bg-soft); color: var(--text); font: inherit; font-size: 13px;
}
textarea { height: auto; padding: 8px 10px; resize: vertical; line-height: 1.4; }
.field.inline input, .field.inline select { width: auto; }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); flex: 0 0 auto; margin: 2px 0 0; }
input.cell { background: transparent; border-color: transparent; height: 28px; padding: 0 6px; min-width: 150px; }
input.cell:hover, input.cell:focus { border-color: var(--line-strong); background: var(--bg-soft); }
.form { display: grid; gap: 14px; margin-bottom: 0; }
.form h2 { margin-top: 6px; padding-top: 14px; border-top: 1px solid var(--line); }
.form.narrow { max-width: 720px; }
.grid { display: grid; gap: 12px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.check { display: flex; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg-soft); color: var(--muted); font-size: 12px; }
.check b { color: var(--text); }
.form-actions { display: flex; gap: 8px; padding-top: 4px; }
.hint { color: var(--muted); font-size: 12px; }

/* ── таблиці ── */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 8px 9px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th.r, .table td.r { text-align: right; }
.table th.c, .table td.c { text-align: center; }
.table th { color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; background: var(--bg-soft); white-space: nowrap; position: sticky; top: 0; }
.table tbody tr:hover { background: var(--hover); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tfoot td { border-top: 1px solid var(--line-strong); border-bottom: 0; font-weight: 650; background: var(--bg-soft); }
.table tr.gap td:first-child { box-shadow: inset 2px 0 0 var(--warn); }
/* маршрут забирає все вільне місце й обрізається — решта колонок лишається по вмісту */
.table .route { width: 100%; max-width: 0; min-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.table th.route-h { min-width: 140px; }
.rowlink { font-weight: 650; }
.rowlink:hover { color: var(--accent-hover); }
.tools { display: flex; align-items: center; justify-content: flex-end; gap: 4px; }
.tools form { display: contents; }
.flag { display: inline-flex; color: var(--faint); cursor: help; }
.flag.warn { color: var(--warn); }
.pill { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: 999px; background: var(--panel-strong); color: var(--muted); font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.pill .ic { width: 12px; height: 12px; }
.pill.bad { background: var(--bad-quiet); color: var(--bad); }
.pill.good { background: var(--good-quiet); color: var(--good); }
.pill.accent { background: var(--accent-quiet); color: var(--text); }

.empty { display: grid; justify-items: center; gap: 10px; padding: 44px 16px; text-align: center; color: var(--muted); }
.empty img { border-radius: 14px; }

/* ── лист: форма + бічна колонка ── */
.split { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 14px; align-items: start; }
.side { display: grid; gap: 14px; position: sticky; top: 16px; }
.side .panel { margin: 0; }
.side h2 { margin-bottom: 10px; }
.calc dl { margin: 0; display: grid; gap: 8px; }
.calc dl div { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.calc dt { color: var(--muted); }
.calc dd { margin: 0; }
.calc dd b { font-size: 16px; font-weight: 650; }
.calc .total { padding-top: 10px; border-top: 1px solid var(--line); }
.calc .total dd b { font-size: 22px; }
.calc.bad .total dd b, .calc.bad .hint { color: var(--bad); }
.calc.good .total dd b { color: var(--good); }
.calc .hint { margin-top: 8px; }
.neighbours, .log { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.neighbours li { display: grid; gap: 2px; }
.neighbours a { font-weight: 600; }
.neighbours a:hover { color: var(--accent-hover); }
.log li { padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.log li:last-child { border: 0; padding: 0; }
.log-head { display: grid; gap: 1px; margin-bottom: 4px; }
.chg { font-size: 12px; color: var(--muted); }
.chg s { color: var(--faint); }
.chg b { color: var(--text); font-weight: 600; }
.danger-zone { display: grid; gap: 6px; justify-items: start; }

/* ── автопарк ── */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 14px; }
.car { margin: 0; display: grid; gap: 14px; }
.car.archived { opacity: .6; }
.car header { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.car h2 { font-size: 16px; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.kv { margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 14px; }
.kv dt { color: var(--muted); font-size: 11.5px; }
.kv dd { margin: 2px 0 0; font-size: 14px; font-weight: 600; }
.kv dd a:hover { color: var(--accent-hover); }
.car footer { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; padding-top: 10px; border-top: 1px solid var(--line); }
.car footer form { display: contents; }

/* ── вхід ── */
.bare { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: radial-gradient(ellipse at 50% 0, var(--accent-quiet), transparent 60%), var(--bg); }
.login { width: min(420px, 100%); display: grid; gap: 14px; justify-items: center; text-align: center; }
.login .hero { height: auto; filter: drop-shadow(0 18px 30px rgba(0, 0, 0, .45)); }
.login .lead { color: var(--muted); font-size: 14px; }
.login .steps { text-align: left; margin: 0; padding: 14px 16px 14px 34px; display: grid; gap: 6px; width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; font-size: 14px; }
.login .steps a { color: var(--accent-hover); font-weight: 600; }
.login .note { width: 100%; text-align: left; }
.login .foot { display: flex; align-items: center; gap: 7px; color: var(--faint); font-size: 12px; margin-top: 6px; }
.login form { display: contents; }

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .split { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; }
}
@media (max-width: 760px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; gap: 10px; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
  .brand span, .side-foot .who, .side-foot .mark { display: none; }
  .brand img { width: 36px; height: 36px; }
  .nav { display: flex; }
  .nav a span { display: none; }
  .side-foot { margin: 0 0 0 auto; padding: 0; border: 0; }
  .main { padding: 14px 12px 32px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.three, .grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cards { grid-template-columns: minmax(0, 1fr); }
  .kv { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  input, select, textarea { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
