/* Timing colors match the driver's view without changing security/error colors. */
#mapPage .trip-late {
  background: #f59e0b !important;
  color: #5b3900;
}

#mapPage .trip-early {
  background: #d92d3a !important;
  color: #fff;
}

#mapPage .trip-ontime {
  background: #16a36d !important;
  color: #fff;
}

#mapPage .trip-idle,
#mapPage .trip-offline,
#mapPage .trip-unknown {
  background: #81939a !important;
  color: #fff;
}

#mapPage .legend .late { background: #f59e0b; }
#mapPage .legend .early,
#mapPage .legend .offroute { background: #d92d3a; }
#mapPage .legend .ontime { background: #16a36d; }
#mapPage .legend .idle { background: #81939a; }

#mapPage .bus-marker.offroute:after,
#mapPage .vehicle-row.offroute:after {
  background: #d92d3a;
  color: #fff;
}

#mapPage .bus-marker.offroute,
#mapPage .vehicle-row.offroute .status-ring {
  background: #d92d3a !important;
  color: #fff;
}

.report-details-head .report-legend {
  display: grid;
  gap: 7px;
  min-width: 0;
  width: min(100%, 760px);
  max-width: 760px;
}

.report-chart.report-status-summary {
  grid-column: 1 / -1;
  min-height: 0;
  padding: 18px 20px;
}

.completion-summary-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 5px 16px;
  margin-bottom: 14px;
}

.completion-summary-head h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.3;
}

.completion-summary-head > span {
  color: #526670;
  font-size: 12px;
}

.completion-status-track {
  display: flex;
  height: 12px;
  overflow: hidden;
  border-radius: 6px;
  background: #e8eef1;
}

.completion-status-track > span {
  display: block;
  flex: 0 0 auto;
  height: 100%;
}

.completion-status-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px 20px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.completion-status-stats > li {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.completion-status-label {
  display: flex;
  align-items: baseline;
  gap: 6px;
  color: #526670;
  font-size: 12px;
  line-height: 1.4;
}

.completion-status-label > i {
  display: inline-block;
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.completion-status-values {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
  font-variant-numeric: tabular-nums;
}

.completion-status-values b {
  font-size: 24px;
  line-height: 1.1;
}

.completion-status-values small {
  color: #526670;
  font-size: 12px;
}

.completion-status-track > .finished,
.completion-status-label > .finished { background: #16a36d; }
.completion-status-track > .data-gaps,
.completion-status-label > .data-gaps { background: #f59e0b; }
.completion-status-track > .incomplete,
.completion-status-label > .incomplete { background: #d92d3a; }
.completion-status-track > .started,
.completion-status-label > .started { background: #1476c4; }
.completion-status-track > .selected,
.completion-status-label > .selected { background: #81939a; }

#mapPage .vehicle-row.offroute { background: #fff1f2; }

#mapPage .timing-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: max-content;
  max-width: 100%;
  padding: 4px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
}

#mapPage .timing-late {
  background: #fff0cc;
  color: #795000;
}

#mapPage .timing-early,
#mapPage .timing-offroute {
  background: #ffe2e5;
  color: #a31d2b;
}

#mapPage .timing-ontime {
  background: #ddf5e9;
  color: #08623e;
}

#mapPage .timing-idle,
#mapPage .timing-offline,
#mapPage .timing-unknown,
#mapPage .timing-selected {
  background: #e8eef1;
  color: #526670;
}

/* Status and punctuality are separate signals: an on-time trip can lack data. */
#reports .report-table .status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  width: max-content;
  max-width: none;
  padding: 3px 7px;
  border-radius: 999px;
  background: #e8eef1;
  color: #526670;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
}

#reports .report-table .status-pill.finished {
  background: #ddf5e9;
  color: #08623e;
}

#reports .report-table .status-pill.finished.data-gaps {
  background: #fff0cc;
  color: #795000;
}

#reports .report-table .status-pill.incomplete {
  background: #ffe2e5;
  color: #a31d2b;
}

#reports .report-table .status-pill.started {
  background: #e1efff;
  color: #07599d;
}

#reports .report-table .status-pill.selected,
#reports .report-table .status-pill.cancelled {
  background: #e8eef1;
  color: #526670;
}

.report-status-legend,
.report-timing-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 6px 12px;
  min-width: 0;
  color: #526670;
  font-size: 11px;
  line-height: 1.4;
}

.report-status-legend > span,
.report-timing-legend > span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  width: auto;
  height: auto;
  margin: 0;
  background: transparent;
}

.report-status-legend i,
.report-timing-legend i {
  display: inline-block;
  flex: 0 0 9px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  font-style: normal;
}

.report-status-legend i.finished,
.report-status-legend .finished > i { background: #16a36d; }
.report-status-legend i.data-gaps,
.report-status-legend .data-gaps > i { background: #f59e0b; }
.report-status-legend i.incomplete,
.report-status-legend .incomplete > i { background: #d92d3a; }
.report-status-legend i.started,
.report-status-legend .started > i { background: #1476c4; }
.report-status-legend i.selected,
.report-status-legend .selected > i { background: #81939a; }

.report-timing-legend i.good,
.report-timing-legend .good > i { background: #16a36d; }
.report-timing-legend i.warn,
.report-timing-legend .warn > i { background: #f59e0b; }
.report-timing-legend i.bad,
.report-timing-legend .bad > i { background: #d92d3a; }

@media (max-width: 700px) {
  .report-chart.report-status-summary { padding: 14px; }

  .completion-status-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 18px;
  }

  .completion-status-values b { font-size: 22px; }

  .report-details-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .report-status-legend,
  .report-timing-legend {
    width: 100%;
    justify-content: flex-start;
    gap: 5px 10px;
  }

  .report-status-legend > span,
  .report-timing-legend > span { max-width: 100%; }
}
