/* Analytics dashboard, same dark palette as the map. */

body.dash { min-height: 100%; background: var(--bg); }

.dash-head { max-width: 1180px; margin: 0 auto; padding: 28px 24px 8px; }
.dash-head-row { display: flex; align-items: center; gap: 18px; margin-bottom: 26px; }
.dash-head-row .spacer { flex: 1; }
.dash-head h1 { margin: 0; font-size: clamp(28px, 4vw, 40px); font-weight: 500; letter-spacing: -0.01em; }
.coverage { margin: 6px 0 0; color: var(--muted); font-size: 14px; }

/* title on the left, time frame on the right */
.title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; flex-wrap: wrap; }

.timeframe, .seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--border); }
.tf, .sg {
  font: inherit; color: var(--muted); cursor: pointer;
  background: none; border: 0; border-radius: 7px; padding: 7px 14px; font-size: 13px;
}
.tf:hover, .sg:hover { color: var(--text); }
.tf.is-on, .sg.is-on { background: rgba(255, 255, 255, 0.12); color: var(--text); }
.seg { padding: 2px; margin-left: 8px; vertical-align: middle; }
.sg { padding: 4px 9px; font-size: 12px; }

.dash-main { max-width: 1180px; margin: 0 auto; padding: 8px 24px 96px; }

.block { margin-top: 44px; }
.block h2 {
  margin: 0 0 16px; font-size: 12px; font-weight: 500; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--muted);
}

/* ---------- numbers at a glance ---------- */
.kpis {
  display: grid; gap: 12px; margin-bottom: 18px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.kpi {
  padding: 14px 16px; border-radius: 12px;
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--border);
}
.kpi strong {
  display: block; font-size: clamp(20px, 2.2vw, 26px); font-weight: 500; line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.kpi strong.tone-good { color: var(--c-on_time); }
.kpi strong.tone-warn { color: var(--c-late); }
.kpi strong.tone-bad { color: var(--c-very_late); }
.kpi span { display: block; margin-top: 4px; font-size: 12px; color: var(--muted); line-height: 1.4; }

/* ---------- charts ---------- */
/* one column on a phone, two from tablet, three for the middle row on desktop */
.cards { display: grid; gap: 14px; grid-template-columns: 1fr; margin-bottom: 14px; }
@media (min-width: 760px) { .cards { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1040px) { .cards.three { grid-template-columns: repeat(3, 1fr); } }
.card-chart {
  margin: 0; padding: 16px 16px 8px; border-radius: 14px;
  background: rgba(255, 255, 255, 0.03); border: 1px solid var(--border);
}
.card-chart.wide { grid-column: 1 / -1; margin-bottom: 14px; }
.card-chart figcaption {
  font-size: 14px; font-weight: 500; margin-bottom: 10px;
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px;
}
.card-chart .hint { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 6px; }
.chart { width: 100%; height: 240px; }
.chart.tall { height: 320px; }
.chart-empty {
  display: flex; align-items: center; justify-content: center; height: 100%;
  margin: 0; color: var(--muted); font-size: 13px; text-align: center;
}

/* ---------- pickers ---------- */
.picker { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; margin: 0 0 18px; }
.picker label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
.picker select {
  font: inherit; font-size: 14px; color: var(--text);
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--border);
  border-radius: 9px; padding: 9px 12px; min-width: 190px;
  color-scheme: dark;              /* the dropdown list itself, not just the box */
}
.picker select option { background: #161d26; color: var(--text); }
.picker select:hover { background: rgba(255, 255, 255, 0.1); }
.picker select:disabled { opacity: 0.45; cursor: not-allowed; }
.picker .hint { color: var(--muted); font-size: 13px; }

/* ---------- the "build your own" note ---------- */
.build-note p { color: var(--muted); max-width: 640px; line-height: 1.7; }
.build-note code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px;
  background: rgba(255, 255, 255, 0.06); padding: 1px 6px; border-radius: 5px;
}
.endpoints { list-style: none; margin: 18px 0 0; padding: 0; }
.endpoints li {
  padding: 10px 0; border-top: 1px solid var(--border);
  font-size: 13px; color: var(--muted); line-height: 1.6;
}
.endpoints a {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--text); text-decoration: none;
}
.endpoints a:hover { color: var(--c-on_time); }

@media (max-width: 640px) {
  .dash-head, .dash-main { padding-left: 16px; padding-right: 16px; }
  .dash-head { padding-top: 20px; }
  .cards, .cards.three { grid-template-columns: 1fr; }
  .chart { height: 210px; }
  .chart.tall { height: 260px; }
  .picker select { min-width: 0; width: 100%; }
  .picker label { flex: 1 1 100%; }
  .title-row { align-items: flex-start; }
  .timeframe { width: 100%; justify-content: space-between; }
  .tf { flex: 1; padding: 9px 6px; text-align: center; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi { padding: 12px 13px; }
  .kpi span { font-size: 11px; }
}

/* ---------- filters in the header ---------- */
.filters { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.filters .chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.filters .chip {
  font: inherit; font-size: 12px; color: var(--text); cursor: pointer;
  padding: 5px 11px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--border);
}
.filters .chip:hover { background: rgba(255, 255, 255, 0.12); }
.filters .chip[aria-pressed="false"] { opacity: 0.4; text-decoration: line-through; }

.more {
  font: inherit; font-size: 12px; color: var(--text); cursor: pointer;
  padding: 4px 11px; margin-left: auto; border-radius: 999px;
  background: rgba(255, 255, 255, 0.08); border: 1px solid var(--border);
}
.more:hover { background: rgba(255, 255, 255, 0.16); }

/* ---------- the route overlay ---------- */
body.overlay-open { overflow: hidden; }
.overlay {
  position: fixed; inset: 0; z-index: 40; display: flex;
  align-items: center; justify-content: center; padding: 24px;
  background: rgba(6, 9, 13, 0.72);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
.overlay-box {
  width: min(1020px, 100%); max-height: calc(100vh - 48px); overflow: auto;
  border-radius: 16px; padding: 16px 18px 12px;
  background: #11171f; border: 1px solid var(--border);
}
.overlay-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.overlay-head h2 { margin: 0; font-size: 17px; font-weight: 500; }
.overlay-head .spacer { flex: 1; }
.overlay-close {
  background: none; border: 0; color: var(--muted); cursor: pointer;
  width: 36px; height: 36px; font-size: 24px; line-height: 1; padding: 0;
}
.overlay-close:hover { color: var(--text); }
.overlay-map-wrap {
  position: relative;
}
.overlay-map {
  width: 100%; height: 340px; border-radius: 12px; overflow: hidden;
  background: var(--bg); border: 1px solid var(--border);
}
.overlay-stop-name {
  position: absolute; top: 12px; right: 12px; z-index: 4;
  max-width: min(360px, calc(100% - 24px));
  padding: 7px 10px; border-radius: 9px;
  background: rgba(13, 18, 24, 0.88); border: 1px solid var(--border);
  color: var(--text); font-size: 12px; line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  pointer-events: none;
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
.overlay-chart { height: 280px; margin-top: 12px; }
.overlay-note { margin: 0 0 4px; font-size: 12px; color: var(--muted); text-align: center; }

@media (max-width: 640px) {
  .filters { align-items: stretch; }
  .filters .chips { justify-content: flex-start; }
  .overlay { padding: 10px; }
  .overlay-box { padding: 12px 12px 8px; max-height: calc(100vh - 20px); }
  .overlay-map { height: 240px; }
  .overlay-chart { height: 240px; }
}

/* ---------- the traffic heatmap ---------- */
.overlay-box.wide-box { width: min(1180px, 100%); }
.heat-controls {
  display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; margin-bottom: 12px;
}
.heat-controls label {
  display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted);
}
.heat-controls select {
  font: inherit; font-size: 14px; color: var(--text); color-scheme: dark;
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--border);
  border-radius: 9px; padding: 8px 12px; min-width: 150px;
}
.heat-time { flex: 1; min-width: 260px; }
.heat-time-row { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.heat-time-row .hint { flex: 1; text-align: center; font-variant-numeric: tabular-nums; }
#heat-hour { width: 100%; accent-color: var(--c-on_time); }
.heat-map { height: 460px; }
.heat-legend { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }
.heat-legend span { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.heat-legend i { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }

@media (max-width: 640px) {
  .heat-map { height: 300px; }
  .heat-controls label, .heat-time { flex: 1 1 100%; }
  .heat-controls select { width: 100%; }
}
