/* ---- Offline banner ---- */
.offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background: #d97706;
  color: #fff;
  text-align: center;
  padding: 0.55rem 1rem;
  font-size: 0.88rem;
  font-weight: 600;
}

.map-shell {
  display: grid;
  grid-template-columns: minmax(340px, 408px) minmax(0, 1fr);
  height: calc(100vh - 86px);
  min-height: 720px;
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 0;
  padding: 1rem;
  background: linear-gradient(180deg, rgba(246, 250, 252, 0.98), rgba(255, 255, 255, 0.96));
  border-right: 1px solid var(--color-border-soft);
}

.control-panel-main {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  gap: 1rem;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 0.2rem;
}

/* ---- Impact bar ---- */
.impact-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem;
  padding: 0.6rem 0.75rem;
  background: rgba(14, 94, 168, 0.06);
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-md);
  flex-shrink: 0;
}

.impact-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.1rem;
}

.impact-num {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--color-btn-primary-bg);
  line-height: 1.2;
}

.impact-label {
  font-size: 0.64rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  line-height: 1.3;
}

/* ---- Search bar ---- */
.map-search {
  position: relative;
  flex-shrink: 0;
}
.map-search input[type="search"] {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  background: rgba(255,255,255,0.95);
  color: var(--color-text-primary);
  outline: none;
}
.map-search input[type="search"]:focus {
  border-color: var(--color-btn-primary-bg);
  box-shadow: 0 0 0 2px rgba(14,94,168,0.15);
}
.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md, 0 4px 12px rgba(0,0,0,0.12));
  z-index: 900;
  list-style: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
}
.search-results.hidden { display: none; }
.search-result-item {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1.4;
  border-bottom: 1px solid var(--color-border-soft);
  color: var(--color-text-primary);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover,
.search-result-item:focus,
.search-result-item.is-focused { background: rgba(14,94,168,0.07); outline: none; }

.panel-hero,
.panel-section {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.panel-hero {
  padding: 1.2rem 1.15rem 1.1rem;
  /* background: white; */
  /* background: #262626; */
  background: var(--color-btn-primary-bg);
  font-weight: 700;
}

.panel-hero-hint {
  margin: 0;
  color: white;
}

.panel-link-text {
  font-size: 0.92rem;
  font-weight: 700;
  color: white;
}

.panel-link-text:hover {
  color: var(--color-text-primary);
}

.panel-hero-hint a {
  color: var(--color-primary);
}

.panel-section {
  padding: 1rem;
}

.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.85rem;
}

.section-header h2 {
  margin-bottom: 0.2rem;
  font-size: 1rem;
}

.layer-toggle-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  max-height: 260px;
  overflow-y: auto;
}

.layer-toggle--all {
  font-weight: 700;
}

.layer-toggle-divider {
  height: 1px;
  background: var(--color-border-soft);
  margin: 0.1rem 0;
}

.layer-toggle {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.92rem;
  color: var(--color-text-primary);
  cursor: pointer;
  user-select: none;
}

.section-header p {
  margin: 0;
  color: var(--color-text-secondary);
  font-size: 0.92rem;
}

.field-row {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.8rem;
}

.field-row label {
  color: var(--color-text-secondary);
  font-weight: 700;
}

.status-filter-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  margin-bottom: 0.9rem;
}

.toggle-chip {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 3rem;
  padding: 0.72rem 0.85rem;
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-sm);
  background: var(--color-surface-soft);
  font-weight: 700;
}

.toggle-chip span {
  color: var(--color-text-primary);
}

.action-row {
  gap: 0.65rem;
}

.action-row .btn {
  flex: 1 1 calc(50% - 0.35rem);
}

#apply-filters-btn {
  flex-basis: 100%;
}

.panel-section--details {
  flex: 1;
}

#detail-content {
  min-height: 120px; /* was 260px */
  padding: 1rem;
  border: 1px solid var(--color-border-medium);
  border-radius: var(--radius-md);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(244, 249, 252, 0.98)),
    var(--color-surface-soft);
}

.detail-empty-state {
  display: flex;
  min-height: 130px;
  max-height: 140px;
  align-items: flex-start;
  justify-content: center;
  flex-direction: column;
  gap: 0.55rem;
  color: var(--color-text-secondary);
}

.detail-empty-state h3 {
  margin: 0;
  font-size: 1.2rem;
  color: var(--color-text-primary);
}

.detail-empty-state p {
  margin: 0;
  max-width: 30ch;
}

.detail-empty-kicker,
.detail-kicker {
  color: var(--color-btn-primary-bg);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.detail-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.detail-panel-header {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.detail-panel-header h3 {
  margin: 0.25rem 0 0;
  font-size: 1.3rem;
}

.detail-badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.detail-badge {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  padding: 0.38rem 0.72rem;
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.detail-badge--pending {
  background: var(--color-status-pending-bg);
  color: var(--color-status-pending-text);
}

.detail-badge--in-progress {
  background: var(--color-status-in-progress-bg);
  color: var(--color-status-in-progress-text);
}

.detail-badge--cleaned {
  background: var(--color-status-cleaned-bg);
  color: var(--color-status-cleaned-text);
}

.detail-badge--invalid {
  background: var(--color-status-invalid-bg);
  color: var(--color-status-invalid-text);
}

.detail-badge--logged,
.detail-badge--verified {
  background: rgba(41, 103, 173, 0.12);
  color: var(--map-route-color);
}

.detail-badge--light {
  background: var(--color-severity-light-bg);
  color: var(--color-severity-light-text);
}

.detail-badge--medium {
  background: var(--color-severity-medium-bg);
  color: var(--color-severity-medium-text);
}

.detail-badge--heavy {
  background: var(--color-severity-heavy-bg);
  color: var(--color-severity-heavy-text);
}

.detail-badge--hazard {
  background: var(--color-hazard-bg);
  color: var(--color-hazard-text);
}

.detail-meta-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.65rem;
}

.detail-meta-item {
  padding: 0.75rem 0.8rem;
  border-radius: var(--radius-sm);
  background: var(--color-surface-soft);
  border: 1px solid var(--color-border-soft);
}

.detail-meta-item dt {
  margin: 0 0 0.2rem;
  color: var(--color-text-muted);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.detail-meta-item dd {
  margin: 0;
  color: var(--color-text-primary);
  font-weight: 700;
}

.detail-section {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.detail-section h4 {
  margin: 0;
  font-size: 0.96rem;
}

.detail-copy {
  margin: 0;
  color: var(--color-text-primary);
}

.detail-copy--muted {
  color: var(--color-text-secondary);
}

.detail-action-row .btn {
  width: 100%;
}

.detail-inline-empty {
  padding: 0.85rem 0.9rem;
  border: 1px dashed var(--color-border-medium);
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  background: var(--color-surface-soft);
}

.proof-list {
  display: grid;
  gap: 0.8rem;
}

.proof-card {
  padding: 0.9rem;
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-sm);
  background: var(--color-surface-soft);
}

.proof-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.proof-bags {
  color: var(--color-text-primary);
  font-weight: 800;
}

.proof-note {
  margin: 0.55rem 0 0.6rem;
}

.proof-meta {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.88rem;
}

.proof-photo-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.7rem;
}

#detail-content img {
  width: 92px;
  height: 92px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border-soft);
  box-shadow: var(--shadow-sm);
  cursor: zoom-in;
}

/* Photo lightbox */
.photo-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity 0.18s ease;
}

.photo-lightbox.hidden {
  display: none;
}

.photo-lightbox-img {
  max-width: min(92vw, 900px);
  max-height: 88vh;
  object-fit: contain;
  border-radius: var(--radius-md);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
}

.photo-lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1.25rem;
  background: none;
  border: none;
  color: white;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  opacity: 0.8;
}

.photo-lightbox-close:hover {
  opacity: 1;
  background: none;
  transform: none;
}

.mode-switcher-section {
  padding: 1rem;
}

.mode-switcher {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.btn-mode {
  flex: 1;
  min-height: 2.85rem;
  border-radius: var(--radius-pill);
  font-weight: 800;
  transition: background-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.btn-mode--report {
  background: var(--color-btn-subtle-bg);
  color: var(--color-btn-subtle-text);
}

.btn-mode--report.is-active {
  background: var(--color-mode-report-bg);
  color: #fff;
}

.btn-mode--report:hover {
  background: var(--color-mode-report-bg-hover);
  color: #fff;
}

.btn-mode--cleanup {
  background: var(--color-btn-subtle-bg);
  color: var(--color-btn-subtle-text);
}

.btn-mode--cleanup.is-active {
  background: var(--color-mode-cleanup-bg);
  color: #fff;
}

.btn-mode--cleanup:hover {
  background: var(--color-mode-cleanup-bg-hover);
  color: #fff;
}

.mode-instructions {
  min-height: 1.4rem;
  color: var(--color-text-secondary);
  font-size: 0.92rem;
}

.report-mode-panel h2,
.cleanup-mode-panel h2 {
  margin-bottom: 0.3rem;
  font-size: 1rem;
}

.report-mode-panel p,
.cleanup-mode-panel p {
  margin: 0 0 0.75rem;
  color: var(--color-text-secondary);
  font-size: 0.92rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--color-text-primary);
  font-weight: 600;
  white-space: normal;
}

.checkbox-label input[type="checkbox"] {
  width: auto;
  margin: 0;
}

.hidden {
  display: none !important;
}

#map {
  min-height: 100%;
  background: #e4edf2;
}

.leaflet-container {
  font-family: var(--font-body);
}

.leaflet-bar a,
.leaflet-bar a:hover {
  border-bottom-color: var(--color-border-soft);
}

.leaflet-control-zoom a {
  color: var(--color-text-primary);
}

.leaflet-popup-content-wrapper {
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.leaflet-popup-content {
  min-width: 200px;
  margin: 1rem;
}

.map-popup {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.map-popup strong {
  font-size: 1rem;
}

.popup-status {
  display: inline-flex;
  align-self: flex-start;
  min-height: 1.9rem;
  padding: 0.32rem 0.65rem;
  border-radius: var(--radius-pill);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.popup-status--pending {
  background: var(--color-status-pending-bg);
  color: var(--color-status-pending-text);
}

.popup-status--in-progress {
  background: var(--color-status-in-progress-bg);
  color: var(--color-status-in-progress-text);
}

.popup-status--cleaned {
  background: var(--color-status-cleaned-bg);
  color: var(--color-status-cleaned-text);
}

.popup-clean-btn {
  width: 100%;
}

/* Sheet handle — hidden on desktop */
.sheet-handle {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  cursor: pointer;
  touch-action: none;
  flex-shrink: 0;
}

.sheet-handle-bar {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: var(--color-border-medium);
}

.sheet-handle-row {
  display: none;
  align-items: center;
  gap: 0.4rem;
}

.sheet-handle-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--color-text-secondary);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 2rem;
}

.sheet-handle-chevron {
  display: block;
  width: 8px;
  height: 8px;
  border-left: 2px solid var(--color-text-secondary);
  border-top: 2px solid var(--color-text-secondary);
  transform: rotate(45deg); /* points up — "tap to expand" */
  transition: transform 0.3s ease;
  flex-shrink: 0;
  margin-top: 3px; /* optical centering after rotation */
}

.control-panel.is-expanded .sheet-handle-chevron {
  transform: rotate(225deg); /* points down — "tap to collapse" */
  margin-top: -3px;
}

/* ---- Event map markers ---- */
.event-map-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: #fff;
  border: 2px solid #7c3aed;
  border-radius: 50%;
  font-size: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.22);
  cursor: pointer;
  user-select: none;
}

/* Mobile-only elements — hidden on desktop */
.mobile-fab-stack,
.mobile-card,
.mobile-mode-picker,
.mobile-detail-card { display: none; }

@media (max-width: 1100px) {
  .map-shell {
    grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
  }
}

@media (max-width: 768px) {
  /* Map fills full viewport */
  .map-shell {
    display: block;
    height: 100vh;
    min-height: 0;
    position: relative;
  }

  #map {
    position: absolute;
    inset: 0;
    height: 100% !important;
    min-height: 0;
    z-index: 1;
  }

  /* Hide desktop control panel entirely on mobile */
  .control-panel { display: none !important; }

  /* ---- FAB stack ---- */
  .mobile-fab-stack {
    display: flex;
    flex-direction: column;
    position: fixed;
    right: 1rem;
    bottom: 2.5rem;
    z-index: 1000;
  }

  .fab {
    width: 52px;
    height: 52px;
    padding: 0;
    margin: 0;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.8);
    background-size: 80%;
    background-repeat: no-repeat;
    background-position: center;
    border: none;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.22);
    cursor: pointer;
    flex-shrink: 0;
    appearance: none;
    -webkit-appearance: none;
    -webkit-tap-highlight-color: transparent;
    /* transform-origin: center center; */
    /* transition: transform 0.12s ease, box-shadow 0.12s ease; */
  }

  .fab:hover {
    background-color: rgba(255, 255, 255, 1.0);
    transform: none !important;
    box-shadow: 0 0 0 2.5px var(--color-district-accent);
  }

  .fab:active {
    transform: none !important;
    box-shadow: 0 0 0 2px var(--color-district-accent);
  }

  /* ---- Layers card & mode picker shared base ---- */
  .mobile-card,
  .mobile-mode-picker {
    position: fixed;
    right: 4.8rem;
    z-index: 1001;
    background: #fff;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--color-border-soft);
    justify-content: left;
  }

  /* .mobile-card:not(.hidden) { display: block; } */

  .mobile-mode-picker:not(.hidden) {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    /* gap: 0.15rem; */
    /* padding: 0.4rem; */
  }

  /* Position mode picker relative to FAB */
  .mobile-mode-picker {
    bottom: calc(6rem - 15px);
    min-width: 170px;
  }

  .mobile-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem 0.6rem;
    border-bottom: 1px solid var(--color-border-soft);
  }

  .mobile-card-title {
    font-size: 0.82rem;
    font-weight: 800;
    color: var(--color-text-primary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
  }

  .mobile-card-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    color: var(--color-text-muted);
    padding: 0.1rem 0.35rem;
  }

  .mobile-card-body {
    padding: 0.85rem 1rem;
  }

  /* ---- Mode picker buttons ---- */
  .mode-pick-btn {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.65rem;
    padding: 0.6rem 0.75rem;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--color-text-primary);
    width: 100%;
    text-align: left;
    -webkit-tap-highlight-color: transparent;
  }

  .mode-pick-btn img { flex-shrink: 0; }

  .mode-pick-btn.is-active {
    background: var(--color-surface-muted);
    color: var(--color-btn-primary-bg);
  }

  /* ---- Mobile detail card (slides up from bottom) ---- */
  .mobile-detail-card {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1002;
    background: #fff;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.16);
    max-height: 65vh;
    flex-direction: column;
    transform: translateY(100%);
    /* transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); */
  }

  .mobile-detail-card:not(.hidden) {
    display: flex;
    transform: translateY(0);
  }

  .mobile-detail-card .mobile-card-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* District label tooltip */
.district-label {
  background: rgba(14, 94, 168, 0.85);
  color: #fff;
  border: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  padding: 3px 8px;
  border-radius: 3px;
}

.district-label::before {
  display: none;
}
