:root {
  --chrome: #111827;
  --chrome-soft: #1f2937;
  --chrome-border: rgba(255, 255, 255, 0.1);
  --panel: rgba(255, 255, 255, 0.94);
  --panel-strong: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #d7dde5;
  --warning: #f59e0b;
  --danger: #dc2626;
  --shadow: 0 14px 34px rgba(15, 23, 42, 0.18);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  color: var(--text);
  background: #dfe7ef;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

.landing-page {
  min-height: 100%;
  background:
    linear-gradient(90deg, rgba(17, 24, 39, 0.92), rgba(17, 24, 39, 0.72)),
    url("https://tile.openstreetmap.org/10/617/320.png");
  background-size: cover;
}

.landing-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  align-items: center;
  gap: 56px;
  width: min(1120px, calc(100% - 40px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 56px 0;
}

.landing-content {
  color: #ffffff;
}

.landing-logo {
  margin: 0 0 28px;
  font-size: 28px;
  font-weight: 900;
}

.landing-content h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(38px, 6vw, 68px);
  line-height: 1;
  font-weight: 900;
}

.landing-copy {
  max-width: 680px;
  margin: 24px 0 0;
  color: #d1d5db;
  font-size: 18px;
  line-height: 1.62;
}

.landing-button,
.login-panel .primary {
  height: 44px;
  border: 0;
  border-radius: 7px;
  color: #ffffff;
  background: #16a34a;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.landing-button {
  margin-top: 34px;
  padding: 0 22px;
}

.landing-button:hover,
.login-panel .primary:hover {
  background: #15803d;
}

.login-panel {
  display: none;
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.login-panel.visible {
  display: block;
}

.login-panel h2 {
  margin: 0 0 18px;
  font-size: 24px;
}

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

.login-panel label {
  display: grid;
  gap: 6px;
  color: #374151;
  font-size: 13px;
  font-weight: 800;
}

.login-panel input {
  width: 100%;
  height: 42px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: #111827;
  font-size: 14px;
}

.login-error {
  min-height: 18px;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
  font-weight: 800;
}

.app-shell {
  display: grid;
  grid-template-columns: 336px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) 218px;
  height: 100vh;
  min-height: 720px;
  overflow: hidden;
}

.fleet-panel {
  grid-row: 1 / 3;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  padding: 18px 16px;
  color: #f8fafc;
  background: var(--chrome);
  border-right: 1px solid #0b1220;
}

.brand-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.brand-row h1 {
  margin: 0;
  font-size: 25px;
  line-height: 1.1;
  font-weight: 800;
}

.brand-row p,
.journal-panel p {
  margin: 5px 0 0;
  color: #9ca3af;
  font-size: 12px;
}

.connection-badge {
  flex: 0 0 auto;
  min-width: 74px;
  padding: 5px 8px;
  border: 1px solid var(--chrome-border);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.connection-badge.online {
  color: #bbf7d0;
  background: rgba(34, 197, 94, 0.13);
}

.connection-badge.offline {
  color: #fecaca;
  background: rgba(239, 68, 68, 0.13);
}

.toolbar {
  display: grid;
  grid-template-columns: 42px 42px 1fr;
  gap: 8px;
}

.icon-button,
.text-button {
  height: 38px;
  border: 1px solid var(--chrome-border);
  border-radius: 7px;
  color: #f9fafb;
  background: var(--chrome-soft);
  cursor: pointer;
}

.icon-button {
  display: grid;
  place-items: center;
  font-size: 18px;
}

.text-button {
  padding: 0 12px;
  font-size: 13px;
  font-weight: 700;
}

.icon-button:hover,
.text-button:hover {
  border-color: rgba(255, 255, 255, 0.28);
  background: #2d3748;
}

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.summary-grid div {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--chrome-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.summary-grid strong {
  display: block;
  font-size: 23px;
  line-height: 1;
}

.summary-grid span {
  display: block;
  margin-top: 5px;
  color: #a7b0c0;
  font-size: 12px;
}

.status-groups {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow: auto;
  padding-right: 3px;
}

.status-section {
  border: 1px solid var(--chrome-border);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.045);
}

.status-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 10px;
  border-left: 4px solid var(--status-color);
  background: rgba(255, 255, 255, 0.04);
  font-size: 13px;
  font-weight: 800;
}

.vehicle-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
}

.vehicle-row:hover {
  background: rgba(255, 255, 255, 0.06);
}

.truck-dot {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  color: #ffffff;
  background: var(--status-color);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.22);
  font-size: 15px;
  font-weight: 900;
}

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

.vehicle-main strong,
.vehicle-main span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vehicle-main strong {
  font-size: 13px;
}

.vehicle-main span,
.status-time {
  color: #a7b0c0;
  font-size: 12px;
}

.vehicle-row.critical {
  background: rgba(245, 158, 11, 0.14);
}

.vehicle-row.critical .status-time {
  color: #fcd34d;
  font-weight: 800;
}

.map-region {
  position: relative;
  min-width: 0;
  min-height: 0;
}

#map {
  width: 100%;
  height: 100%;
}

.map-topbar {
  position: absolute;
  z-index: 800;
  top: 16px;
  left: 18px;
  right: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 13px;
  border: 1px solid rgba(15, 23, 42, 0.11);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.map-topbar strong {
  display: block;
  font-size: 14px;
}

.map-topbar span {
  color: var(--muted);
  font-size: 12px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px 10px;
  max-width: 600px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #4b5563;
  font-size: 11px;
  white-space: nowrap;
}

.legend-swatch {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.journal-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-top: 1px solid var(--line);
  background: var(--panel-strong);
}

.journal-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px 10px;
}

.journal-panel h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1.2;
}

#journalCount {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.table-wrap {
  min-height: 0;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 13px;
}

th,
td {
  overflow: hidden;
  padding: 9px 12px;
  border-top: 1px solid #edf0f4;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #6b7280;
  background: #f8fafc;
  font-size: 11px;
  text-transform: uppercase;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
  padding: 4px 8px;
  border-radius: 6px;
  color: #111827;
  background: rgba(17, 24, 39, 0.07);
  font-size: 12px;
  font-weight: 800;
}

.status-chip::before {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--status-color);
  content: "";
}

.truck-marker {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 3px solid #fff;
  border-radius: 50%;
  color: #fff;
  background: var(--status-color);
  box-shadow: 0 7px 18px rgba(15, 23, 42, 0.32);
  font-size: 16px;
  font-weight: 900;
}

.leaflet-popup-content {
  min-width: 230px;
  margin: 12px;
}

.popup-title {
  margin: 0 0 8px;
  font-size: 15px;
}

.popup-grid {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 5px 10px;
  font-size: 12px;
}

.popup-grid span:nth-child(odd) {
  color: var(--muted);
}

.key-dialog {
  width: min(420px, calc(100vw - 32px));
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.key-dialog::backdrop {
  background: rgba(15, 23, 42, 0.58);
}

.key-dialog h2 {
  margin: 0 0 8px;
}

.key-dialog p {
  color: var(--muted);
  font-size: 13px;
}

.key-dialog input {
  width: 100%;
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.key-dialog menu {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin: 16px 0 0;
  padding: 0;
}

.key-dialog button {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  cursor: pointer;
}

.key-dialog .primary {
  border-color: #111827;
  color: #ffffff;
  background: #111827;
}

@media (max-width: 900px) {
  .landing-shell {
    grid-template-columns: 1fr;
    gap: 28px;
    width: min(100% - 32px, 520px);
  }

  .landing-content h1 {
    font-size: 38px;
  }

  .landing-copy {
    font-size: 16px;
  }

  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: 280px minmax(420px, 1fr) 260px;
    min-height: 100vh;
    overflow: auto;
  }

  .fleet-panel {
    grid-row: auto;
    max-height: 280px;
    border-right: 0;
  }

  .map-topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .journal-panel {
    min-height: 260px;
  }
}
