:root {
  --green: #2e9e3f;
  --yellow: #f4c20d;
  --red: #e23b3b;
  --unknown: #9aa5ad;
  --sea: #0277bd;
  --sea-dark: #015a8e;
  --ink: #16242e;
  --bg: #f3f6f8;
  --card: #ffffff;
  --line: #e2e8ec;
  --shadow: 0 2px 12px rgba(0, 40, 70, 0.12);
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

body { display: flex; flex-direction: column; height: 100vh; }

/* ---------- Topbar ---------- */
.topbar {
  background: linear-gradient(135deg, var(--sea), var(--sea-dark));
  color: #fff;
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  box-shadow: var(--shadow);
  z-index: 1000;
}
.brand { display: flex; align-items: center; gap: 0.6rem; }
.brand-icon { font-size: 2rem; }
.brand h1 { margin: 0; font-size: 1.25rem; letter-spacing: -0.02em; }
.brand h1 span { opacity: 0.7; font-weight: 400; }
.tagline { margin: 0; font-size: 0.8rem; opacity: 0.9; }

.controls { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin-left: auto; }
.controls input[type="search"],
.controls select {
  padding: 0.5rem 0.7rem;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  background: rgba(255, 255, 255, 0.95);
  color: var(--ink);
  min-width: 180px;
}
.controls input:focus, .controls select:focus { outline: 2px solid #fff; }

.flag-filters { display: flex; gap: 0.35rem; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: none;
  border-radius: 20px;
  padding: 0.4rem 0.7rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
  opacity: 0.45;
  transition: opacity 0.15s, background 0.15s;
}
.chip.is-active { opacity: 1; background: rgba(255, 255, 255, 0.95); color: var(--ink); }
.chip .dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.chip-green .dot { background: var(--green); }
.chip-yellow .dot { background: var(--yellow); }
.chip-red .dot { background: var(--red); }
.chip-unknown .dot { background: var(--unknown); }

/* ---------- Layout ---------- */
main { flex: 1; display: flex; min-height: 0; position: relative; }
#map { flex: 1; height: 100%; background: #aadaf0; }

.sidebar {
  width: 340px;
  max-width: 85vw;
  background: var(--card);
  border-left: 1px solid var(--line);
  overflow-y: auto;
  padding: 0;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  position: absolute;
  right: 0; top: 0; bottom: 0;
  box-shadow: var(--shadow);
  z-index: 900;
}
.sidebar.open { transform: translateX(0); }

.sb-header { padding: 1rem 1.1rem 0.6rem; position: sticky; top: 0; background: var(--card); border-bottom: 1px solid var(--line); }
.sb-flag { display: inline-flex; align-items: center; gap: 0.5rem; font-weight: 700; font-size: 0.95rem; padding: 0.3rem 0.7rem; border-radius: 20px; color: #fff; }
.sb-flag.green { background: var(--green); }
.sb-flag.yellow { background: var(--yellow); color: var(--ink); }
.sb-flag.red { background: var(--red); }
.sb-flag.unknown { background: var(--unknown); }
.sb-close { position: absolute; top: 0.8rem; right: 0.9rem; border: none; background: var(--bg); width: 30px; height: 30px; border-radius: 50%; cursor: pointer; font-size: 1.1rem; }
.sb-title { margin: 0.6rem 0 0.2rem; font-size: 1.25rem; }
.sb-loc { margin: 0; color: #5a6b76; font-size: 0.88rem; }
.sb-body { padding: 0.9rem 1.1rem 2rem; }
.sb-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; margin: 0.8rem 0; }
.sb-stat { background: var(--bg); border-radius: 10px; padding: 0.6rem 0.7rem; }
.sb-stat .k { font-size: 0.72rem; color: #5a6b76; text-transform: uppercase; letter-spacing: 0.03em; }
.sb-stat .v { font-size: 1.05rem; font-weight: 700; }
.sb-note { background: #fff5f5; border-left: 3px solid var(--red); padding: 0.6rem 0.8rem; border-radius: 6px; font-size: 0.88rem; margin: 0.6rem 0; }
.sb-source { font-size: 0.78rem; color: #5a6b76; margin-top: 1rem; }
.sb-source .badge { display: inline-block; background: var(--bg); border-radius: 6px; padding: 0.15rem 0.45rem; font-weight: 600; margin-right: 0.3rem; }
.sb-source a { color: var(--sea); }
.sb-link { display: inline-block; margin-top: 0.8rem; color: var(--sea); font-weight: 600; text-decoration: none; }

/* ---------- Markers ---------- */
.flag-icon { filter: drop-shadow(0 2px 2px rgba(0, 30, 50, 0.35)); transition: transform 0.1s; }
.flag-icon:hover { transform: scale(1.12); }

.beach-marker {
  width: 22px; height: 22px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
.beach-marker.green { background: var(--green); }
.beach-marker.yellow { background: var(--yellow); }
.beach-marker.red { background: var(--red); }
.beach-marker.unknown { background: var(--unknown); }

/* ---------- Status bar ---------- */
.status-bar {
  background: var(--card);
  border-top: 1px solid var(--line);
  padding: 0.4rem 1rem;
  font-size: 0.8rem;
  color: #5a6b76;
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}
.status-bar .legend { display: flex; gap: 0.8rem; margin-left: auto; }
.status-bar .legend span { display: inline-flex; align-items: center; gap: 0.3rem; }
.status-bar .legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

@media (max-width: 680px) {
  .topbar { gap: 0.6rem; }
  .tagline { display: none; }
  .controls { width: 100%; }
  .controls input[type="search"], .controls select { flex: 1; min-width: 0; }
  .sidebar { width: 100%; max-width: 100%; }
  .status-bar .legend { width: 100%; margin-left: 0; }
}
