:root {
  --brand: #2f5fde;
  --brand-dark: #1f3f9e;
  --brand-deep: #16255c;
  --red: #d92d20;
  --red-bg: #fee4e2;
  --orange: #dc6803;
  --orange-bg: #fef0c7;
  --grey: #98a2b3;
  --grey-bg: #f2f4f7;
  --green: #067647;
  --green-bg: #d1fadf;
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #101828;
  --muted: #667085;
  --border: #e4e7ec;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.1);
  --shadow-lg: 0 12px 24px -8px rgba(16, 24, 40, 0.18);
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background:
    radial-gradient(1200px 400px at 80% -120px, rgba(47, 95, 222, 0.08), transparent),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Header ---------- */

header {
  background:
    radial-gradient(900px 300px at 15% -80px, rgba(255, 255, 255, 0.14), transparent),
    linear-gradient(135deg, var(--brand-deep) 0%, var(--brand-dark) 55%, var(--brand) 100%);
  color: #fff;
  padding: 2rem 1.5rem 4.2rem;
  text-align: center;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
}
.logo-badge {
  display: inline-grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: #fff;
  color: var(--brand-dark);
  font-weight: 800;
  font-size: 1.5rem;
  box-shadow: var(--shadow-lg);
}
header h1 {
  margin: 0;
  font-size: clamp(1.4rem, 4vw, 1.9rem);
  font-weight: 800;
  letter-spacing: -0.02em;
}
header h1 small {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  opacity: 0.75;
  text-align: left;
}
header > p {
  margin: 0.8rem auto 0;
  max-width: 34rem;
  font-size: 0.95rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.85);
}

/* ---------- Tabs ---------- */

nav#tabs {
  display: flex;
  gap: 0.3rem;
  max-width: 560px;
  margin: -1.7rem auto 0;
  padding: 0.3rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 500;
}
.tab {
  flex: 1;
  padding: 0.6rem 0.4rem;
  background: none;
  border: none;
  border-radius: 999px;
  color: var(--muted);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.tab:hover { color: var(--text); background: var(--grey-bg); }
.tab.active {
  background: linear-gradient(135deg, var(--brand-dark), var(--brand));
  color: #fff;
  box-shadow: 0 4px 10px -2px rgba(47, 95, 222, 0.5);
}

main { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1rem 2rem; }

.panel { display: none; }
.panel.active { display: block; animation: fade 0.25s ease; }
@keyframes fade {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Map panel ---------- */

#map-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.9rem;
}
#map-toolbar label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.42rem 0.85rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
}
#map-toolbar label:hover { border-color: var(--brand); color: var(--brand-dark); }
#map-toolbar label:has(input:checked) {
  background: #eef2fe;
  border-color: var(--brand);
  color: var(--brand-dark);
  font-weight: 600;
}
#map-toolbar input { display: none; }

#map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(280px, 1fr);
  gap: 1rem;
  align-items: start;
}
@media (max-width: 880px) {
  #map-layout { grid-template-columns: 1fr; }
}

#map-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
#map { height: 480px; }

#legend {
  display: flex;
  gap: 1.1rem;
  padding: 0.6rem 1rem;
  font-size: 0.82rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  background: #fcfcfd;
}
.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 5px;
}
.active-dot { background: var(--red); box-shadow: 0 0 0 3px var(--red-bg); }
.upcoming-dot { background: var(--orange); box-shadow: 0 0 0 3px var(--orange-bg); }
.past-dot { background: var(--grey); box-shadow: 0 0 0 3px var(--grey-bg); }

#list {
  display: grid;
  gap: 0.65rem;
  max-height: 524px;
  overflow-y: auto;
  padding-right: 2px;
}
@media (max-width: 880px) {
  #list { max-height: none; }
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.85rem 1rem;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
}
.card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
  border-color: #c7d2f0;
}
.card-top {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}
.type-icon {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--grey-bg);
  font-size: 1.1rem;
  flex-shrink: 0;
}
.card h3 {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.card .when { margin: 0; font-size: 0.8rem; color: var(--muted); }
.card .desc {
  margin: 0.5rem 0 0;
  font-size: 0.85rem;
  color: #475467;
  line-height: 1.45;
}
.card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.6rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.14rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}
.chip.status-active { background: var(--red-bg); color: var(--red); }
.chip.status-upcoming { background: var(--orange-bg); color: var(--orange); }
.chip.status-past { background: var(--grey-bg); color: var(--muted); }
.chip.scope { background: #eef2fe; color: var(--brand-dark); }
.chip.votes { background: var(--grey-bg); color: var(--muted); font-weight: 500; }
.chip.photos { background: var(--green-bg); color: var(--green); }

/* Location controls + photo thumbs in forms */
.locate-btn {
  padding: 0.42rem 0.85rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
}
.locate-btn:hover { border-color: var(--brand); color: var(--brand-dark); }

#loc-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0.4rem 0;
}
#loc-controls .seg {
  display: inline-flex;
  gap: 0.2rem;
  padding: 0.2rem;
  background: var(--grey-bg);
  border-radius: 999px;
}
#loc-controls .seg label {
  margin: 0;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
}
#loc-controls .seg label:has(input:checked) {
  background: #fff;
  color: var(--brand-dark);
  font-weight: 600;
  box-shadow: var(--shadow);
}
#loc-controls .seg input { display: none; }

#photo-thumbs { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 0.3rem 0 0.5rem; }
.thumb { position: relative; display: inline-block; }
.thumb img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.thumb button {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: var(--red);
  color: #fff;
  font-size: 0.7rem;
  line-height: 1;
  cursor: pointer;
}

.popup-photo {
  width: 86px;
  height: 64px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  margin: 0.3rem 0.3rem 0 0;
}

.empty {
  background: var(--card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem 1.2rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}
.empty .big { font-size: 1.8rem; display: block; margin-bottom: 0.4rem; }

/* ---------- Forms ---------- */

form {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.6rem 1.7rem 1.4rem;
  max-width: 580px;
  margin: 0 auto;
}
form h2 {
  margin: 0 0 0.2rem;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}
form > .hint { margin: 0 0 0.8rem; }
form label {
  display: block;
  margin: 0.85rem 0;
  font-weight: 600;
  font-size: 0.86rem;
  color: #344054;
}
form input,
form select,
form textarea {
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 9px;
  font: inherit;
  font-weight: 400;
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}
form input:focus,
form select:focus,
form textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(47, 95, 222, 0.18);
}
form .row { display: flex; gap: 0.85rem; }
form .row label { flex: 1; }
.hint { font-weight: 400; color: var(--muted); font-size: 0.83rem; }

#report-map, #alert-map {
  height: 280px;
  border-radius: 10px;
  border: 1px solid var(--border);
  margin: 0.35rem 0 0.4rem;
}

button[type="submit"] {
  width: 100%;
  margin-top: 0.9rem;
  background: linear-gradient(135deg, var(--brand-dark), var(--brand));
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 0.75rem 1.2rem;
  font: inherit;
  font-size: 0.98rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 14px -4px rgba(47, 95, 222, 0.55);
  transition: transform 0.12s, box-shadow 0.12s, filter 0.12s;
}
button[type="submit"]:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
  box-shadow: 0 10px 18px -4px rgba(47, 95, 222, 0.6);
}
button[type="submit"]:active { transform: none; }

.msg { font-size: 0.88rem; min-height: 1.3em; margin: 0.7rem 0 0; text-align: center; }
.msg.ok { color: var(--green); }
.msg.error { color: var(--red); }

/* ---------- Leaflet popup ---------- */

.leaflet-popup-content-wrapper {
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  font-family: inherit;
}
.leaflet-popup-content { margin: 0.8rem 1rem; font-size: 0.85rem; line-height: 1.5; }
.popup-title { font-weight: 700; font-size: 0.95rem; }
.popup-actions { margin-top: 0.55rem; display: flex; gap: 0.4rem; }
.popup-actions button {
  border: 1px solid var(--border);
  background: var(--grey-bg);
  border-radius: 7px;
  padding: 0.3rem 0.6rem;
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  color: #344054;
  transition: background 0.12s, border-color 0.12s;
}
.popup-actions button:hover { background: #e9edf3; border-color: #c7d2f0; }
.popup-note { margin-top: 0.45rem; font-size: 0.7rem; color: var(--muted); }

/* ---------- Footer ---------- */

footer {
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
  padding: 1.2rem 1rem 2rem;
}
footer a { color: var(--brand-dark); }
footer .disclaimer { max-width: 46rem; margin: 0 auto 0.5rem; line-height: 1.55; }

/* ---------- Mobile ---------- */

@media (max-width: 540px) {
  header { padding: 1.2rem 1rem 3.4rem; }
  header > p { font-size: 0.85rem; margin-top: 0.6rem; }
  .logo-badge { width: 38px; height: 38px; font-size: 1.2rem; border-radius: 10px; }

  nav#tabs { margin: -1.5rem 0.75rem 0; max-width: none; }
  .tab { padding: 0.55rem 0.2rem; font-size: 0.85rem; }
  .tab-long { display: none; }

  main { padding: 1rem 0.75rem 1.5rem; }

  #map-toolbar { gap: 0.3rem; }
  #map-toolbar label, .locate-btn { padding: 0.38rem 0.7rem; font-size: 0.8rem; }
  #map { height: 62vh; min-height: 320px; }
  #report-map, #alert-map { height: 46vh; min-height: 260px; }

  form { padding: 1.1rem 1rem 1rem; }
  form .row { flex-direction: column; gap: 0; }
  #loc-controls .seg label { padding: 0.3rem 0.55rem; font-size: 0.78rem; }

  .card { padding: 0.7rem 0.8rem; }
  .card h3 { font-size: 0.92rem; }

  .leaflet-popup-content { margin: 0.7rem 0.8rem; }
  .popup-actions button { padding: 0.4rem 0.6rem; }
}
footer .support { margin-top: 0.3rem; font-size: 0.75rem; opacity: 0.85; }
footer .support a { color: var(--muted); text-decoration-color: var(--border); }
footer .support a:hover { color: var(--brand-dark); }
