html, body { margin: 0; height: 100%; font: 14px/1.4 system-ui, sans-serif; }
header {
  position: absolute; top: 0; left: 0; right: 0; height: 46px; z-index: 20;
  background: #1f2937; color: #f9fafb; display: flex; align-items: center;
  gap: 24px; padding: 0 16px; box-sizing: border-box;
}
header h1 { font-size: 15px; font-weight: 600; margin: 0; }
nav { display: flex; gap: 4px; }
nav button {
  background: none; border: 0; color: #9ca3af; font: inherit;
  padding: 6px 14px; border-radius: 6px; cursor: pointer;
}
nav button.active { background: #374151; color: #fff; }
#help-btn {
  margin-left: auto; width: 26px; height: 26px; border-radius: 50%;
  background: none; border: 1px solid #6b7280; color: #d1d5db;
  font: inherit; font-weight: 600; cursor: pointer; padding: 0;
}
#help-btn:hover { background: #374151; color: #fff; }
#help-modal {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(17, 24, 39, 0.55);
  display: flex; align-items: center; justify-content: center;
}
#help-modal.hidden { display: none; }
#help-card {
  position: relative; width: min(480px, 90vw); max-height: 85vh;
  overflow-y: auto; background: #fff; border-radius: 8px;
  padding: 20px 24px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
#help-card h2 { margin: 0 24px 8px 0; font-size: 17px; }
#help-card h3 { margin: 16px 0 6px; font-size: 14px; }
#help-card p { margin: 0 0 8px; line-height: 1.5; color: #374151; }
#help-card ul { margin: 0; padding-left: 20px; line-height: 1.6; color: #374151; }
#help-card .close {
  position: absolute; top: 10px; right: 12px; border: 0; background: none;
  font-size: 20px; line-height: 1; cursor: pointer; color: #6b7280; padding: 0;
}
#help-dismiss {
  margin-top: 16px; background: #2563eb; color: #fff; border: 0;
  border-radius: 6px; padding: 8px 16px; font: inherit; font-weight: 600;
  cursor: pointer;
}
#help-dismiss:hover { background: #1d4ed8; }
#dash-view { flex-direction: column; }
#dash-view:not(.hidden) { display: flex; }
#dash-stats {
  padding: 8px 16px; background: #f3f4f6; color: #374151; font-size: 13px;
  border-bottom: 1px solid #e5e7eb; white-space: nowrap; overflow: hidden;
}
#dash-stats b { color: #111827; font-weight: 600; }
#dash-overview {
  display: flex; gap: 24px; align-items: stretch; flex-shrink: 0;
  padding: 12px 16px; border-bottom: 1px solid #e5e7eb; font-size: 13px;
}
.ov-panel h4 { margin: 0 0 6px; font-size: 13px; font-weight: 600; }
#overview-total { min-width: 220px; }
.ov-big { font-size: 28px; font-weight: 700; color: #111827; }
.ov-sub { font-size: 12px; color: #6b7280; }
#overview-rush { flex: 1; }
#overview-rush .bars { display: flex; align-items: flex-end; gap: 2px; height: 56px; }
#overview-rush .bar { flex: 1; background: #2563eb; border-radius: 2px 2px 0 0; min-height: 1px; }
#overview-rush .hours { display: flex; gap: 2px; font-size: 9px; color: #6b7280; margin-top: 3px; }
#overview-rush .hours span { flex: 1; text-align: center; }
.ov-error { color: #b91c1c; }
#dash-mount { flex: 1; position: relative; }
.view { position: absolute; top: 46px; bottom: 0; left: 0; right: 0; }
.hidden { display: none; }
#map {
  position: absolute; inset: 16px; border-radius: 8px;
}
#panel {
  position: absolute; top: 10px; left: 10px; z-index: 10;
  background: rgba(255, 255, 255, 0.92); border-radius: 6px;
  padding: 8px 12px; font-size: 13px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  display: flex; align-items: center; gap: 10px;
}
#route-filter { font: inherit; max-width: 140px; }
#route-filter option.route-inactive { color: #9ca3af; }
#heatmap-label { display: flex; align-items: center; gap: 4px; cursor: pointer; }
.btn {
  background: #2563eb; color: #fff; border: 0; border-radius: 4px;
  padding: 4px 10px; font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover, .btn.active { background: #1d4ed8; }
.clear-btn {
  background: #e5e7eb; color: #374151; border: 0; border-radius: 4px;
  padding: 4px 10px; font: inherit; font-weight: 600; cursor: pointer;
}
.clear-btn:hover { background: #d1d5db; }
/* The three floating boxes over the map: Ask, Filter, and the departures
   popup. Ask and Filter sit in different corners so both can be open. */
.panel {
  position: absolute; z-index: 15; background: rgba(255, 255, 255, 0.97);
  border-radius: 6px; padding: 10px 12px; font-size: 13px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}
.panel h3 { margin: 0 18px 8px 0; font-size: 13px; font-weight: 600; }
.panel .close {
  position: absolute; top: 6px; right: 8px; border: 0; background: none;
  font-size: 14px; cursor: pointer; color: #6b7280; padding: 0;
}
.panel form { display: flex; gap: 6px; margin-bottom: 8px; }
.panel input[type="text"] {
  flex: 1; font: inherit; padding: 4px 6px; min-width: 0;
  border: 1px solid #d1d5db; border-radius: 4px;
}
.panel input:disabled { opacity: 0.6; }
.pending { color: #6b7280; }
#ask-box {
  top: 10px; right: 10px; width: 340px;
  max-height: calc(100% - 20px); overflow-y: auto;
}
.ask-answer { margin-bottom: 6px; }
.ask-rationale { color: #6b7280; font-size: 12px; margin-bottom: 6px; }
.ask-sql {
  background: #f3f4f6; border-radius: 4px; padding: 6px 8px; font-size: 12px;
  white-space: pre-wrap; word-break: break-word; margin: 0; color: #111827;
}
.ask-error { color: #b91c1c; }
#map-filter-box { top: 54px; left: 10px; width: 320px; }
#map-filter-result { color: #374151; }
#stop-box { max-width: 280px; max-height: 320px; overflow-y: auto; }
#stop-box .mode { color: #6b7280; margin-bottom: 6px; }
#stop-box table { border-collapse: collapse; width: 100%; }
#stop-box td { padding: 2px 6px 2px 0; white-space: nowrap; }
#stop-box td.headsign { white-space: normal; }
#stop-box .route-badge {
  display: inline-block; min-width: 22px; text-align: center;
  background: #374151; color: #fff; border-radius: 4px;
  padding: 0 4px; font-weight: 600;
}
#stop-box .delay { font-weight: 600; }
/* The schedule a delayed service is no longer keeping — struck through so
   it reads as the superseded value, not a second departure. */
#stop-box .sched { color: #6b7280; text-decoration: line-through; }
/* Answer to "why is this pole marked for the line I filtered to?" — set off
   from the departure table above it, since it is about a different window. */
#stop-box .route-next {
  margin-top: 8px; padding-top: 8px; border-top: 1px solid #e5e7eb;
  color: #374151; font-size: 13px;
}
#stop-box .delay.late { color: #b91c1c; }
#stop-box .delay.early { color: #047857; }
.latency-badge {
  display: inline-block; background: #e0e7ff; color: #3730a3;
  border-radius: 4px; padding: 0 6px; font-weight: 600; font-size: 12px;
}
.latency-badge[data-stats] { cursor: pointer; }
.latency-badge[data-stats]:hover { background: #c7d2fe; }
/* The explain panel: Pinot's own scan figures behind a latency badge,
   opened on click (see app.js). Fixed + body-appended so it floats free of
   whichever scrollable panel (stop popup, histogram) the badge lives in. */
.latency-popover {
  position: fixed; z-index: 50; background: #fff; color: #1f2937;
  border-radius: 6px; padding: 8px 10px; font-size: 12px; line-height: 1.5;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35); max-width: 240px;
}
.latency-popover .reading { font-weight: 600; margin-bottom: 4px; }
#route-histogram {
  position: absolute; z-index: 10; left: 10px; bottom: 10px; width: 320px;
  background: rgba(255, 255, 255, 0.95); border-radius: 6px;
  padding: 8px 12px 6px; font-size: 12px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}
#route-histogram h4 { margin: 0 0 6px; font-size: 13px; font-weight: 600; }
#route-histogram .bars {
  display: flex; align-items: flex-end; gap: 2px; height: 60px;
}
#route-histogram .bar {
  flex: 1; background: #2563eb; border-radius: 2px 2px 0 0; min-height: 1px;
}
#route-histogram .hours {
  display: flex; gap: 2px; font-size: 9px; color: #6b7280; margin-top: 3px;
}
#route-histogram .hours span { flex: 1; text-align: center; }
#schema-view { overflow-y: auto; padding: 16px; box-sizing: border-box; background: #f9fafb; }
#schema-status { padding: 8px; color: #374151; }
#schema-status.error { color: #b91c1c; }
.schema-card {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 8px;
  padding: 12px 16px; margin-bottom: 16px; max-width: 900px;
}
.schema-card h3 { margin: 0 0 8px; font-size: 15px; }
.schema-card table { border-collapse: collapse; width: 100%; font-size: 13px; }
.schema-card th {
  text-align: left; color: #6b7280; font-weight: 600;
  padding: 2px 8px 4px 0; border-bottom: 1px solid #e5e7eb;
}
.schema-card td { padding: 3px 8px 3px 0; border-bottom: 1px solid #f3f4f6; }
.schema-card td.col-name { font-family: ui-monospace, Consolas, monospace; }
.schema-card td.kind { color: #6b7280; }
.idx-badge {
  display: inline-block; background: #e0e7ff; color: #3730a3; border-radius: 4px;
  padding: 0 6px; font-size: 11px; font-weight: 600; margin-right: 4px;
}
.table-type { margin-top: 8px; font-size: 12px; color: #374151; }
#schema-note { color: #6b7280; font-size: 12px; max-width: 900px; }
#schema-note code { font-size: 11px; }
#dash-mount iframe { display: block; width: 100%; height: 100%; border: 0; }
#dash-status { padding: 24px; color: #374151; }
#dash-status.error { color: #b91c1c; }
