:root {
  --color-primary: #1a7340;
  --color-primary-dark: #135430;
  --color-primary-light: #e8f5ee;
  --color-walk: #4a90d9;
  --color-cycle: #27ae60;
  --color-walk2: #e67e22;
  --color-surface: #ffffff;
  --color-bg: #f0f2f5;
  --color-text: #1a1a2e;
  --color-text-muted: #6b7280;
  --color-border: #e5e7eb;
  --color-error-bg: #fef2f2;
  --color-error: #dc2626;
  --color-bikes: #16a34a;
  --color-stands: #2563eb;
  --radius: 8px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
}

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 14px;
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

/* Viewport lock — height = 100vh - nav - footer */
:root {
  --nav-h: 64px;
  --footer-h: 56px;
}

html:has(#app),
body:has(#app) {
  height: 100%;
  overflow: hidden;
}

body:has(#app) {
  display: flex;
  flex-direction: column;
}

main:has(#app) {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

main:has(#app) + .footer {
  margin-top: 0;
  flex-shrink: 0;
  height: var(--footer-h);
}

/* Layout */

#app {
  display: flex;
  height: calc(100vh - var(--nav-h) - var(--footer-h));
  overflow: hidden;
}

#sidebar {
  width: 380px;
  min-width: 320px;
  height: 100%;
  overflow-y: auto;
  background: var(--color-surface);
  box-shadow: 2px 0 12px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  z-index: 10;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

#map-container {
  flex: 1;
  height: 100%;
  position: relative;
}

#map {
  width: 100%;
  height: 100%;
}

/* Header */

header {
  background: var(--color-primary);
  color: white;
  padding: 18px 20px;
  flex-shrink: 0;
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-icon {
  font-size: 28px;
  line-height: 1;
}

header h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.subtitle {
  font-size: 12px;
  opacity: 0.8;
  margin-top: 2px;
}

/* Journey Form */

#journey-form {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid #e5e7eb;
  gap: 12px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.input-group label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
}

.input-group input {
  padding: 9px 12px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-surface);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
  width: 100%;
}

.input-group input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(26, 115, 64, 0.12);
}

.input-row {
  display: flex;
  gap: 10px;
}

.input-group.half {
  flex: 1;
}

.button-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

/* Buttons*/

.btn {
  padding: 9px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--color-primary);
  color: white;
  flex: 1;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: var(--color-primary-dark);
  box-shadow: var(--shadow-md);
}

.btn-primary:disabled {
  background: #9ca3af;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1.5px solid var(--color-border);
}

.btn-secondary:hover {
  background: var(--color-bg);
  border-color: #9ca3af;
}

.form-hint {
  margin: 10px 20px;
  font-size: 11px;
  color: #b0b7c3;
  line-height: 1.5;
}

/* Status / Error */

#status-message {
  margin: 12px 20px;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  background: var(--color-error-bg);
  color: var(--color-error);
  border: 1px solid #fecaca;
}

/* Panel Sections */

.panel-section {
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
}

.section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--color-text-muted);
  margin-bottom: 12px;
}

/* Route Summary */

.summary-stats {
  display: flex;
  gap: 12px;
}

.summary-stat {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--color-primary-light);
  padding: 10px 12px;
  border-radius: var(--radius);
}

.stat-icon {
  font-size: 20px;
  line-height: 1;
}

.stat-label {
  display: block;
  font-size: 11px;
  color: var(--color-text-muted);
}

.stat-value {
  display: block;
  font-size: 15px;
  font-weight: 700;
  color: var(--color-primary);
}

/* Station Cards */

.cards-row {
  display: flex;
  gap: 10px;
}

.station-card {
  flex: 1;
  border-radius: var(--radius);
  border: 1.5px solid var(--color-border);
  padding: 10px 12px;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.station-card:hover {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.predicted-label {
  position: absolute;
  bottom: 6px;
  right: 10px;
  font-size: 10px;
  font-weight: 500;
  color: #9ca3af;
  letter-spacing: 0.3px;
  pointer-events: none;
  user-select: none;
}

.live-label {
  color: #16a34a;
}


.station-card::before {
  content: '';
  display: block;
  height: 3px;
  border-radius: 2px 2px 0 0;
  position: absolute;
  top: 0; left: 0; right: 0;
}

.station-card.pickup::before { background: var(--color-walk); }
.station-card.dropoff::before { background: var(--color-walk2); }

.card-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}

.station-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 8px;
  line-height: 1.3;
  min-height: 30px;
}

.availability {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.avail-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
}

.avail-badge.bikes {
  background: #dcfce7;
  color: var(--color-bikes);
}

.avail-badge.stands {
  background: #dbeafe;
  color: var(--color-stands);
}

/* Directions */

.leg-section {
  margin-bottom: 14px;
}

.leg-section:last-child {
  margin-bottom: 0;
}

.leg-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 10px;
  border-radius: var(--radius);
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  border-left: 4px solid transparent;
}

.leg-header.walk-color {
  background: #eff6ff;
  border-left-color: var(--color-walk);
  color: #1e40af;
}

.leg-header.cycle-color {
  background: #f0fdf4;
  border-left-color: var(--color-cycle);
  color: #166534;
}

.leg-header.walk2-color {
  background: #fff7ed;
  border-left-color: var(--color-walk2);
  color: #9a3412;
}

.leg-meta {
  font-size: 11px;
  font-weight: 400;
  opacity: 0.8;
}

.steps-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.steps-list li {
  font-size: 12px;
  color: var(--color-text);
  padding: 5px 8px 5px 14px;
  position: relative;
  line-height: 1.45;
  border-left: 2px solid var(--color-border);
}

.steps-list li::before {
  content: '';
  position: absolute;
  left: -5px;
  top: 10px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-border);
}

.step-meta {
  display: block;
  font-size: 11px;
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* Map Loading Overlay */

#map-loading {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.75);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-muted);
  backdrop-filter: blur(2px);
  z-index: 5;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Responsive */

@media (max-width: 768px) {
  #app {
    flex-direction: column;
  }

  #sidebar {
    width: 100%;
    height: auto;
    max-height: 55vh;
    min-width: unset;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  }

  #map-container {
    flex: 1;
    height: 45vh;
  }
}

/* Google Maps InfoWindow */

.gm-iw {
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 13px;
  line-height: 1.5;
  min-width: 140px;
}

.gm-iw strong {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
  color: var(--color-text);
}

.gm-iw .iw-avail {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.footer{
  margin-top: auto;
}

/* Prediction Banner */
.prediction-banner {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 10px 0;
  padding: 10px 14px;
  background: #fffbeb;
  border: 1px solid #f59e0b;
  border-left: 4px solid #f59e0b;
  border-radius: 6px;
  color: #92400e;
  font-size: 13px;
  line-height: 1.45;
}

/* Journey: sidebar “More information” (opens same ML InfoWindow as Stations) */
.journey-card-more-btn {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  color: #fff;
  background: var(--color-primary);
  border: 1px solid rgba(19, 84, 48, 0.45);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s ease;
}

.journey-card-more-btn:hover:not(:disabled) {
  background: var(--color-primary-dark);
}

/* Journey: InfoWindow ML charts (same rules as static/css/ml.css, scoped to #app) */
#app .gm-iw .iw-more-btn {
  display: block;
  width: 100%;
  margin: 0;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-head, inherit);
  color: #fff;
  background: var(--color-primary, #1a7340);
  border: 1px solid rgba(19, 84, 48, 0.45);
  border-radius: var(--radius, 8px);
  box-shadow: none;
  cursor: pointer;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

#app .gm-iw .iw-more-btn:hover:not(:disabled) {
  background: var(--color-primary-dark, #135430);
  box-shadow: var(--shadow-md, 0 2px 6px rgba(0, 0, 0, 0.08));
}

#app .gm-iw .iw-more-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

#app .gm-iw .iw-charts {
  margin: 0;
  padding-top: 10px;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  width: 100%;
  min-width: 0;
  max-width: none;
  box-sizing: border-box;
}

#app .gm-iw .iw-charts-title {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 600;
  color: #374151;
}

#app .gm-iw .iw-chart-subtitle {
  margin: 6px 0 4px;
  font-size: 10px;
  font-weight: 600;
  color: #6b7280;
}

#app .gm-iw .iw-chart-wrap {
  position: relative;
  height: 130px;
  margin-bottom: 0;
}

#app .gm-iw .iw-chart-wrap-line {
  height: 168px;
}

#app .gm-iw .iw-chart-wrap canvas {
  max-height: 130px;
}

#app .gm-iw .iw-chart-wrap-line canvas {
  max-height: 168px;
}

#app .gm-iw .iw-charts-error {
  margin: 0;
  font-size: 12px;
  color: #b91c1c;
}

/* Journey: InfoWindow card layout (mirror stations.css — same as Stations map)
   Without .gm-iw-inner { flex; gap } the status line can overlap the green button. */
#app .gm-style-iw-d {
  padding: 12px !important;
  box-sizing: border-box !important;
  max-width: min(288px, calc(100vw - 32px));
  overflow-x: hidden !important;
  overflow-y: auto !important;
}

#app.journey-page .gm-iw:has(.gm-iw-inner) {
  font-family: var(--font-head, "Segoe UI", system-ui, sans-serif);
  font-size: 13px;
  line-height: 1.45;
  width: 100%;
  max-width: none;
  min-width: 200px;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  color: var(--color-text);
}

#app.journey-page .gm-iw-inner {
  display: flex;
  flex-direction: column;
  gap: 7px;
  width: 100%;
  min-width: 0;
}

#app.journey-page .gm-iw:has(.gm-iw-inner) strong {
  display: block;
  margin: 0;
  padding: 0 32px 0 0;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: 0.02em;
  color: #111827;
}

#app.journey-page .gm-iw .iw-avail {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin: 0;
}

#app.journey-page .gm-iw .iw-tag {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  line-height: 1.2;
}

#app.journey-page .gm-iw .iw-tag-bikes {
  background: #dcfce7;
  color: var(--color-bikes);
}

#app.journey-page .gm-iw .iw-tag-stands {
  background: #dbeafe;
  color: var(--color-stands);
}

#app.journey-page .gm-iw .iw-status {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #6b7280;
  line-height: 1.3;
  flex-shrink: 0;
  overflow-wrap: anywhere;
}