:root {
  --bg: #0b1220;
  --panel: #141e30;
  --panel-2: #1a2740;
  --border: #2a3a55;
  --text: #e8eef8;
  --muted: #9aadc7;
  --accent: #22d3ee;
  --accent-2: #38bdf8;
  --good: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 12px;
  --sidebar-w: 340px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
}

a {
  color: var(--accent-2);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

button,
.btn {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 8px;
  padding: 0.55rem 0.9rem;
}
button.primary,
.btn.primary {
  background: linear-gradient(135deg, #0891b2, #2563eb);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}
button.ghost {
  background: transparent;
}
button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

input,
select,
textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: #0d1524;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
}
textarea {
  min-height: 110px;
  resize: vertical;
}
label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.3rem;
}
.field {
  margin-bottom: 0.85rem;
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
.hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.25rem;
}
.error {
  color: var(--danger);
  font-size: 0.9rem;
  margin: 0.5rem 0;
}
.success {
  color: var(--good);
  font-size: 0.9rem;
  margin: 0.5rem 0;
}

/* Layout: map home */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 1rem 1.1rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
.sidebar-header h1 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: 0.01em;
}
.sidebar-header p {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.35;
}

.sidebar-body {
  padding: 1rem 1.1rem;
  overflow-y: auto;
  flex: 1;
}

.sidebar-footer {
  padding: 0.85rem 1.1rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.map-pane {
  flex: 1;
  position: relative;
  min-width: 0;
}
#map {
  width: 100%;
  height: 100%;
}

.map-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1000;
  background: rgba(11, 18, 32, 0.9);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.filter-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.filter-list button {
  width: 100%;
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  background: var(--panel-2);
}
.filter-list button.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
  background: #0f2a3a;
}
.filter-list .count {
  font-size: 0.8rem;
  color: var(--muted);
  background: #0d1524;
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
}

.section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 0.6rem;
}

.results-list {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.results-list a {
  display: block;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--text);
  text-decoration: none;
}
.results-list a:hover {
  border-color: var(--accent);
  text-decoration: none;
}
.results-list .name {
  font-weight: 600;
}
.results-list .meta {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

/* Leaflet popup */
.leaflet-popup-content-wrapper {
  background: var(--panel);
  color: var(--text);
  border-radius: 10px;
}
.leaflet-popup-tip {
  background: var(--panel);
}
.leaflet-popup-content {
  margin: 0.75rem 0.9rem;
  font-size: 0.9rem;
  line-height: 1.35;
}
.popup-title {
  font-weight: 700;
  margin-bottom: 0.25rem;
}
.popup-meta {
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 0.4rem;
}
.popup-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 0.4rem 0;
}
.tag {
  font-size: 0.7rem;
  background: #0f2a3a;
  border: 1px solid #164e63;
  color: #a5f3fc;
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
}

/* Account + profile pages */
.page {
  min-height: 100vh;
  padding: 1.25rem;
  max-width: 920px;
  margin: 0 auto;
}
.topnav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.topnav-left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.1rem;
}
.topnav .brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  text-decoration: none;
}
.topnav .brand:hover {
  color: var(--accent-2);
  text-decoration: underline;
}
.site-home-link {
  display: inline-block;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  text-decoration: none;
  margin-bottom: 0.45rem;
}
.site-home-link:hover {
  color: var(--accent-2);
  text-decoration: underline;
}
.site-home-btn {
  width: 100%;
  text-align: center;
  text-decoration: none !important;
  margin-top: 0.45rem;
  display: inline-block;
}
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.card h2 {
  margin: 0 0 0.75rem;
  font-size: 1.15rem;
}
.card h3 {
  margin: 1.25rem 0 0.5rem;
  font-size: 0.95rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.auth-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.auth-tabs button.active {
  border-color: var(--accent);
  color: var(--accent);
}
.google-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  background: #fff;
  color: #1f2937;
  border: none;
  font-weight: 600;
  margin-top: 0.5rem;
}
.divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--muted);
  font-size: 0.8rem;
  margin: 1rem 0;
}
.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}
.check-grid {
  display: grid;
  gap: 0.45rem;
}
.check-grid label {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  color: var(--text);
  font-size: 0.92rem;
  margin: 0;
  cursor: pointer;
}
.check-grid input {
  width: auto;
  margin-top: 0.2rem;
}
.profile-hero {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}
.avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #0f2a3a;
  border: 1px solid var(--border);
  object-fit: cover;
  flex-shrink: 0;
}
.avatar.placeholder {
  display: grid;
  place-items: center;
  font-weight: 700;
  color: var(--accent);
}
.badge {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: #0f2a3a;
  border: 1px solid #164e63;
  color: #a5f3fc;
}
.badge.off {
  background: #2a1f0a;
  border-color: #78350f;
  color: var(--warn);
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

@media (max-width: 820px) {
  .app-shell {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    max-height: 48vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .map-pane {
    min-height: 52vh;
  }
  .field-row {
    grid-template-columns: 1fr;
  }
}
