:root {
  color-scheme: light;
  --bg: #edf4ef;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-border: rgba(21, 64, 52, 0.14);
  --text: #173229;
  --muted: #56736a;
  --accent: #0d8f66;
  --accent-strong: #0b6b55;
  --device: #0f766e;
  --gateway: #b91c1c;
  --shadow: 0 18px 48px rgba(15, 23, 42, 0.12);
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(13, 143, 102, 0.22), transparent 30%),
    radial-gradient(circle at bottom right, rgba(29, 78, 216, 0.18), transparent 26%),
    linear-gradient(135deg, #f6fbf8 0%, var(--bg) 45%, #deefe6 100%);
}

.layout {
  display: grid;
  grid-template-columns: minmax(340px, 430px) 1fr;
  min-height: 100vh;
}

.sidebar {
  padding: 20px;
  display: grid;
  gap: 16px;
  align-content: start;
  max-height: 100vh;
  overflow: auto;
  overflow-x: hidden;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 22px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.hero {
  background:
    linear-gradient(160deg, rgba(13, 143, 102, 0.14), rgba(255, 255, 255, 0.9)),
    var(--panel);
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-strong);
}

h1,
h2 {
  margin: 0 0 10px;
}

h1 {
  font-size: 1.8rem;
  line-height: 1.1;
}

h2 {
  font-size: 0.92rem;
}

.muted,
.status,
.summary-card p,
.leaflet-popup-content p,
th,
td {
  color: var(--muted);
}

button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 11px 16px;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
}

button.ghost {
  color: var(--accent-strong);
  background: rgba(13, 143, 102, 0.12);
}

button.danger {
  color: #b42318;
  background: rgba(180, 35, 24, 0.1);
}

button.compact {
  padding: 8px 12px;
  font-size: 0.85rem;
}

.status {
  min-height: 1.2em;
  margin: 10px 2px 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.status.error {
  color: #b42318;
}

.summary {
  display: grid;
  gap: 6px;
}

.summary.empty {
  color: var(--muted);
}

.summary-card {
  padding: 9px 10px;
  border-radius: 14px;
  background: rgba(240, 247, 243, 0.96);
  border: 1px solid rgba(21, 64, 52, 0.09);
}

.summary-card strong {
  display: block;
  margin-bottom: 2px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-strong);
}

.summary-card p {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.25;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.table-shell {
  overflow-y: auto;
  overflow-x: hidden;
  border-radius: 16px;
  border: 1px solid rgba(21, 64, 52, 0.08);
  max-height: 320px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  background: rgba(250, 252, 250, 0.95);
}

thead {
  background: rgba(13, 143, 102, 0.08);
}

th,
td {
  padding: 8px 8px;
  text-align: left;
  border-bottom: 1px solid rgba(21, 64, 52, 0.08);
  white-space: normal;
  word-break: break-word;
}

th {
  font-size: 0.74rem;
}

td strong {
  color: var(--text);
}

.select-button {
  padding: 6px 8px;
  font-size: 0.76rem;
}

.map-shell {
  padding: 20px 20px 20px 0;
}

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

.metric {
  display: inline-block;
  margin: 4px 6px 0 0;
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  background: rgba(29, 78, 216, 0.08);
  color: #18418d;
}

@media (max-width: 1180px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    max-height: none;
    overflow: visible;
  }

  .map-shell {
    padding: 0 20px 20px;
  }

  #map {
    height: 60vh;
  }
}
