:root {
  color-scheme: light;
  --bg: #eef2f5;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --line: #d8e0e7;
  --text: #17212b;
  --muted: #667383;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --accent-soft: #dff5f1;
  --warning: #b45309;
  --warning-soft: #fff3d6;
  --danger: #b42318;
  --shadow: 0 18px 46px rgba(23, 33, 43, 0.12);
  --shadow-soft: 0 8px 24px rgba(23, 33, 43, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 390px minmax(0, 1fr);
  background: var(--bg);
  color: var(--text);
  font-family: Inter, Arial, Helvetica, sans-serif;
}

body.modal-open {
  overflow: hidden;
}

.hidden {
  display: none !important;
}

.material-symbols-outlined {
  font-size: 24px;
  line-height: 1;
  vertical-align: middle;
}

.auth-view {
  grid-column: 1 / -1;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgba(15, 118, 110, 0.2), transparent 34%),
    linear-gradient(135deg, rgba(15, 118, 110, 0.08), rgba(36, 99, 235, 0.08)),
    var(--bg);
}

.auth-panel {
  width: min(100%, 440px);
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-brand {
  margin-bottom: 20px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 18px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
}

.tab-button {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
}

.tab-button.active {
  background: var(--surface);
  color: var(--accent-strong);
  box-shadow: var(--shadow-soft);
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-form label,
.vehicle-form label {
  display: grid;
  gap: 6px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.input-wrap {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--muted);
}

.input-wrap:focus-within {
  border-color: rgba(15, 118, 110, 0.55);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.input-wrap input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 15px;
}

.auth-message {
  min-height: 20px;
  margin-top: 14px;
  color: #a23b2a;
  font-size: 13px;
  line-height: 1.4;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
  border-right: 1px solid var(--line);
  background: var(--surface);
  min-width: 0;
  z-index: 2;
  box-shadow: 8px 0 26px rgba(23, 33, 43, 0.06);
  overflow: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  padding: 2px 2px 8px;
}

.brand > .material-symbols-outlined {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 21px;
  line-height: 1.2;
}

.brand p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}

.panel.compact {
  padding: 10px;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 15px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff, var(--surface-soft));
}

.panel-title h2 {
  font-size: 15px;
}

.panel-title p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.vehicle-form {
  display: grid;
  gap: 12px;
}

.form-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.form-actions .primary-button,
.form-actions .secondary-button {
  min-width: 0;
}

.vehicle-message {
  min-height: 18px;
  color: var(--accent-strong);
  font-size: 13px;
  line-height: 1.4;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at top, rgba(15, 118, 110, 0.16), transparent 34%),
    rgba(23, 33, 43, 0.54);
  backdrop-filter: blur(4px);
}

.modal-panel {
  position: relative;
  z-index: 1;
  width: min(100%, 760px);
  max-height: min(92vh, 820px);
  overflow: auto;
  padding: 0;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(22, 32, 27, 0.24);
}

.modal-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  gap: 16px;
  align-items: start;
  padding: 22px 22px 18px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.1), rgba(37, 99, 235, 0.06)),
    var(--surface);
}

.modal-header h2 {
  font-size: 22px;
  line-height: 1.2;
}

.modal-header p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.icon-button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.icon-button:hover {
  background: var(--surface-soft);
}

.vehicle-form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) 250px;
  gap: 18px;
  padding: 20px 22px;
}

.vehicle-form-main {
  display: grid;
  gap: 14px;
}

.form-section {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
}

.form-section h3,
.form-section legend {
  margin: 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
}

.option-group {
  display: grid;
  gap: 12px;
  margin: 0;
  border: 1px solid var(--line);
}

.option-group legend {
  margin-bottom: 0;
  padding: 0;
}

.icon-options,
.color-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.icon-option,
.color-option {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.icon-option input,
.color-option input {
  accent-color: var(--accent);
}

.icon-option:has(input:checked),
.color-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
  box-shadow: inset 0 0 0 1px rgba(15, 118, 110, 0.18);
}

.icon-option:hover,
.color-option:hover {
  border-color: rgba(15, 118, 110, 0.34);
  transform: translateY(-1px);
}

.color-option span {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  border: 2px solid #ffffff;
  outline: 1px solid var(--line);
  background: var(--swatch);
}

.vehicle-preview {
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(15, 118, 110, 0.08), transparent 62%),
    var(--surface-soft);
}

.preview-map {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 170px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(102, 115, 131, 0.1) 1px, transparent 1px),
    linear-gradient(rgba(102, 115, 131, 0.1) 1px, transparent 1px),
    #eef4f6;
  background-size: 28px 28px;
  overflow: hidden;
}

.preview-map::before,
.preview-map::after {
  content: "";
  position: absolute;
  background: rgba(15, 118, 110, 0.22);
}

.preview-map::before {
  width: 150%;
  height: 18px;
  transform: rotate(-24deg);
}

.preview-map::after {
  width: 18px;
  height: 150%;
  transform: rotate(24deg);
}

.preview-map > .material-symbols-outlined {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border-radius: 999px;
  background: #ffffff;
  border: 2px solid rgba(23, 33, 43, 0.1);
  box-shadow: 0 16px 36px rgba(23, 33, 43, 0.18);
  font-size: 42px;
}

.vehicle-preview strong {
  display: block;
  font-size: 15px;
}

.vehicle-preview p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.modal-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 14px;
  align-items: center;
  padding: 16px 22px 20px;
  border-top: 1px solid var(--line);
  background: var(--surface-soft);
}

.vehicle-list {
  display: grid;
  gap: 0;
}

.vehicle-card {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 12px;
  padding: 15px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  transition: background 0.18s ease, transform 0.18s ease;
  cursor: pointer;
}

.vehicle-card:hover {
  background: #fbfcfd;
}

.vehicle-card.selected {
  background: linear-gradient(180deg, #ffffff, var(--accent-soft));
  box-shadow: inset 3px 0 0 var(--accent);
}

.vehicle-card:last-child {
  border-bottom: 0;
}

.vehicle-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 13px;
  background: #edf2f7;
  color: var(--accent);
}

.vehicle-icon .material-symbols-outlined {
  font-size: 26px;
}

.vehicle-name {
  font-weight: 700;
  font-size: 15px;
  overflow-wrap: anywhere;
}

.vehicle-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.vehicle-status-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.vehicle-status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #f2f5f3;
}

.vehicle-status.running {
  border-color: rgba(15, 118, 110, 0.24);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.vehicle-status.parked {
  border-color: rgba(183, 121, 31, 0.28);
  background: var(--warning-soft);
  color: var(--warning);
}

.vehicle-status.unknown {
  color: var(--muted);
}

.vehicle-content {
  min-width: 0;
}

.vehicle-actions {
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.vehicle-card.selected .vehicle-actions {
  display: flex;
}

.empty-state {
  padding: 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.icon-text-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  background: var(--surface-soft);
  color: var(--accent-strong);
  font-weight: 700;
  cursor: pointer;
}

.icon-text-button .material-symbols-outlined {
  font-size: 20px;
}

.icon-text-button:hover {
  border-color: rgba(15, 118, 110, 0.32);
  background: var(--accent-soft);
}

.primary-button {
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #ffffff;
  background: var(--accent);
  font-weight: 700;
  cursor: pointer;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.secondary-button {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text);
  background: var(--surface);
  font-weight: 700;
  cursor: pointer;
}

.secondary-button:hover {
  background: var(--surface-soft);
}

.map-shell {
  position: relative;
  min-width: 0;
  min-height: 100vh;
  padding: 14px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.12), transparent 34%),
    var(--bg);
}

#map {
  width: 100%;
  height: calc(100vh - 28px);
  border-radius: 18px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.topbar {
  position: absolute;
  top: 28px;
  left: 28px;
  right: 28px;
  z-index: 500;
  display: flex;
  justify-content: flex-end;
  pointer-events: none;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
}

.status.offline {
  color: var(--warning);
}

.vehicle-map-icon {
  display: grid;
  place-items: center;
  width: 42px !important;
  height: 42px !important;
  margin: 0 !important;
  border-radius: 999px;
  background: #ffffff;
  border: 2px solid rgba(22, 32, 27, 0.18);
  box-shadow: 0 10px 24px rgba(22, 32, 27, 0.22);
}

.vehicle-map-icon .material-symbols-outlined {
  font-size: 28px;
}

@media (max-width: 820px) {
  body {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(520px, 1fr);
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: none;
  }

  .map-shell {
    padding: 10px;
  }

  .map-shell,
  #map {
    min-height: 520px;
    height: 100%;
  }

  #map {
    border-radius: 14px;
  }

  .icon-options,
  .color-options,
  .form-actions,
  .vehicle-form-grid,
  .modal-footer {
    grid-template-columns: 1fr;
  }

  .modal {
    padding: 12px;
  }

  .modal-header,
  .vehicle-form-grid,
  .modal-footer {
    padding-left: 16px;
    padding-right: 16px;
  }

  .preview-map {
    min-height: 140px;
  }
}
