:root {
  --tesla-red: #e82127;
  --tesla-cyan: #2dd4bf;
  --tesla-blue: #60a5fa;
  --tesla-amber: #f59e0b;
  --tesla-panel: rgba(13, 18, 28, 0.86);
  --tesla-line: rgba(255, 255, 255, 0.09);
}

.tesla-monitor-shell {
  min-height: 100vh;
  color: var(--text-primary);
  background: linear-gradient(180deg, rgba(9, 13, 20, 0.98), rgba(7, 10, 16, 0.98));
}

.tesla-monitor-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 64px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--tesla-line);
  background: rgba(8, 12, 18, 0.9);
  backdrop-filter: blur(14px);
}

.tesla-brand,
.tesla-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tesla-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--tesla-red), #111827);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.tesla-brand-title {
  font-size: 1rem;
  font-weight: 800;
}

.tesla-brand-subtitle {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.tesla-ws-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid var(--tesla-line);
  border-radius: 999px;
  color: var(--text-secondary);
  font-size: 0.76rem;
}

.tesla-ws-pill.ok .ws-dot { background: var(--tesla-cyan); }
.tesla-ws-pill.warn .ws-dot { background: var(--tesla-amber); }
.tesla-ws-pill.error .ws-dot { background: var(--tesla-red); }
.ws-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--text-muted);
}

.tesla-monitor-main {
  display: grid;
  grid-template-columns: 330px minmax(420px, 1.1fr) minmax(360px, 0.95fr);
  grid-template-rows: minmax(420px, 1fr) minmax(170px, auto);
  gap: 14px;
  min-height: calc(100vh - 64px);
  padding: 14px;
}

.tesla-fleet-rail,
.tesla-live-map,
.tesla-detail,
.tesla-alerts {
  min-width: 0;
  border: 1px solid var(--tesla-line);
  border-radius: 8px;
  background: var(--tesla-panel);
  overflow: hidden;
}

.tesla-fleet-rail {
  grid-row: 1 / span 2;
  display: flex;
  flex-direction: column;
}

.tesla-live-map {
  position: relative;
}

.tesla-detail {
  display: flex;
  flex-direction: column;
}

.tesla-alerts {
  grid-column: 2 / span 2;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--tesla-line);
}

.panel-title {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 800;
}

.panel-sub {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.fleet-list {
  overflow: auto;
  padding: 10px;
}

.vehicle-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--tesla-line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
  cursor: pointer;
}

.vehicle-row + .vehicle-row {
  margin-top: 9px;
}

.vehicle-row.active {
  border-color: rgba(232, 33, 39, 0.46);
  background: rgba(232, 33, 39, 0.08);
}

.vehicle-name {
  font-weight: 800;
}

.vehicle-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 0.74rem;
}

.state-chip {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--tesla-line);
  color: var(--text-secondary);
  font-size: 0.72rem;
}

.state-chip.driving,
.state-chip.online {
  color: var(--tesla-cyan);
  border-color: rgba(45, 212, 191, 0.38);
}

.state-chip.alert {
  color: var(--tesla-red);
  border-color: rgba(232, 33, 39, 0.42);
}

.state-chip.idle,
.state-chip.asleep {
  color: var(--tesla-amber);
  border-color: rgba(245, 158, 11, 0.36);
}

.battery-mini {
  min-width: 48px;
  text-align: right;
  color: var(--tesla-cyan);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.map-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.045) 1px, transparent 1px);
  background-size: 38px 38px;
}

.map-roads {
  position: absolute;
  inset: 0;
}

.map-road {
  position: absolute;
  height: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  transform-origin: left center;
}

.map-dot {
  position: absolute;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid rgba(255, 255, 255, 0.92);
  border-radius: 999px;
  background: var(--tesla-red);
  box-shadow: 0 0 0 6px rgba(232, 33, 39, 0.13);
  cursor: pointer;
}

.map-dot.driving {
  background: var(--tesla-cyan);
  box-shadow: 0 0 0 6px rgba(45, 212, 191, 0.13);
}

.map-label {
  position: absolute;
  transform: translate(12px, -28px);
  padding: 4px 7px;
  border: 1px solid var(--tesla-line);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.52);
  color: var(--text-primary);
  font-size: 0.72rem;
  white-space: nowrap;
}

.detail-body {
  overflow: auto;
  padding: 14px;
}

.dial-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.dial {
  display: grid;
  place-items: center;
  min-height: 112px;
  border: 1px solid var(--tesla-line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
}

.dial-ring {
  display: grid;
  place-items: center;
  width: 82px;
  height: 82px;
  border-radius: 999px;
  background: conic-gradient(var(--dial-color, var(--tesla-cyan)) var(--pct, 0%), rgba(255,255,255,0.08) 0);
}

.dial-core {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 999px;
  background: #0b0f17;
  text-align: center;
}

.dial-value {
  font-size: 1rem;
  font-weight: 800;
  line-height: 1;
}

.dial-label {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 0.68rem;
}

.car-graphic {
  position: relative;
  height: 226px;
  margin: 10px 0 14px;
  border: 1px solid var(--tesla-line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255,255,255,0.035), rgba(255,255,255,0.015));
}

.car-body {
  position: absolute;
  left: 50%;
  top: 18px;
  width: 138px;
  height: 188px;
  transform: translateX(-50%);
  border: 2px solid rgba(255,255,255,0.42);
  border-radius: 46px 46px 28px 28px;
  background: linear-gradient(180deg, rgba(232,33,39,0.36), rgba(96,165,250,0.15));
}

.car-cabin {
  position: absolute;
  left: 50%;
  top: 56px;
  width: 86px;
  height: 74px;
  transform: translateX(-50%);
  border: 1px solid rgba(255,255,255,0.28);
  border-radius: 28px 28px 18px 18px;
  background: rgba(0, 0, 0, 0.28);
}

.tire {
  position: absolute;
  width: 76px;
  padding: 8px;
  border: 1px solid var(--tesla-line);
  border-radius: 8px;
  background: rgba(0,0,0,0.24);
  color: var(--text-secondary);
  font-size: 0.72rem;
}

.tire strong {
  display: block;
  color: var(--text-primary);
  font-size: 1rem;
}

.tire.fl { left: 16px; top: 26px; }
.tire.fr { right: 16px; top: 26px; }
.tire.rl { left: 16px; bottom: 26px; }
.tire.rr { right: 16px; bottom: 26px; }

.route-box,
.command-box {
  padding: 12px;
  border: 1px solid var(--tesla-line);
  border-radius: 8px;
  background: rgba(255,255,255,0.025);
}

.command-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.command-grid .btn {
  justify-content: center;
}

.alert-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
  padding: 12px;
}

.alert-card {
  padding: 12px;
  border: 1px solid var(--tesla-line);
  border-left: 3px solid var(--tesla-amber);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
}

.alert-card.critical {
  border-left-color: var(--tesla-red);
}

.alert-card.info {
  border-left-color: var(--tesla-blue);
}

.alert-title {
  font-weight: 800;
}

.alert-meta {
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 0.74rem;
}

@media (max-width: 1180px) {
  .tesla-monitor-main {
    grid-template-columns: 300px minmax(0, 1fr);
    grid-template-rows: 420px auto auto;
  }

  .tesla-detail {
    grid-column: 2;
  }

  .tesla-alerts {
    grid-column: 1 / span 2;
  }
}

@media (max-width: 820px) {
  .tesla-monitor-header {
    flex-wrap: wrap;
  }

  .tesla-monitor-main {
    grid-template-columns: 1fr;
    grid-template-rows: auto 360px auto auto;
  }

  .tesla-fleet-rail,
  .tesla-detail,
  .tesla-alerts {
    grid-column: 1;
    grid-row: auto;
  }

  .dial-grid,
  .command-grid {
    grid-template-columns: 1fr;
  }
}
