*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Header ─────────────────────────────────────────────────────────────── */

#header {
  height: 58px;
  background: #005DAA;
  color: white;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  flex-shrink: 0;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.header-icon {
  font-size: 1.4rem;
  line-height: 1;
}

.header-titles h1 {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.header-titles p {
  font-size: 0.68rem;
  opacity: 0.7;
  white-space: nowrap;
}

.header-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.progress-text {
  font-size: 0.88rem;
  font-weight: 600;
}

.sep {
  margin: 0 3px;
  opacity: 0.5;
}

.visited-label {
  margin-left: 5px;
  opacity: 0.7;
  font-size: 0.75rem;
  font-weight: 400;
}

.progress-track {
  width: 180px;
  max-width: 100%;
  height: 5px;
  background: rgba(255,255,255,0.25);
  border-radius: 3px;
  overflow: hidden;
}

#progress-fill {
  height: 100%;
  background: #E31837;
  border-radius: 3px;
  width: 0%;
  transition: width 0.4s ease;
}

.header-right {
  flex-shrink: 0;
}

.list-btn {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  color: white;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.82rem;
  white-space: nowrap;
  transition: background 0.15s;
}

.list-btn:hover {
  background: rgba(255,255,255,0.28);
}

/* ── App + Map ───────────────────────────────────────────────────────────── */

#app {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#map {
  position: absolute;
  inset: 0;
}

/* ── Markers ─────────────────────────────────────────────────────────────── */

.marker-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
  cursor: pointer;
  transition: transform 0.1s;
}

.marker-dot:hover {
  transform: scale(1.3);
}

.marker-dot.unvisited {
  background: #9ca3af;
}

.marker-dot.visited {
  background: #16a34a;
}

/* ── Popup ───────────────────────────────────────────────────────────────── */

.popup-content {
  padding: 2px 0;
  min-width: 150px;
}

.popup-city {
  font-weight: 700;
  font-size: 0.95rem;
  color: #111827;
  line-height: 1.3;
}

.popup-state {
  font-size: 0.78rem;
  color: #6b7280;
  margin-bottom: 10px;
}

.popup-btn {
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.popup-btn.mark-visited {
  background: #005DAA;
  color: white;
}

.popup-btn.mark-visited:hover {
  background: #004a8a;
}

.popup-btn.mark-unvisited {
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #86efac;
}

.popup-btn.mark-unvisited:hover {
  background: #dcfce7;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */

#sidebar {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 290px;
  background: white;
  z-index: 500;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 20px rgba(0,0,0,0.15);
}

#sidebar.hidden {
  display: none;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: #005DAA;
  color: white;
  flex-shrink: 0;
}

.sidebar-header h2 {
  font-size: 0.95rem;
  font-weight: 600;
}

#sidebar-close {
  background: none;
  border: none;
  color: white;
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  line-height: 1;
  opacity: 0.8;
}

#sidebar-close:hover {
  opacity: 1;
  background: rgba(255,255,255,0.15);
}

#state-groups {
  overflow-y: auto;
  flex: 1;
}

.state-group {
  border-bottom: 1px solid #f3f4f6;
}

.state-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 16px;
  background: #f9fafb;
  font-size: 0.82rem;
  font-weight: 600;
  color: #374151;
  cursor: pointer;
  user-select: none;
}

.state-label:hover {
  background: #f0f0f0;
}

.state-progress-text {
  font-size: 0.72rem;
  color: #9ca3af;
  font-weight: 400;
}

.state-locations {
  display: none;
}

.state-locations.open {
  display: block;
}

.location-item {
  display: flex;
  align-items: center;
  padding: 7px 16px 7px 24px;
  gap: 9px;
  cursor: pointer;
  font-size: 0.82rem;
  color: #374151;
  transition: background 0.1s;
}

.location-item:hover {
  background: #f9fafb;
}

.location-item.visited {
  color: #15803d;
}

.location-check {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid #d1d5db;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  line-height: 1;
}

.location-item.visited .location-check {
  background: #16a34a;
  border-color: #16a34a;
  color: white;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 600px) {
  #sidebar {
    width: 100%;
  }

  .header-titles p {
    display: none;
  }

  .progress-track {
    width: 120px;
  }
}

/* ── Login overlay ───────────────────────────────────────────────────────── */

#login-overlay {
  position: fixed;
  inset: 0;
  background: #f5f5f5;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

#login-overlay.hidden {
  display: none;
}

.login-card {
  background: white;
  border-radius: 16px;
  padding: 48px 40px;
  text-align: center;
  box-shadow: 0 4px 32px rgba(0,0,0,0.10);
  max-width: 360px;
  width: 100%;
}

.login-icon {
  font-size: 48px;
  display: block;
  margin-bottom: 16px;
}

.login-card h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
  color: #1a1a1a;
}

.login-card p {
  color: #666;
  margin-bottom: 32px;
  font-size: 15px;
}

.apple-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: #000;
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  transition: background 0.15s;
}

.apple-btn:hover {
  background: #333;
}

/* ── Logout button ───────────────────────────────────────────────────────── */

.logout-btn {
  font-size: 13px;
  color: #666;
  text-decoration: none;
  padding: 4px 8px;
  border-radius: 4px;
  margin-left: 8px;
}

.logout-btn:hover {
  background: rgba(0,0,0,0.06);
  color: #333;
}
