:root {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #18202a;
  background: #f4f6f8;
}

* { box-sizing: border-box; }

body { margin: 0; }

header {
  background: #17202a;
  color: white;
  padding: 22px max(20px, calc((100% - 1200px) / 2));
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}

h1 { margin: 0 0 4px; font-size: 1.5rem; }
h2 { margin-top: 0; font-size: 1.1rem; }
header p { margin: 0; opacity: .75; }

.status {
  padding: 7px 12px;
  border-radius: 999px;
  background: #68727d;
  font-size: .85rem;
  white-space: nowrap;
}

.status.connected { background: #258a50; }

main {
  max-width: 1200px;
  margin: 20px auto;
  padding: 0 20px;
}

.panel {
  background: white;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 2px 10px rgba(0,0,0,.06);
}

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

.controls-grid {
  grid-template-columns: 1.6fr .8fr .8fr .8fr;
}

label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-weight: 600;
  font-size: .9rem;
}

input, select {
  width: 100%;
  border: 1px solid #ccd2d8;
  border-radius: 7px;
  padding: 10px;
  font: inherit;
  background: white;
}

input[type="range"] { padding: 0; }

output { font-weight: 400; color: #69737d; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

button {
  border: 0;
  border-radius: 7px;
  padding: 10px 16px;
  background: #2672d9;
  color: white;
  font-weight: 650;
  cursor: pointer;
}

button:hover { filter: brightness(.94); }
button:disabled { opacity: .5; cursor: not-allowed; }

button.secondary {
  background: #e8edf2;
  color: #26323e;
}

.hint {
  color: #66717d;
  font-size: .82rem;
  margin-bottom: 0;
}

.error {
  color: #b42318;
  margin-bottom: 0;
  white-space: pre-wrap;
}

.hidden { display: none !important; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.stats div {
  background: white;
  border-radius: 10px;
  padding: 15px;
  box-shadow: 0 2px 10px rgba(0,0,0,.05);
}

.stats strong, .stats span {
  display: block;
}

.stats strong { font-size: 1.35rem; }
.stats span { color: #69737d; font-size: .8rem; margin-top: 3px; }

.map-wrap {
  height: 650px;
  position: relative;
  background: #ddd;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0,0,0,.08);
}

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

.loading {
  position: absolute;
  z-index: 1000;
  left: 50%;
  top: 20px;
  transform: translateX(-50%);
  background: white;
  padding: 10px 16px;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0,0,0,.2);
}

footer {
  text-align: center;
  color: #77818b;
  padding: 12px;
  font-size: .8rem;
}

@media (max-width: 800px) {
  .grid, .controls-grid, .stats { grid-template-columns: 1fr 1fr; }
  .map-wrap { height: 70vh; }
}

@media (max-width: 520px) {
  .grid, .controls-grid, .stats { grid-template-columns: 1fr; }
  header { align-items: flex-start; flex-direction: column; }
}
