* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  background: #f4f6fa;
  color: #26303b;
}

.topbar {
  background: #1f2a44;
  color: #fff;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 32px;
  flex-wrap: wrap;
}
.topbar h1 { font-size: 18px; margin: 0; }
.topbar nav a {
  color: #b9c4da;
  text-decoration: none;
  margin-right: 16px;
  padding-bottom: 2px;
}
.topbar nav a.active, .topbar nav a:hover {
  color: #fff;
  border-bottom: 2px solid #6ea8ff;
}

main { max-width: 1100px; margin: 24px auto; padding: 0 16px; }

.panel {
  background: #fff;
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 24px;
  box-shadow: 0 1px 3px rgba(20, 40, 80, .08);
}
.panel h2 { font-size: 16px; margin: 0 0 12px; }
.meta { font-size: 12px; color: #8894a8; font-weight: normal; }

.empty {
  color: #8894a8;
  background: #f0f3f8;
  border-radius: 6px;
  padding: 14px 16px;
}
.empty code { background: #e2e8f2; padding: 1px 5px; border-radius: 4px; }

.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid #edf0f5;
}
.data-table th { color: #8894a8; font-size: 13px; }
.data-table .wait { font-variant-numeric: tabular-nums; }

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  color: #fff;
}
.st-open   { background: #3aa17e; }
.st-closed { background: #98a2b3; }
.st-warn   { background: #d98e3a; }
.st-muted  { background: #b9c0cd; }

.controls { margin-bottom: 12px; display: flex; gap: 20px; flex-wrap: wrap; }
.controls select {
  font-size: 14px;
  padding: 4px 8px;
  border: 1px solid #ccd4e0;
  border-radius: 6px;
  max-width: 320px;
}

.chart { width: 100%; height: 360px; }
.chart.tall { height: 460px; }

/* park map (AMap) */
.map { width: 100%; height: 480px; border-radius: 6px; }
.map-dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35); }

/* history timeline controls */
.timeline-controls { align-items: center; }
.timeline-controls input[type="date"] {
  font-size: 14px;
  padding: 4px 8px;
  border: 1px solid #ccd4e0;
  border-radius: 6px;
}
.timeline-controls input[type="range"] {
  flex: 1;
  min-width: 200px;
}
.timeline-controls button {
  min-width: 72px;
}
.timeline-controls button:disabled {
  background: #98a2b3;
  cursor: default;
}

/* route page */
.ride-picker {
  border: 1px solid #e2e8f2;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 14px;
  flex: 1;
  min-width: 220px;
}
.ride-picker legend { font-size: 13px; color: #55617a; padding: 0 4px; }
.ride-picker legend button {
  font-size: 12px;
  margin-left: 6px;
  border: 1px solid #ccd4e0;
  border-radius: 4px;
  background: #fff;
  color: #1f2a44;  /* .controls button sets color:#fff — override back */
  cursor: pointer;
  padding: 1px 8px;
}
.ride-picker-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  max-height: 140px;
  overflow-y: auto;
  margin-top: 6px;
}
.ride-picker-list label { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.controls button {
  font-size: 14px;
  padding: 4px 16px;
  border: none;
  border-radius: 6px;
  background: #1f2a44;
  color: #fff;
  cursor: pointer;
  align-self: center;
}
.controls button:hover { background: #31415f; }

/* auth / forms */
.topbar nav { display: flex; align-items: center; flex: 1; }
.topbar nav .nav-right { margin-left: auto; }

.auth-panel { max-width: 420px; margin: 40px auto; }
.auth-form { display: flex; flex-direction: column; gap: 12px; max-width: 360px; }
.auth-form label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.auth-form label.checkbox { flex-direction: row; align-items: center; gap: 6px; }
.auth-form input[type="text"], .auth-form input[type="password"],
td.actions input[type="password"] {
  font-size: 14px;
  padding: 6px 10px;
  border: 1px solid #ccd4e0;
  border-radius: 6px;
}
.auth-form button, td.actions button {
  font-size: 14px;
  padding: 6px 14px;
  border: none;
  border-radius: 6px;
  background: #1f2a44;
  color: #fff;
  cursor: pointer;
  align-self: flex-start;
}
.auth-form button:hover, td.actions button:hover { background: #31415f; }

td.actions form { display: inline-flex; gap: 6px; margin-right: 12px; }
td.actions input[type="password"] { width: 130px; padding: 4px 8px; }
td.actions button { padding: 4px 10px; }

.form-error, .form-ok {
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 14px;
}
.form-error { color: #b3362b; background: #fbeae8; }
.form-ok { color: #2c7a5b; background: #e7f5ef; }

/* mobile bottom tab bar (hidden on desktop) */
.mobile-tabbar {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 56px;
  padding-bottom: env(safe-area-inset-bottom);
  background: #1f2a44;
  z-index: 1000;
}
.mobile-tabbar a {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  color: #b9c4da;
  text-decoration: none;
  font-size: 14px;
}
.mobile-tabbar a.active {
  color: #fff;
  border-top: 2px solid #6ea8ff;
}

/* ---------- mobile layout (≤768px); desktop rules above stay untouched ---------- */
@media (max-width: 768px) {
  body { padding-bottom: 64px; }  /* room for the fixed tab bar */

  .topbar { padding: 10px 14px; gap: 12px; }
  .topbar h1 { font-size: 16px; }
  /* the four main tabs move to the bottom tab bar; keep account links */
  .topbar nav > a { display: none; }
  .topbar nav .nav-right a { font-size: 13px; margin-right: 10px; }

  .mobile-tabbar { display: flex; }

  main { margin: 12px auto; padding: 0 10px; }
  .panel { padding: 12px; margin-bottom: 14px; }
  .panel h2 { font-size: 15px; }

  /* tables may scroll horizontally as a fallback for many columns */
  .data-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    font-size: 13px;
  }
  .data-table th, .data-table td { padding: 6px 8px; }

  .map { height: 60vh; }
  .chart { height: 280px; }
  .chart.tall { height: 340px; }

  /* timeline controls stack vertically; the slider takes the full width */
  .timeline-controls { flex-direction: column; align-items: stretch; gap: 10px; }
  .timeline-controls input[type="range"] { width: 100%; min-width: 0; height: 32px; }

  /* touch-friendly form controls (16px font also avoids iOS auto-zoom) */
  .controls { gap: 12px; }
  .controls select,
  .controls input[type="date"],
  .timeline-controls input[type="date"] {
    font-size: 16px;
    padding: 8px 10px;
    min-height: 40px;
    max-width: 100%;
  }
  .controls button, .timeline-controls button {
    min-height: 44px;
    padding: 8px 20px;
    font-size: 15px;
  }

  /* route page: pickers stack full-width, two-column checkbox grid inside */
  .controls .ride-picker { flex: 1 1 100%; min-width: 0; margin-right: 0; }
  .ride-picker-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 4px 8px;
    max-height: 112px;
  }
  .ride-picker-list label { white-space: normal; }

  .auth-panel { margin: 20px auto; }
  .auth-form input[type="text"], .auth-form input[type="password"] {
    min-height: 40px;
    font-size: 16px;
  }
  .auth-form button { min-height: 44px; }
}
