:root {
  --blue: #1e5aa8;
  --blue-d: #164a8c;
  --blue-s: #eaf1fb;
  --bg: #eef2f7;
  --surface: #fff;
  --line: #dfe6ee;
  --ok: #2e9d5a;
  --ok-bg: #d9f3e3;
  --bad: #d23c3c;
  --bad-bg: #f8d4d4;
  --warn: #d88916;
  --warn-bg: #ffe6c2;
  --muted: #6b7789;
  --text: #1a2332;
  --shadow: 0 1px 2px rgba(22, 40, 70, .05), 0 10px 28px rgba(22, 40, 70, .06);
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  font-family: "Segoe UI", "PT Sans", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}
a { color: #1a6fd4; text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: #122033; letter-spacing: -.02em; }
h1 { font-size: 22px; font-weight: 700; margin: 0; }
h2 { font-size: 18px; font-weight: 700; margin: 0 0 14px; }
h3 { font-size: 15px; font-weight: 700; margin: 0 0 10px; }

.top {
  background: var(--blue);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 18px;
  min-height: 56px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 1px 0 rgba(0,0,0,.08);
}
.top a { color: #fff; text-decoration: none; }
.brand {
  font-weight: 700;
  letter-spacing: .2px;
  margin-right: 4px;
  font-size: 16px;
  white-space: nowrap;
}
.nav { display: flex; gap: 2px; flex: 1; flex-wrap: wrap; }
.nav a { padding: 8px 12px; border-radius: 8px; opacity: .92; }
.nav a.on, .nav a:hover { background: rgba(255,255,255,.16); opacity: 1; text-decoration: none; }
.who {
  font-size: 12px;
  opacity: .95;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.who-role {
  background: rgba(255,255,255,.16);
  border-radius: 999px;
  padding: 3px 8px;
  font-weight: 600;
}
.job-run {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  flex-shrink: 0;
}
.job-run-label {
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  color: #fff;
}
.job-run select {
  border: 0;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  background: #fff;
  min-width: 180px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--blue);
  color: #fff;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
}
.btn:hover { background: var(--blue-d); text-decoration: none; color: #fff; }
.btn:disabled { opacity: 0.55; cursor: wait; }
.btn.light { background: #fff; color: var(--blue); border-color: #fff; }
.btn.light:hover { filter: brightness(.97); color: var(--blue); background: #fff; }
.btn.secondary {
  background: #fff;
  color: var(--blue);
  border-color: var(--line);
}
.btn.secondary:hover { background: var(--blue-s); color: var(--blue); }
.btn.ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.45); }
.btn.ghost:hover { background: rgba(255,255,255,.12); color: #fff; }
.btn.danger { background: var(--bad); color: #fff; }
.btn.danger:hover { filter: brightness(.95); color: #fff; }
.btn.ok { background: var(--ok); color: #fff; }
.btn.ok:hover { filter: brightness(.95); color: #fff; }
.btn.small { padding: 5px 10px; font-weight: 600; font-size: 12px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.wrap { padding: 20px 20px 88px; max-width: 1480px; margin: 0 auto; }
/* Главная — на всю ширину экрана: таблица клиентов широкая, на больших мониторах видно все колонки. */
.wrap.full { max-width: none; }
/* Главная: таблица клиентов на всю высоту окна под шапкой — страницу прокрутили
   ниже фильтров, и в таблице видно больше строк. */
.wrap.full .panel > .table-wrap { max-height: calc(100vh - 72px); }
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.page-head .lede { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  align-items: end;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}
.toolbar label { font-size: 11px; color: #5b6777; display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; align-items: end; }
.filters label { font-size: 11px; color: #5b6777; display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
.filters label[hidden] { display: none; }

input, select, textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.3;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #8bb4e8;
  box-shadow: 0 0 0 3px rgba(30, 90, 168, .14);
}
textarea { width: 100%; min-height: 84px; resize: vertical; }
input[type="file"] { padding: 6px; }
/* В строке фильтров поля и кнопки одной высоты, маленькая кнопка не проседает. */
.toolbar input, .toolbar select, .toolbar .btn,
.filters input, .filters select, .filters .btn { min-height: 36px; }
.toolbar .btn.small, .filters .btn.small { padding: 8px 14px; font-size: 14px; }

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 210px);
  background: #fff;
}
.panel > .table-wrap { max-height: calc(100vh - 240px); }
table { border-collapse: collapse; width: 100%; min-width: 1280px; }
th {
  background: #f4f7fb;
  text-align: left;
  font-size: 11px;
  letter-spacing: .35px;
  color: #5b6777;
  padding: 10px 12px;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 5;
  box-shadow: inset 0 -1px 0 var(--line);
  font-weight: 700;
}
td { padding: 10px 12px; border-bottom: 1px solid #d3dde8; border-right: 1px solid #e4ebf3; vertical-align: top; }
th { border-right: 1px solid #e4ebf3; }
table.clients > tbody.client { border-bottom: 2px solid #5e7086; }
table.clients > tbody.client > tr > td[rowspan] { border-bottom: 2px solid #5e7086; }
table.clients > tbody.client > tr:not(:last-child) > td:not([rowspan]) {
  border-bottom: 1px dashed #b7c4d4;
}
table.leads > tbody > tr > td { border-bottom: 2px solid #5e7086; }
table.vehicles > tbody > tr > td { border-bottom: 1px dashed #b7c4d4; }
td form { margin: 0; }
tr:nth-child(even) td { background: #fafbfd; }
tbody tr:hover td { background: #f3f7fd; }
.name { font-weight: 700; }
.name a { color: inherit; }
.phone { color: #1a6fd4; white-space: nowrap; }
.plate { font-family: ui-monospace, "Cascadia Mono", monospace; font-weight: 700; letter-spacing: .02em; }
.vin { font-family: ui-monospace, "Cascadia Mono", monospace; font-size: 12px; color: #3d4a5c; }
.empty {
  padding: 36px 20px;
  text-align: center;
  color: var(--muted);
  background: #fff;
}

.icon-btn {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line);
  display: inline-flex; align-items: center; justify-content: center; background: #fff;
  font-size: 13px;
}
.icon-btn.ok { background: var(--ok-bg); color: var(--ok); border-color: #b7e4c7; }
.icon-btn.bad { background: var(--bad-bg); color: var(--bad); border-color: #f0b4b4; }
.icon-btn.warn { background: var(--warn-bg); color: var(--warn); border-color: #f0c98a; }
button.icon-btn { cursor: pointer; }

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.badge.ok { background: var(--ok-bg); color: #176b38; }
.badge.bad { background: var(--bad-bg); color: #9b1c1c; }
/* Аннулированный пропуск: красный и перечёркнутый — видно и без цвета. */
.annulled { text-decoration: line-through; text-decoration-thickness: 1.5px; }
.badge.warn { background: var(--warn-bg); color: #8a4b00; }
.badge.muted { background: #edf1f5; color: #667; }
.badge.zone { background: #d6e6ff; color: #1e5aa8; }
.badge.price { background: #ffe0b8; color: #9a4b00; }
.badge.lead-quality { background: var(--ok-bg); color: #176b38; }
.badge.lead-bad { background: var(--bad-bg); color: #9b1c1c; }
.badge.lead-noanswer { background: #e8e8e8; color: #555; }
.badge.lead-thinking { background: var(--warn-bg); color: #8a4b00; }
.badge.lead-new { background: #d6e6ff; color: #1e5aa8; }
.leads-count { margin: 8px 0; }
.people { display: grid; gap: 10px; margin: 12px 0; }
.person { border: 1px solid #e4ebf3; border-radius: 8px; padding: 10px 12px; }
.person-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.person-head form, .addr form { margin: 0; }
.addr { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 4px 0; }
.addr-kind { width: 44px; color: var(--muted); font-size: 12px; }
.addr.is-off .addr-val { color: var(--muted); text-decoration: line-through; }
.person-add { margin-top: 8px; }
.contact-people > div + div { margin-top: 6px; }
th.num, td.num { width: 1%; white-space: nowrap; text-align: right; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  max-width: 880px;
  box-shadow: var(--shadow);
}
.card.wide { max-width: none; }
.card + .card, .panel + .card, .card + .panel, .panel + .panel { margin-top: 14px; }

.multi-field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: #5b6777; font-weight: 600; }
.multi-wrap { display: flex; align-items: stretch; gap: 8px; }
.multi { position: relative; flex: 1; min-width: 0; }
.multi-control {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  min-height: 38px;
}
.multi.is-open .multi-control {
  border-color: #8bb4e8;
  box-shadow: 0 0 0 3px rgba(30, 90, 168, .14);
}
.multi-input {
  flex: 1;
  min-width: 0;
  width: auto !important;
  border: 0 !important;
  box-shadow: none !important;
  background: transparent;
  padding: 8px 10px;
  font: inherit;
  font-size: 14px;
  font-weight: 400;
  color: var(--text);
  outline: none;
  border-radius: 8px 0 0 8px;
}
.multi-input.is-text { display: flex; align-items: center; }
.multi-chevron {
  flex-shrink: 0;
  width: 34px;
  border: 0;
  border-left: 1px solid var(--line);
  background: transparent;
  color: #5b6777;
  font-size: 12px;
  cursor: pointer;
  border-radius: 0 8px 8px 0;
  padding: 0;
}
.multi-chevron:hover { background: #f4f7fb; color: var(--blue); }
.multi-plus {
  flex-shrink: 0;
  width: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #5b6777;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.multi-plus:hover { border-color: var(--blue); color: var(--blue); background: #f3f7fd; }
.multi-menu {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 30;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-height: 240px;
  overflow: auto;
  padding: 4px 0;
}
.multi-option-row { display: flex; align-items: center; }
.multi-pick { margin: 0; flex: 1; min-width: 0; }
.multi-option {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 8px 12px;
  font: inherit;
  font-size: 14px;
  font-weight: 400;
  color: var(--text);
  cursor: pointer;
}
button.multi-option:hover { background: #f3f7fd; }
.multi-option.is-current {
  background: #eef4fb;
  color: var(--blue);
  font-weight: 600;
  cursor: default;
}
.multi-option.is-plain { cursor: default; flex: 1; }
.multi-option.muted { color: var(--muted); cursor: default; }
.multi-x {
  border: 0;
  background: transparent;
  color: var(--muted);
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 16px;
  flex-shrink: 0;
}
.multi-x:hover { color: var(--bad); background: var(--bad-bg); }
.multi-new {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-top: 1px solid var(--line);
  margin: 0;
}
.multi-new input {
  flex: 1;
  min-width: 120px;
  width: auto !important;
}


.when { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.when-item { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: #fafbfd; }
.check-log { margin-top: 12px; }
.check-log summary { cursor: pointer; font-weight: 600; }
.checks { margin: 8px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.checks li { margin: 6px 0; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.grid label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: #5b6777; font-weight: 600; }
.card > form > label, .card form.sec > label {
  display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: #5b6777; font-weight: 600;
}
.card > form > .btn, .card form.sec > .btn { margin-top: 8px; }
.grid input, .grid select { width: 100%; }
.full { grid-column: 1 / -1; }
.grid fieldset.full {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  margin: 0;
  display: grid;
  gap: 10px;
}
.grid fieldset.full legend {
  padding: 0 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text, #1a2332);
}
.grid label.check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}
.grid label.check input { width: auto; }
.muted { color: var(--muted); font-size: 12px; }
.hint { margin: 0 0 12px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; align-items: center; }
.actions.flush { margin-top: 0; }
.card .table-wrap { border: 1px solid var(--line); border-radius: 8px; }
.sec { padding-top: 16px; margin-top: 16px; border-top: 1px solid var(--line); }
.danger-zone .actions { margin-top: 0; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
  max-width: 880px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow);
}
.stat-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 6px;
}
.stat-value { font-weight: 700; font-size: 14px; }
.stat-sub { margin-top: 4px; font-size: 12px; color: var(--muted); font-weight: 500; }

.fleet {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}
.fleet-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.fleet-card header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
/* Госномер РФ (кабинет): белый фон, чёрные символы, справа регион + флаг + RUS. */
.ru-plate {
  display: inline-flex;
  align-items: stretch;
  background: #f4f4f4;
  color: #111;
  border: 2.5px solid #1a1a1a;
  border-radius: 7px;
  overflow: hidden;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .85),
    0 1px 2px rgba(22, 40, 70, .08);
  font-family: "PT Mono", "Roboto Mono", "Cascadia Mono", ui-monospace, monospace;
  line-height: 1;
  user-select: all;
}
.ru-plate-body {
  display: flex;
  align-items: center;
  gap: .32em;
  padding: 9px 11px 8px 12px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: .04em;
}
.ru-plate-plain { gap: 0; letter-spacing: .06em; }
.ru-plate-code {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 46px;
  padding: 4px 7px 5px;
  border-left: 2px solid #1a1a1a;
  background: #fff;
}
.ru-plate-region {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: .02em;
}
.ru-plate-rus {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: .08em;
  color: #222;
}
.ru-flag {
  width: 14px;
  height: 9px;
  border: 1px solid #2a2a2a;
  border-radius: 1px;
  background: linear-gradient(
    to bottom,
    #fff 0 33.33%,
    #0039a6 33.33% 66.66%,
    #d52b1e 66.66% 100%
  );
  flex-shrink: 0;
}
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.kv dt {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 700;
}
.kv dd { margin: 4px 0 0; font-weight: 600; }
.note {
  background: #f6f8fb;
  border-radius: 8px;
  padding: 10px 12px;
  margin: 0;
  font-size: 13px;
}
.vin-line { font-family: ui-monospace, monospace; font-size: 12px; color: var(--muted); word-break: break-all; }

.file-list { list-style: none; padding: 0; margin: 0; }
.file-list li {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.file-list li:last-child { border-bottom: 0; }
.contact-list { list-style: none; padding: 0; margin: 0 0 12px; }
.contact-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.callout {
  border-radius: 8px;
  padding: 10px 12px;
  margin: 0 0 14px;
  font-size: 13px;
}
.callout.warn { background: var(--warn-bg); color: #8a4b00; }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(1200px 480px at 10% -10%, rgba(255,255,255,.14), transparent),
    linear-gradient(165deg, #12325f, #1e5aa8 55%, #2a6ec4);
  padding: 24px;
}
.login-box {
  background: #fff;
  padding: 32px 28px;
  border-radius: 16px;
  width: min(420px, 92vw);
  box-shadow: 0 24px 50px rgba(8, 24, 48, .28);
}
.login-box h1 { margin: 0 0 6px; font-size: 24px; }
.login-box label { font-size: 12px; font-weight: 700; color: #5b6777; display: block; margin-bottom: 12px; }
.login-box input { width: 100%; margin-top: 5px; }
.login-box .btn { width: 100%; margin-top: 4px; }

.err { background: var(--bad-bg); color: #8a1f1f; padding: 10px 12px; border-radius: 8px; margin: 0 0 12px; }
.ok-box { background: var(--ok-bg); color: #176b38; padding: 10px 12px; border-radius: 8px; margin: 0 0 12px; }

.toast {
  position: fixed; right: 18px; top: 18px; background: #fff; border: 1px solid var(--line);
  border-left: 4px solid var(--warn); border-radius: 10px; padding: 14px 16px; width: min(360px, 92vw);
  box-shadow: var(--shadow); z-index: 60;
}

.nlog {
  position: fixed; right: 18px; bottom: 18px; width: min(360px, 92vw); z-index: 50;
  background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--warn);
  border-radius: 10px; box-shadow: var(--shadow); overflow: hidden;
}
.nlog-head {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  background: var(--warn-bg); border-bottom: 1px solid var(--line);
}
.nlog.is-folded .nlog-head { border-bottom: 0; }
.nlog-title {
  flex: 1; border: 0; background: transparent; text-align: left; font: inherit;
  font-weight: 600; cursor: pointer; color: #8a4b00;
}
.nlog-count {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; margin-left: 8px;
  padding: 0 6px; border-radius: 99px; background: var(--warn); color: #fff; font-size: 12px;
}
.nlog-fold {
  border: 0; background: transparent; cursor: pointer; font-size: 16px; line-height: 1; color: #8a4b00;
}
.nlog.is-folded .nlog-fold { transform: rotate(-90deg); }
.nlog-list { max-height: min(360px, 50vh); overflow: auto; }
.nlog.is-folded .nlog-list { display: none; }
.nlog-item { padding: 10px 12px; border-top: 1px solid var(--line); }
.nlog-item:first-child { border-top: 0; }
.nlog-meta { color: var(--muted); font-size: 12px; margin: 4px 0 8px; }
.nlog-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.fab { position: fixed; right: 18px; bottom: 18px; width: 52px; height: 52px; border-radius: 50%;
  background: #f08a1a; color: #fff; display: grid; place-items: center; font-size: 22px; box-shadow: 0 8px 20px rgba(240,138,26,.4); }

@media (max-width: 900px) {
  .stats { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 800px) {
  .grid { grid-template-columns: 1fr; }
  .who { display: none; }
  .nav a span { display: none; }
  .wrap { padding: 14px 12px 80px; }
  .card { padding: 16px; }
  .kv { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .stats, .when { grid-template-columns: 1fr; }
}
