:root{
  --bg:#0b1020;
  --bg2:#131a31;
  --panel:rgba(15,23,42,.72);
  --panel2:rgba(30,41,59,.55);
  --border:rgba(255,255,255,.08);
  --text:#edf2ff;
  --muted:#9fb0d0;
  --accent:#6ea8fe;
  --accent2:#8b5cf6;
  --green:#22c55e;
  --red:#64748b;
  --shadow:0 20px 70px rgba(0,0,0,.35);
  --radius:24px;
}
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  color:var(--text);
  font:14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(110,168,254,.22), transparent 25%),
    radial-gradient(circle at top right, rgba(139,92,246,.16), transparent 24%),
    linear-gradient(180deg, var(--bg), var(--bg2));
}
a{color:inherit;text-decoration:none}
.glass{
  background:linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.03));
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border:1px solid var(--border);
  box-shadow:var(--shadow);
}
.muted{color:var(--muted)}
.hidden{display:none!important}

.login-page{
  min-height:100vh;
  display:grid;
  place-items:center;
  padding:24px;
}
.login-shell{width:min(100%, 460px)}
.login-card{
  border-radius:28px;
  padding:32px;
}
.brand{
  display:inline-flex;
  padding:8px 12px;
  border-radius:999px;
  background:rgba(110,168,254,.12);
  border:1px solid rgba(110,168,254,.25);
  color:#d9e8ff;
  margin-bottom:18px;
}
.login-card h1{margin:0 0 8px;font-size:32px}
.login-form{display:grid;gap:14px;margin-top:20px}
.login-form label{display:grid;gap:8px}
input{
  width:100%;
  border:none;
  outline:none;
  border-radius:16px;
  padding:14px 16px;
  color:var(--text);
  background:rgba(255,255,255,.06);
  border:1px solid rgba(255,255,255,.08);
}
.alert{
  background:rgba(239,68,68,.12);
  color:#ffd4d4;
  border:1px solid rgba(239,68,68,.25);
  padding:12px 14px;
  border-radius:16px;
  margin-top:16px;
}
.btn{
  border:none;
  border-radius:16px;
  padding:12px 16px;
  color:white;
  cursor:pointer;
  transition:.2s ease;
}
.btn:hover{transform:translateY(-1px)}
.btn-primary{
  background:linear-gradient(135deg, var(--accent), var(--accent2));
}
.btn-ghost{
  background:rgba(255,255,255,.07);
  border:1px solid rgba(255,255,255,.08);
}

.app-shell{
  height:100vh;
  display:grid;
  grid-template-rows:auto 1fr;
  gap:14px;
  padding:14px;
}
.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:14px 18px;
  border-radius:22px;
}
.eyebrow{font-size:12px;color:var(--muted);text-transform:uppercase;letter-spacing:.12em}
.title{font-size:24px;font-weight:700}
.user-pill{
  padding:10px 12px;
  border-radius:999px;
  background:rgba(255,255,255,.06);
  border:1px solid rgba(255,255,255,.08);
}
.topbar-actions{display:flex;gap:10px;align-items:center}

.dashboard{
  min-height:0;
  display:grid;
  grid-template-columns:1fr;
  grid-template-rows:44vh minmax(0, 1fr);
  gap:14px;
  transition:.35s ease;
}
.dashboard.detail-open{ z-index: 100;
  grid-template-rows:30vh minmax(180px, auto) minmax(0,1fr);
}
.map-panel,.list-panel,.detail-panel{
    z-index: 100;
  min-height:0;
  border-radius:14px;
  overflow:hidden;
}
.map-panel{display:grid;grid-template-rows:auto 1fr}
.map-toolbar,.list-head{
    z-index: 100;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:1px;
  padding:14px 16px;
  border-bottom:1px solid rgba(255,255,255,.08);
}
.panel-title{font-size:18px;font-weight:700}
.list-head-right{display:flex;flex-direction:column;align-items:flex-end;gap:2px}
.last-updated{font-size:11px;opacity:.6}
.status-ago{font-size:11px;opacity:.7;margin-left:2px}
.notify-item-time{font-size:11px;opacity:.5;margin-top:2px}
.panel-subtitle{font-size:13px;color:var(--muted)}
#map{width:100%;height:100%}

.legend{display:flex;gap:16px;flex-wrap:wrap;color:var(--muted)}
.dot{
  display:inline-block;
  width:10px;height:10px;border-radius:50%;
  margin-right:8px;
}
.dot.online{background:var(--green); box-shadow:0 0 12px rgba(34,197,94,.65)}
.dot.offline{background:#64748b}
.dot.warn{background:#f59e0b; box-shadow:0 0 10px rgba(245,158,11,.5)}

.list-panel{display:grid;grid-template-rows:auto 1fr}
.vehicle-list{
  overflow:auto;
  padding:14px;
  display:grid;
  gap:12px;
}
.vehicle-card{
  border:1px solid rgba(255,255,255,.08);
  background:rgba(255,255,255,.04);
  border-radius:20px;
  padding:14px;
  cursor:pointer;
  transition:.22s ease;
}
.vehicle-card:hover{
  transform:translateY(-2px);
  background:rgba(255,255,255,.06);
}
.vehicle-card.active{
  border-color:rgba(110,168,254,.55);
  box-shadow:0 0 0 1px rgba(110,168,254,.25) inset;
}
.vehicle-top{
  display:flex;
  justify-content:space-between;
  gap:12px;
  align-items:flex-start;
}
.vehicle-name{font-size:18px;font-weight:700;display:flex;align-items:center;gap:6px}
.vehicle-make{font-size:12px;color:var(--muted);margin-top:3px}

.maint-icon{
  display:inline-flex;align-items:center;
  padding:3px 5px;
  border-radius:6px;
  line-height:1;
  flex-shrink:0;
}
.maint-icon svg{flex-shrink:0}
.maint-icon.maint-overdue{
  background:rgba(239,68,68,.18);
  color:#f87171;
  border:1px solid rgba(239,68,68,.35);
  box-shadow:0 0 6px rgba(239,68,68,.25);
}
.maint-icon.maint-warn{
  background:rgba(245,158,11,.18);
  color:#fbbf24;
  border:1px solid rgba(245,158,11,.35);
}
.maint-icon.maint-ok{
  background:rgba(34,197,94,.15);
  color:#4ade80;
  border:1px solid rgba(34,197,94,.3);
}
.maint-icon.maint-unknown{
  background:rgba(255,255,255,.05);
  color:#64748b;
  border:1px solid rgba(255,255,255,.1);
}

.vehicle-plate-row{display:flex;align-items:center;gap:8px;margin-top:8px;flex-wrap:wrap}
.maint-status-wrap{display:inline-flex;gap:4px;align-items:center;justify-content:flex-end}
.maint-status-wrap:empty{display:none}
.vehicle-side{display:flex;flex-direction:column;align-items:flex-end;justify-content:space-between;gap:6px;flex-shrink:0;align-self:stretch}

/* California-style plate */
.ca-plate{
  display:inline-flex;flex-direction:column;align-items:center;
  background:linear-gradient(180deg,#f9f5eb,#ede8d5);
  border:1.5px solid #bfb28a;
  border-radius:5px;
  padding:2px 10px 3px;
  box-shadow:0 1px 4px rgba(0,0,0,.3),inset 0 0 0 1px rgba(255,255,255,.5);
  line-height:1;
  gap:1px;
}
.ca-plate-state{
  font-size:7px;font-weight:800;letter-spacing:1.8px;
  color:#c0392b;font-family:Arial,sans-serif;text-transform:uppercase;
}
.ca-plate-num{
  font-size:13px;font-weight:700;letter-spacing:2px;
  color:#1a3a8c;font-family:'Courier New',monospace;text-transform:uppercase;
}

/* Firmware version row */
.fw-row{display:flex;align-items:center;gap:6px;margin-top:6px;flex-wrap:wrap}
.fw-badge{
  font-size:10px;font-weight:600;padding:2px 7px;border-radius:5px;line-height:1.5;
}
.fw-cur{background:rgba(34,197,94,.13);color:#22c55e;border:1px solid rgba(34,197,94,.3)}
.fw-old{background:rgba(245,158,11,.13);color:#f59e0b;border:1px solid rgba(245,158,11,.3)}
.fw-err{background:rgba(239,68,68,.13);color:#ef4444;border:1px solid rgba(239,68,68,.3)}

/* Кнопка обновления — также служит прогресс-баром */
.fw-update-btn{
  position:relative;overflow:hidden;
  font-size:10px;font-weight:700;padding:2px 9px;border-radius:5px;
  cursor:pointer;line-height:1.6;z-index:0;
  background:transparent;
  color:#c4d9ff;
  border:1px solid rgba(110,168,254,.35);
  transition:color .15s ease, border-color .15s ease;
  white-space:nowrap;
}
.fw-update-btn::before{
  content:'';position:absolute;inset:0;
  background:linear-gradient(135deg,rgba(110,168,254,.22),rgba(139,92,246,.22));
  z-index:-1;
}
.fw-update-btn:not(.fw-in-progress):hover::before{
  background:linear-gradient(135deg,rgba(110,168,254,.38),rgba(139,92,246,.38));
}

/* Прогресс-заливка внутри кнопки */
.fw-update-btn.fw-in-progress{
  cursor:default;
  color:#e8f4ff;
  border-color:rgba(110,168,254,.5);
  min-width:80px;
  text-align:center;
}
.fw-update-btn.fw-in-progress::before{
  background:rgba(255,255,255,.05);
}
.fw-update-btn.fw-in-progress::after{
  content:'';position:absolute;
  inset:0 auto 0 0;
  width:var(--fw-pct,0%);
  background:linear-gradient(90deg,rgba(110,168,254,.45),rgba(139,92,246,.45));
  transition:width .6s ease;
  z-index:-1;
}

/* Color swatch */
.car-color-dot{
  width:20px;height:20px;border-radius:5px;flex-shrink:0;
  border:1.5px solid rgba(255,255,255,.18);
  box-shadow:0 1px 4px rgba(0,0,0,.35);
}

.badge{
  padding:6px 10px;border-radius:16px;font-size:12px;
  background:rgba(255,255,255,.06);border:1px solid rgba(255,255,255,.08);
  display:flex;flex-direction:column;align-items:flex-end;gap:6px;
}
.status{
  display:inline-flex;align-items:center;gap:8px;font-weight:600;
}
.vehicle-meta{
  margin-top:8px;color:var(--muted);display:flex;gap:10px;flex-wrap:wrap
}
.vehicle-desc{margin-top:10px;color:#dbe6ff}

.detail-panel{
  display:grid;
  grid-template-rows:auto 1fr auto;
}
.detail-tabs{
  overflow:auto;
  white-space:nowrap;
  padding:10px;
  display:flex;
  gap:10px;
  border-bottom:1px solid rgba(255,255,255,.08);
}
.tab{
  background:rgba(255,255,255,.04);
  color:var(--text);
  border:1px solid rgba(255,255,255,.08);
  border-radius:14px;
  padding:10px 14px;
  cursor:pointer;
}
.tab.active{
  background:linear-gradient(135deg, rgba(110,168,254,.24), rgba(139,92,246,.24));
  border-color:rgba(110,168,254,.4);
}
.detail-content{
  overflow:auto;
  padding:16px;
}
.tab-pane{display:none}
.tab-pane.active{display:block}

.info-grid{
  display:grid;
  grid-template-columns:repeat(4, minmax(0,1fr));
  gap:12px;
}
.telemetry-main-grid{padding:0}
.car-dashboard{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:10px;
  padding:14px 16px 6px;
  align-items:start;
}
.car-dash-col{display:flex;flex-direction:column;gap:8px}
.car-dash-center{
  display:flex;flex-direction:column;align-items:center;gap:10px;padding-top:4px;
}
.car-dash-center object{width:100%;max-height:140px}
.car-dash-iframe{
  width:100%;
  height:420px;
  border:none;
  border-radius:14px;
  display:block;
  background:transparent;
}
.car-dash-stats{
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(110px,1fr));
  gap:8px;
  padding:8px 16px 4px;
}
.dash-stat{
  background:rgba(255,255,255,.04);
  border:1px solid rgba(255,255,255,.07);
  border-radius:14px;
  padding:9px 12px;
}
.dash-stat-label{font-size:10px;color:var(--muted);text-transform:uppercase;letter-spacing:.06em;margin-bottom:3px}
.dash-stat-value{font-size:17px;font-weight:700;line-height:1.1;display:flex;align-items:baseline;gap:3px}
.dash-stat-unit{font-size:11px;font-weight:400;opacity:.55}
.dash-bat-wrap{display:flex;align-items:center;gap:7px;width:100%}
.dash-bat-bar{flex:1;height:6px;background:rgba(255,255,255,.1);border-radius:4px;overflow:hidden}
.dash-bat-fill{height:100%;background:linear-gradient(90deg,#22c55e,#4ade80);border-radius:4px;transition:width .4s}
.car-dash-bottom{
  display:flex;flex-wrap:wrap;gap:6px;
  padding:0 16px 14px;
}
.dash-stat-sm{
  flex:1 1 auto;
  display:flex;align-items:center;gap:6px;
  background:rgba(255,255,255,.03);
  border:1px solid rgba(255,255,255,.06);
  border-radius:10px;
  padding:5px 10px;
  font-size:12px;
}
.dash-stat-sm-label{color:var(--muted);font-size:10px;white-space:nowrap}
.info-card{
  background:rgba(255,255,255,.04);
  border:1px solid rgba(255,255,255,.08);
  border-radius:20px;
  padding:14px;
}
.telem-unit{font-size:13px;font-weight:400;opacity:.6;margin-left:2px}
.telem-badge{font-size:13px;font-weight:700;padding:2px 10px;border-radius:20px}
.telem-on{background:rgba(34,197,94,.2);color:#22c55e}
.telem-off{background:rgba(100,116,139,.2);color:#94a3b8}
.label{font-size:12px;color:var(--muted);margin-bottom:6px;text-transform:uppercase;letter-spacing:.06em}
.value{font-size:18px;font-weight:700;word-break:break-word}
.table-wrap{
  overflow:auto;
  border-radius:20px;
  border:1px solid rgba(255,255,255,.08);
}
table{
  width:100%;
  border-collapse:collapse;
}
th,td{
  padding:12px 14px;
  text-align:left;
  border-bottom:1px solid rgba(255,255,255,.06);
  vertical-align:top;
}
th{color:var(--muted);font-weight:600;background:rgba(255,255,255,.03)}
.phone-list{display:grid;gap:10px}
.phone-link{
  display:flex;align-items:center;justify-content:space-between;
  padding:12px 14px;border-radius:16px;
  background:rgba(255,255,255,.04);
  border:1px solid rgba(255,255,255,.08);
}
.docs{
  display:grid;
  grid-template-columns:repeat(2, minmax(0,1fr));
  gap:12px;
  margin-top:16px;
}
.doc-card{
  min-height:180px;
  border-radius:20px;
  border:1px dashed rgba(255,255,255,.12);
  background:rgba(255,255,255,.03);
  padding:14px;
  display:grid;
  place-items:center;
  color:var(--muted);
}
.log-list{display:grid;gap:10px}
.log-item{
  padding:14px;border-radius:18px;
  background:rgba(255,255,255,.04);
  border:1px solid rgba(255,255,255,.08);
}
.log-head{
  display:flex;justify-content:space-between;gap:12px;flex-wrap:wrap;
  margin-bottom:8px;color:var(--muted)
}
.empty-state{
  padding:24px;border-radius:20px;
  background:rgba(255,255,255,.04);
  border:1px solid rgba(255,255,255,.08);
}
.leaflet-container{
    z-index:100;
  background:#0f172a;
}
@media (max-width: 640px){
  .app-shell{
    height:100dvh;
  }

  .dashboard.detail-open{
    grid-template-rows:26vh minmax(0,1fr);
  }

  .dashboard.detail-open .list-panel{
    display:none;
  }

  .detail-panel{
    min-height:0;
    height:100%;
  }

  .detail-content{
    min-height:0;
    height:100%;
    overflow:auto;
  }
}
@media (max-width: 980px){
  .dashboard{grid-template-rows:36vh minmax(0,1fr)}
  .dashboard.detail-open{grid-template-rows:26vh 180px minmax(0,1fr)}
  .info-grid{grid-template-columns:repeat(2, minmax(0,1fr))}
  .docs{grid-template-columns:1fr}
  .title{font-size:10px}
}
@media (max-width: 640px){
  .app-shell{padding:10px}
  .topbar{padding:12px 14px}
  .vehicle-name{font-size:16px}
  .info-grid{grid-template-columns:1fr}
  .topbar-actions{gap:8px}
  .user-pill{display:none}
}


.vehicle-marker-wrap{
  background: transparent;
  border: none;
  overflow: visible;
}


.vehicle-label{
  background: rgba(11,16,32,.88);
  color: #edf2ff;
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 8px;
  padding: 3px 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,.35);
  font-size: 9px;
  font-weight: 600;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  white-space: nowrap;
  border-top: none !important;
}
.vehicle-label::before { display: none !important; }
.ml-name  { font-size: 9px; font-weight: 700; color: #edf2ff; }
.ml-plate {
  font-size: 8px; font-weight: 700; letter-spacing: 1px;
  color: #1a3a8c; font-family: 'Courier New', monospace;
  background: linear-gradient(180deg,#f9f5eb,#ede8d5);
  border: 1px solid #bfb28a; border-radius: 2px;
  padding: 0 4px; line-height: 1.4;
}
.ml-ago   { font-size: 8px; font-weight: 500; color: #94a3b8; }
.vehicle-label:before{
  display: none;
}
.vehicle-label-grey{
  background: rgba(210,215,220,.92) !important;
  border-color: rgba(150,155,165,.4) !important;
  color: #374151;
}

/* ===== MOBILE FIX DETAIL PANEL ===== */
@media (max-width: 980px){

  .app-shell{
    height:100dvh;
  }

  .dashboard{
    height:100%;
  }

  /* Когда открыта машина */
  .dashboard.detail-open{
    grid-template-rows:26vh minmax(0,1fr);
  }

  /* Скрываем список */
  .dashboard.detail-open .list-panel{
    display:none;
  }

  /* Detail панель на всю высоту */
  .detail-panel{
    min-height:0;
    height:100%;
  }

  .detail-content{
    min-height:0;
    height:100%;
    overflow:auto;
  }
}

/* Маленькие телефоны */
@media (max-width: 640px){

  .title{
    font-size:18px;
  }

  .info-grid{
    grid-template-columns:1fr;
  }

  .vehicle-card{
    padding:12px;
    border-radius:16px;
  }

  .detail-content{
    padding:12px;
  }
}




/* контейнер */
.leaflet-control-zoom {
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
}

/* кнопки */
.leaflet-control-zoom a {
  width: 44px;
  height: 44px;
  margin-bottom: 10px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 14px;

  color: #edf2ff;
  font-size: 20px;
  font-weight: 600;

  background:
    linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.03));

  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);

  border: 1px solid rgba(255,255,255,.08);

  box-shadow:
    0 10px 30px rgba(0,0,0,.35),
    inset 0 1px 0 rgba(255,255,255,.06);

  transition: all 0.18s ease;
}

/* hover */
.leaflet-control-zoom a:hover {
  transform: translateY(-2px);

  background:
    linear-gradient(135deg, rgba(110,168,254,.25), rgba(139,92,246,.25));

  border-color: rgba(110,168,254,.4);

  box-shadow:
    0 12px 30px rgba(0,0,0,.45),
    0 0 14px rgba(110,168,254,.35);
}

/* активное состояние */
.leaflet-control-zoom a:active {
  transform: scale(0.95);
}

/* отключено */
.leaflet-control-zoom a.leaflet-disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

/* плюс/минус */
.leaflet-control-zoom a span {
  pointer-events: none;
  color:#043e8f;
}

.leaflet-control-attribution {
  display: none !important;
}

.map-toolbar{
  padding: 0 !important;
  border-bottom: none !important;
  min-height: 0 !important;
}

/* ── Info popup ── */
.info-popup {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  width: min(520px, calc(100% - 32px));
  background: rgba(11,16,32,.97);
  border: 1px solid rgba(110,168,254,.22);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,.6), 0 0 0 1px rgba(110,168,254,.08);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  z-index: 3000;
  opacity: 0;
  visibility: hidden;
  transition: opacity .25s ease, transform .25s ease, visibility 0s .25s;
  pointer-events: none;
}
.info-popup.show {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
  transition: opacity .25s ease, transform .25s ease;
}
.info-popup-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.info-popup-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--accent);
  margin-bottom: 3px;
}
.info-popup-vehicle {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.info-popup-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  padding: 2px 6px;
  border-radius: 8px;
  line-height: 1;
  transition: background .15s, color .15s;
  flex-shrink: 0;
}
.info-popup-close:hover {
  background: rgba(255,255,255,.08);
  color: var(--text);
}
.info-popup-body {
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.65;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 240px;
  overflow-y: auto;
}
.info-popup-meta {
  padding: 4px 16px 12px;
  font-size: 11px;
  color: var(--muted);
}