/* ============================================================
   ГЛОНАСС/GPS мониторинг транспорта — макет интерфейса
   Демонстрационная вёрстка. Данные — синтетические.
   ============================================================ */

/* Фирменный стиль ВС Инжиниринг: синий #1f4e9d, тёмный #0b1025 / #0f1e3a,
   голубые акценты #7eb1ff / #3aa6e8, Arial, скругления 14px, кнопки-пилюли. */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #eef0f6;
  --line: #e5e9f3;
  --line-strong: #cfd7e8;
  --text: #1c2025;
  --text-2: #525874;
  --text-3: #7a8290;

  --nav: #0b1025;
  --nav-2: #0f1e3a;
  --nav-text: #a8b3cc;
  --nav-active: #7eb1ff;

  --brand: #1f4e9d;
  --brand-d: #173d7d;
  --brand-2: #3aa6e8;
  --ok: #16a34a;
  --warn: #f59e0b;
  --danger: #dc2626;
  --idle: #f59e0b;
  --stop: #525874;
  --offline: #7a8290;

  --r: 14px;
  --r-sm: 10px;
  --shadow: 0 1px 2px rgba(11, 16, 37, .05), 0 4px 16px rgba(11, 16, 37, .07);
  --shadow-lg: 0 14px 44px rgba(11, 16, 37, .2);
  --font: Arial, Helvetica, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ── Демо-плашка ─────────────────────────────────────────── */
.demo-flag {
  position: fixed; right: 14px; bottom: 14px; z-index: 1200;
  background: rgba(11, 16, 37, .9); color: #dfe6f3;
  font-size: 11px; letter-spacing: .04em; text-transform: uppercase;
  padding: 7px 12px; border-radius: 100px; backdrop-filter: blur(6px);
  border: 1px solid rgba(126, 177, 255, .3); pointer-events: none;
}

/* ── Каркас ──────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px; flex: 0 0 232px; background: var(--nav); color: var(--nav-text);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar__brand {
  display: flex; align-items: center; gap: 10px; padding: 18px 18px 16px;
  border-bottom: 1px solid rgba(148, 163, 184, .14);
}
.sidebar__mark { width: 34px; height: 34px; flex: 0 0 34px; display: grid; place-items: center; }
.sidebar__mark img { width: 34px; height: 34px; display: block; }
.sidebar__name { color: #fff; font-weight: 650; font-size: 15px; letter-spacing: -.01em; line-height: 1.15; }
.sidebar__sub { font-size: 11px; color: #7f8db0; letter-spacing: .01em; }
.sidebar__nav { padding: 12px 10px; overflow-y: auto; flex: 1; }
.sidebar__group { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: #5b6788; padding: 14px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--r-sm);
  color: var(--nav-text); font-size: 13.5px; margin-bottom: 2px; transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--nav-2); color: #e2e8f0; }
.nav-item.is-active { background: rgba(126, 177, 255, .14); color: #fff; box-shadow: inset 2px 0 0 var(--nav-active); }
.nav-item svg { width: 17px; height: 17px; flex: 0 0 17px; opacity: .9; }
.nav-item__badge {
  margin-left: auto; background: var(--danger); color: #fff; font-size: 11px;
  min-width: 20px; height: 19px; padding: 0 6px; border-radius: 100px; display: grid; place-items: center;
}
.sidebar__foot { padding: 12px 14px; border-top: 1px solid rgba(168, 179, 204, .16); font-size: 11px; color: #6b7793; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  min-height: 58px; background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px; padding: 0 18px; position: sticky; top: 0; z-index: 500;
}
.topbar__burger { display: none; background: none; border: 0; padding: 6px; cursor: pointer; color: var(--text-2); }
.topbar__title { font-weight: 650; font-size: 16px; letter-spacing: -.01em; }
.topbar__sub { font-size: 12px; margin-top: -2px; }
.topbar__spacer { flex: 1; }
.org-switch {
  display: flex; align-items: center; gap: 8px; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 100px; padding: 6px 12px; font-size: 13px; cursor: pointer;
  max-width: 260px;
}
.org-switch b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.org-switch > svg:first-child { width: 16px; height: 16px; flex: 0 0 16px; color: var(--text-3); }
.topbar__user { display: flex; align-items: center; gap: 9px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, #1f4e9d, #0f1e3a);
  color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 650;
}
.topbar__user-meta { line-height: 1.15; }
.topbar__user-meta b { font-size: 13px; font-weight: 600; }
.topbar__user-meta span { font-size: 11.5px; color: var(--text-3); display: block; }

.content { padding: 20px; flex: 1; min-width: 0; }
.content--flush { padding: 0; display: flex; min-height: 0; flex: 1; }

/* ── Типографика и утилиты ───────────────────────────────── */
h1, h2, h3 { margin: 0; letter-spacing: -.015em; }
h1 { font-size: 22px; font-weight: 800; letter-spacing: -.5px; }
h2 { font-size: 16px; font-weight: 700; }
h3 { font-size: 13.5px; font-weight: 700; }
.muted { color: var(--text-2); }
.dim { color: var(--text-3); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.page-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head p { margin: 3px 0 0; color: var(--text-2); font-size: 13px; }
.page-head__actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Кнопки, поля ────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 13px;
  border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface);
  font-size: 13px; font-weight: 700; cursor: pointer; white-space: nowrap; transition: .12s;
}
.btn:hover { border-color: var(--text-3); background: var(--surface-2); }
.btn svg { width: 15px; height: 15px; }
.btn--primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-d); border-color: var(--brand-d); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn--ghost:hover { background: var(--surface-2); border-color: var(--line); }
.btn--sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn--danger { color: var(--danger); border-color: #fecaca; background: #fef2f2; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; color: var(--text-2); font-weight: 550; }
.input, .select {
  height: 34px; border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  background: var(--surface); padding: 0 10px; width: 100%; outline: none;
}
.input:focus, .select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(31,78,157, .13); }
.search { position: relative; }
.search .input { padding-left: 32px; }
.search svg { position: absolute; left: 9px; top: 9px; width: 16px; height: 16px; color: var(--text-3); }

.switch { width: 36px; height: 20px; border-radius: 100px; background: var(--line-strong); position: relative; cursor: pointer; flex: 0 0 36px; }
.switch::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; background: #fff; top: 2px; left: 2px; transition: .15s; }
.switch.is-on { background: var(--ok); }
.switch.is-on::after { left: 18px; }

/* ── Карточки, сетки ─────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.card__head { padding: 13px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card__head .badge { max-width: 100%; height: auto; white-space: normal; }
.card__head .btn { margin-left: auto; }
.card__body { padding: 16px; }
.grid { display: grid; gap: 14px; }
.grid > * { min-width: 0; }
.grid--kpi { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi__label { font-size: 12px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.kpi__value { font-size: 26px; font-weight: 800; letter-spacing: -.5px; margin-top: 6px; line-height: 1; }
.kpi__value small { font-size: 13px; font-weight: 500; color: var(--text-3); }
.kpi__delta { font-size: 12px; margin-top: 6px; display: flex; align-items: center; gap: 5px; }
.kpi__delta.up { color: var(--ok); }
.kpi__delta.down { color: var(--danger); }
.kpi__dot { width: 8px; height: 8px; border-radius: 50%; }

/* ── Бейджи и статусы ────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 21px; padding: 0 8px;
  border-radius: 100px; font-size: 11.5px; font-weight: 550; background: var(--surface-2);
  border: 1px solid var(--line); color: var(--text-2); white-space: nowrap;
}
.badge--ok { background: #f0fdf4; border-color: #bbf7d0; color: #15803d; }
.badge--warn { background: #fffbeb; border-color: #fde68a; color: #b45309; }
.badge--danger { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }
.badge--info { background: #eaf0fa; border-color: #c3d3ee; color: #1f4e9d; }
.badge--muted { background: #f1f5f9; border-color: #e2e8f0; color: #64748b; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: 0 0 8px; }
.dot--move { background: var(--ok); }
.dot--idle { background: var(--idle); }
.dot--stop { background: var(--stop); }
.dot--offline { background: var(--offline); }
.dot--alarm { background: var(--danger); animation: pulse 1.4s infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, .55); } 70% { box-shadow: 0 0 0 7px rgba(220, 38, 38, 0); } }

.plate {
  font-family: var(--mono); font-weight: 600; font-size: 12.5px; letter-spacing: .02em;
  background: #fff; border: 1px solid var(--line-strong); border-radius: 4px; padding: 2px 6px;
  display: inline-block; white-space: nowrap;
}

/* ── Таблицы ─────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-3); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line);
  background: var(--surface-2); white-space: nowrap; position: sticky; top: 0;
}
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ── Карта и панель мониторинга ──────────────────────────── */
.monitor { display: flex; flex: 1; min-height: 0; width: 100%; }
.veh-panel {
  width: 320px; flex: 0 0 320px; background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
.veh-panel__head { padding: 12px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.filter-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  height: 26px; padding: 0 10px; border-radius: 100px; border: 1px solid var(--line-strong);
  background: var(--surface); font-size: 12px; display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
}
.chip.is-active { background: var(--nav); color: #fff; border-color: var(--nav); }
.veh-list { overflow-y: auto; flex: 1; }
.veh-item { padding: 11px 13px; border-bottom: 1px solid var(--line); cursor: pointer; display: flex; gap: 10px; }
.veh-item:hover { background: var(--surface-2); }
.veh-item.is-active { background: #eaf0fa; box-shadow: inset 3px 0 0 var(--brand); }
.veh-item__ico { width: 34px; height: 34px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; flex: 0 0 34px; }
.veh-item__body { min-width: 0; flex: 1; }
.veh-item__top { display: flex; align-items: center; gap: 7px; }
.veh-item__driver { font-size: 12px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.veh-item__meta { display: flex; gap: 10px; font-size: 11.5px; color: var(--text-3); margin-top: 3px; }
.veh-item__meta span { display: inline-flex; align-items: center; gap: 4px; }

.map-area { flex: 1; position: relative; min-width: 0; }
.map-area #map { position: absolute; inset: 0; }
#map { background: #dfe6ee; }
.map-overlay { position: absolute; z-index: 400; }
.map-overlay--tl { top: 12px; left: 12px; display: flex; gap: 8px; flex-wrap: wrap; }
.map-overlay--br { left: 12px; bottom: 16px; }
.leaflet-bottom.leaflet-right { margin-bottom: 34px; }
.map-btn {
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  height: 32px; padding: 0 11px; font-size: 12.5px; display: inline-flex; align-items: center; gap: 6px;
  box-shadow: var(--shadow); cursor: pointer;
}
.map-btn.is-on { background: var(--nav); color: #fff; border-color: var(--nav); }
.map-legend {
  background: rgba(255, 255, 255, .95); border: 1px solid var(--line); border-radius: var(--r);
  padding: 10px 12px; box-shadow: var(--shadow); font-size: 12px; display: grid; gap: 6px;
}
.map-legend div { display: flex; align-items: center; gap: 7px; }

.veh-card {
  position: absolute; right: 12px; top: 12px; width: 296px; z-index: 450;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.veh-card__head { padding: 12px 14px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.veh-card__close { margin-left: auto; background: none; border: 0; cursor: pointer; color: var(--text-3); padding: 2px; }
.veh-card__body { padding: 12px 14px; display: grid; gap: 10px; }
.param-row { display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.param-row span { color: var(--text-2); }
.param-row b { font-weight: 600; font-variant-numeric: tabular-nums; }

.bar { height: 7px; border-radius: 100px; background: var(--line); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 100px; background: var(--brand); }
.bar--ok > i { background: var(--ok); }
.bar--warn > i { background: var(--warn); }
.bar--danger > i { background: var(--danger); }

.marker-veh {
  width: 26px; height: 26px; border-radius: 50%; border: 2.5px solid #fff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, .35); display: grid; place-items: center;
}
.marker-veh svg { width: 13px; height: 13px; color: #fff; }
.marker-label {
  background: rgba(15, 23, 42, .86); color: #fff; font-size: 10.5px; font-family: var(--mono);
  padding: 1px 5px; border-radius: 4px; white-space: nowrap; transform: translateY(2px);
}

/* ── События ─────────────────────────────────────────────── */
.event-row { display: flex; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.event-row:hover { background: var(--surface-2); }
.event-ico { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; flex: 0 0 32px; }
.event-ico svg { width: 16px; height: 16px; }
.event-ico--critical { background: #fef2f2; color: var(--danger); }
.event-ico--warning { background: #fffbeb; color: #b45309; }
.event-ico--info { background: #eaf0fa; color: #1f4e9d; }
.event-row__body { flex: 1; min-width: 0; }
.event-row__title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.event-row__detail { color: var(--text-2); font-size: 12.5px; margin-top: 2px; }
.event-row__meta { margin-left: auto; text-align: right; font-size: 12px; color: var(--text-3); white-space: nowrap; }

/* ── Правила ─────────────────────────────────────────────── */
.rule-row { display: flex; align-items: center; gap: 14px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.rule-row:last-child { border-bottom: 0; }
.rule-row__main { flex: 1; min-width: 0; }
.rule-cond {
  font-family: var(--mono); font-size: 12px; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 5px; padding: 2px 7px; display: inline-block; margin-top: 4px; color: var(--text-2);
}

/* ── Графики ─────────────────────────────────────────────── */
.chart { width: 100%; display: block; }
.chart-legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-2); flex-wrap: wrap; }
.chart-legend i { width: 10px; height: 3px; border-radius: 2px; display: inline-block; margin-right: 6px; vertical-align: middle; }

/* ── Таймлайн ────────────────────────────────────────────── */
.timeline { display: grid; gap: 0; }
.tl-item { display: flex; gap: 12px; padding: 9px 0; position: relative; }
.tl-item::before { content: ""; position: absolute; left: 7px; top: 22px; bottom: -9px; width: 2px; background: var(--line); }
.tl-item:last-child::before { display: none; }
.tl-dot { width: 16px; height: 16px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1.5px var(--line-strong); flex: 0 0 16px; margin-top: 3px; background: var(--stop); }
.tl-body { flex: 1; font-size: 13px; }
.tl-time { font-family: var(--mono); font-size: 12px; color: var(--text-3); }

/* ── Вход ────────────────────────────────────────────────── */
.auth {
  min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr;
  background: var(--nav);
}
.auth__aside {
  padding: 48px; color: #cbd5e1; display: flex; flex-direction: column; justify-content: space-between;
  background:
    radial-gradient(900px 500px at 20% 15%, rgba(58, 166, 232, .20), transparent 60%),
    radial-gradient(700px 500px at 80% 85%, rgba(31, 78, 157, .34), transparent 60%), var(--nav);
  position: relative; overflow: hidden;
}
.auth__aside h2 { color: #fff; font-size: 32px; font-weight: 800; letter-spacing: -.5px; line-height: 1.16; max-width: 460px; }
.auth__aside p { max-width: 430px; font-size: 14.5px; color: #dfe6f3; }
.auth__points { display: grid; gap: 12px; margin-top: 26px; }
.auth__points div { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; }
.auth__points svg { width: 18px; height: 18px; color: var(--nav-active); flex: 0 0 18px; margin-top: 1px; }
.auth__form { background: var(--surface); display: grid; place-items: center; padding: 32px; }
.auth__box { width: 100%; max-width: 356px; display: grid; gap: 14px; }
.auth__hint { background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: var(--r-sm); padding: 10px 12px; font-size: 12.5px; color: var(--text-2); }

/* ── Адаптив ─────────────────────────────────────────────── */
@media (max-width: 1200px) {
  .veh-card { width: 264px; }
}
@media (max-width: 980px) {
  .sidebar {
    position: fixed; z-index: 900; left: 0; top: 0; transform: translateX(-100%);
    transition: transform .2s ease; box-shadow: var(--shadow-lg);
  }
  .sidebar.is-open { transform: none; }
  .topbar__burger { display: inline-flex; }
  .veh-panel { width: 268px; flex-basis: 268px; }
  .auth { grid-template-columns: 1fr; }
  .auth__aside { display: none; }
}
@media (max-width: 720px) {
  .content { padding: 14px; }
  .monitor { flex-direction: column; }
  .veh-panel { width: 100%; flex: 0 0 auto; max-height: 46vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .map-area { min-height: 54vh; }
  .veh-card { position: static; width: auto; margin: 12px; }
  .topbar { padding: 0 12px; gap: 10px; }
  .org-switch { max-width: 150px; }
  .topbar__user-meta { display: none; }
  h1 { font-size: 19px; }
  .kpi__value { font-size: 22px; }
  .grid--2 { grid-template-columns: minmax(0, 1fr); }
  .badge { white-space: normal; height: auto; padding: 3px 8px; }
  .tbl .badge { white-space: nowrap; }
  .rule-row { flex-wrap: wrap; }
  .rule-cond { word-break: break-word; }
  .topbar__title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar__sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar > div { min-width: 0; }
  .org-switch { max-width: 118px; padding: 6px 9px; }
}
.scrim { display: none; position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 800; }
.scrim.is-open { display: block; }
