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

:root {
  --primary-from: #7882ff;
  --primary-to: #09ff8c;
  --primary: #20c07a;
  --primary-dark: #17a368;
  --bg: #f5f7fa;
  --card-bg: #ffffff;
  --text: #1a1a2e;
  --text-secondary: #6b7280;
  --border: #e5e7eb;
  --error: #ef4444;
  --success: #10b981;
  --shadow: 0 2px 16px rgba(0,0,0,0.08);
  --radius: 16px;
  --radius-sm: 10px;
}

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

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

header {
  background: linear-gradient(107.56deg, var(--primary-from) 0%, var(--primary-to) 100%);
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  z-index: 1000;
  min-height: 56px;
  flex-shrink: 0;
}

header h1 {
  font-size: 18px;
  font-weight: 600;
  flex: 1;
}

.back-btn {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.9;
  transition: opacity 0.2s;
  flex-shrink: 0;
}

.back-btn:hover { opacity: 1; }

.progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(255,255,255,0.3);
}

.progress-bar {
  height: 100%;
  background: #fff;
  transition: width 0.4s ease;
  width: 0%;
}

/* Screens */
#content {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
}

.screen.active {
  opacity: 1;
  visibility: visible;
}

/* Modal screens (bottom sheet style) */
.modal-screen {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease;
}

.modal-screen.active {
  opacity: 1;
  visibility: visible;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
}

.modal-sheet {
  position: relative;
  background: var(--card-bg);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 16px 24px;
  transform: translateY(100%);
  transition: transform 0.3s ease;
  -webkit-overflow-scrolling: touch;
}

.modal-screen.active .modal-sheet {
  transform: translateY(0);
}

.modal-handle {
  width: 36px;
  height: 4px;
  background: #d1d5db;
  border-radius: 2px;
  margin: 0 auto 12px;
  flex-shrink: 0;
}

.processing-sheet,
.result-sheet {
  padding-bottom: 32px;
}

/* Map */
#map {
  width: 100%;
  height: 100%;
}

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

.leaflet-popup-content {
  margin: 12px 16px;
  font-size: 14px;
}

.wash-popup h3 {
  font-size: 15px;
  margin-bottom: 4px;
}

.wash-popup .status {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.wash-popup .status.active { color: var(--success); }
.wash-popup .status.maintenance { color: var(--error); }

.wash-popup .select-btn {
  display: inline-block;
  padding: 6px 20px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.wash-popup .select-btn:hover { background: var(--primary-dark); }

.custom-marker {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-from), var(--primary-to));
  border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
}

.custom-marker.closed {
  background: #9ca3af;
}

/* Cards */
.card-container {
  padding: 16px;
  max-width: 480px;
  margin: 0 auto;
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.modal-sheet .card {
  box-shadow: none;
  border-radius: 0;
  padding: 4px 0;
}

.card h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 16px;
}

/* Nearby screen */
.nearby-sheet {
  display: flex;
  flex-direction: column;
  padding: 8px 0 0;
  max-height: 65vh;
}

.nearby-header {
  padding: 0 16px 12px;
  flex-shrink: 0;
}

.nearby-header h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 4px;
}

.nearby-header p {
  font-size: 13px;
  color: var(--text-secondary);
}

.nearby-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 16px;
}

.nearby-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 8px;
}

.nearby-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  background: var(--card-bg);
}

.nearby-item:hover { border-color: var(--primary); }
.nearby-item.selected { border-color: var(--primary); background: #f0fdf4; }

.nearby-item .item-index {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.nearby-item.selected .item-index {
  background: var(--primary);
  color: #fff;
}

.nearby-item .item-info {
  flex: 1;
  min-width: 0;
}

.nearby-item .item-name {
  font-weight: 600;
  font-size: 15px;
}

.nearby-item .item-address {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nearby-item .item-distance {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}

.nearby-item.selected .item-distance {
  color: var(--primary);
  font-weight: 600;
}

.nearby-footer {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--card-bg);
}

.nearby-footer .btn {
  flex: 1;
}

/* Select screen */
.wash-head {
  margin-bottom: 16px;
}

.wash-head h2 {
  margin-bottom: 4px;
}

.wash-head .wash-address {
  font-size: 14px;
  color: var(--text-secondary);
}

.post-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.post-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  background: var(--card-bg);
}

.post-item:hover { border-color: var(--primary); }
.post-item.selected { border-color: var(--primary); background: #f0fdf4; }
.post-item.busy, .post-item.closed { opacity: 0.5; cursor: not-allowed; }

.post-list.has-selected .post-item:not(.selected) {
  display: none;
}

.post-item .post-name {
  font-weight: 500;
}

.post-item .post-status {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 500;
}

.post-status.free { background: #dcfce7; color: #166534; }
.post-status.busy { background: #fef3c7; color: #92400e; }
.post-status.closed { background: #fee2e2; color: #991b1b; }

/* Amount selector — vertical progress bar */
.amount-section-vertical {
  margin-top: 16px;
  padding: 20px 16px 16px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

.amount-section-vertical label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  text-align: center;
}

.vslider-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  height: 200px;
}

.vslider-track {
  position: relative;
  width: 6px;
  height: 100%;
  background: #e0e0e0;
  border-radius: 3px;
  cursor: pointer;
  touch-action: none;
}

.vslider-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background: linear-gradient(to top, var(--primary-from), var(--primary-to));
  border-radius: 3px;
  pointer-events: none;
}

.vslider-thumb {
  position: absolute;
  left: 50%;
  z-index: 2;
  width: 28px;
  height: 28px;
  background: var(--primary);
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  cursor: grab;
  transform: translate(-50%, 50%);
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.vslider-thumb:active {
  cursor: grabbing;
}

.vslider-value {
  position: absolute;
  left: 40px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  background: var(--card-bg);
  padding: 2px 10px;
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  pointer-events: none;
}

.vslider-labels {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  padding: 2px 0;
}

.vslider-stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 16px;
}

.step-btn {
  width: 44px;
  height: 44px;
  border: 2px solid var(--border);
  border-radius: 50%;
  background: var(--card-bg);
  font-size: 22px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  color: var(--text);
}

.step-btn:hover { border-color: var(--primary); color: var(--primary); }
.step-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.step-value {
  font-size: 18px;
  font-weight: 700;
  min-width: 80px;
  text-align: center;
}

.amount-hint {
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
  margin-top: 12px;
}

.osm-attrib {
  font-size: 9px;
  opacity: 0.6;
}

.list-btn {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 4px;
  display: flex;
  opacity: 0.85;
  transition: opacity 0.2s;
  flex-shrink: 0;
}

.list-btn:hover { opacity: 1; }

body.modal-open .list-btn {
  display: none;
}

body.modal-open .leaflet-control-attribution {
  display: none;
}

body.modal-open .leaflet-control-zoom {
  z-index: 1 !important;
}

body.modal-open .leaflet-top,
body.modal-open .leaflet-bottom {
  z-index: 400 !important;
}

.select-footer {
  margin-top: 16px;
  display: flex;
  gap: 10px;
}

.select-footer .btn {
  flex: 1;
}

/* Info */
.info-card .form-group {
  margin-bottom: 16px;
}

.info-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  margin-top: -8px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px;
  transition: border-color 0.2s;
  background: var(--card-bg);
  color: var(--text);
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
}

.form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}

.hint {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Buttons */
.btn {
  padding: 14px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

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

.btn.primary {
  background: linear-gradient(135deg, var(--primary-from), var(--primary-to));
  color: #fff;
}

.btn.primary:hover:not(:disabled) {
  opacity: 0.9;
}

.btn.secondary {
  background: var(--bg);
  color: var(--text);
}

.btn.secondary:hover:not(:disabled) {
  background: var(--border);
}

/* Payment methods */
.payment-methods {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.payment-method {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  background: var(--card-bg);
}

.payment-method:hover { border-color: var(--primary); }
.payment-method.selected { border-color: var(--primary); background: #f0fdf4; }

.payment-method .method-icon {
  font-size: 24px;
  width: 36px;
  text-align: center;
}

.payment-method .method-name {
  font-weight: 500;
}

.payment-summary {
  padding: 14px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

.payment-details {
  font-size: 14px;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.payment-details .amount-line {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

/* Processing */
.processing-card {
  text-align: center;
  padding: 48px 20px;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Result */
.result-card {
  text-align: center;
  padding: 40px 20px;
}

.result-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
}

.result-icon.success {
  background: #dcfce7;
  color: var(--success);
}

.result-icon.error {
  background: #fee2e2;
  color: var(--error);
}

.result-icon.info {
  background: #e0f2fe;
  color: #3b82f6;
}

.result-card h2 {
  margin-bottom: 8px;
}

.result-card p {
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.result-details {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 12px 0 24px;
  padding: 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

#payBtn, #infoNextBtn {
  width: 100%;
}

/* Input validation */
.form-input.error {
  border-color: var(--error);
}

.error-text {
  color: var(--error);
  font-size: 12px;
  margin-top: 4px;
}

/* Notify error */
.notify-error {
  padding: 12px 16px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  color: var(--error);
  font-size: 14px;
  margin-bottom: 12px;
}
