:root {
  --bg: #f9f8f2;
  --surface: #ffffff;
  --ink: #242424;
  --muted: #5f5f5f;
  --accent: #1e5a3e;
  --border: #d9d6c8;
  --plenty: #2fa84f;
  --few: #f0ba1f;
  --none: #db3a34;
  --unknown: #8d8d8d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Helvetica Neue", sans-serif;
  color: var(--ink);
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  background: var(--bg);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 20px 20px 10px;
  flex-wrap: wrap;
}

h1 {
  margin: 0;
  letter-spacing: 0.5px;
  font-size: clamp(1.8rem, 4vw, 2.5rem);
}

#tagline {
  margin: 6px 0 0;
  color: var(--muted);
}

.lang-group {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  min-width: 0;
}

.lang-buttons {
  display: inline-flex;
  gap: 6px;
}

.locate-btn,
.admin-link {
  justify-self: end;
  white-space: nowrap;
}

@media (max-width: 980px) {
  .lang-group {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    justify-items: stretch;
    width: 100%;
  }

  .admin-link {
    justify-self: end;
  }
}

@media (min-width: 981px) {
  .lang-group {
    grid-template-columns: 1fr;
  }

  .admin-link {
    width: 100%;
    text-align: right;
  }
}

.lang-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.lang-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.lang-btn:hover {
  filter: brightness(0.97);
}

.locate-btn {
  border: none;
  background: linear-gradient(180deg, #fff0c2 0%, var(--few) 100%);
  color: #1f1f1f;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.18s ease, box-shadow 0.18s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 10px rgba(250, 190, 60, 0.12);
  width: auto;
  white-space: nowrap;
}

.locate-btn:hover {
  filter: brightness(0.98);
  box-shadow: 0 6px 14px rgba(250, 190, 60, 0.16);
}

.locate-btn .loc-icon {
  font-size: 1.05rem;
  line-height: 1;
  display: inline-block;
}

.locate-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.admin-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
}

.admin-link:hover {
  text-decoration: underline;
}

.notice {
  margin: 0 20px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.86);
  max-width: calc(100vw - 40px);
}

.notice p {
  margin: 8px 0;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.admin-notice {
  padding: 8px 14px;
  margin-bottom: 12px;
}

.admin-notice p {
  margin: 0;
  line-height: 1.3;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  margin: 12px 20px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.86);
}

.legend div {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.18);
}

.dot.plenty {
  background: var(--plenty);
}

.dot.few {
  background: var(--few);
}

.dot.none {
  background: var(--none);
}

.dot.unknown {
  background: var(--unknown);
}

main {
  padding: 0 20px 20px;
  min-height: 0;
}

#map {
  height: 100%;
  min-height: 240px;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.08);
}

.popup h3 {
  margin: 0 0 6px;
}

.popup .address {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

.popup .vote-prompt {
  margin: 0 0 8px;
  font-size: 0.88rem;
}

.vote-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.vote-btn {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  padding: 6px 8px;
  cursor: pointer;
  font-size: 0.85rem;
}

.vote-btn:hover {
  filter: brightness(0.97);
}

.vote-btn.plenty {
  border-color: var(--plenty);
}

.vote-btn.few {
  border-color: var(--few);
}

.vote-btn.none {
  border-color: var(--none);
}

.popup .counts {
  margin-top: 8px;
  font-size: 0.82rem;
  color: #3b3b3b;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: #1f1f1f;
  color: #fff;
  padding: 9px 12px;
  border-radius: 8px;
  opacity: 0;
  transform: translateY(8px);
  transition: all 0.2s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 0.95;
  transform: translateY(0);
}

.admin-main {
  padding: 0 20px 20px;
}

.admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-bottom: 10px;
  color: var(--muted);
}

.nearby-cities {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.nearby-city-buttons {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

.city-nav {
  display: inline-flex;
  gap: 6px;
  margin-right: 10px;
}

.city-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.city-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.city-btn:hover {
  filter: brightness(0.97);
}

.nearby-city-btn {
  font-size: 0.82rem;
  padding: 5px 9px;
}

.admin-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.86);
}

.admin-table {
  border-collapse: collapse;
  width: 100%;
  min-width: 860px;
}

.admin-table th,
.admin-table td {
  border-bottom: 1px solid #e7e5dc;
  text-align: left;
  vertical-align: top;
  padding: 10px 12px;
  font-size: 0.92rem;
}

.admin-table thead th {
  background: #f4f2e7;
}

.admin-vote-list {
  margin: 0;
  padding-left: 18px;
}

.admin-vote-list li {
  margin: 2px 0;
}

.repo-link {
  font-size: inherit;
  color: #6a6a6a;
  text-decoration: none;
  white-space: nowrap;
}

.repo-note {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  overflow-wrap: anywhere;
}

.repo-link:hover {
  text-decoration: underline;
}

@media (max-width: 720px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .lang-group {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
  }

  .lang-buttons,
  .locate-btn,
  .admin-link {
    justify-self: auto;
    align-self: center;
  }

  #map {
    min-height: 220px;
  }
}
