:root {
  --ink: #0A1F44;
  --muted: #5d6b7d;
  --line: #dce3ec;
  --paper: #ffffff;
  --wash: #f5f7fb;
  --blue: #0A1F44;
  --green: #2f7d61;
  --gold: #F59E0B;
  --red: #b43d32;
  --teal: #0f766e;
  --amber-soft: #fff3d8;
}

* {
  box-sizing: border-box;
}

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

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: white;
  border-radius: 6px;
  padding: 0.7rem 0.9rem;
  cursor: pointer;
}

button.secondary {
  background: white;
  color: var(--ink);
  border-color: var(--line);
}

button:hover {
  filter: brightness(0.96);
}

button.name-button {
  border: 0;
  background: transparent;
  color: var(--blue);
  padding: 0;
  font-weight: 800;
  text-align: left;
  text-decoration: underline;
}

a {
  color: var(--blue);
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  padding: 1rem clamp(1rem, 3vw, 2.5rem);
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  align-items: center;
}

.brand {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  width: 100%;
}

.brand-logo {
  width: clamp(150px, 18vw, 220px);
  height: auto;
  display: block;
}

.brand h1 {
  margin: 0;
  font-size: 1.15rem;
}

.brand p,
.source-pill {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.source-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.45rem 0.7rem;
  background: var(--amber-soft);
  color: var(--ink);
}

.layout {
  display: grid;
  grid-template-columns: minmax(260px, 340px) 1fr;
  gap: 1rem;
  padding: 1rem clamp(1rem, 3vw, 2.5rem) 2rem;
}

.sidebar,
.main {
  min-width: 0;
}

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.panel h2,
.panel h3 {
  margin: 0 0 0.7rem;
}

.panel h2 {
  font-size: 1rem;
}

.panel h3 {
  font-size: 0.96rem;
}

.event-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1.2rem;
  margin-bottom: 1rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: start;
}

.event-card h2 {
  margin: 0 0 0.25rem;
  font-size: clamp(1.35rem, 2vw, 1.9rem);
}

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

.current-roster {
  margin-top: 1rem;
}

.current-roster h3 {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
}

.current-roster ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
}

.current-roster li {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  background: #fbfcfc;
  min-width: 0;
}

.current-roster span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 0.1rem;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 1rem;
  margin-bottom: 0.8rem;
}

.mode-controls {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.definition {
  margin: 0.25rem 0 0;
  color: var(--muted);
  max-width: 54rem;
  font-size: 0.88rem;
  line-height: 1.45;
}

.segmented {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.25rem;
  display: flex;
  gap: 0.2rem;
  background: #f8fbfa;
  min-width: max-content;
}

.segmented button {
  border: 0;
  background: transparent;
  color: var(--ink);
  border-radius: 6px;
  padding: 0.45rem 0.6rem;
  font-weight: 800;
  font-size: 0.8rem;
  cursor: pointer;
}

.segmented button[aria-pressed="true"] {
  background: var(--ink);
  color: white;
}

.club-column {
  display: none;
}

.metric-stack {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.7rem;
  min-width: 9rem;
  background: #fbfcfc;
}

.metric strong {
  display: block;
  font-size: 1.15rem;
}

.metric span {
  color: var(--muted);
  font-size: 0.82rem;
}

.control {
  display: grid;
  gap: 0.4rem;
  margin-bottom: 0.85rem;
}

.control label,
.check-row {
  font-weight: 650;
  font-size: 0.88rem;
}

.control input,
.control select,
.control textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.65rem;
  background: white;
  color: var(--ink);
}

.control textarea {
  min-height: 8rem;
  resize: vertical;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.6rem 0;
}

.check-row input {
  width: 1rem;
  height: 1rem;
}

.button-row {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.lookup-form {
  display: grid;
  gap: 0.2rem;
}

.lookup-result {
  border-top: 1px solid var(--line);
  margin-top: 0.8rem;
  padding-top: 0.8rem;
  display: grid;
  gap: 0.25rem;
}

.lookup-result span {
  color: var(--muted);
  font-size: 0.84rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
}

.form-grid .wide {
  grid-column: 1 / -1;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.draw-grid {
  display: grid;
  gap: 0.85rem;
}

.empty-state,
.draw-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  padding: 0.85rem;
}

.empty-state strong,
.empty-state span {
  display: block;
}

.empty-state span,
.draw-card header span {
  color: var(--muted);
  font-size: 0.86rem;
  margin-top: 0.15rem;
}

.draw-card header {
  margin-bottom: 0.65rem;
}

.draw-card h3 {
  margin: 0;
}

.draw-card table {
  min-width: 520px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
}

th,
td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 0.9rem;
}

th {
  background: #eef4f3;
  font-size: 0.78rem;
  text-transform: uppercase;
  color: #35444c;
}

td strong,
td span {
  display: block;
}

.rank {
  display: inline-grid;
  place-items: center;
  min-width: 2.4rem;
  min-height: 2rem;
  border-radius: 6px;
  background: #edf3ff;
  color: var(--blue);
  font-weight: 800;
}

.confidence,
.status,
.flag,
.stage-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.25rem 0.45rem;
  font-size: 0.75rem;
  font-weight: 700;
  margin: 0.1rem 0.15rem 0.1rem 0;
  white-space: nowrap;
}

.flags {
  min-width: 13rem;
}

.flags .flag {
  white-space: normal;
}

.confidence.high,
.status.ok,
.flag.good {
  color: var(--green);
  background: #e8f5ef;
}

.confidence.medium,
.status.warn {
  color: var(--gold);
  background: #fff4d8;
}

.confidence.low,
.status.idle,
.flag {
  color: var(--red);
  background: #fbecea;
}

.stage-pill {
  color: var(--blue);
  background: #edf3ff;
}

.muted-cell {
  color: var(--muted);
}

.blade {
  width: 3rem;
  height: 1rem;
  border: 1px solid #aebbc2;
  border-radius: 2px 8px 8px 2px;
  background: white;
  margin-bottom: 0.25rem;
}

.blade.lake-union {
  background: linear-gradient(90deg, white 0 42%, var(--red) 43%);
}

.blade.vashon {
  background: var(--blue);
}

.blade.burnaby {
  background: white;
}

.adapter-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.75rem;
}

.adapter-list li {
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.7rem;
}

.adapter-list li:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.adapter-list strong,
.adapter-list span:last-child {
  display: block;
}

.adapter-list span:last-child,
.source-summary dd,
.athlete-panel p,
.athlete-panel li span,
.note {
  color: var(--muted);
}

.source-summary dl {
  margin: 0;
}

.source-summary div {
  border-bottom: 1px solid var(--line);
  padding: 0.55rem 0;
}

.source-summary div:last-child {
  border-bottom: 0;
}

.source-summary dt {
  font-weight: 800;
}

.source-summary dd {
  margin: 0.2rem 0 0;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.9rem;
}

.athlete-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
  background: #fbfcfc;
  scroll-margin-top: 1rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.athlete-panel.is-highlighted {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(30, 99, 168, 0.14);
}

.athlete-panel h3,
.athlete-panel p {
  margin: 0;
}

.athlete-panel ul {
  padding-left: 1.1rem;
  margin: 0.8rem 0 0;
}

.athlete-panel li {
  margin: 0.45rem 0;
}

.evidence-wrap {
  margin-top: 0.9rem;
}

.evidence-table {
  min-width: 1180px;
}

.evidence-table td span {
  margin-top: 0.15rem;
}

.context-label {
  color: var(--ink);
  font-weight: 800;
}

.waterline {
  height: 86px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    repeating-linear-gradient(0deg, rgba(30, 99, 168, 0.12) 0 1px, transparent 1px 14px),
    linear-gradient(90deg, rgba(47, 125, 97, 0.16), rgba(30, 99, 168, 0.12));
  position: relative;
  overflow: hidden;
}

.waterline::before,
.waterline::after {
  content: "";
  position: absolute;
  left: 12%;
  right: 12%;
  height: 2px;
  background: rgba(23, 32, 38, 0.22);
}

.waterline::before {
  top: 30%;
}

.waterline::after {
  bottom: 30%;
}

.boat-dot {
  position: absolute;
  top: 39%;
  width: 42px;
  height: 10px;
  border-radius: 999px;
  background: var(--ink);
}

.boat-dot.one {
  left: 22%;
}

.boat-dot.two {
  left: 44%;
  background: var(--green);
}

.boat-dot.three {
  left: 66%;
  background: var(--blue);
}

.mini-table table {
  min-width: 520px;
}

@media (max-width: 980px) {
  .layout,
  .event-card,
  .section-heading {
    grid-template-columns: 1fr;
    display: grid;
  }

  .metric-stack {
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .topbar,
  .form-grid {
    display: block;
  }

  .current-roster ul {
    grid-template-columns: 1fr;
  }

  .source-pill {
    margin-top: 0.8rem;
  }

  .control {
    margin-bottom: 0.7rem;
  }
}
