*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: #eef0f4;
  color: #1a1a1a;
  font-size: 14px;
}

/* ── Header ── */
.site-header {
  background: #1b2a4a;
  color: #fff;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.site-header h1 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-mark { flex: none; }

.updated {
  font-size: 0.8rem;
  color: #8aaccc;
}

/* ── Tab nav ── */
.tab-nav {
  background: #fff;
  border-bottom: 2px solid #dde2ea;
  padding: 0 24px;
  display: flex;
}

.tab {
  padding: 11px 20px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 500;
  color: #555;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}

.tab:hover { color: #1b2a4a; }

.tab.active {
  color: #1b2a4a;
  border-bottom-color: #1b6abf;
  font-weight: 700;
}

/* ── Content layout ── */
.content {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ── Section card ── */
.group-section {
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.09);
  overflow: hidden;
}

.group-header {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #1b2a4a;
  padding: 10px 16px;
  background: #f2f5fa;
  border-bottom: 1px solid #dde3ec;
}

/* ── Table scroll wrapper ── */
.table-scroll { overflow-x: auto; }

/* ── Sticky team column ── */
.forecast-table th.col-group-empty,
.forecast-table th.col-team {
  position: sticky;
  left: 0;
  z-index: 3;
  box-shadow: 2px 0 0 0 #3a5580;
}

.forecast-table td.col-team {
  position: sticky;
  left: 0;
  z-index: 1;
  box-shadow: 2px 0 0 0 #c4d0de;
}

/* ── Forecast table ── */
.forecast-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 1020px;
}

/* ── Group header row (first thead row) ── */
.forecast-table thead tr.group-row th {
  background: #1b2a4a;
  color: #7090b8;
  padding: 4px 12px 3px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  white-space: nowrap;
  user-select: none;
  border-bottom: 1px solid #263c60;
}

.forecast-table thead tr.group-row th.col-group-label {
  text-align: center;
  border-right: 2px solid #3a5580;
}

.forecast-table thead tr.group-row th.col-group-empty {
  text-align: left;
  border-right: 2px solid #3a5580;
}

.forecast-table thead tr.group-row th:last-child { border-right: none; }

/* ── Column header row (second thead row) ── */
.forecast-table thead tr:not(.group-row) th {
  background: #1b2a4a;
  color: #c8d8ee;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  border-right: 1px solid #253a60;
  user-select: none;
}

.forecast-table thead tr:not(.group-row) th:last-child { border-right: none; }

.forecast-table thead tr:not(.group-row) th.sortable { cursor: pointer; }
.forecast-table thead tr:not(.group-row) th.sortable:hover { background: #253d6e; color: #fff; }

/* Sorted column: prominent highlight */
.forecast-table thead tr:not(.group-row) th.sorted {
  background: #1f5cb0;
  color: #ffffff;
}

/* Group boundary divider in column header row */
.forecast-table thead tr:not(.group-row) th.group-last {
  border-right: 2px solid #3a5580;
}

.sort-arrow {
  display: inline-block;
  margin-left: 3px;
  font-size: 9px;
  vertical-align: middle;
  line-height: 1;
}

/* ── Body rows ── */
.forecast-table tbody td {
  padding: 6px 12px;
  border-bottom: 1px solid #edf0f4;
  border-right: 1px solid #edf0f4;
  white-space: nowrap;
}

.forecast-table tbody td:last-child { border-right: none; }
.forecast-table tbody tr:last-child td { border-bottom: none; }

.forecast-table tbody tr:nth-child(odd)  td { background: #ffffff; }
.forecast-table tbody tr:nth-child(even) td { background: #f7f9fc; }

/* Sorted column body cells: blue tint overrides alternating rows */
.forecast-table tbody tr:nth-child(odd)  td.col-sorted { background: #ebf1fb; }
.forecast-table tbody tr:nth-child(even) td.col-sorted { background: #e1ecf7; }

/* Group boundary divider in body */
.forecast-table tbody td.group-last { border-right: 2px solid #c4d0de; }

/* Active team row (team page standings box) */
.forecast-table tbody tr.row-active td { background: #fff6e0; font-weight: 700; }
.forecast-table tbody tr.row-active td.col-sorted { background: #ffedc4; }
.forecast-table tbody tr.row-active td.col-team {
  box-shadow: 2px 0 0 0 #c4d0de, inset 3px 0 0 0 #e0a72c;
}

/* ── Alignment ── */
.align-right { text-align: right; }
.align-left  { text-align: left;  }

/* ── Mini stacked-bar sparklines (standings table: seed & advancement depth) ── */
.forecast-table td.col-seedDist,
.forecast-table td.col-advanceDist { padding-top: 0; padding-bottom: 0; }

.mini-stack {
  display: flex;
  width: 96px;
  height: 14px;
  border-radius: 3px;
  overflow: hidden;
}

.mini-stack-segment {
  min-width: 1px;
  border-right: 1px solid #fff;
}

.mini-stack-segment:last-child { border-right: none; }

/* ── Team cell ── */
.team-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 80px;
}

.logo {
  width: 22px;
  height: 22px;
  object-fit: contain;
  flex-shrink: 0;
}

.abbrev {
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.02em;
  color: #1a1a1a;
}

/* ── Error / loading ── */
.error {
  padding: 24px;
  color: #c0392b;
  font-style: italic;
}

.loading { padding: 24px; color: #666; }

/* ── Team link in main table ── */
a.team-link {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: inherit;
  min-width: 80px;
}

a.team-link:hover .abbrev {
  text-decoration: underline;
  color: #1b6abf;
}

/* ── Today column ── */
.today-win     { color: #1a7a3c; font-weight: 600; }
.today-loss    { color: #c0392b; font-weight: 600; }
.today-no-game { color: #aaa; font-style: italic; font-size: 12px; }
.today-game + .today-game { border-top: 1px solid #edf0f4; margin-top: 3px; padding-top: 3px; }

/* ── Site title as link (team page header) ── */
.site-title-link { color: inherit; text-decoration: none; }

/* ── Division section header link ── */
.group-header-link { color: inherit; text-decoration: none; }
.group-header-link:hover { text-decoration: underline; }

/* ── Team page layout ── */
.team-content {
  max-width: 1000px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.team-page-header { margin-bottom: 4px; }

.back-link {
  display: inline-block;
  margin-bottom: 14px;
  color: #1b6abf;
  text-decoration: none;
  font-size: 0.88rem;
}

.back-link:hover { text-decoration: underline; }

.team-identity {
  display: flex;
  align-items: center;
  gap: 18px;
}

.team-logo-lg {
  width: 72px;
  height: 72px;
  object-fit: contain;
  flex-shrink: 0;
}

.team-fullname {
  font-size: 1.65rem;
  font-weight: 700;
  color: #1b2a4a;
  line-height: 1.2;
}

.team-record {
  font-size: 1rem;
  color: #333;
  margin-top: 5px;
}

.muted { color: #888; font-weight: 400; }

/* ── Team stats bar ── */
.team-stats {
  display: flex;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.09);
  margin-bottom: 24px;
  overflow: hidden;
}

.stat-group {
  flex: 1;
  padding: 14px 18px;
  border-right: 1px solid #e0e6f0;
}

.stat-group:last-child { border-right: none; }

.stat-group-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: #7090b8;
  margin-bottom: 10px;
}

.stat-items {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}

.stat-item { min-width: 52px; }

.stat-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1a1a1a;
  line-height: 1.2;
}

.stat-label {
  font-size: 0.7rem;
  color: #777;
  margin-top: 3px;
}

/* ── Histogram section ── */
.histogram-section {
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.09);
  padding: 20px 24px;
}

.histogram-explainer {
  font-size: 0.85rem;
  color: #555;
  line-height: 1.55;
  margin-bottom: 16px;
  max-width: 720px;
}

.histogram-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #1b2a4a;
  margin-bottom: 10px;
}

/* ── Wild Card matchup widget ── */
.wc-subhead {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #7a869a;
  margin: 16px 0 6px;
}

.wc-outcome {
  max-width: 900px;
}

.wc-seg-label {
  font-size: 12px;
  font-weight: 700;
  font-family: system-ui, -apple-system, sans-serif;
}

.wc-seg-pct {
  font-size: 10px;
  font-weight: 600;
  font-family: system-ui, -apple-system, sans-serif;
}

.wc-bracket {
  fill: none;
  stroke: #9aa5b4;
  stroke-width: 1.2;
}

.wc-bracket-label {
  fill: #6b7686;
  font-size: 10.5px;
  font-weight: 600;
  font-family: system-ui, -apple-system, sans-serif;
}

.wc-opp-link { cursor: pointer; }
.wc-opp-link:hover text { fill: #1b6abf; text-decoration: underline; }

.histogram {
  display: block;
  width: 100%;
  max-width: 900px;
}

.axis-label {
  font-size: 11px;
  fill: #666;
  font-family: system-ui, -apple-system, sans-serif;
}

.axis-title {
  font-size: 11px;
  fill: #777;
  font-family: system-ui, -apple-system, sans-serif;
}

.legend-label {
  font-size: 11.5px;
  fill: #444;
  font-family: system-ui, -apple-system, sans-serif;
}

/* ── Histogram tooltip ── */
/* ── Histogram bar hover ── */
.bar-slot { cursor: default; }

.bar-slot .bar-bg   { fill: transparent; }
.bar-slot:hover .bar-bg { fill: rgba(255, 215, 80, 0.28); }

.bar-slot .bar-side { fill: transparent; }
.bar-slot:hover .bar-side { fill: rgba(160, 30, 30, 0.45); }

.bar-slot .bar-label {
  visibility: hidden;
  font-size: 11px;
  font-weight: 700;
  fill: #1b2a4a;
  font-family: system-ui, -apple-system, sans-serif;
}
.bar-slot:hover .bar-label { visibility: visible; }

.bar-tooltip {
  position: fixed;
  background: #1b2a4a;
  color: #fff;
  padding: 10px 14px;
  border-radius: 5px;
  font-size: 12.5px;
  line-height: 1.65;
  font-family: system-ui, -apple-system, sans-serif;
  pointer-events: none;
  white-space: normal;
  max-width: 340px;
  z-index: 200;
  display: none;
}

.bar-tooltip strong { color: #9ec8f0; }

/* ── Standings-over-time line chart (standings_history.js) ── */
.sh-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin: 4px 0 10px;
}

.sh-key {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  color: #555;
  cursor: default;
}

.sh-key:hover { color: #1b2a4a; }

.sh-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex: none;
}

.sh-chart-wrap {
  position: relative;
  max-width: 900px;
}

.sh-svg { display: block; }

.sh-line {
  fill: none;
  stroke-width: 1.75;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.sh-line, .sh-end-label { transition: opacity 0.12s ease, stroke-width 0.12s ease; }

.sh-svg.sh-focused .sh-line,
.sh-svg.sh-focused .sh-end-label { opacity: 0.12; }

.sh-svg.sh-focused .sh-hot { opacity: 1; }
.sh-svg.sh-focused .sh-line.sh-hot { stroke-width: 3; }

.sh-end-label {
  font-size: 10.5px;
  font-weight: 700;
  font-family: system-ui, -apple-system, sans-serif;
}

.sh-asb-label {
  fill: #5f6672;
  font-size: 9.5px;
  letter-spacing: 0.03em;
  font-family: system-ui, -apple-system, sans-serif;
}

.sh-crosshair {
  stroke: #8a94a4;
  stroke-width: 1;
  stroke-dasharray: 3 3;
  pointer-events: none;
}

.sh-hit { cursor: crosshair; }

.sh-tooltip {
  position: absolute;
  display: none;
  pointer-events: none;
  z-index: 200;
  min-width: 190px;
  max-width: 340px;
  background: #1b2a4a;
  color: #fff;
  padding: 9px 11px;
  border-radius: 5px;
  font-size: 12px;
  line-height: 1.5;
  font-family: system-ui, -apple-system, sans-serif;
}

.sh-tooltip.show { display: block; }

.sh-tt-date { font-weight: 700; margin-bottom: 5px; }

.sh-tt-stand { border-collapse: collapse; width: 100%; }
.sh-tt-stand td { padding: 1px 0; vertical-align: top; }
.sh-tt-stand td.sh-tt-num { text-align: right; font-variant-numeric: tabular-nums; padding-left: 10px; }
.sh-tt-stand td.sh-tt-h { color: #9db3d1; font-weight: 600; font-size: 10.5px; }
.sh-tt-stand td.sh-tt-res { padding-left: 12px; white-space: nowrap; font-weight: 600; }

.sh-tt-swatch {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  margin-right: 5px;
}

.sh-tt-win  { color: #63d98a; }
.sh-tt-loss { color: #f2867d; }
.sh-tt-idle { color: #7f93b3; font-weight: 400; }

/* ── Archived-run banner (main page, ?run=…) ── */
.archived-banner {
  background: #fdf2d6;
  border-bottom: 1px solid #e6d08a;
  color: #6b551a;
  padding: 9px 24px;
  font-size: 0.85rem;
}
.archived-banner a { color: #1b6abf; text-decoration: none; }
.archived-banner a:hover { text-decoration: underline; }

/* ── Run-history page (runs.html) ── */
.runs-intro {
  font-size: 0.85rem;
  color: #555;
  margin-bottom: 16px;
}

.runs-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
  white-space: nowrap;
}

.runs-table th {
  text-align: left;
  background: #1b2a4a;
  color: #c8d8ee;
  font-weight: 600;
  padding: 8px 14px;
  position: sticky;
  top: 0;
}

.runs-table td {
  padding: 7px 14px;
  border-bottom: 1px solid #edf0f4;
}

.runs-table tbody tr:nth-child(even) td { background: #f7f9fc; }
.runs-table tbody tr:hover td { background: #eef4fc; }

.runs-table td.runs-num, .runs-table th.runs-num { text-align: right; font-variant-numeric: tabular-nums; }
.runs-table td.runs-ver { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.runs-table a { color: #1b6abf; text-decoration: none; }
.runs-table a:hover { text-decoration: underline; }

.run-latest {
  display: inline-block;
  margin-left: 7px;
  padding: 1px 6px;
  border-radius: 3px;
  background: #1b6abf;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
