:root {
  --bg: #0f1419;
  --surface: #161d26;
  --surface-2: #1e2733;
  --line: #2a3543;
  --text: #e8edf3;
  --muted: #8b9bad;
  --accent: #ff7a1a;
  --ok: #22c55e;
  --queue: #f5a623;
  --out: #ef4444;
  --unknown: #64748b;
  --radius: 12px;
  --topbar-h: 62px;
  --filters-h: 96px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6f9;
    --surface: #ffffff;
    --surface-2: #eef1f6;
    --line: #dde3ec;
    --text: #16202b;
    --muted: #5f7186;
    --unknown: #94a3b8;
  }
}

* { box-sizing: border-box; }

/* The UA's `[hidden] { display: none }` is a bare attribute selector, so any
   class rule that sets `display` beats it -- which silently un-hides every
   flex container we toggle with the hidden attribute. Win explicitly. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ---------- topbar ---------- */
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 1000;
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo { font-size: 26px; }
.topbar h1 { margin: 0; font-size: 19px; letter-spacing: -0.3px; }
.topbar h1 span { color: var(--accent); }
.tagline { margin: 0; font-size: 11.5px; color: var(--muted); }
.topbar-actions { display: flex; gap: 8px; }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  padding: 9px 14px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform .08s ease, filter .15s ease;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #1a0e03; }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 10px; font-size: 15px; }
.btn-block { width: 100%; justify-content: center; padding: 13px; font-size: 15px; }
.pin { font-size: 15px; }

/* ---------- filters ---------- */
.filters {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 10px 16px;
  position: relative;
  z-index: 999;
}
.fuel-tabs { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
.fuel-tabs::-webkit-scrollbar { display: none; }
.fuel-tab {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.fuel-tab.active { background: var(--accent); border-color: var(--accent); color: #1a0e03; }

.filter-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.select {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 7px 10px;
  font-size: 13px;
  max-width: 190px;
}
.toggle { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; }
.toggle input { accent-color: var(--accent); width: 16px; height: 16px; }
.stat { margin-left: auto; font-size: 12.5px; color: var(--muted); }

/* ---------- layout ---------- */
.layout {
  display: flex;
  height: calc(100vh - var(--topbar-h) - var(--filters-h));
  min-height: 380px;
}
#map { flex: 1; height: 100%; background: var(--surface-2); }

.sidebar {
  width: 370px;
  flex: 0 0 370px;
  background: var(--surface);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px 8px;
}
.sidebar-head h2 { margin: 0; font-size: 14.5px; }
.legend {
  display: flex; flex-wrap: wrap; gap: 10px;
  padding: 0 14px 10px;
  font-size: 11.5px; color: var(--muted);
  border-bottom: 1px solid var(--line);
}
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.ok { background: var(--ok); }
.dot.queue { background: var(--queue); }
.dot.out { background: var(--out); }
.dot.unknown { background: var(--unknown); }

/* ---------- station list ---------- */
.station-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.station-item {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  display: grid;
  grid-template-columns: 10px 1fr auto;
  gap: 10px;
  align-items: start;
}
.station-item:hover { background: var(--surface-2); }
.station-item .bar { width: 4px; height: 100%; min-height: 34px; border-radius: 3px; }
.bar.ok { background: var(--ok); }
.bar.queue { background: var(--queue); }
.bar.out { background: var(--out); }
.bar.unknown { background: var(--unknown); }
.st-name { font-size: 14px; font-weight: 650; margin: 0 0 2px; }
.st-meta { font-size: 11.5px; color: var(--muted); margin: 0 0 6px; }
.st-dist { font-size: 12.5px; font-weight: 700; color: var(--accent); white-space: nowrap; }
.fuel-pills { display: flex; flex-wrap: wrap; gap: 4px; }
.pill {
  font-size: 10.5px; font-weight: 700;
  padding: 2.5px 7px; border-radius: 999px;
  border: 1px solid transparent;
}
.pill.ok { background: rgba(34,197,94,.15); color: var(--ok); border-color: rgba(34,197,94,.35); }
.pill.queue { background: rgba(245,166,35,.15); color: var(--queue); border-color: rgba(245,166,35,.35); }
.pill.out { background: rgba(239,68,68,.13); color: var(--out); border-color: rgba(239,68,68,.3); }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- map markers ----------
   The pin body stays coloured by availability -- that is the question the map
   exists to answer, so it must survive at a glance. The brand logo sits in a
   white disc inside it rather than replacing it. */
.marker {
  width: 34px; height: 34px; border-radius: 50% 50% 50% 5px;
  transform: rotate(-45deg);
  border: 2px solid rgba(255,255,255,.9);
  box-shadow: 0 2px 7px rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
}
.marker .brand-badge { transform: rotate(45deg); }
.marker.ok { background: var(--ok); }
.marker.queue { background: var(--queue); }
.marker.out { background: var(--out); }
.marker.unknown { background: var(--unknown); }
/* Out of fuel is not what you are looking for -- let those recede. */
.marker.out, .marker.unknown { opacity: .82; }

/* ---------- brand badge ---------- */
.brand-badge {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #fff;
  overflow: hidden;
  vertical-align: -3px;
}
.brand-badge img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  padding: 12%;
  background: #fff;
}
.brand-letter {
  font-size: 10px; font-weight: 800; line-height: 1;
  color: var(--brand, #64748b);
}
.st-name .brand-badge { margin-right: 6px; }
.popup h4 .brand-badge { margin-right: 6px; }
.me-marker {
  width: 16px; height: 16px; border-radius: 50%;
  background: #2f7cf6; border: 3px solid #fff;
  box-shadow: 0 0 0 6px rgba(47,124,246,.25);
}
.leaflet-popup-content-wrapper { background: var(--surface); color: var(--text); border-radius: 10px; }
.leaflet-popup-tip { background: var(--surface); }
.popup h4 { margin: 0 0 3px; font-size: 14px; }
.popup p { margin: 0 0 8px; font-size: 11.5px; color: var(--muted); }
.popup .btn { width: 100%; justify-content: center; padding: 8px; }

/* ---------- bottom sheet ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 1500;
}
.sheet {
  position: fixed;
  z-index: 1600;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  width: min(440px, calc(100% - 24px));
  max-height: 88vh;
  overflow-y: auto;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 24px 60px rgba(0,0,0,.5);
}
.sheet-close {
  position: absolute; top: 12px; right: 14px;
  background: none; border: none; color: var(--muted);
  font-size: 26px; line-height: 1; cursor: pointer;
}
.sheet h3 { margin: 0 0 3px; font-size: 17px; padding-right: 28px; }
.sheet-sub { margin: 0 0 14px; font-size: 12.5px; color: var(--muted); }
.sheet-current { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.cur-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-2); border-radius: 9px; padding: 9px 11px;
  font-size: 13px;
}
.cur-row .fuel-name { font-weight: 700; min-width: 78px; }
.cur-row .cur-status { font-weight: 700; }
.cur-row .cur-status.ok { color: var(--ok); }
.cur-row .cur-status.queue { color: var(--queue); }
.cur-row .cur-status.out { color: var(--out); }
.cur-row .cur-status.unknown { color: var(--unknown); }
.cur-row .cur-age { margin-left: auto; font-size: 11px; color: var(--muted); text-align: right; }
.src-tag {
  font-size: 9.5px; font-weight: 800; letter-spacing: .4px;
  padding: 2px 5px; border-radius: 4px;
  background: rgba(255,122,26,.16); color: var(--accent);
}

.form-label { font-size: 12px; color: var(--muted); margin: 0 0 8px; text-transform: uppercase; letter-spacing: .6px; }
.form-label .req { color: var(--accent); }

.sheet-photos {
  display: flex; gap: 8px; overflow-x: auto; margin-bottom: 16px;
  padding-bottom: 4px;
}
.sheet-photos figure { margin: 0; flex: 0 0 auto; width: 118px; }
.sheet-photos img {
  width: 118px; height: 90px; object-fit: cover;
  border-radius: 9px; border: 1px solid var(--line); display: block;
}
.sheet-photos figcaption { font-size: 10.5px; color: var(--muted); margin-top: 4px; }

/* ---------- photo proof ---------- */
.photo-slot { margin-bottom: 14px; }
.photo-cta {
  width: 100%; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 18px 14px;
  background: var(--surface-2);
  border: 1.5px dashed var(--line);
  border-radius: 12px;
  color: var(--text);
  transition: border-color .15s ease, background .15s ease;
}
.photo-cta:hover { border-color: var(--accent); background: rgba(255,122,26,.07); }
.photo-icon { font-size: 26px; line-height: 1; }
.photo-cta-text { font-size: 14px; font-weight: 700; }
.photo-cta-sub { font-size: 11.5px; color: var(--muted); }

.photo-preview { margin-bottom: 14px; }
.photo-preview img {
  width: 100%; max-height: 210px; object-fit: cover;
  border-radius: 12px; border: 1px solid var(--line); display: block;
}
.photo-meta {
  display: flex; align-items: center; gap: 10px;
  margin-top: 7px; font-size: 11.5px; color: var(--muted);
}
.photo-meta .btn { margin-left: auto; }
.photo-busy { font-size: 12.5px; color: var(--muted); text-align: center; padding: 14px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 10px; }
.chip {
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  padding: 8px 13px; border-radius: 999px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.chip.selected { border-color: var(--accent); background: rgba(255,122,26,.15); color: var(--accent); }
.chip.status.selected[data-status="available"] { border-color: var(--ok); background: rgba(34,197,94,.16); color: var(--ok); }
.chip.status.selected[data-status="queue"]     { border-color: var(--queue); background: rgba(245,166,35,.16); color: var(--queue); }
.chip.status.selected[data-status="out"]       { border-color: var(--out); background: rgba(239,68,68,.16); color: var(--out); }
.status-row { margin-bottom: 12px; }
.input {
  width: 100%; padding: 11px 12px; margin-bottom: 12px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 10px; color: var(--text); font-size: 13.5px;
}
.form-hint { font-size: 11.5px; color: var(--muted); margin: 8px 0 0; text-align: center; }

/* ---------- compose modal (Facebook-style post box) ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 1500; }
.modal {
  position: fixed; z-index: 1600;
  left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(520px, calc(100% - 24px));
  max-height: 90vh;
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 24px 70px rgba(0,0,0,.55);
  overflow: hidden;
}
.modal-head {
  display: flex; align-items: center; justify-content: center;
  padding: 14px 16px; border-bottom: 1px solid var(--line); position: relative;
}
.modal-head h3 { margin: 0; font-size: 16.5px; }
.modal-close {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--surface-2); border: none; color: var(--muted);
  font-size: 21px; line-height: 1; cursor: pointer;
}
.modal-body { padding: 16px; overflow-y: auto; flex: 1; }
.modal-foot { padding: 12px 16px 16px; border-top: 1px solid var(--line); }

/* location primer */
.geo-primer { width: min(400px, calc(100% - 24px)); }
.geo-body { padding: 26px 22px 22px; text-align: center; }
.geo-icon { font-size: 40px; line-height: 1; margin-bottom: 10px; }
.geo-primer h3 { margin: 0 0 8px; font-size: 19px; }
.geo-text { margin: 0 0 16px; font-size: 13.5px; color: var(--muted); line-height: 1.5; }
.geo-text b { color: var(--text); }
.geo-points {
  list-style: none; margin: 0 0 20px; padding: 0;
  text-align: left; display: flex; flex-direction: column; gap: 9px;
}
.geo-points li {
  font-size: 12.5px; color: var(--text); line-height: 1.4;
  background: var(--surface-2); border-radius: 9px; padding: 9px 11px;
}
.geo-primer .btn-block + .btn-block { margin-top: 8px; }
.geo-primer .form-hint { margin-top: 12px; }

.author { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; font-size: 19px;
}
.author-name { margin: 0; font-size: 14px; font-weight: 700; }
.author-meta { margin: 1px 0 0; font-size: 11px; color: var(--muted); }

.picker-geo {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: rgba(255,122,26,.1); border: 1px solid rgba(255,122,26,.35);
  border-radius: 10px; padding: 10px 12px; margin-bottom: 10px;
  font-size: 12.5px; color: var(--text);
}
.picker-geo span { flex: 1; min-width: 180px; }
.picker-head {
  margin: 0 0 6px; font-size: 11px; font-weight: 700;
  letter-spacing: .5px; text-transform: uppercase; color: var(--muted);
}

/* pick-a-station map */
.picker-map-wrap { position: relative; margin-bottom: 12px; }
#picker-map {
  height: 230px; border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  z-index: 0;                 /* keep Leaflet panes under the modal chrome */
}
.picker-map-hint {
  position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%);
  z-index: 500; pointer-events: none;
  background: rgba(15,20,25,.82); color: #fff;
  font-size: 11px; font-weight: 600;
  padding: 4px 10px; border-radius: 999px;
  white-space: nowrap;
}
/* station pins inside the picker */
.pick-pin {
  width: 30px; height: 30px; border-radius: 50%;
  background: #fff; border: 2px solid rgba(255,255,255,.9);
  box-shadow: 0 2px 6px rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: transform .12s ease;
}
.pick-pin:hover { transform: scale(1.15); }
.pick-pin.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(255,122,26,.35), 0 2px 6px rgba(0,0,0,.45);
  transform: scale(1.2);
}
.pick-label {
  background: rgba(15,20,25,.9); color: #fff;
  font-size: 10.5px; font-weight: 700;
  padding: 2px 6px; border-radius: 5px; white-space: nowrap;
  border: none; box-shadow: none;
}
.pick-label::before { display: none; }

/* No inner scroll: a scroll region inside a scrolling modal is miserable to
   use. The map covers browsing; this list stays short. */
.picker-list { list-style: none; margin: 0 0 12px; padding: 0; }
.picker-more {
  padding: 8px 11px; font-size: 11.5px; color: var(--muted);
  text-align: center; cursor: default;
}
.picker-more:hover { background: none; }
.picker-list li {
  padding: 9px 11px; border-radius: 9px; cursor: pointer;
  display: flex; align-items: center; gap: 8px; font-size: 13.5px;
}
.picker-list li:hover, .picker-list li.active { background: var(--surface-2); }
.picker-list .p-name { font-weight: 650; }
.picker-list .p-meta { font-size: 11.5px; color: var(--muted); margin-left: auto; text-align: right; }
.picker-list .p-km { color: var(--accent); font-size: 12.5px; }
.picker-empty { padding: 14px 4px; font-size: 12.5px; color: var(--muted); text-align: center; }

.chosen {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-2); border: 1px solid var(--accent);
  border-radius: 10px; padding: 10px 12px; margin-bottom: 12px;
}
.chosen-name { margin: 0; font-size: 14px; font-weight: 700; }
.chosen-meta { margin: 2px 0 0; font-size: 11.5px; color: var(--muted); }
.chosen .btn { margin-left: auto; }

.textarea {
  width: 100%; min-height: 92px; resize: vertical;
  padding: 12px; margin-bottom: 14px;
  background: transparent; border: 1px solid var(--line);
  border-radius: 10px; color: var(--text);
  font-size: 15px; font-family: inherit; line-height: 1.45;
}
.textarea::placeholder { color: var(--muted); }
.textarea:focus, .input:focus { outline: none; border-color: var(--accent); }
.modal .form-label { margin-top: 4px; }
.modal-foot .form-hint { margin: 0 0 10px; }

/* locate control on the map */
.leaflet-control.locate-ctrl { border: none; box-shadow: none; }
.locate-ctrl button {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); font-size: 18px; cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,.3);
  display: flex; align-items: center; justify-content: center;
}
.locate-ctrl button.busy { opacity: .55; }
.locate-ctrl button.on { color: var(--accent); border-color: var(--accent); }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line); border-left: 4px solid var(--accent);
  padding: 12px 18px; border-radius: 10px; font-size: 13.5px;
  z-index: 2000; box-shadow: 0 8px 30px rgba(0,0,0,.4);
  max-width: 90vw;
}
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--out); }

.attrib {
  padding: 8px 16px; font-size: 10.5px; color: var(--muted);
  background: var(--surface); border-top: 1px solid var(--line); text-align: center;
}

/* ---------- mobile ---------- */
@media (max-width: 780px) {
  .layout { flex-direction: column; height: auto; }
  #map { height: 52vh; min-height: 300px; }
  .sidebar { width: 100%; flex: 1 1 auto; border-left: none; border-top: 1px solid var(--line); max-height: none; }
  .station-list { overflow-y: visible; }
  .tagline { display: none; }
  .stat { margin-left: 0; width: 100%; }
  .sheet { top: auto; bottom: 0; left: 0; transform: none; width: 100%;
           border-radius: 18px 18px 0 0; max-height: 92vh; }
  .modal { top: auto; bottom: 0; left: 0; transform: none; width: 100%;
           border-radius: 18px 18px 0 0; max-height: 94vh; }
}
