:root {
  --primary:      #e63946;
  --primary-dark: #c1121f;
  --bg:           #f1f3f5;
  --surface:      #ffffff;
  --border:       #dee2e6;
  --text:         #212529;
  --muted:        #6c757d;
  --green:        #2d6a4f;
  --green-bg:     #d8f3dc;
  --red-bg:       #fde8e8;
  --radius:       10px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 16px;
}

/* ── Header ── */
header {
  background: var(--primary);
  color: #fff;
  padding: .85rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
}

header h1 {
  font-size: 1.15rem;
  font-weight: 700;
  white-space: nowrap;
}

#park-select {
  background: rgba(255,255,255,.18);
  border: 1px solid rgba(255,255,255,.35);
  color: #fff;
  padding: .35rem .7rem;
  border-radius: 6px;
  font-size: .9rem;
  cursor: pointer;
  max-width: 200px;
}
#park-select option { background: var(--primary-dark); color: #fff; }

/* ── Tabs ── */
.tabs {
  display: flex;
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  padding: 0 1rem;
  gap: .25rem;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  padding: .8rem 1.1rem;
  font-size: .92rem;
  color: var(--muted);
  cursor: pointer;
  transition: color .15s, border-color .15s;
  white-space: nowrap;
}
.tab-btn.active, .tab-btn:hover { color: var(--primary); }
.tab-btn.active { border-bottom-color: var(--primary); font-weight: 600; }

/* ── Tab content ── */
.tab-content { display: none; padding: 1rem; max-width: 900px; margin: 0 auto; }
.tab-content.active { display: block; }

/* ── Controls ── */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  margin-bottom: 1rem;
}

.controls select,
.controls input[type="date"] {
  flex: 1;
  min-width: 140px;
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .9rem;
  background: var(--surface);
  color: var(--text);
}

.btn-primary {
  padding: .5rem 1.1rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s;
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-sm {
  padding: .28rem .65rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg);
  font-size: .78rem;
  cursor: pointer;
}
.btn-sm:hover { background: var(--border); }

/* ── Card / Chart ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}

.ride-detail-header {
  margin-bottom: .75rem;
}
.ride-detail-header h2 {
  font-size: 1.05rem;
  font-weight: 700;
}
.ride-detail-header .land {
  font-size: .8rem;
  color: var(--muted);
  margin-top: .1rem;
}

.chart-wrap {
  position: relative;
  height: 240px;
}
@media (min-width: 540px) {
  .chart-wrap { height: 320px; }
}

/* ── Stat bar ── */
.stat-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: .6rem;
  margin-bottom: 1rem;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .65rem .75rem;
  text-align: center;
}
.stat-label {
  font-size: .7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: .25rem;
}
.stat-value {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.1;
}
.stat-value small { font-size: .65rem; font-weight: 400; color: var(--muted); }

/* ── Filter bar ── */
.filter-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  margin-bottom: 1rem;
}
.filter-bar-header {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .6rem;
  flex-wrap: wrap;
}
.filter-bar-header strong { margin-right: auto; font-size: .88rem; }

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  max-height: 130px;
  overflow-y: auto;
}

.chip {
  padding: .22rem .6rem;
  border-radius: 20px;
  border: 1px solid var(--border);
  font-size: .78rem;
  cursor: pointer;
  background: var(--bg);
  user-select: none;
  transition: background .12s, border-color .12s, color .12s;
}
.chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ── Ride list ── */
.ride-list { display: flex; flex-direction: column; gap: .45rem; }

.ride-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .7rem 1rem;
  display: flex;
  align-items: center;
  gap: .85rem;
  transition: opacity .15s;
}
.ride-row.closed { opacity: .45; }
.ride-row.clickable {
  cursor: pointer;
}
.ride-row.clickable:hover {
  border-color: var(--primary);
  background: #fff5f5;
}

.ride-wait {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--primary);
  min-width: 3.8rem;
  text-align: right;
  line-height: 1;
}
.ride-wait small { font-size: .6rem; font-weight: 400; color: var(--muted); }

.ride-info { flex: 1; min-width: 0; }
.ride-name { font-weight: 600; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ride-land { font-size: .75rem; color: var(--muted); margin-top: .1rem; }

.badge {
  font-size: .7rem;
  padding: .18rem .5rem;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}
.badge-open   { background: var(--green-bg); color: var(--green); }
.badge-closed { background: var(--red-bg);   color: var(--primary-dark); }

/* ── Live tab timestamp ── */
.live-updated {
  font-size: .78rem;
  color: var(--muted);
  margin-bottom: .75rem;
  text-align: right;
}

/* ── States ── */
.hidden { display: none !important; }

.info-box {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--muted);
  font-size: .92rem;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 2rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
