:root {
  --bg: #f4f1ea;
  --ink: #1c241c;
  --muted: #5b6258;
  --card: #fffcf6;
  --line: #d9d2c5;
  --green: #1b7a4e;
  --green-dark: #145c3a;
  --teal: #1a5fb4;
  --amber: #c45c00;
  --purple: #5c4d7a;
  --danger: #9b1c1c;
  --shadow: 0 8px 28px rgba(28, 36, 28, 0.12);
  --radius: 14px;
  --header-h: auto;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); }
button, input, select { font: inherit; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

/* Login */
.login-body {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background:
    radial-gradient(1200px 600px at 10% -10%, #dcead9 0%, transparent 50%),
    radial-gradient(800px 400px at 110% 10%, #efe3c9 0%, transparent 45%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px 22px 24px;
  box-shadow: var(--shadow);
}
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 11px;
  font-weight: 700;
  color: var(--green-dark);
  margin: 0 0 6px;
}
.login-card h1, .topbar h1 {
  font-size: 1.55rem;
  line-height: 1.15;
  margin: 0 0 8px;
  letter-spacing: -0.02em;
}
.lede { margin: 0 0 18px; color: var(--muted); font-size: 0.95rem; }
.login-card label { display: block; font-weight: 600; font-size: 0.86rem; margin: 12px 0 6px; }
.login-card input[type="text"],
.login-card input[type="password"] {
  width: 100%;
  padding: 12px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  min-height: 44px;
}
.login-card input:focus, .map-body input:focus, .map-body select:focus {
  outline: 2px solid var(--green);
  outline-offset: 1px;
}
.form-error {
  background: #fdecec;
  color: var(--danger);
  border: 1px solid #f0c3c3;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  font-size: 0.92rem;
}
.btn {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 700;
  min-height: 44px;
  background: #ece7dc;
  color: var(--ink);
}
.btn.primary { background: var(--green); color: #fff; }
.btn.primary:hover, .btn.primary:focus { background: var(--green-dark); }
.btn.block { width: 100%; margin-top: 16px; }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn.compact { min-height: 36px; padding: 6px 10px; font-size: 0.85rem; }
.btn.icon {
  width: 44px; min-width: 44px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--green); color: #fff;
}
.btn.maps {
  display: block;
  width: 100%;
  text-align: center;
  text-decoration: none;
  background: var(--green);
  color: #fff !important;
  padding: 12px 14px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 1.02rem;
  margin-top: 12px;
  min-height: 48px;
  line-height: 24px;
}

/* Map chrome */
.map-body { display: flex; flex-direction: column; height: 100%; }
.topbar {
  flex: 0 0 auto;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 10px 12px 8px;
  z-index: 500;
}
.topbar-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.topbar h1 { font-size: 1.15rem; margin: 0; }
.logout-form { margin: 0; }
.search-row { display: flex; gap: 8px; margin-top: 8px; }
.search-row input[type="search"] {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
  background: #fff;
}
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  align-items: center;
}
.filters select {
  flex: 1 1 120px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 8px;
  background: #fff;
  max-width: 100%;
}
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  min-height: 40px;
  padding: 0 4px;
  white-space: nowrap;
}
.toggle input { width: 18px; height: 18px; accent-color: var(--green); }
.status-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
}
.status { margin: 0; font-size: 0.82rem; color: var(--muted); }
.legend {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin: 0;
  padding: 0;
  font-size: 0.75rem;
  color: var(--muted);
}
.dot {
  width: 8px; height: 8px; border-radius: 50%; display: inline-block;
  margin-right: 5px; vertical-align: middle;
}
.dot.all-meat { background: var(--green); }
.dot.halal-menu { background: var(--teal); }
.dot.partial { background: var(--amber); }
.dot.other { background: var(--purple); }

#map { flex: 1 1 auto; min-height: 220px; background: #dce5d9; }

.search-results {
  margin-top: 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  max-height: 220px;
  overflow: auto;
  box-shadow: var(--shadow);
}
.search-results button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  min-height: 44px;
  cursor: pointer;
}
.search-results button:last-child { border-bottom: 0; }
.search-results strong { display: block; }
.search-results span { color: var(--muted); font-size: 0.82rem; }

/* Markers */
.place-dot {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.35);
}
.place-dot.all-meat { background: var(--green); }
.place-dot.halal-menu { background: var(--teal); }
.place-dot.partial { background: var(--amber); }
.place-dot.other { background: var(--purple); }
.place-dot.closed { opacity: 0.55; box-shadow: 0 0 0 2px #9b1c1c; }

.server-cluster {
  background: #145c3a;
  color: #fff;
  border: 2px solid #fff;
  border-radius: 50%;
  font-weight: 800;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.server-cluster.large { background: #0e3d27; }

/* Popup */
.leaflet-popup-content-wrapper {
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.leaflet-popup-content { margin: 14px 16px; min-width: 200px; max-width: 260px; }
.popup h2 { font-size: 1.05rem; margin: 0 0 6px; line-height: 1.25; }
.popup p { margin: 0 0 4px; font-size: 0.9rem; }
.popup .note-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  margin: 4px 0 6px;
  background: #e8f4ec;
  color: var(--green-dark);
}
.popup .note-badge.halal-menu { background: #e6eef8; color: #143a6e; }
.popup .note-badge.partial { background: #fbe9d6; color: #7a3b00; }
.popup .note-badge.other { background: #ece8f2; color: #3c3152; }
.popup a.plain { color: var(--teal); word-break: break-word; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  background: #1c241c;
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  z-index: 2000;
  max-width: calc(100% - 24px);
  font-size: 0.92rem;
  box-shadow: var(--shadow);
}

/* Leaflet cluster (client-side, high zoom only) */
.marker-cluster-small { background-color: rgba(27, 122, 78, 0.35); }
.marker-cluster-small div { background-color: rgba(27, 122, 78, 0.85); color: #fff; }
.marker-cluster-medium { background-color: rgba(20, 92, 58, 0.4); }
.marker-cluster-medium div { background-color: rgba(20, 92, 58, 0.9); color: #fff; }
.marker-cluster-large { background-color: rgba(14, 61, 39, 0.45); }
.marker-cluster-large div { background-color: rgba(14, 61, 39, 0.95); color: #fff; }

@media (min-width: 720px) {
  .topbar { padding: 12px 16px 10px; }
  .topbar h1 { font-size: 1.35rem; }
  .status-row { flex-direction: row; align-items: center; justify-content: space-between; }
}

/* Google Maps */
#map .gm-style { font-family: inherit; }
#map .gm-style-iw-c {
  padding: 0 !important;
  border-radius: 14px !important;
  box-shadow: var(--shadow) !important;
}
#map .gm-style-iw-d {
  overflow: auto !important;
  padding: 14px 16px 16px !important;
  max-width: 280px;
}
#map .gm-style-iw-chr { padding: 6px 6px 0 0; }
#map .gm-style-iw-tc::after { background: #fff; }
#map .popup h2 { margin-top: 0; padding-right: 12px; }
#map .gm-style a[href^="https://maps.google.com/maps"] { display: none !important; } /* hide "keyboard shortcuts" clutter if needed — actually don't hide Google logo/legal */

/* Keep our Maps button large inside InfoWindows */
#map .popup .btn.maps { display: block; }

@media (max-width: 420px) {
  #map .gm-style-iw-d { max-width: 240px; }
}

/* Phone / narrow: place details as a bottom sheet so they are not clipped by the filter bar */
.place-sheet {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1500;
  background: var(--card);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -10px 32px rgba(28, 36, 28, 0.2);
  padding: 6px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  max-height: min(48vh, 420px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.place-sheet:not([hidden]) { display: block; }
.place-sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 4px;
  background: var(--line);
  margin: 6px auto 10px;
}
.place-sheet-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  border-radius: 22px;
}
.place-sheet-close:hover, .place-sheet-close:focus {
  background: #ece7dc;
  color: var(--ink);
  outline: none;
}
.place-sheet .popup { padding-right: 36px; padding-bottom: 4px; }
.place-sheet .popup h2 { font-size: 1.12rem; margin: 0 0 8px; }
.place-dot.selected {
  box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--green);
  transform: scale(1.2);
}
body:has(#place-sheet:not([hidden])) .toast { bottom: auto; top: 16px; }

@media (min-width: 721px) {
  .place-sheet { display: none !important; }
}
