:root { color-scheme: dark; }
* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: #0b0f14;
  color: #e9eef6;
}

/* TOPBAR */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  position: sticky;
  top: 0;
  background: rgba(11,15,20,0.85);
  backdrop-filter: blur(10px);
  z-index: 10;
}

.title { min-width: 0; }
.title h1 { margin: 0; font-size: 18px; line-height: 1.2; font-weight: 900; letter-spacing: 0.2px; }
.sub { opacity: 0.75; font-size: 12px; margin-top: 2px; }

.brandAccent {
  color: #ff8a3d;
  font-weight: 900;
}

.actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pill {
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  max-width: min(520px, 60vw);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* BUTTONS */
.btn {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.12);
  background: #141b25;
  color: #e9eef6;
  cursor: pointer;
  touch-action: manipulation;
}
.btn:hover { background: #1a2432; }
.btn.primary { background: #172235; }
.btn.primary:hover { background: #1d2b45; }

/* FILTERS */
.filters {
  padding: 10px 12px 6px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.filtersRow {
  display: grid;
  grid-template-columns: 160px 1fr 160px 220px 260px;
  gap: 10px;
  align-items: end;
}

.field label {
  display: block;
  font-size: 12px;
  opacity: 0.75;
  margin-bottom: 6px;
}

.field label.ghost { opacity: 0.0; user-select: none; }

.field input, .field select {
  width: 100%;
  padding: 10px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.12);
  background: #0f1620;
  color: #e9eef6;
  outline: none;
}

.field.buttons .btnRow {
  display: flex;
  gap: 8px;
}

.field.buttons .btnRow .btn {
  flex: 1 1 auto;
}

/* GRID LAYOUT */
.grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 12px;
  padding: 12px;
}

/* CARD */
.card {
  border: 1px solid rgba(255,255,255,0.10);
  background: #0f1620;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}

.cardHeader {
  padding: 12px 12px 8px 12px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.cardHeader h2 { margin: 0; font-size: 14px; }

.hint {
  opacity: 0.7;
  font-size: 12px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Legend */
.legend { align-items: center; }
.legendItem {
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.04);
}

/* Map */
.mapCard { grid-row: span 3; }
#map {
  height: 640px;
  width: 100%;
  background: #0b0f14;
}

/* Chart wrapper */
.canvasWrap { padding: 0 10px 12px 10px; }

/* Split stats */
.splitStats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 12px;
}

.splitCard {
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.03);
  border-radius: 14px;
  padding: 12px;
}

.splitValue { font-size: 24px; font-weight: 700; }
.splitLabel { opacity: 0.75; margin-top: 3px; font-size: 12px; }

/* Table */
.tableCard { grid-column: 1 / -1; }
.tableWrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-top: 1px solid rgba(255,255,255,0.08);
}

table { width: 100%; border-collapse: collapse; min-width: 860px; }
th, td {
  padding: 10px 10px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 12px;
  vertical-align: top;
}
th {
  text-align: left;
  opacity: 0.85;
  background: rgba(255,255,255,0.03);
  position: sticky;
  top: 0;
  z-index: 2;
}

a { color: #9fd3ff; text-decoration: none; }
a:hover { text-decoration: underline; }

/* Lists */
.list { padding: 10px 12px 14px 12px; display: grid; gap: 8px; }

.row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.03);
}

.row .left { display: flex; gap: 8px; align-items: center; min-width: 0; }
.row .name { opacity: 0.95; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 340px; }
.row .meta { opacity: 0.75; }

.iconPill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.05);
}

.leaflet-div-icon { background: transparent; border: none; }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 1100px) {
  .filtersRow { grid-template-columns: 160px 1fr 160px 1fr 1fr; }
}

@media (max-width: 980px) {
  .grid { grid-template-columns: 1fr; }
  .mapCard { grid-row: auto; }
  #map { height: 520px; }
  .tableCard { grid-column: auto; }
  .row .name { max-width: 60vw; }

  .filtersRow {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; align-items: flex-start; }
  .actions { width: 100%; justify-content: space-between; }
  .pill { width: 100%; max-width: 100%; }

  .filtersRow { grid-template-columns: 1fr; }
  .field.buttons .btnRow { flex-direction: column; }

  .cardHeader { flex-direction: column; align-items: flex-start; }
  .hint { justify-content: flex-start; }
  .legend { overflow-x: auto; white-space: nowrap; flex-wrap: nowrap; padding-bottom: 2px; }
  .legendItem { flex: 0 0 auto; }

  #map { height: min(420px, 55vh); }

  .grid { padding: 10px; gap: 10px; }
}

@media (max-width: 380px) {
  #map { height: min(360px, 52vh); }
  .title h1 { font-size: 16px; }
}
