:root {
  --ink: #17202a;
  --muted: #627084;
  --line: #d8dee7;
  --panel: #f4f7fa;
  --warn: #9a4d00;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  color: var(--ink);
  background: #fff;
}

header {
  padding: 26px 32px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

main {
  padding: 24px 32px 42px;
}

h1 {
  font-size: 28px;
  margin: 0 0 7px;
  font-weight: 720;
}

h2 {
  font-size: 17px;
  margin: 0 0 12px;
}

p {
  color: var(--muted);
  margin: 0;
}

#metadata {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.metadata-item {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
  padding: 6px 8px;
}

.metadata-item strong {
  color: var(--ink);
  font-weight: 680;
}

label {
  display: block;
  font-size: 12px;
  font-weight: 650;
  color: var(--muted);
  margin-bottom: 5px;
}

select {
  width: 100%;
  min-width: 220px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
  font-size: 14px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 8px 10px;
  white-space: nowrap;
}

th {
  background: #eef2f6;
  font-weight: 650;
}

.sort-button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-weight: inherit;
  padding: 0;
  white-space: nowrap;
}

.sort-button:hover {
  color: #2f6f4e;
}

.sort-marker {
  display: inline-block;
  min-width: 8px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
}

tbody tr:hover td {
  background: #f8fafc;
}

.expandable-row {
  cursor: pointer;
}

.expand-cell {
  width: 32px;
}

.expand-button {
  width: 22px;
  height: 22px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  line-height: 1;
  padding: 0;
}

.expand-button:hover {
  border-color: #2f6f4e;
  color: #2f6f4e;
}

.detail-row td {
  background: #f8fafc;
  padding: 10px 10px 14px 42px;
}

.detail-row:hover td {
  background: #f8fafc;
}

.outcome-detail {
  max-width: 560px;
}

.outcome-detail table {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.outcome-detail th {
  background: #f1f4f8;
}

.outcome-detail tr:last-child td {
  border-bottom: 0;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 340px) minmax(250px, 320px) minmax(260px, 1fr);
  gap: 16px;
  align-items: end;
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
}

.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.tab {
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 680;
  padding: 9px 12px 10px;
}

.tab:hover {
  color: var(--ink);
}

.tab.active {
  border-bottom-color: #2f6f4e;
  color: var(--ink);
}

.hidden {
  display: none;
}

.band {
  border-top: 1px solid var(--line);
  padding-top: 20px;
  overflow-x: auto;
}

.primary-band {
  border-top: 0;
  padding-top: 0;
}

.team-summary {
  min-height: 36px;
  border-left: 1px solid var(--line);
  padding-left: 16px;
}

.metric-label,
.metric-note {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.metric-label {
  font-weight: 650;
  margin-bottom: 3px;
}

.metric-value {
  display: block;
  font-size: 22px;
  line-height: 1.05;
  font-weight: 760;
}

.finish-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.finish-strip strong {
  color: var(--ink);
  font-weight: 650;
}

.route-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 22px;
}

.route-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  min-height: 92px;
}

.route-card.good {
  border-left: 4px solid #2f6f4e;
}

.route-card.bad {
  border-left: 4px solid #a33b3b;
}

.route-card span,
.route-card small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.route-card strong {
  display: block;
  font-size: 24px;
  line-height: 1.05;
  margin: 6px 0;
}

.guide-section {
  overflow-x: auto;
}

.empty {
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 14px;
}

.warnings {
  border-left: 4px solid var(--warn);
  background: #fff7ed;
  padding: 12px 16px;
  color: #603711;
  margin-top: 16px;
}

.warnings ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.num {
  font-variant-numeric: tabular-nums;
}

@media (max-width: 680px) {
  header,
  main {
    padding-left: 18px;
    padding-right: 18px;
  }

  .toolbar {
    grid-template-columns: 1fr;
  }

  .team-summary {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding-left: 0;
    padding-top: 14px;
  }

  .tabs {
    overflow-x: auto;
  }

  .route-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 460px) {
  .route-grid {
    grid-template-columns: 1fr;
  }
}
