:root {
  --color-bg: #f1f5f9;
  --color-surface: #ffffff;
  --color-surface-alt: #f8fafc;
  --color-border: #e2e8f0;
  --color-text: #1e293b;
  --color-text-muted: #94a3b8;
  --color-accent: #fbbf24;
  --color-accent-hover: #f59e0b;
  --color-accent-soft: #fffbeb;
  --color-accent-text: #1e1400;
  --color-success: #10b981;
  --color-success-soft: #ecfdf5;
  --color-danger: #f43f5e;
  --color-danger-soft: #fff1f2;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 3px rgba(30, 41, 59, 0.06);
  --shadow-md: 0 8px 24px rgba(251, 191, 36, 0.18);
  --font-heading: "Fraunces", Georgia, serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
}

h1 {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  margin: 0 0 0.75rem;
}

/* --- App shell: the white "card" everything sits on, edge-to-edge on
   phones (installed PWA look) and a centered rounded card on wider
   screens, matching the desktop preview in the mockup. --- */

.app-shell {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
}

.wrap {
  flex: 1;
  overflow-y: auto;
  padding: 1.15rem 1.2rem 1.75rem;
}

/* --- Persistent app header --- */

.app-header {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1.15rem 1.2rem;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

@media (min-width: 640px) {
  body {
    padding: 24px;
    align-items: center;
  }
  .app-shell {
    min-height: 0;
    max-height: 90vh;
    border-radius: 24px;
    border: 1px solid var(--color-border);
    box-shadow: 0 20px 45px rgba(30, 41, 59, 0.12);
    overflow: hidden;
  }
}

.app-header .app-icon {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: var(--color-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.app-header .app-titles h1 {
  margin: 0;
  font-size: 1.1rem;
  font-family: var(--font-body);
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.25;
}

.app-header .app-titles p {
  margin: 0.15rem 0 0;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  font-weight: 500;
}

nav.tabbar {
  flex-shrink: 0;
  display: flex;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: 0.4rem 0 calc(0.4rem + env(safe-area-inset-bottom));
}

nav.tabbar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  text-align: center;
  text-decoration: none;
  color: var(--color-text-muted);
  font-size: 0.68rem;
  font-weight: 500;
  padding: 0.3rem 0.1rem;
  min-width: 0;
}

nav.tabbar a[hidden] {
  display: none;
}

nav.tabbar .tab-icon {
  font-size: 1.05rem;
  line-height: 1;
}

nav.tabbar .tab-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

nav.tabbar a.active {
  color: var(--color-accent-hover);
  font-weight: 700;
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1rem 1.1rem;
  margin-bottom: 0.9rem;
  box-shadow: var(--shadow-sm);
}

.meta {
  color: var(--color-text-muted);
  font-size: 0.88rem;
}

.error {
  background: var(--color-danger-soft);
  color: #9f1239;
  border: 1px solid #fecdd3;
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.9rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

label {
  display: block;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

input, textarea, select {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.6rem 0.75rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  text-transform: none;
  letter-spacing: normal;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--color-accent);
}

.row {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}
.row > * {
  flex: 1;
}

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0.65rem 1.3rem;
  border-radius: 999px;
  border: 1px solid var(--color-accent);
  background: var(--color-accent);
  color: var(--color-accent-text);
  cursor: pointer;
  margin-top: 1.1rem;
  text-decoration: none;
}
button:hover, .btn:hover {
  background: var(--color-accent-hover);
  border-color: var(--color-accent-hover);
}

button.secondary, .btn.secondary {
  background: transparent;
  color: var(--color-text);
  border-color: var(--color-border);
  font-weight: 500;
}

button.small, .btn.small {
  padding: 0.35rem 0.8rem;
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

.hub-btn {
  display: flex;
  width: 100%;
  margin-top: 1rem;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.6rem;
}
.checkbox-row input {
  width: auto;
  margin-top: 0;
}

.center-note {
  text-align: center;
  color: var(--color-text-muted);
  margin-top: 3rem;
}

/* --- Order screen: route card --- */

.route-card {
  position: relative;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.2rem;
  margin-top: 0.3rem;
}

.route-card .swap-btn {
  position: absolute;
  right: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  cursor: pointer;
  margin: 0;
  padding: 0;
}
.route-card .swap-btn:hover {
  color: var(--color-accent-hover);
  border-color: var(--color-accent);
  background: var(--color-surface);
}

.route-point {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding-right: 2.6rem;
}
/* A dedicated class instead of `.route-point + .route-point`: the empty
   #stops-container sits between pickup and dropoff in the DOM, breaking
   adjacent-sibling matching whenever there are zero stops - which made
   "Откуда"/"Куда" render with no divider between them at all. */
.route-point.with-divider {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--color-border);
}

.route-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--color-success);
  box-shadow: 0 0 0 4px var(--color-success-soft);
}
.route-dot.dropoff {
  border-radius: 3px;
  background: var(--color-danger);
  box-shadow: 0 0 0 4px var(--color-danger-soft);
}
.route-dot.stop {
  width: 9px;
  height: 9px;
  background: var(--color-accent);
  box-shadow: none;
}

.route-point .field {
  flex: 1;
  min-width: 0;
}
.route-point .field-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.2rem;
}
.route-point input {
  border: none;
  background: transparent;
  padding: 0;
  margin-top: 0;
  font-weight: 600;
  font-size: 0.95rem;
}
.route-point input:focus {
  outline: none;
}
.route-point .icon-btn {
  flex-shrink: 0;
  margin: 0;
  padding: 0.3rem 0.5rem;
  font-size: 0.85rem;
  border-radius: 8px;
}

.quick-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.9rem;
  gap: 0.5rem;
}
.quick-row button {
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-text);
  border-radius: 0;
}
.quick-row button:hover {
  background: none;
  color: var(--color-accent-hover);
}
.quick-row .plus-badge {
  display: inline-flex;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-border);
  color: var(--color-text);
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  margin-right: 0.35rem;
}

/* --- Category cards (real service categories, replaces fake priced tariffs) --- */

.category-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.7rem;
  margin-top: 0;
}

.category-card {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 92px;
  padding: 1rem 0.5rem;
  border-radius: var(--radius-md);
  border: 2px solid var(--color-border);
  background: var(--color-surface);
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}
.category-card .icon {
  font-size: 1.9rem;
  line-height: 1;
  display: block;
  margin-bottom: 0.5rem;
}
.category-card .label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-text);
}
.category-card.active {
  border-color: var(--color-accent);
  background: var(--color-accent-soft);
}

/* --- Quick comment chips --- */

.chips-row {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.15rem 0.1rem 0.5rem;
  margin-top: 0;
}
.chip {
  flex-shrink: 0;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text);
  cursor: pointer;
  white-space: nowrap;
}
.chip.active {
  border-color: var(--color-accent);
  background: var(--color-accent-soft);
  color: #92620a;
}

.submit-cta {
  width: 100%;
  margin-top: 1.3rem;
  padding: 0.95rem 1.3rem;
  font-size: 1rem;
  box-shadow: var(--shadow-md);
}

.map-picker-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  flex-direction: column;
  background: var(--color-bg);
}
.map-picker-overlay:not([hidden]) {
  display: flex;
}

.map-picker-map {
  flex: 1;
}

.map-picker-status {
  padding: 0.6rem 0.9rem;
  background: var(--color-danger-soft);
  color: #9f1239;
  font-size: 0.85rem;
  border-top: 1px solid #fecdd3;
}

.map-picker-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  padding: 0.8rem;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
}
.map-picker-actions button {
  flex: 1 1 auto;
  min-width: 40%;
}
.map-picker-actions button {
  flex: 1;
  margin-top: 0;
}

/* --- Rides screen: filter tabs + ride history cards --- */

.rides-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.9rem;
}
.rides-header h1 {
  margin: 0;
}

.segmented {
  display: flex;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  padding: 0.2rem;
  border-radius: 11px;
  gap: 0.15rem;
  flex-shrink: 0;
}
.segmented-btn {
  border: none;
  background: none;
  margin: 0;
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-text-muted);
  border-radius: 8px;
  cursor: pointer;
}
.segmented-btn:hover {
  background: none;
  color: var(--color-text);
}
.segmented-btn.active {
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
}

.ride-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 0.9rem;
  box-shadow: var(--shadow-sm);
}
.ride-card.active {
  border: 2px solid var(--color-accent);
}

.ride-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding-bottom: 0.7rem;
  margin-bottom: 0.9rem;
  border-bottom: 1px solid var(--color-border);
}
.ride-card-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}
.ride-card-title .icon {
  font-size: 1.3rem;
  flex-shrink: 0;
}
.ride-card-title .name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-text);
}
.ride-card-title .date {
  font-size: 0.72rem;
  color: var(--color-text-muted);
}

.ride-status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}
.ride-status .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  animation: ride-status-pulse 1.4s ease-in-out infinite;
}
.ride-status.status-pending {
  background: var(--color-surface-alt);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}
.ride-status.status-pending .dot {
  background: var(--color-text-muted);
}
.ride-status.status-accepted {
  background: var(--color-accent-soft);
  color: #92620a;
  border: 1px solid #fde68a;
}
.ride-status.status-accepted .dot {
  background: var(--color-accent-hover);
}
.ride-status.status-completed {
  background: var(--color-success-soft);
  color: #067a55;
  border: 1px solid #a7f3d0;
}
.ride-status.status-cancelled {
  background: var(--color-danger-soft);
  color: #9f1239;
  border: 1px solid #fecdd3;
}

@keyframes ride-status-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.ride-route {
  position: relative;
  margin-bottom: 0.9rem;
}
.ride-route-line {
  position: absolute;
  left: 5px;
  top: 10px;
  bottom: 10px;
  border-left: 2px dashed var(--color-border);
}
.ride-point {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding-left: 1.35rem;
  min-height: 1.5rem;
}
.ride-point + .ride-point {
  margin-top: 0.5rem;
}
.ride-point .route-dot {
  position: absolute;
  left: 0;
}
.ride-point-text {
  flex: 1;
  min-width: 0;
}
.ride-point-text .label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--color-text);
}
.ride-point-text .coords {
  font-size: 0.72rem;
  font-weight: 600;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  color: var(--color-text-muted);
}
.ride-point-text .address {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--color-text-muted);
}
.ride-point .map-link {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--color-accent-hover);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.ride-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--color-border);
}
.ride-price {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--color-text);
}
.ride-payment {
  font-size: 0.68rem;
  font-weight: 700;
}
.ride-payment.paid {
  color: #067a55;
}
.ride-payment.unpaid {
  color: var(--color-danger);
}
.ride-card-footer button {
  margin-top: 0;
}
