:root {
  color-scheme: light;
  --bg: #eef3f7;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-strong: #ffffff;
  --text: #132238;
  --muted: #5f6f82;
  --border: rgba(19, 34, 56, 0.08);
  --shadow: 0 18px 40px rgba(19, 34, 56, 0.12);
  --available: #2fb365;
  --few: #f0b429;
  --busy: #df4c4c;
  --offline: #7d8a97;
  --accent: #1f6feb;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: var(--bg);
  color: var(--text);
}

body {
  min-height: 100vh;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 8px;
  pointer-events: none;
}

.topbar > * {
  pointer-events: auto;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.toolbar-btn {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--text);
  padding: 9px 14px;
  font-weight: 600;
  font-size: 0.85rem;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.toolbar-btn:hover {
  border-color: rgba(31, 111, 235, 0.35);
}

.topbar h1,
.section-heading h2 {
  margin: 0;
  font-size: 1.1rem;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.8rem;
}

.locate-btn {
  border: 0;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--text);
  padding: 10px 14px;
  font-weight: 600;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.map-layout {
  min-height: 100vh;
}

.map-panel {
  position: relative;
  min-height: 100vh;
}

.map-auth-gate {
  display: none;
  position: fixed;
  top: 72px;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9998;
  box-sizing: border-box;
  padding: 72px 20px 24px;
  align-items: center;
  justify-content: flex-start;
  flex-direction: column;
  gap: 12px;
  background: rgba(19, 34, 56, 0.52);
  backdrop-filter: blur(3px);
  pointer-events: auto;
}

.app-shell.auth-locked .map-auth-gate {
  display: flex;
}

.app-shell.auth-locked #map,
.app-shell.auth-locked .bottom-sheet {
  pointer-events: none;
}

.app-shell.auth-locked .bottom-sheet {
  opacity: 0.75;
}

.map-auth-gate-text {
  margin: 0;
  max-width: 360px;
  text-align: center;
  color: #fff;
  font-size: 0.95rem;
  line-height: 1.45;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

/* Кнопки вынесены в `document.body`, чтобы затемнение карты не перекрывало авторизацию */
.map-floating-toolbar {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top, 0px));
  right: calc(12px + env(safe-area-inset-right, 0px));
  z-index: 2147483000;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  pointer-events: auto;
}

.map-floating-toolbar .map-account-btn,
.map-floating-toolbar .map-locate-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  pointer-events: auto;
  box-shadow: var(--shadow);
}

#map {
  height: 100vh;
  width: 100%;
  background: linear-gradient(180deg, #dfe8f3 0%, #eef3f7 100%);
}

#map .leaflet-control-attribution {
  display: none !important;
}

.map-message {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 1rem;
}

.legend {
  position: fixed;
  left: 16px;
  right: 16px;
  top: 88px;
  z-index: 980;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 8px;
  padding: 12px;
  border-radius: 18px;
  background: var(--surface);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  font-size: 0.85rem;
}

.legend span {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.available {
  background: var(--available);
}

.status-dot.few {
  background: var(--few);
}

.status-dot.busy {
  background: var(--busy);
}

.status-dot.offline {
  background: var(--offline);
}

.status-ring.booking-only-ring {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 3px solid #e07800;
  box-sizing: border-box;
  background: transparent;
}

.legend-booking {
  grid-column: span 2;
}

@media (min-width: 520px) {
  .legend-booking {
    grid-column: auto;
  }
}

.bottom-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 950;
  padding: 10px 14px calc(14px + env(safe-area-inset-bottom));
  background: var(--surface);
  backdrop-filter: blur(14px);
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  box-shadow: 0 -10px 40px rgba(19, 34, 56, 0.14);
  max-height: 42vh;
  overflow: hidden;
}

.bottom-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1cm;
  width: 100%;
  height: 20px;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #87cefa;
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
}

.sheet-handle {
  width: 48px;
  height: 5px;
  border-radius: 999px;
  background: #c7d0db;
  margin: 0 auto 12px;
}

.selected-card {
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px;
  margin-bottom: 12px;
}

.card-placeholder {
  margin: 0;
  color: var(--muted);
}

.station-search-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.station-search-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.station-search-input {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-strong);
  padding: 10px 12px;
  font-size: 0.92rem;
}

.station-search-actions {
  display: flex;
  gap: 8px;
}

.station-search-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.station-photo {
  display: block;
  width: 100%;
  max-height: 160px;
  object-fit: cover;
  border-radius: 12px;
  margin-bottom: 12px;
  background: #e2e8f0;
}

.station-coords {
  margin: 0 0 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.8rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.station-pills {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.venue-pill {
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.venue-pill.venue-open {
  background: rgba(47, 179, 101, 0.18);
  color: #1a7a45;
}

.venue-pill.venue-closed {
  background: rgba(125, 138, 151, 0.25);
  color: #4a5568;
}

.station-item-venue {
  font-size: 0.78rem !important;
  color: var(--text) !important;
  opacity: 0.85;
}

.map-popup-inner {
  min-width: 200px;
}

.map-popup-photo {
  display: block;
  width: 100%;
  max-width: 240px;
  height: auto;
  border-radius: 8px;
  margin-bottom: 8px;
  object-fit: cover;
  background: #e2e8f0;
}

.map-popup-title {
  display: block;
  margin-bottom: 6px;
  font-size: 0.95rem;
}

.map-popup-meta {
  font-size: 0.82rem;
  color: #3d4f63;
  margin-bottom: 4px;
}

.map-popup-booking {
  color: #a15a00;
  font-weight: 700;
}

.map-popup-coords {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.75rem;
  color: #5f6f82;
  margin-bottom: 6px;
  word-break: break-all;
}

.map-popup-hoses-wrap {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(19, 34, 56, 0.08);
}

.map-popup-hoses-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.map-popup-hoses {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 160px;
  overflow: auto;
  font-size: 0.78rem;
}

.map-popup-hoses .hose-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 0;
  border-bottom: 1px solid rgba(19, 34, 56, 0.06);
}

.map-popup-hoses .hose-row:last-child {
  border-bottom: 0;
}

.hose-num {
  color: var(--muted);
  font-weight: 600;
}

.hose-status-pill {
  flex-shrink: 0;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

.hose-status-pill.hose-status--available {
  background: rgba(47, 179, 101, 0.18);
  color: #1a7a45;
}

.hose-status-pill.hose-status--occupied {
  background: rgba(223, 76, 76, 0.16);
  color: #b12d2d;
}

.hose-status-pill.hose-status--faulty {
  background: rgba(125, 138, 151, 0.22);
  color: #4b5563;
}

.hose-status-pill.hose-status--reserved {
  background: rgba(240, 180, 41, 0.22);
  color: #8a5a00;
}

.hose-status-pill.hose-status--mine {
  background: rgba(31, 111, 235, 0.18);
  color: #1450b8;
}

.station-hoses-block {
  margin-top: 12px;
}

.station-hoses-heading {
  margin: 0 0 8px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
}

.station-hose-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.station-hose-list .hose-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(19, 34, 56, 0.04);
  border: 1px solid var(--border);
}

.venue-tag {
  font-weight: 700;
  font-size: 0.8rem;
}

.venue-tag.venue-open {
  color: #1a7a45;
}

.venue-tag.venue-closed {
  color: #6b7280;
}

.leaflet-popup-content-wrapper {
  border-radius: 14px;
}

.station-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.station-title-row h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.station-meta,
.station-address,
.station-connectors {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.status-pill {
  padding: 6px 10px;
  border-radius: 999px;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill.available {
  background: var(--available);
}

.status-pill.few {
  background: var(--few);
}

.status-pill.busy {
  background: var(--busy);
}

.status-pill.offline {
  background: var(--offline);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.section-heading span {
  color: var(--muted);
  font-size: 0.9rem;
}

.station-list {
  display: grid;
  gap: 10px;
  max-height: calc(42vh - 170px);
  overflow: auto;
  padding-bottom: 6px;
}

.app-shell.station-focused .station-list-section {
  display: none;
}

.app-shell.station-focused .bottom-sheet {
  max-height: 88vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: calc(40px + env(safe-area-inset-bottom));
}

.app-shell.station-focused .selected-card {
  margin-bottom: 0;
  max-height: none;
  overflow: visible;
}

.selected-card-top-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}

.station-item {
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-strong);
  padding: 12px;
  cursor: pointer;
}

.station-item.active {
  border-color: rgba(31, 111, 235, 0.35);
  box-shadow: 0 8px 20px rgba(31, 111, 235, 0.12);
}

.station-item h3 {
  margin: 0 0 6px;
  font-size: 0.95rem;
}

.station-item p {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.station-item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 6px;
}

.tag-mini {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(224, 120, 0, 0.15);
  color: #a15a00;
}

.booking-only-notice {
  margin: 0 0 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(224, 120, 0, 0.12);
  border: 1px solid rgba(224, 120, 0, 0.35);
  color: #6b3d00;
  font-size: 0.82rem;
  line-height: 1.35;
}

.route-panel {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.route-status {
  margin: 0;
  font-size: 0.82rem;
}

.primary-btn {
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  padding: 10px 14px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
}

.primary-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.secondary-btn {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-strong);
  padding: 8px 14px;
  font-weight: 600;
  cursor: pointer;
}

.hose-row--card {
  flex-direction: column;
  align-items: stretch !important;
}

.hose-row-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.hose-row-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}

.hose-btn {
  border: 0;
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.hose-btn-book {
  background: rgba(31, 111, 235, 0.15);
  color: #1450b8;
}

.hose-btn-cancel {
  background: rgba(223, 76, 76, 0.14);
  color: #b12d2d;
}

.hose-muted {
  font-size: 0.75rem;
  color: var(--muted);
}

.app-dialog {
  z-index: 2147483647;
  border: none;
  border-radius: 18px;
  padding: 0;
  max-width: min(420px, calc(100vw - 24px));
  box-shadow: var(--shadow);
}

.app-dialog.force-open {
  display: block;
  position: fixed;
  top: 50%;
  left: 50%;
  width: min(420px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow: auto;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  margin: 0;
  transform: translate(-50%, -50%);
  z-index: 2147483647 !important;
}

.app-dialog::backdrop {
  background: rgba(19, 34, 56, 0.45);
}

.dialog-surface {
  padding: 0;
  margin: 0;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.dialog-head h2 {
  margin: 0;
  font-size: 1.05rem;
}

.icon-close {
  border: 0;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 4px 8px;
}

.dialog-hint {
  margin: 0 0 12px;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
}

#accountGuestBlock,
#accountUserBlock {
  padding: 14px 16px 18px;
}

.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

.tab {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  background: var(--surface-strong);
  font-weight: 600;
  cursor: pointer;
}

.tab.active {
  border-color: rgba(31, 111, 235, 0.45);
  background: rgba(31, 111, 235, 0.08);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
  font-size: 0.82rem;
  color: var(--muted);
}

.field input {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 1rem;
}

.field select {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 1rem;
  background: var(--surface-strong);
}

.booking-dialog-body {
  padding: 14px 16px 18px;
}

.booking-time-line {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.84rem;
}

.form-error {
  color: #b12d2d;
  font-size: 0.82rem;
  margin: 0 0 8px;
}

.form-success {
  color: #1a7a45;
  font-size: 0.82rem;
  margin: 0 0 8px;
  font-weight: 600;
}

.app-toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 2147483647;
  background: rgba(26, 122, 69, 0.96);
  color: #fff;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 0.9rem;
  font-weight: 700;
  box-shadow: var(--shadow);
}

.booking-bottom-notice {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2147483647;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  text-align: center;
  background: #1a7a45;
  color: #fff;
  font-weight: 700;
  font-size: 0.92rem;
  box-shadow: 0 -8px 22px rgba(19, 34, 56, 0.24);
}

.dialog-user-line {
  margin: 0 0 10px;
  font-size: 0.9rem;
}

.dialog-subtitle {
  margin: 16px 0 8px;
  font-size: 0.9rem;
}

.bookings-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
}

.booking-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.82rem;
  background: rgba(19, 34, 56, 0.03);
}

.booking-card strong {
  display: block;
  margin-bottom: 4px;
}

.station-info-body {
  padding: 14px 16px 18px;
}

.station-info-dl {
  margin: 0;
  display: grid;
  gap: 12px;
}

.station-info-dl dt {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.station-info-dl dd {
  margin: 2px 0 0;
  font-size: 0.95rem;
  line-height: 1.4;
  color: var(--text);
}

.station-info-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.82rem !important;
  color: var(--muted) !important;
  word-break: break-all;
}

.leaflet-route-line {
  stroke: #1f6feb;
  stroke-width: 5;
  stroke-opacity: 0.85;
}

.custom-marker-wrap {
  position: relative;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
}

.custom-marker-wrap.marker-booking-only::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 2px solid #e07800;
  pointer-events: none;
}

.custom-marker {
  width: 22px;
  height: 22px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid #fff;
  box-shadow: 0 4px 12px rgba(19, 34, 56, 0.18);
}

.custom-marker.available {
  background: var(--available);
}

.custom-marker.few {
  background: var(--few);
}

.custom-marker.busy {
  background: var(--busy);
}

.custom-marker.offline {
  background: var(--offline);
}

.cluster-badge {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(31, 111, 235, 0.92);
  color: #fff;
  font-weight: 700;
  border: 3px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 8px 22px rgba(19, 34, 56, 0.2);
}

@media (min-width: 900px) {
  .bottom-sheet {
    left: auto;
    top: 72px;
    right: 16px;
    bottom: 42px;
    width: 360px;
    max-height: none;
    border-radius: 24px;
  }

  .legend {
    top: 96px;
    right: auto;
    width: 300px;
  }

  .station-list {
    max-height: calc(100vh - 330px);
  }

  .app-shell.station-focused .selected-card {
    max-height: none;
  }
}
