* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: #333;
  font: 14px/1.43 Verdana, serif;
}

header,
footer {
  padding: 5px;
  background: #393939;
  color: #cecece;
}

header {
  display: flex;
  align-items: center;
  gap: 15px;
  height: 51px;
  box-shadow: 0 2px 5px #0004;
}

header i,
header a {
  color: #00b5e2;
}

header i {
  padding: 10px 15px;
  border-radius: 5px;
  background: #484848;
}

header a {
  margin-left: auto;
  text-decoration: none;
}

header span {
  margin-right: 5px;
  font-size: 16pt;
}

footer {
  position: fixed;
  inset: auto 0 0;
  height: 30px;
}

main {
  position: absolute;
  inset: 52px 0 30px;
  overflow: auto;
  padding: 10px;
  scrollbar-gutter: stable;
}

.panel,
.legend,
#details {
  border: 1px solid #ddd;
  border-radius: 4px;
  background: white;
  box-shadow: 0 1px 4px #0003;
}

.panel {
  min-width: max-content;
  min-height: 100%;
  padding-bottom: 22px;
}

.panel>h1 {
  margin: 0;
  padding: 5px 5px 5px 10px;
  border-bottom: 1px solid #ddd;
  border-radius: 3px 3px 0 0;
  background-color: #f5f5f5;
  color: #333;
  text-align: center;
  font-size: 16px;
  font-weight: normal;
  line-height: 20px;
}

.panel>h1>small {
  padding-left: 10px;
  font-size: 10pt;
  font-style: italic;
  font-weight: normal;
}

#grid {
  padding: 100px 144px 0 10px;
}

table {
  border-collapse: collapse;
}

#grid table {
  margin: auto;
}

#grid th,
#grid td {
  padding: 0;
}

#grid td.heatmap_metric {
  vertical-align: middle;
  padding-top: 2px;
}

#grid .source_label {
  width: 150px;
  padding-right: 10px;
  text-align: right;
  white-space: nowrap;
  font-size: 8pt;
}

#grid .sla_heading {
  position: relative;
  bottom: 30px;
  padding-right: 20px;
  text-align: right;
  font-size: 14pt;
  font-weight: bold;
}

.rotate {
  position: relative;
  left: 5px;
  white-space: nowrap;
  text-align: left;
}

#grid th.destination_label.rotate {
  left: 2px;
}

.rotate div {
  width: 18px;
  height: 17px;
  transform: translate(-3px, 1px) rotate(295deg);
}

.rotate span {
  margin-left: 5px;
  font-size: 8pt;
  font-weight: normal;
}

.green_metric {
  --color: #6c6;
}

.yellow_metric {
  --color: #fffd85;
}

.red_metric {
  --color: #ff8585;
}

.black_metric {
  --color: #979797;
}

.no_base {
  --color: #c6c;
}

.heatmap_metric {
  width: 18px;
  height: 18px;
  border: 1px solid white;
  background: var(--color, white);
  text-align: center;
  font-size: 6pt;
}

#grid td.heatmap_metric.active {
  position: relative;
  z-index: 1;
}

/* Collapsed borders let the neighbor's white border win, so draw trail lines on an overlay */
#grid td.trail_row,
#grid td.trail_column {
  position: relative;
}

#grid td.trail_row::before,
#grid td.trail_column::before {
  content: "";
  position: absolute;
  inset: -1px;
  border: 0 solid #000;
  pointer-events: none;
}

#grid td.trail_row::before {
  border-block-width: 1px;
}

#grid td.trail_column::before {
  border-inline-width: 1px;
}

#grid td.heatmap_metric.active::after {
  content: attr(data-hover-value);
  position: absolute;
  inset: -1px;
  box-sizing: border-box;
  display: grid;
  place-items: center;
  border: 1px solid white;
  background: var(--color, white);
  box-shadow: 0 2px 4px #0005;
  font-size: 7pt;
  font-weight: bold;
  line-height: 1;
  pointer-events: none;
  transform: scale(1.6);
  animation: heatmap-grow 120ms ease-out;
}

/* ::after is created when .active is added, so a transition can't run; animate instead */
@keyframes heatmap-grow {
  from {
    transform: scale(1);
  }
}

.heatmap_metric[flowid_be]:not([flowid_be=""]) {
  cursor: pointer;
}

.heatmap_metric.active {
  font-size: 7pt;
  font-weight: bold;
}

.source_label.active,
.rotate.active span {
  color: #ffa000;
  font-weight: bold;
  text-decoration: underline;
}

.legend {
  width: max-content;
  min-width: 365px;
  margin: 25px auto 0;
  text-align: center;
}

.legend h2 {
  margin: 0;
  padding: 2px 10px;
  border-bottom: 1px solid #ddd;
  border-radius: 3px 3px 0 0;
  background: #f5f5f5;
  font-size: 12px;
  font-weight: bold;
  line-height: 18px;
}

.legend p {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 11px;
  margin: 0;
  padding: 10px 15px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  flex: none;
  height: 20px;
  padding: 0 5px;
  border-left: 20px solid var(--color);
  background: #faefd0;
  box-shadow: 0 1px 3px #0004;
  font-size: 10pt;
  line-height: 1;
  white-space: nowrap;
}

#details {
  position: fixed;
  z-index: 10;
  width: min(26.25rem, calc(100vw - 0.5rem));
  padding: 0;
  overflow: hidden;
  pointer-events: none;
  transform-origin: top left;
  border: 1px solid #ddd;
  border-radius: 5px;
  background: #fff;
  color: #000;
  font: 8pt/1.2 Verdana, sans-serif;
  box-shadow: 0 2px 2px #0002, 0 3px 1px -2px #0003, 0 1px 5px #0002;
}

/* Equal city columns keep "to" centered even when the names differ in length. */
#pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  column-gap: 10px;
  margin: 0;
  padding: 2px 6px;
  border-bottom: 1px solid #ddd;
  background: #f5f5f5;
  font-size: 10pt;
  font-weight: 700;
  line-height: 24px;
  text-align: center;
}

#pair-source {
  text-align: right;
}

#pair-destination {
  text-align: left;
}

#details>p {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 25px;
  min-height: 28px;
  margin: 0;
  padding: 0 6px;
  border-bottom: 1px dashed #ddd;
}

#details>p b {
  font-size: 9pt;
}

#baseline {
  margin: 0;
}

#details table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  text-align: center;
}

#details .metric-name {
  width: 7.5em;
}

#details .metric-direction {
  width: 4em;
}

#details th,
#details td {
  padding: 5px 2px;
  vertical-align: middle;
  line-height: 12px;
}

#details thead th {
  border-left: 1px dashed #ccc;
  font-size: 10pt;
  line-height: 15px;
}

#details tbody tr {
  border-top: 1px dashed #ddd;
}

#details tbody th {
  padding-right: 5px;
  text-align: right;
  font-weight: 700;
}

#details tbody td {
  border-left: 1px dashed #ccc;
  text-align: center;
}

/* The direction is the first td, including rows beneath a spanning th. */
#details tbody td:first-of-type {
  font-weight: 700;
  white-space: nowrap;
}