:root {
  --bg: #12181c;
  --panel: #1a2227;
  --panel-border: #263038;
  --ink: #e7edf0;
  --ink-dim: #8fa1a8;
  --accent: #ffb454;
  --residual: #b5651d;
  --combinada: #9b6bc9;
  --lluvias: #2fa6a0;
  --colector: #d94f4f;
  --acueducto: #2f7fd9;
  --valvula: #ffb454;
  --hidrante: #e04545;
  --pozo: #f2f2f0;
  --mono: 'SF Mono', 'Consolas', 'Menlo', monospace;
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
}

#map {
  position: absolute;
  inset: 0;
}

.topbar {
  position: absolute;
  z-index: 5;
  top: 0;
  right: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  pointer-events: none;
}

.topbar h1 {
  margin: 0;
  padding: 9px 14px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: rgba(18, 24, 28, 0.88);
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.2px;
  pointer-events: auto;
}

.topbar h1 span {
  color: var(--ink-dim);
  font-weight: 400;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

.topbar-actions button {
  padding: 9px 14px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: rgba(18, 24, 28, 0.92);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.topbar-actions button:disabled {
  cursor: wait;
  opacity: 0.7;
}

#location-status {
  max-width: 250px;
  color: var(--ink-dim);
  font-size: 12px;
}

.map-panel {
  position: absolute;
  z-index: 5;
  top: 64px;
  bottom: 16px;
  left: 16px;
  width: 268px;
  overflow-y: auto;
  padding: 4px 0 12px;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  background: rgba(26, 34, 39, 0.92);
  backdrop-filter: blur(8px);
}

.group-title {
  padding: 14px 14px 6px;
  color: var(--ink-dim);
  font-size: 11px;
  font-weight: 600;
}

.panel-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px 2px;
}

.panel-actions button {
  padding: 7px 5px;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}

.panel-actions button:hover,
.row:hover {
  background: rgba(255, 255, 255, 0.1);
}

.row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 14px;
  cursor: pointer;
  user-select: none;
}

.swatch {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  border-radius: 3px;
}

.swatch.line {
  height: 3px;
  border-radius: 2px;
}

.swatch.dot {
  border-radius: 50%;
}

.row label {
  flex: 1;
  font-size: 13px;
  cursor: pointer;
}

.row .count {
  color: var(--ink-dim);
  font-family: var(--mono);
  font-size: 11px;
}

.divider {
  height: 1px;
  margin: 10px 14px;
  background: var(--panel-border);
}

#hover-card {
  position: absolute;
  z-index: 6;
  display: none;
  max-width: 240px;
  padding: 8px 11px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: rgba(18, 24, 28, 0.95);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12px;
  pointer-events: none;
}

#hover-card .t {
  color: var(--ink-dim);
}

.user-location-marker {
  width: 18px;
  height: 18px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: #1688ff;
  box-shadow: 0 0 0 7px rgba(22, 136, 255, 0.22), 0 1px 5px rgba(0, 0, 0, 0.65);
}

.maplibregl-ctrl-attrib {
  font-size: 10px;
}

@media (max-width: 600px) {
  .topbar {
    align-items: flex-start;
    padding: 10px;
  }

  .topbar h1 {
    max-width: 55%;
    font-size: 12px;
  }

  .topbar h1 span {
    display: block;
    margin-top: 3px;
  }

  .topbar-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .topbar-actions button {
    padding: 8px 10px;
    font-size: 12px;
  }

  #location-status {
    width: 100%;
    max-width: 180px;
    text-align: right;
  }

  .map-panel {
    top: 92px;
    bottom: 12px;
    left: 10px;
    width: min(250px, calc(100vw - 20px));
  }
}
