:root {
  --topbar-height: 56px;
  --text: #1f2937;
  --background: #ffffff;
  --accent: #0d6efd;
  --accent-muted: #e8f0fe;
  --border: #e5e7eb;
  --sidebar-width: 320px;
  --touch-min: 44px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  font-family: Arial, sans-serif;
  color: var(--text);
  background: var(--background);
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.topbar--desktop {
  height: var(--topbar-height);
  display: none;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}

.topbar--desktop h1 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.3;
}

.layout {
  flex: 1;
  display: flex;
  min-height: 0;
  position: relative;
}

.map-wrap {
  flex: 1;
  position: relative;
  min-width: 0;
  min-height: 0;
}

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

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--background);
  display: flex;
  flex-direction: column;
  z-index: 2;
}

.sheet-toggle {
  display: none;
}

.sidebar__inner {
  padding: 16px;
  overflow: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sidebar__title {
  display: none;
  margin: 0 0 4px;
  font-size: 1.05rem;
}

.zip-form__label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.zip-form__row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.zip-form__input {
  flex: 1;
  min-height: var(--touch-min);
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
}

.btn {
  min-height: var(--touch-min);
  padding: 0 16px;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: inherit;
}

.btn--primary {
  background: var(--accent);
  color: #fff;
}

.btn--primary:hover {
  filter: brightness(0.95);
}

.btn--secondary {
  width: 100%;
  background: var(--accent-muted);
  color: #1e3a5f;
  border: 1px solid #c7d7f6;
}

.btn--secondary:hover {
  background: #dbeafe;
}

.near-me {
  margin-top: 4px;
}

.status {
  margin: 0;
  min-height: 1.25em;
  font-size: 0.88rem;
  line-height: 1.4;
}

.status--ok {
  color: #166534;
}

.status--warn {
  color: #a16207;
}

.status--error {
  color: #b91c1c;
}

.status--muted {
  color: #6b7280;
}

.results-heading {
  margin: 8px 0 0;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280;
}

.results-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.results-empty {
  padding: 12px;
  font-size: 0.9rem;
  color: #6b7280;
  border: 1px dashed var(--border);
  border-radius: 8px;
}

.results-item {
  min-height: var(--touch-min);
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  background: #fafafa;
}

.results-item:hover,
.results-item:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  background: #fff;
}

.results-item__name {
  font-weight: 600;
  font-size: 0.95rem;
}

.results-item__meta {
  font-size: 0.85rem;
  color: #4b5563;
}

.popup {
  min-width: 220px;
  line-height: 1.4;
}

.popup h2 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.popup p {
  margin: 0 0 6px;
  font-size: 0.9rem;
}

.popup .cta {
  display: inline-block;
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  text-decoration: none;
  color: #ffffff;
  background: var(--accent);
  font-size: 0.9rem;
  font-weight: 600;
}

@media (min-width: 768px) {
  .topbar--desktop {
    display: flex;
  }

  .sidebar__title {
    display: none;
  }
}

@media (max-width: 767px) {
  .layout {
    flex-direction: column;
  }

  .topbar--desktop {
    display: none;
  }

  .map-wrap {
    flex: 1;
    min-height: 0;
  }

  .sidebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 52vh;
    border-right: none;
    border-top: 1px solid var(--border);
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.12);
    z-index: 1100;
  }

  .sidebar--collapsed {
    max-height: 52px;
  }

  .sidebar--collapsed .sidebar__inner {
    display: none;
  }

  .sidebar--collapsed .sheet-toggle__chevron {
    transform: rotate(180deg);
  }

  .sheet-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    min-height: var(--touch-min);
    padding: 8px 12px;
    border: none;
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
    border-radius: 14px 14px 0 0;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
  }

  .sheet-toggle__grip {
    width: 36px;
    height: 5px;
    background: #cbd5e1;
    border-radius: 99px;
  }

  .sheet-toggle__chevron {
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 8px solid #64748b;
    transition: transform 0.2s ease;
  }

  .sidebar__title {
    display: block;
  }

  .sidebar__inner {
    padding: 12px 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    max-height: calc(52vh - 52px);
  }
}

/* Fuel type badges in popups */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 6px;
}
.badge--diesel {
  background: #dcfce7;
  color: #166534;
}
.badge--gas {
  background: #fff7ed;
  color: #9a3412;
}

/* Map legend */
.map-legend {
  position: absolute;
  bottom: 24px;
  right: 12px;
  z-index: 1000;
  background: white;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.8rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.map-legend__title {
  font-weight: 700;
  margin-bottom: 4px;
}
.map-legend__item {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
}
.map-legend__dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 2px rgba(0,0,0,0.3);
  flex-shrink: 0;
}
.map-legend__dot--diesel {
  background: #16a34a;
}
.map-legend__dot--gas {
  background: #ea580c;
}
